請看看下面的代碼餐巾紙外觀和感覺錯誤
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