Search code examples
javaswingopacityjtextfield

How do I adjust the opacity of a field when disabled in Java Swing


I have a program that when started disables fields so that the user cant change parameters. However the opacity changes so much that the writing then is not as clear as I would like. I set the font to Bold but this does not help so much and it also looks out of place when not disabled.


Solution

  • If you really referring to the JTextComponents, then I guess what you need is setDisabledTextColor(...), something like this :

    tarea = new JTextArea(10, 10);
    tarea.setText("Hello World!");
    tarea.setEnabled(false);
    tarea.setDisabledTextColor(Color.BLACK);