📄 maxintervaltimebean.java
字号:
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 > 60) {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 + -