If you just want to use different fonts, there is a better and easy way
than extending WindowsLookAndFeel class.

I use following in my main() or some top level method, before instantiating
any of the UI components ..

Hope this helps ..

- Ajit

        /**** Do some custom UI settings for all the components we are using
****/
        FontUIResource sansserifPlain11 = new FontUIResource("SansSerif",
Font.PLAIN, 11);
        FontUIResource sansserifBold11 = new FontUIResource("SansSerif",
Font.BOLD, 11);
        FontUIResource sansserifBold12 = new FontUIResource("SansSerif",
Font.BOLD, 12);

        UIManager.put("Button.font", sansserifPlain11);
        UIManager.put("Label.font", sansserifPlain11);
        UIManager.put("Table.font", sansserifPlain11);
        UIManager.put("TextField.font", sansserifPlain11);
        UIManager.put("ScrollPane.font", sansserifPlain11);
        UIManager.put("ComboBox.font", sansserifPlain11);
        UIManager.put("CheckBox.font", sansserifPlain11);
        UIManager.put("TitledBorder.font", sansserifPlain11);
        UIManager.put("RadioButton.font", sansserifPlain11);
        UIManager.put("ToolTip.font", sansserifPlain11);
        UIManager.put("TextPane.font", sansserifPlain11);
        UIManager.put("TextArea.font", sansserifPlain11);

        UIManager.put("Tree.font", sansserifBold12);
        UIManager.put("List.font", sansserifPlain11);

        UIManager.put("MenuBar.font", sansserifBold12);
        UIManager.put("Menu.font", sansserifBold11);
        UIManager.put("MenuItem.font", sansserifBold11);
        UIManager.put("TableHeader.font", sansserifBold11);
        UIManager.put("TabbedPane.font", sansserifBold12);

        SwingUtilities.updateComponentTreeUI(this);


"Ravyts, Sofie" wrote:

> Hello,
>
> I want to create a look and feel much like the windows look and feel, but
> different size fonts.
> I extended WindowsLookAndFeel.java (com.sun.java.swing.plaf.windows). Here
> is my class:
>
> public class MyWindowsLAF extends WindowsLookAndFeel {
>
>     public String getID(){ return "MyWindowsLAF"; }
>     public String getName(){return "My Look And Feel for Windows"; }
>     public String getDescription(){ return "L&F for Windows";}
>     public boolean isNativeLookAndFeel () { return false; }
>     public boolean isSupportedLookAndFeel() { return true;}
>
>     protected void initComponentDefaults(UIDefaults table)
>     {
>         super.initComponentDefaults(table);
>
>         FontUIResource commonFont = new FontUIResource("Dialog", Font.PLAIN,
> 11);
>
>         Object [] defaults = {
>                       "Button.font", commonFont,
>                         "Button.margin", new InsetsUIResource(1, 12, 1, 12),
>
>                      "RadioButton.font", commonFont,
>                         "CheckBox.font", commonFont,
>                 "ColorChooser.font", commonFont,
>                    "ComboBox.font", commonFont,
>                 "FileChooser.font", commonFont,
>                       "Label.font", commonFont,
>                            "List.font", commonFont,
>                         "MenuBar.font", commonFont,
>                        "MenuItem.font", commonFont,
>             "RadioButtonMenuItem.font", commonFont,
>            "CheckBoxMenuItem.font", commonFont,
>                        "Menu.font", commonFont,
>                   "PopupMenu.font", commonFont,
>                      "OptionPane.font", commonFont,
>                           "Panel.font", commonFont,
>                 "ProgressBar.font", commonFont,
>                  "ScrollPane.font", commonFont,
>                    "Viewport.font", commonFont,
>                  "TabbedPane.font", commonFont,
>                       "Table.font", commonFont,
>                     "TableHeader.font", commonFont,
>                   "TextField.font", commonFont,
>               "PasswordField.font", commonFont,
>                    "TextArea.font", commonFont,
>                    "TextPane.font", commonFont,
>                  "EditorPane.font", commonFont,
>                "TitledBorder.font", commonFont,
>                         "ToolBar.font", commonFont,
>                     "ToolTip.font", commonFont,
>                            "Tree.font", commonFont,
>                "ToggleButton.font", commonFont,
>         };
>
>         table.putDefaults(defaults);
>     }
>
> Everything works fine until my program uses a platform icon (fi TreeOpen.gif
> or HardDrive.gif)
> Then i get the message:
>
>         mypackage.MyWindowsLAF/icons/HardDrive.gif not found
>         mypackage.MyWindowsLAF/icons/TreeOpen.gif not found
>
> Does anybody have an idea about what i do wrong?
>
> I set the look and feel in the following manner in the initialisation of my
> applet:
>
>         String laf;
>         if (!RunningOnMac()){
>             try{
>                 laf = MyWindowsLAF.getClassPath();
>             }
>             catch(Exception e){
>                 e.printStackTrace();
>                 laf = UIManager.getSystemLookAndFeelClassName();
>             }
>         }
>         else     // set system look and feel.
>             laf = UIManager.getSystemLookAndFeelClassName ();
>       }
>
> Greetings
> Sofie
>
> Sofie Ravyts
> Barco Commercial Printing
> Tramstraat 69
> B-9052 Zwijnaarde (Gent)
> email: [EMAIL PROTECTED]
> tel: +32 9 216 9335
>
> _______________________________________________
> Advanced-swing mailing list
> [EMAIL PROTECTED]
> http://eos.dk/mailman/listinfo/advanced-swing

_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to