📄 rangebean.java
字号:
/**
* @version 1.20 1999-09-26
* @author Cay Horstmann
*/
import java.awt.*;
import java.beans.*;
import java.io.*;
import javax.swing.*;
public class RangeBean extends JPanel
implements VetoableChangeListener, Serializable
{ public RangeBean()
{ add(new JLabel("From"));
add(from);
add(new JLabel("To"));
add(to);
from.addVetoableChangeListener(this);
to.addVetoableChangeListener(this);
}
public void vetoableChange(PropertyChangeEvent event)
throws PropertyVetoException
{ int v = ((Integer)event.getNewValue()).intValue();
if (event.getSource() == from && v > to.getValue())
throw new PropertyVetoException("from > to", event);
if (event.getSource() == to && v < from.getValue())
throw new PropertyVetoException("to < from", event);
}
public int getFrom() { return from.getValue(); }
public int getTo() { return to.getValue(); }
public void setFrom(int v) throws PropertyVetoException
{ from.setValue(v);
}
public void setTo(int v) throws PropertyVetoException
{ to.setValue(v);
}
private IntTextBean from = new IntTextBean();
private IntTextBean to = new IntTextBean();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -