Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Strange UIManager.setLookAndFeel(...) behavior

843806Mar 3 2009 — edited Mar 3 2009
Hi,

I am trying to use a layout library delivered by http://www.jtattoo.net/. When I am trying with the code example they deliver on http://www.jtattoo.net/HowTo_MinFrame.html:
package Main;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Main extends JFrame {

    public Main() {
        super("Minimal-Frame-Application");

        // setup menu
        JMenuBar menuBar = new JMenuBar();
        JMenu menu = new JMenu("File");
        menu.setMnemonic('F');
        JMenuItem menuItem = new JMenuItem("Exit");
        menuItem.setMnemonic('x');
        menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, KeyEvent.ALT_MASK));
        menuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                System.exit(0);
            }
        });
        menu.add(menuItem);
        menuBar.add(menu);
        setJMenuBar(menuBar);

        // setup widgets
        JPanel contentPanel = new JPanel(new BorderLayout());
        contentPanel.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4));
        JScrollPane westPanel = new JScrollPane(new JTree());
        JEditorPane editor = new JEditorPane("text/plain", "Hello World");
        JScrollPane eastPanel = new JScrollPane(editor);
        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, westPanel,eastPanel);
        splitPane.setDividerLocation(148);
        contentPanel.add(splitPane, BorderLayout.CENTER);
        setContentPane(contentPanel);

        // add listeners
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        // show application
        setLocation(32, 32);
        setSize(400, 300);
        show();
    } // end CTor MinFrame

    public static void main(String[] args) {
        try {

            // start application
            new Main();

            // select Look and Feel
            UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel");
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
    } // end main

} // end class MinFrame
Everything works fine, I get the AcrylLookAndFeel layout on the JFrame.

Yet, when I used a similar piece of code in my application:
    public static void main(String args[]) {
        
        Dock_Application_1_0_0 ThePulp = null;
        
        try {
            
            // Setting default look & feel
            UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel"); // HERE
            // Visual.SetDefaultLookAndFeel();
            
            // Checking for multiple instance of the application
            CheckForMultipleInstanceOfTheApplication();

            // Checking debug options
            if (Debugger.DEBUGGING_IS_ON) {

                LOG.log(Level.INFO, "Debugging is ON", Level.INFO);

                // Do you want to start from scratch?
                int Answer = Visual.AskYesNoQuestion("Do you want to start the application as if it were started for the first time?", "Debug Mode");

                if (Answer==JOptionPane.YES_OPTION) {

                    LOG.log(Level.INFO, "Deleting existing infrastructure", Level.INFO);

                    File ThePersistenceDirectory = new File(Dock_Installation_1_0_0.PersistenceDirectory);
                    Dock_Installation_1_0_0.RecursiveDelete(ThePersistenceDirectory);

                }

            }
            
            // Creating a new main class
            ThePulp = new Dock_Application_1_0_0();

            // Should we start the debugging monitor?
            if (Debugger.DEBUGGING_IS_ON) {

                ThePulp.TheScreenManager.launchScreen(new Debugging_Monitor_1_0_0(ThePulp));

            }

        } catch (RuntimeException Ex) {

            Debugger.LogUnreachableCodeReachedSituation(LOG, Ex);

        } catch (Exception Ex) {

            Debugger.LogUnreachableCodeReachedSituation(LOG, Ex);

        } catch (Throwable Ex) {

            Debugger.LogUnreachableCodeReachedSituation(LOG, Ex);

        }
        
        // Making sure we leave in a clear state and that we wipe as many traces as possible
        System.runFinalization();
        System.gc();
        
    }
My frames are displayed with the normal Windows look and feel.

I don't get any exception from calling UIManager.setLookAndFeel("com.jtattoo.plaf.acryl.AcrylLookAndFeel");

There is no other call to UIManager.setLookAndFeel(...) in my application.

The same JTattoo library is used in both projects.

Does anybody know what is going wrong?

Thanks,

J.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 31 2009
Added on Mar 3 2009
1 comment
245 views