?? maxintervaltimebean.java~2~
字號:
package readfileprocessbarbean;import java.awt.*;import javax.swing.JLabel;import javax.swing.*;import java.beans.*;/** * 這個JavaBean組件是用來定義進度條的最大間隔時間 */public class maxIntervalTimeBean extends JLabel{ BorderLayout borderLayout1 = new BorderLayout(); private int maxIntervalTimeValue; // 存放最大間隔時間 /* 實例化一個PropertyChangeSupport的局部對象 */ private PropertyChangeSupport changes = new PropertyChangeSupport(this); public maxIntervalTimeBean() { try { jbInit(); } catch(Exception ex) { ex.printStackTrace(); } } private void jbInit() throws Exception { this.setLayout(borderLayout1); } public void setmaxIntervalTimeValue() { /* 設計器的方法,其中引用關聯屬性 */ int oldmaxIntervalTimeValue = this.maxIntervalTimeValue; // 定義一個變量,用以存放原來的屬性值 int newmaxIntervalTimeValue = -1; // 定義一個變量,用以存放當前的屬性值 /* 調用showOptionDialogWindows()方法來設置新的進度條最大時間間隔 */ newmaxIntervalTimeValue = this.showOptionDialogWindows(); this.maxIntervalTimeValue = newmaxIntervalTimeValue; changes.firePropertyChange("maxIntervalTimeValue",oldmaxIntervalTimeValue,newmaxIntervalTimeValue); } public int getmaxIntervalTimeValue() { return maxIntervalTimeValue; } private int showOptionDialogWindows() { /* 這是一個顯示提示框的方法 */ JSlider slid = new JSlider(); // 首先建立一個滑動塊對象 MainFrame mainframe = new MainFrame(); Object[] opt = {"確 定"}; int inputValue = -1; slid.setMaximum(60); slid.setMinimum(10); slid.setValue(20); JOptionPane.showOptionDialog(mainframe,slid,"設定進度條的最大間隔時間(10ms~80ms):",JOptionPane.OK_OPTION,JOptionPane.QUESTION_MESSAGE,null,null,opt[0]); inputValue = slid.getValue(); if(inputValue < 10 || inputValue > 80) {inputValue = 20;} return inputValue; } public void addPropertyChangeListener(PropertyChangeListener l) { /* 注冊屬性監聽方法 */ try {changes.addPropertyChangeListener(l);} catch(Exception e) {} } public void removePropertyChangeListener(PropertyChangeListener l) { /* 刪除屬性監聽方法 */ try {changes.removePropertyChangeListener(l);} catch(Exception e) {} }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -