NetBeans: Dinamically changing Look and Feel Problem

Hi there, Java lovers.
I need some help here!
I love java, and I used to program my graphical user interfaces by hand. In my applications, there is a dropdown for the user to chose the desired look and feel. Then I save the selected option to a file and on the startup I do something like this:
            UIManager.setLookAndFeel(savedUserSelectedLookAndFeel);That always worked really fine. The look and feel would change and everything worked really well.
However, programing GUI by hand is really a PITA. So I was seduced by Netbeans. I am using Netbeans 6.0 on Windows XP, and I designed the GUIs really fast now.
The problem is, the system look and feel works really well, but when I change the look and feel of my application to a different one (Java/Motif/etc..) the look and feel changes but the components positions and sizes becomes all messed up. It really becomes impossible to work with a different look and feel because some components are outside of frames.
I believe the cause of this is because Netbeans generates the code automatically using Grids and stuff like that, and by doing so, the change of the look and feel becomes messed up. This is a thing that would not happen with my manually created code.
This is really troubling me. Does someone has the same problem. Is there something I can do? Or do I need to create my GUIs by hand like before?

Oyashiro-sama (少し日本語を知っているし、そんな「様」っていう使い方はちょっと変そうですね (^_-) 「冗談」っていう顔文字です。)
Sorry for the delay in reply, but one problem for you is that this is not a NetBeans users forum, thus you will not necessarily receive speedy replies here to your NetBeans questions. The best place to send NetBeans questions is:
[email protected]
[email protected] (for NetBeans API issues)
As for your question, you seem to already know quite a bit about NetBeans UI Look and Feel programming, but have you seen these:
WORKING WITH SWING LOOK AND FEEL:
http://java.sun.com/developer/JDCTechTips/2004/tt0309.html#1
Java GUI Swing Programming Using NetBeans 5 (should apply to NetBeans 6):
http://wiki.netbeans.org/JavaGUISwingProgrammingUsingNetBeans5
Regards,
-Brad Mayer

Similar Messages

  • Losing Title Bar when changing Look and Feel on the fly

    Hello,
    I have an option in my Swing app for the user to change the Look & Feel on the fly by selecting from a radio button list. The look and feel is changed when the user make the selection, however the Windows Title Bar disappears. Any ideas what I'm missing?
    private void setLook(String mode)
    String lookAndFeelClassName = null;
    UIManager.LookAndFeelInfo looks[] = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < looks.length; i++)
    if (mode.equalsIgnoreCase(looks.getName()))
    lookAndFeelClassName = looks[i].getClassName();
    break;
    try
    m_view.dispose();
    UIManager.setLookAndFeel(lookAndFeelClassName);
    SwingUtilities.updateComponentTreeUI(m_view);
    m_view.setVisible(true);
    catch (Exception e)
    JOptionPane.showMessageDialog(m_view, "Can't change look and feel:" + lookAndFeelClassName, "Invalid PLAF", JOptionPane.ERROR_MESSAGE);

    You are disposing the view. My guess is that this is your problem. Try creating a new one instead of just showing the old disposed one

  • How can we remove the space after changing look and feel to generic

    Hi
    I want to remove the space which left blank after changing look and feel to generic in formsweb.cfg file.
    Can anybody help me to remove this blank space.

    Hi,
    can you be more specific on teh space you mean?
    Frank

  • Event on changing Look and Feel

    I want to know what event is fired when I change Look and Feel.
    Thanks,
    Pati

    Ideally you'll be using the UIManager.setLookAndFeel() to change the installed LookAndFeel. In the UIManager, the installed LNF is bound to a JavaBeans property using the SwingPropertyChangeSupport with the key: "lookandfeel". Any time this changes, a PropertyChangeEvent will be fired to the PropertyChangeListeners registered with the UIManager. You can simply add a PropertyChangeListener to the UIManager and listen for events that are bound to that particular property, such as...
        UIManager.addPropertyChangeListener( new PropertyChangeListener() {
            public void propertyChange( PropertyChangeEvent e ) {
                if( "lookAndFeel".equals( e.getPropertyName() ) ) {
                    System.out.println( "look and feel changed" );
        });The event encapsulates the new value and the old value so you can do whatever you need with that information.
    I used an anonymous inner class mostly as an example - You may need to consider a cleaner design for your purposes.
    Hope this helps!
    Matt

  • Extending JComboBox  behavior and changing look and feel

    In order to change JComboBox behavior, usually we will extend the MetalComboBoxUI or WindowsComboBoxUI (for example: for controlling the popup width)
    The problem arise when we want to be able to change the pluggable look and feel: all components got the new look and feel except for the comboboxes.
    A dirty solution can be extending our ComboBoxUI from the new look and feel library but in the case of jgoodies it is even impossible because PlasticComboBoxUI is final
    Any ideas?

    In order to change JComboBox behavior, usually we will extend the MetalComboBoxUI or WindowsComboBoxUI (for example: for controlling the popup width).
    The problem arise when we want to be able to change the pluggable look and feel: all components got the
    new look and feel except for the comboboxes. A dirty solution can be extending our ComboBoxUI from
    the new look and feel library but in the case of jgoodies it is even impossible because PlasticComboBoxUI is final
    My best suggestion: request the L&F provider to make his combo box homogeneous with the other components.

  • Swing disabled components look and feel problem.

    Hi All,
    I have a Swing application. My system is recently upgraded to JRE 1.6 and I'm facing problem with look and feel of swing components when they are disabled. Color of disabled components is very faint and its being difficult to read the text in such disabled components. In JRE 1.4 this problem was not there. Please let me know what I can do to get the look and feel(Color and Font) of disabled components, same as JRE 1.4.
    Thanks

    Sandip_Jarad wrote:
    ..I have a Swing application. My system is recently upgraded to JRE 1.6 and I'm facing problem with look and feel of swing components when they are disabled. Which look and feel is the application using? As an aside, did it never occur to you to mention the PLAF?
    ..Color of disabled components is very faint and its being difficult to read the text in such disabled components. Why is it so gosh-darned important to read the text on a control that is (supposedly) not relevant or not available?
    ..In JRE 1.4 this problem was not there. Please let me know what I can do to get the look and feel(Color and Font) of disabled components, same as JRE 1.4. Here are some suggestions, some of them are actually serious. I'll leave it as an exercise for you, to figure out which ones.
    - Run the app. in 1.4.
    - Use a custom PLAF that offers a 'less faint' rendering of disabled components.
    - Use Motif PLAF (I haven't checked, but I bet that has not changed since 1.4).
    - Put the important text in a tool-tip.

  • Changing look and feel with radio buttons

    k this is the code that i have so far, Yes i read the tutorial and stuff but it doesnt seem to make any sense and all. tell me what else i need in this code to do what i want, its the action performed part i didnt put the other code, what else do i need??? but well...you will see grips of duke dollars to whom can do it
    public void actionPerformed(ActionEvent e)
    String actionCommand = e.getActionCommand();
    if(actionCommand.equals("Metal"))
    try
    UIManager.setLookAndFeel( "javax.swing.plaf.metal.MetalLookAndFeel" );
    catch (Exception ex)
    else if(actionCommand.equals("Windows"))
    try
    UIManager.setLookAndFeel( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" );
    catch (Exception ex)
    else if(actionCommand.equals("Motif"))
    try
    UIManager.setLookAndFeel( "com.sun.java.swing.plaf.motif.MotifLookAndFeel");
    catch (Exception ex)
    }

    While not in the tutorial, I have found several other things necessary to get the look and feel change to be complete. Here is the code I'm using after I set the look and feel. It seems to do a pretty good job of sync'ing everything together.
                SwingUtilities.updateComponentTreeUI(TDba.getFrame());
                TDba.getFrame().pack();
                Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
                Integer w = new Integer((int)(dim.width * .8));
                Integer h = new Integer((int)(dim.height * .8));           
                TDba.getFrame().setSize(w.intValue(), h.intValue());
    [\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Changing Look and feel of template pagelets

    Hello,
    I have a requirement to show different look and feel for different template pagelets.
    Something like:
    Related links - Grey Header
    Related Content - Blue Header
    Other pagelets - Red Header
    I was able to acheive this very easily for homepage pagelets by cloning PORTAL_HP_COMPONENT.
    But looks like PORTAL_HP_COMPONENT HTML is not used for template pagelets.
    Does anyone have any idea which HTML is used to build Template pagelets?
    Otherwise how to meet the above requirement?
    Many Thanks for your help.
    Best Regards,
    Ekta

    Each pagelet has a unique ID based on the CREF ID. Rather than change the HTML template, an alternate option is to add this information to your stylesheet. Look in PeopleTools > Utilities > PeopleTools Options for your stylesheet name. I recommend cloning this one, adding a new free form stylesheet with override information, and then updating the PeopleTools Options to use your new stylesheet.
    I don't believe template pagelets have a common HTML definition. Instead, the "wrapper" HTML depends on the use location. For example, Workcenter pagelets use a different HTML definition than Intelligent Context and Related Content pagelets.

  • Changing Look and Feel

    I finally figured out how to change the look and feel of an application, but now I'm trying to figure out how the user can change it during run time. I was thinking that when the user chooses a "look" the program could just reload and send the lookAndFeel (such as com.sun.java.swing.plaf.windows.WindowsLookAndFeel) to the main's arguments, but I'm not sure how I could do this exactly... any push in the right direction would be great.. thanks.

    thanks! I tried using the SwingUtilities.updateComponentTreeUI method, and it worked for the most part, but for some reason now when I use this code:
    try {
         UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
         SwingUtilities.updateComponentTreeUI(this);
         pack();
    catch (Exception e) {
    }The frame seems to turn into a JWindow... as in the title bar disappears.... I'm not sure why it's doing that...

  • Changing Look and Feel of Annual Appraisal document

    Hi all,
    I have the requirement to change the look and feel of Annual Appraisal document.
    I need to add a header to the first column in Appraisal document.
    I am confused as to where the changes are to be made (In HAP_DOCUMENT,Annual template or BSP code)
    Have checked most of the blogs and threads in forums,but no help yet.
    Please let me know where the changes have to made and how?
    Thanks and Regards,
    Sumangala

    Hi,
    Thanks for the reply.
    I checked "Document_header.htm" as you mentioned.
    It agian points to few other header files such as "Document_header_appraisee.htm","Document_header_appraiser.htm" .
    When i go and check these files,  the code refers to settings no of columns,rows. No link to Header text anywhere.
    From where these headers are set actually.Any configuration in template or header text are written in the code only?
    and also curious to know what this line refers to
    "<%= otr(PAOC_HAP_DOCUMENT_UI/TEXT_ADDITIONAL) %> <%= APPLICATION->doc-S_HEADER_TEXTS-OTHER_TYPE_TXT %>"
    Regards,
    Sumangala

  • Changing Look and Feel programatically ??

    Hi,
    Is there a way in WLP815 to apply a look and feel programatically may be by using desktop backing or some other way?
    I tried to use LookAndFeel.setSkin() in desktop backing preRender method to change the skin from 'default' to say 'custom',
    To my surprise, It is rendering images from 'custom' and CSS styles from 'default' skin. Hmmmm.
    I even cleared the cache on my browser. But no luck :-(
    Does any one had this issue and know a work around?
    Thanks in advance!
    -Subba

    I use following code in header backing "init":
    LookAndFeel lookAndFeel = LookAndFeel.getLookAndFeel(request);
    lookAndFeel.setSkin(newskin);
    lookAndFeel.setSkeleton(newskeleton);
    lookAndFeel.reinit();

  • Changing look and feel for one INSTANCE of a component

    I am trying to change the look and feel of just ONE instance of a component. In particular, I want to change the color of the JScrollBar thumb on a certain JScrollPane. I want this change to not affect any other component, either before or after. How can I do this?? Any help would be much appreciated.
    AC

    Hi acalvin3!
    I have a solution. Use the UIManagers database. You should overwrite the default settings for the resource you want to change, the code is self explaining:
          UIManager.put( "Button.margin", commonMargin );
          UIManager.put( "Button.focusInputMap", commonInputMap );
          UIManager.put( "Button.font", buttonFont );To reset values you only have to use
          UIManager.put( "Button.margin", null );
          UIManager.put( "Button.focusInputMap", null );
          UIManager.put( "Button.font", null );Set values before you create your component and reset values immedeately after you created your component, otherwise you may affect other components too.
    With following code you can find out default values for the whole UIManagers database:
          Hashtable defaultProps = UIManager.getDefaults();
          Enumeration enum = defaultProps.keys();
          while (enum.hasMoreElements()) {
             Object key = enum.nextElement();
             System.out.println( "key: '" + key + "'\t value: '" + defaultProps.get(key) + "'" );
          }You just have to look for the output for the component you want to change the look and feel.
    Have fun...

  • How to change look and feel on different pages

    Hi,
    I'm new to oracle portal, i want to chnage the look and feel dynamically,
    for example:
    when i entry page A,i want to use look and feel "RED",when i entry page B,i want to use look and feel "BLUE".
    what should I do in my programming or configuration ?
    thanks!!
    Edited by: user11361456 on 2009-7-6 下午7:16
    Edited by: user11361456 on 2009-7-6 下午7:33

    For a quick result, you can use Portal Templates with Portal Styles
    For a better but slower result, you can write HTML templates (page skins), with your own CSS.
    In both cases, you assign the template to the page. You can also use Portal Templates to mantain the structure of the pages, and Page Skins to change the look.

  • Changing Look and Feel of JFileChooser

    HI,
    How to change the look and of the JFileChooser?
    I am trying to apply the styles from the CSS. My intention is to put the JFileChooser component as applet.
    Solution pls.
    Thanx.

    JFileChooser is in fact a dialog and it cannot be used as an applet. Nor you can apply CSS styles to it.

  • Problem in JButton while changing look and feel to CDE/Motif

    In my application i'm using JButtons placed in JToolbar. I've setIcons for the JButtons. The top of the icons i.e the JButtons get hided while i changing the look & feel to CDE/Motif. But again if i change the look & feel to Metal, no problem is there. Expecting a favourable response from someone well versed / faced such problems earlier problems.
    Cheers
    sunil s

    Sounds suspiciously like you are setting absolute sizes for your buttons or elsewhere in application. Can you post code snippets showing how you layout your application.
    Cheers
    DB

Maybe you are looking for

  • K8T Neo F1S2R No Longer Boots - Help Diagnosing

    Hello, I've had good service from my K8T Neo Athlon 64 mobo for 2 years. Today when I turned on the PC, all the fans cranked up and nothing more. The four test LEDs stayed red. No beeps, no display to the monitor. The light on one CD drive (I have 2)

  • In need of some help....

    I am looking to get a new laptop if you had these 3 following choices which would you choose and why? http://www.bestbuy.com/site/HP---Pavilion-17.3%26%​2334%3B-Laptop---4GB-Memory---640GB-Hard-Drive---S​... http://www.bestbuy.com/site/Acer---Aspire-

  • PSE 6 for Mac: Pop-Up Palettes No Longer Open Automatically

    I have a MacBook Pro. Since upgrading to Leopard, PSE 6 no longer opens the Pop-Up Palettes automatically. When using Tiger, if I clicked on the lower-right corner of a Tool (like Blur) then a Pop-Up Palette would appear showing the other related Too

  • Problème avec   '

    Lorsque je télécharge un document et que je visualise si il y a des  ' apostrophes, je ne vois que des signes confus qui remplacent l'apostrophe, du style  $%?&%?  . Si je regarde le même docuyment sans me servir du PDF, soit sur le site internet, to

  • Help with Apple Script Code

    Hi, I found this Apple script online and here's how it works: tell application "QuickTime Player" activate try if not (exists document 1) then display dialog "Please open a QuickTime movie." buttons {"Cancel"} default button 1 with icon 1 set thefile