67 lines
1.6 KiB
Java
67 lines
1.6 KiB
Java
package org.hwo.ui.servicelink.register;
|
|
|
|
import java.awt.Component;
|
|
import java.awt.event.FocusEvent;
|
|
import java.awt.event.FocusListener;
|
|
import java.math.BigInteger;
|
|
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JTextField;
|
|
|
|
import org.hwo.io.servicelink.ServiceLink;
|
|
import java.awt.GridBagLayout;
|
|
import java.awt.GridBagConstraints;
|
|
|
|
public class IntegerRegisterEditor extends JPanel implements ServiceRegisterControl {
|
|
|
|
private ServiceRegister serviceRegister;
|
|
private JTextField tfValue;
|
|
|
|
public IntegerRegisterEditor()
|
|
{
|
|
super();
|
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
|
gridBagLayout.columnWidths = new int[]{0, 0};
|
|
gridBagLayout.rowHeights = new int[]{0, 0};
|
|
gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
gridBagLayout.rowWeights = new double[]{0.0, Double.MIN_VALUE};
|
|
setLayout(gridBagLayout);
|
|
|
|
tfValue = new JTextField();
|
|
GridBagConstraints gbc_tfValue = new GridBagConstraints();
|
|
gbc_tfValue.fill = GridBagConstraints.HORIZONTAL;
|
|
gbc_tfValue.gridx = 0;
|
|
gbc_tfValue.gridy = 0;
|
|
add(tfValue, gbc_tfValue);
|
|
tfValue.setColumns(10);
|
|
}
|
|
|
|
@Override
|
|
public Component getComponent() {
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public void setServiceRegister(ServiceRegister serviceRegister) {
|
|
this.serviceRegister = serviceRegister;
|
|
}
|
|
|
|
@Override
|
|
public void writeValue() {
|
|
this.serviceRegister.writeIntegerValue(Integer.decode(tfValue.getText()));
|
|
}
|
|
|
|
@Override
|
|
public void readValue() {
|
|
Integer i = this.serviceRegister.readIntegerValue();
|
|
if ( i == null )
|
|
i = 0;
|
|
tfValue.setText(i.toString());
|
|
}
|
|
|
|
@Override
|
|
public boolean requestFocusInWindow() {
|
|
return tfValue.requestFocusInWindow();
|
|
}
|
|
}
|