
org.yaoqiang.collaboration.TextPanel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yaoqiang-bpmn-editor Show documentation
Show all versions of yaoqiang-bpmn-editor Show documentation
an Open Source BPMN 2.0 Modeler
package org.yaoqiang.collaboration;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
/**
* TextPanel
*
* @author Shi Yaoqiang([email protected])
*/
public class TextPanel extends JPanel {
private static final long serialVersionUID = 3113761135402336001L;
protected JTextField textField;
public TextPanel(String name) {
this(name, false, 150, 27);
}
public TextPanel(String name, String value) {
this(name, false, 150, 27);
textField.setText(value);
}
public TextPanel(String name, String value, boolean password) {
this(name, password, 150, 27);
textField.setText(value);
}
public TextPanel(String name, int width, int height) {
this(name, false, width, height);
}
public TextPanel(String name, boolean password, int width, int height) {
setLayout(new BorderLayout());
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
JLabel label = new JLabel(name + ": ");
if (password) {
textField = new JPasswordField();
} else {
textField = new JTextField();
}
Dimension textDim = new Dimension(width, height);
textField.setMinimumSize(textDim);
textField.setMaximumSize(textDim);
textField.setPreferredSize(textDim);
add(label, BorderLayout.WEST);
add(Box.createHorizontalGlue(), BorderLayout.EAST);
add(textField, BorderLayout.CENTER);
}
public String getText() {
return textField.getText().trim();
}
public void setText(String text) {
textField.setText(text);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy