Link to home
Start Free TrialLog in
Avatar of sangameshrh
sangameshrh

asked on

Problem with PGS Look And Feel

I am using PGS Look and feel. I was having a problem with JTextFileld and JTextArea. Hence according to the suggestion I got in experts-exchange I changed my code to

class TextFieldLookNFeel extends PgsLookAndFeel
{
      protected void initClassDefaults(UIDefaults table)
      {
            super.initClassDefaults(table);
            Object[] defaults = {"TextFieldUI","com.sun.java.swing.plaf.windows.WindowsTextFieldUI","TextAreaUI","com.sun.java.swing.plaf.windows.WindowsTextAreaUI"};
            table.putDefaults(defaults);
      }
}

and
UIManager.setLookAndFeel(new TextFieldLookNFeel());

But Now I am not getting icons in JOptionPane.(That is cross mark for error or "!" for information)

Also JFileChooser is not working

Thanks
Avatar of ksivananth
ksivananth
Flag of United States of America image

can you post the exception stack?

one approach would be, you can find the name of the missing icons and provide them. The other would be to use windows LAF for thos components too like you did for text fields!
if you want to try the second approach,

for file chooser,

"FileChooserUI", "com.sun.java.swing.plaf.windows.WindowsFileChooserUI"
Avatar of sangameshrh
sangameshrh

ASKER

When I gave
"FileChooserUI",      "com.sun.java.swing.plaf.windows.WindowsFileChooserUI"

JFileChooser is opening but with a look and feel of PGS.
I want it to be windows look and feel
on the other hand looks like you can fix the issue with the JOptionPane in PSG itself,

all you have to do is extend the below method and return appropriate Icon object for appropriate properties,

    protected Icon getIconForType(int messageType) {
      if(messageType < 0 || messageType > 3)
          return null;
        String propertyName = null;
      switch(messageType) {
      case 0:
          propertyName = "OptionPane.errorIcon";
            break;
      case 1:
          propertyName = "OptionPane.informationIcon";
            break;
      case 2:
          propertyName = "OptionPane.warningIcon";
            break;
      case 3:
          propertyName = "OptionPane.questionIcon";
            break;
      }
        if (propertyName != null) {
            return (Icon)DefaultLookup.get(optionPane, this, propertyName);
      }
      return null; //HERE YOU CAN RETURN YOUR ICON OBJ FOR APPROPRIATE PROPERTIES
    }

of the OptionPaneUI class of PSG LAF and register that class as UI as below,

"OptionPaneUI", "YOUR UI CLASS"


I am not getting that. Can u tell me how exactly it should be done??
>>JFileChooser is opening but with a look and feel of PGS.
I want it to be windows look and feel
>>

I would rather say, it would have a mix of PGS and Windows! Since you use PGS for other fields like buttons, dropdown, table... they will retain the look of the PGS!
ASKER CERTIFIED SOLUTION
Avatar of ksivananth
ksivananth
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Forced accept.

Computer101
EE Admin