如何點擊一個JButton獲得它上面的圖片,再點擊另一個JButton讓這個上面顯示剛才那個按鈕上的圖片,謝謝~
public class Dialog2 extends JDialog{ JPanel panel1 = new JPanel(); BorderLayout borderLayout1 = new BorderLayout(); public Dialog2(Frame owner, String title, boolean modal) { super(owner, title, modal); try { setDefaultCloseOperation(DISPOSE_ON_CLOSE); jbInit(); pack(); } catch (Exception exception) { exception.printStackTrace(); } } public Dialog2() { this(new Frame(), "Dialog2", true);//這裡設為了模態 this.setSize(10,20);//這裡設對話框大小 } private void jbInit() throws Exception { panel1.setLayout(borderLayout1); getContentPane().add(panel1); }}用這個就可以了