0
比方說,我有2個JFrames。將JFrame設置爲可見之後,如果不首先將隱藏和正常的可見性設置爲可見,您似乎無法更改LAF。這意味着一個閃爍,並且JFrame跳轉到頂部。如何讓某個JFrame與其他JFrame有不同的LAF?
否則,你會得到這樣的:
另外,重繪似乎並沒有幫助(金屬和Ubuntu系統LAF之間的一些混合物)。
現在,假設第一個JFrame是使用Metal LAF製作的。顯示之後,LAF將更改爲系統LAF。然後出現第二個。現在,第一個受到這個有趣的事情的影響。第二個是好的。這是爲什麼?這是我的代碼有:
public static void main(String[] args) throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException {
JFrame first = new JFrame("First");
first.add(new JButton("Click me, I look funny"));
first.setPreferredSize(new Dimension(100, 100));
first.pack();
first.setVisible(true);
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
first.repaint();
JFrame second = new JFrame("Second");
second.add(new JButton("Click"));
second.setPreferredSize(new Dimension(100, 100));
second.pack();
second.setVisible(true);
second.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
那麼,怎樣才能讓我的新的LAF隻影響1 JFrame的?
或者是LAF全局,不能僅適用於1個JFrame?
* 「比方說,我有2個JFrames。」 *請參閱(HTTP [多個JFrames,好/壞的做法的使用?] ://stackoverflow.com/q/9554636/418556) –