请看看下面的代码餐巾纸外观和感觉错误
Form.java
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class Form extends JFrame
{
private JButton[]buttonHolder;
public Form()
{
//Intializing instance variables
buttonHolder = new JButton[9];
this.add(createCenterPanel());
this.setSize(300,300);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private JPanel createCenterPanel()
{
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new GridLayout(3,3,0,0));
for(int i=0;i<9;i++)
{
buttonHolder[i] = new JButton();
centerPanel.add(buttonHolder[i]);
}
return centerPanel;
}
}
Main.java
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import napkin.NapkinLookAndFeel;
public class Main
{
public static void main(String[]args)
{
try
{
Form f = new Form();
UIManager.setLookAndFeel(new NapkinLookAndFeel());
}
catch(Exception e)
{
}
}
}
我使用餐巾纸的外观和感觉这里,我得到错误keys we didn't overwrite: []
。为什么是这样?我没有得到GUI。请帮忙。
如果你掉这些语句的顺序(即设置UIManager的外观和感觉_before_实例化“Form”,而不是事后)。 – 2013-03-12 17:28:07
@IanRoberts:适用于GUI显示。但是这并没有消除这个信息。无论如何,这不是一个例外 – 2013-03-12 17:49:41