我只是有這個問題:的JPanel comonents無需點擊鼠標
public class Sales extends JPanel{
ArrayList<JPanel> panes;
ArrayList<String> tabs;
JTabbedPane tp;
public Sales(Dimension d){
setSize(d);
setLayout(null);
tp = new JTabbedPane();
Font f = new Font("Arial",Font.PLAIN,32);
tp.setFont(f);
for(Menu menu : FileManager.menus){
JPanel tmp = new JPanel();
/*int s = (int) Math.ceil(Math.sqrt(menu.products.size()));
tmp.setLayout(new GridLayout(s,s));
System.out.println("size" + s);
for(Product p : menu.products){
p.setFont(f);
tmp.add(p);
}*/
tp.addTab(menu.name,null,tmp,"What is this?");
}
tp.setBounds(0,0,getWidth(),getHeight());
add(tp);
}
}
這裏銷售的只是添加到一個簡單的JFrame:
public Main(){
super("HoboGames Pos System");
setUndecorated(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(this);
sale = new Sales(getSize());
add(sale);
}
一切正常,除了組件唐直到窗口由於點擊或更新而被更新時才繪製。所以它是一個空白的屏幕,直到你點擊的東西。(對不起,我削減了一些東西,如使其全屏幕...)
請編輯您的問題以包含展示您描述的問題的[sscce](http://sscce.org/)。 – trashgod 2013-02-20 23:50:10