Reputation: 253
I use jgoodies in my project. It works good only with some components.
Look at my project, please.
As you can see JButton, JTextField, JLabel, JFrame have been successfully modified. But JTabbedPane and JRadioButton have not been modified. Jgoodies had no impact on them. JTabbedPane created when the user selects the menu item. You can see it in this code:
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
createTabbedPane();
fieldForName.requestFocus();
}
});
In this ActionListener I call method createTabbedPane();
that creates JTabbedPane:
private static void createTabbedPane() {
taskTabbedPane.setBounds(50, 50, 1000, 550);
taskTabbedPane.addTab("Задача", createTasksMainInfoPanel());
taskTabbedPane.addTab("Данные", null);
taskTabbedPane.setEnabledAt(1, false);
}
I set look and fell in main method:
public static void main(String[] args) {
// TODO Auto-generated method stub
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(new Plastic3DLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
createAndShowGui();
}
});
}
What I'm doing wrong?
Upvotes: 0
Views: 198
Reputation: 66
It seems to me that the JTabbedPane is created before the JGoodies L&f is installed. That should explain why updating the component tree affects the JTabbedPane UI delegates. Your method #createTabbedPane does not create the JTabbedPane, it just configures it.
A change of the tab layout policy is not required. Updating the component tree is only necessary if you change the L&f at runtime.
Btw. all Swing initialization must happen in the EDT, and so it is necessary to create the GUI in the EDT.
Upvotes: 0
Reputation: 253
I decided my problem. I found 2 solutions. The first solution is to add this code:
taskTabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
Another solution is to add this code:
SwingUtilities.updateComponentTreeUI(taskTabbedPane);
Thank you all for your help
Upvotes: 0