參照一些網友的資料,終於做了個swing的界面。
repaint(); 組件重繪方法
//重新設置組件的顯示尺寸,可是外層的JScrollPane適應變化
JPanel.setPreferredSize(new Dimension(this.width,this.height))
JScrollPane.setViewportView(JPanel);
ImagePanel();
scrollPane.revalidate();//重新顯示JScrollPane形狀。
Jbutton 組件引發ActionEvent事件,可註冊addActionListener監聽器,實現actionPerformed()方法。用getActionCommand()或getSource方法確定事件源。
JCheckBox類的選擇事件是ItemEvent,可註冊addItemListener監聽器,實現ItemListener接口的itemStateChanged()方法處理事件。