0 Replies Latest reply on Oct 28, 2010 4:58 PM by 322169

    Synth LAF and JTextField's disabled text color.

      I'm trying to implement my own look and feel using synth. I want the LAF to have user-defined colors, including text color for disabled JTextFields through the properties file.

      Unfortunately when I read the properties file and set the corresponding UIDefaults property, it gets ignored by SynthTextFieldUI:
      Color dfg = comp.getDisabledTextColor(); 
          if (dfg == null || dfg instanceof UIResource) {
              comp.setDisabledTextColor(style.getColor(context, ColorType.TEXT_FOREGROUND));
      So, if a color is specified, it promptly get's ignored, and is read from the xml <style> attribute. Nothing wrong with this, since styles are how synth does it's work, but how do I set the thing programatically?

      The only solutions I can come up with are sadly just hacks.
      SynthLookAndFeel synth = new SynthLookAndFeel();
      synth.load(LAFTest.class.getResourceAsStream("test.xml"), LAFTest.class);
      I could intercept loading of test.xml file and insert appropriate <style> tag contents on the fly. Or just generate the file dynamically.

      Or do this (ugly, ugly hack):
      public class TextFieldPainter extends SynthPainter {
          public void paintTextFieldBorder(SynthContext context, Graphics g, int x, int y, int w, int h) {
              // carry on with painting...