本文整理汇总了Java中javax.swing.JTextField.setBorder方法的典型用法代码示例。如果您正苦于以下问题:Java JTextField.setBorder方法的具体用法?Java JTextField.setBorder怎么用?Java JTextField.setBorder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextField
的用法示例。
在下文中一共展示了JTextField.setBorder方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTableCellEditorComponent
import javax.swing.JTextField; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected,
int row, int column) {
JComponent c = (JComponent)super.getTableCellEditorComponent(table, value, isSelected, row, column);
cell.setText((String) value);
this.orig = cell.getTextField().getText();
this.action = ((ActionHolder) table.getValueAt(row, 0)).getAction();
final JTextField textField = cell.getTextField();
textField.addActionListener(delegate);
textField.setBorder(new LineBorder(Color.BLACK));
if(!Arrays.asList(textField.getKeyListeners()).contains(escapeAdapter)) {
textField.addKeyListener(escapeAdapter);
}
// allow the UI delegate to replace the background with more sensible color
cell.setBgColor(c.getBackground());
cell.setFgCOlor(c.getForeground(), false);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
textField.requestFocus();
}
});
return cell;
}
示例2: getTreeCellEditorComponent
import javax.swing.JTextField; //导入方法依赖的package包/类
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) {
Component c = super.getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row);
DirectoryNode node = (DirectoryNode)value;
editorPanel.setOpaque(false);
editorPanel.add(new JLabel(fileChooser.getIcon(node.getFile())), BorderLayout.CENTER);
editorPanel.add(c, BorderLayout.EAST);
textField = (JTextField)getComponent();
String text = fileChooser.getName(node.getFile());
textField.setText(text);
textField.setColumns(text.length());
//#232162
if( "Nimbus".equals( UIManager.getLookAndFeel().getID() ) ) { //NOI18N
textField.setBorder( BorderFactory.createEmptyBorder() );
}
return editorPanel;
}
示例3: getTableCellEditorComponent
import javax.swing.JTextField; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
Component editComponent = null;
this.domainVector = ctsDialog.getDomainVector();
this.domainName = (String) value;
if (this.domainName!=null && this.domainName.equals(GeneralGraphSettings4MAS.DEFAULT_DOMAIN_SETTINGS_NAME)==true) {
JLabel jLabel = new JLabel(this.domainName);
editComponent = jLabel;
} else {
JTextField jTextField = new JTextField(this.domainName);
jTextField.setBorder(BorderFactory.createEmptyBorder());
jTextField.getDocument().addDocumentListener(this.getTextFieldDocumentListener());
editComponent = jTextField;
}
return editComponent;
}
示例4: finishRename
import javax.swing.JTextField; //导入方法依赖的package包/类
private void finishRename(JTextField text, boolean saveName) {
String newName = text.getText();
if (saveName && newName != null && newName.length() > 0) {
try {
m_controller.rename(m_reference, newName);
} catch (IllegalNameException ex) {
text.setBorder(BorderFactory.createLineBorder(Color.red, 1));
text.setToolTipText(ex.getReason());
GuiTricks.showToolTipNow(text);
}
return;
}
// abort the rename
JPanel panel = (JPanel)m_infoPanel.getComponent(0);
panel.remove(panel.getComponentCount() - 1);
panel.add(GuiTricks.unboldLabel(new JLabel(m_reference.getNamableName(), JLabel.LEFT)));
m_editor.grabFocus();
redraw();
}
示例5: getTableCellEditorComponent
import javax.swing.JTextField; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, int row, int column) {
Component c = super.getTableCellEditorComponent(table, "", isSelected, row, column);
JTextField jtf = (JTextField) c;
initialValue = getValueAsTimestamp(value);
jtf.setText(dateFormat.format(initialValue));
if (suppressEditorBorder) {
jtf.setBorder(BorderFactory.createEmptyBorder());
}
return c;
}
示例6: setType
import javax.swing.JTextField; //导入方法依赖的package包/类
private void setType() {
int locationPoint = 323;
for (int i = 0; i < 3; i++) {
roomTypes = new JTextField();
roomTypes.setColumns(10);
roomTypes.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
roomTypes.setBounds(locationPoint, 97, 86, 20);
roomTypes.setVisible(false);
bottomPanel.add(roomTypes);
roomTypeFields[i] = roomTypes;
locationPoint = locationPoint + 96;
}
}
示例7: installUI
import javax.swing.JTextField; //导入方法依赖的package包/类
@Override
public void installUI(JComponent c) {
super.installUI(c);
jtf = (JTextField) c;
JTextField editor = jtf;
UIDefaults uidefaults = XToolkit.getUIDefaults();
String prefix = getPropertyPrefix();
Font f = editor.getFont();
if ((f == null) || (f instanceof UIResource)) {
editor.setFont(uidefaults.getFont(prefix + ".font"));
}
Color bg = editor.getBackground();
if ((bg == null) || (bg instanceof UIResource)) {
editor.setBackground(uidefaults.getColor(prefix + ".background"));
}
Color fg = editor.getForeground();
if ((fg == null) || (fg instanceof UIResource)) {
editor.setForeground(uidefaults.getColor(prefix + ".foreground"));
}
Color color = editor.getCaretColor();
if ((color == null) || (color instanceof UIResource)) {
editor.setCaretColor(uidefaults.getColor(prefix + ".caretForeground"));
}
Color s = editor.getSelectionColor();
if ((s == null) || (s instanceof UIResource)) {
editor.setSelectionColor(uidefaults.getColor(prefix + ".selectionBackground"));
}
Color sfg = editor.getSelectedTextColor();
if ((sfg == null) || (sfg instanceof UIResource)) {
editor.setSelectedTextColor(uidefaults.getColor(prefix + ".selectionForeground"));
}
Color dfg = editor.getDisabledTextColor();
if ((dfg == null) || (dfg instanceof UIResource)) {
editor.setDisabledTextColor(uidefaults.getColor(prefix + ".inactiveForeground"));
}
Border b = editor.getBorder();
if ((b == null) || (b instanceof UIResource)) {
editor.setBorder(uidefaults.getBorder(prefix + ".border"));
}
Insets margin = editor.getMargin();
if (margin == null || margin instanceof UIResource) {
editor.setMargin(uidefaults.getInsets(prefix + ".margin"));
}
}
示例8: ViewAlkaneLengthSelection
import javax.swing.JTextField; //导入方法依赖的package包/类
public ViewAlkaneLengthSelection(String frameTitle){
super(frameTitle);
this.setMinimumSize(new Dimension(500,200));
alkaneSpherePanel = new JPanel();
this.add(alkaneSpherePanel);
closeWindow = new JButton("Cancel");
saveValues = new JButton("Save");
GridBagLayout gridbagOtherParam = new GridBagLayout();
alkaneSpherePanel.setLayout(gridbagOtherParam);
NoOfSpheres = new JTextField();
NoOfSpheres.setColumns(10);
NoOfSpheres.setSize(new Dimension(5,20));
NoOfSpheres.setText("4");
JLabel NLabel = new JLabel("Cn (where n is 4 or greater)");
NLabel.setLabelFor(NoOfSpheres);
Border compoundField1;
compoundField1 = BorderFactory.createCompoundBorder(
BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder());
NoOfSpheres.setBorder(compoundField1);
JComponent[] OtherParamLeft= {NLabel,saveValues};
JComponent[] OtherParamRight = { NoOfSpheres,closeWindow};
addLeftRightComponents(OtherParamLeft,OtherParamRight,gridbagOtherParam,alkaneSpherePanel);
}
示例9: createTextField
import javax.swing.JTextField; //导入方法依赖的package包/类
/** Create a test field. */
private JTextField createTextField(int width) {
JTextField f = new JTextField(width);
f.setEditable(false);
f.setBorder(null);
return f;
}
示例10: IndividualDataPanel
import javax.swing.JTextField; //导入方法依赖的package包/类
public IndividualDataPanel(ZooracleContentPanel zooracleContentPanel)
{
this.zooracleContentPanel = zooracleContentPanel;
labelName = GUISettings.getDefaultLabel(Locale.labelName, lw, lh, a, va);
labelGender = GUISettings.getDefaultLabel(Locale.labelSex, lw, lh, a, va);
labelComment = GUISettings.getDefaultLabel(Locale.labelComment, lw, 80, a, va);
labelMetaData = GUISettings.getDefaultLabel(Locale.labelMetaData, lw, 100, a, va);
textFieldName = new JTextField(""); textFieldName.setPreferredSize(new Dimension(200, 30)); textFieldName.setBorder(BorderFactory.createLineBorder(Color.BLACK));
textAreaComment = new JTextArea(); textAreaComment.setPreferredSize(new Dimension(200, 80));
textAreaComment.setBorder(BorderFactory.createLineBorder(Color.BLACK));
comboBoxGender = new JComboBox();
// comboBoxGender.setBorder(BorderFactory.createLineBorder(Color.BLACK));
for (Object item : Locale.dropDownGenders)
comboBoxGender.addItem(item);
// Create some items to add to the list
String listData[] =
{
"BT_1.1",
"BT_1.2",
"BT_1.3",
"BT_1.4"
};
metaList = new JList(listData);
JScrollPane metaScrollPane = new JScrollPane(metaList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
metaScrollPane.setPreferredSize(new Dimension(200, 100));
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
JPanel panelName = new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel panelGender = new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel panelComment = new JPanel(new FlowLayout(FlowLayout.LEFT));
JPanel panelMetaList = new JPanel(new FlowLayout(FlowLayout.LEFT));
panelName.add(labelName);
panelName.add(textFieldName);
panelGender.add(labelGender);
panelGender.add(comboBoxGender);
panelComment.add(labelComment);
panelComment.add(textAreaComment);
panelMetaList.add(labelMetaData);
panelMetaList.add(metaScrollPane);
this.add(panelName);
this.add(panelGender);
this.add(panelComment);
this.add(panelMetaList);
this.setBackground(GUISettings.windowColor);
this.setForeground(GUISettings.windowColor);
this.setMinimumSize(new Dimension(300, 500));
}
示例11: ToadDataPanel
import javax.swing.JTextField; //导入方法依赖的package包/类
public ToadDataPanel(DisplayMode displayMode)
{
super(displayMode);
comboBoxPopulation = new JComboBox();
for (Object item : Locale.dropDownPopulations)
comboBoxPopulation.addItem(item);
comboBoxPopulation.setPreferredSize(new Dimension(iw, lh));
textFieldSize1 = new JTextField(""); textFieldSize1.setPreferredSize(new Dimension(iw, 30)); textFieldSize1.setBorder(BorderFactory.createLineBorder(Color.BLACK));
textFieldSize2 = new JTextField(""); textFieldSize2.setPreferredSize(new Dimension(iw, 30)); textFieldSize2.setBorder(BorderFactory.createLineBorder(Color.BLACK));
textFieldWeight = new JTextField(""); textFieldWeight.setPreferredSize(new Dimension(iw, 30)); textFieldWeight.setBorder(BorderFactory.createLineBorder(Color.BLACK));
textFieldTotal = new JTextField(""); textFieldTotal.setPreferredSize(new Dimension(iw, 30)); textFieldTotal.setBorder(BorderFactory.createLineBorder(Color.BLACK));
textFieldTotal.setEditable(false);
labelPopulation = GUISettings.getDefaultLabel(Locale.labelPopulation, lw, lh, a, va);
labelSize1 = GUISettings.getDefaultLabel(Locale.labelSize1, lw, lh, a, va);
labelSize2 = GUISettings.getDefaultLabel(Locale.labelSize2, lw, lh, a, va);
labelSizeTotal = GUISettings.getDefaultLabel(Locale.labelSizeTotal, lw, lh, a, va);
labelWeight = GUISettings.getDefaultLabel(Locale.labelWeight, lw, lh, a, va);
JPanel panelSize1 = new JPanel(new FlowLayout(orientation));
JPanel panelSize2 = new JPanel(new FlowLayout(orientation));
JPanel panelSizeTotal = new JPanel(new FlowLayout(orientation));
JPanel panelWeight = new JPanel(new FlowLayout(orientation));
JPanel panelPopulation = new JPanel(new FlowLayout(orientation));
if (currentDisplayMode.equals(DisplayMode.vertical_align_left))
{
panelSize1.add(textFieldSize1);
panelSize1.add(labelSize1);
panelSize2.add(textFieldSize2);
panelSize2.add(labelSize2);
panelSizeTotal.add(textFieldTotal);
panelSizeTotal.add(labelSizeTotal);
panelWeight.add(textFieldWeight);
panelWeight.add(labelWeight);
panelPopulation.add(comboBoxPopulation);
panelPopulation.add(labelPopulation);
}
else
{
panelSize1.add(labelSize1);
panelSize1.add(textFieldSize1);
panelSize2.add(labelSize2);
panelSize2.add(textFieldSize2);
panelSizeTotal.add(labelSizeTotal);
panelSizeTotal.add(textFieldTotal);
panelWeight.add(labelWeight);
panelWeight.add(textFieldWeight);
panelPopulation.add(labelPopulation);
panelPopulation.add(comboBoxPopulation);
}
inputLabels.add(labelSize1);
inputLabels.add(labelSize2);
inputLabels.add(labelSizeTotal);
inputLabels.add(labelWeight);
inputLabels.add(labelPopulation);
JPanel toadDataPanel = new JPanel();
toadDataPanel.setLayout(new BoxLayout(toadDataPanel, BoxLayout.Y_AXIS));
toadDataPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black, 1), Locale.labelToadData));
toadDataPanel.add(panelPopulation);
toadDataPanel.add(panelSize1);
toadDataPanel.add(panelSize2);
toadDataPanel.add(panelSizeTotal);
toadDataPanel.add(panelWeight);
JPanel placeholder = new JPanel();
toadDataPanel.add(placeholder);
dataPanel.add(toadDataPanel);
}
示例12: ViewSimEnvironmentSelection
import javax.swing.JTextField; //导入方法依赖的package包/类
public ViewSimEnvironmentSelection(ModelSimulationEnvironment simEnvironmentObj){
super();
this.setMinimumSize(new Dimension(500,400));
SimEnvParamPanel = new JPanel();
GridBagLayout gridbagOtherParam = new GridBagLayout();
SimEnvParamPanel.setLayout(gridbagOtherParam);
this.add(SimEnvParamPanel);
closeWindow = new JButton("Cancel");
saveValues = new JButton("Save");
temperatureField = new JTextField();
temperatureField.setColumns(10);
temperatureField.setSize(new Dimension((int)temperatureField.getSize().getWidth(),20));
temperatureField.setText(Double.toString(simEnvironmentObj.getTemperature()));
JLabel temperatureLabel = new JLabel("Temperature(K)");
temperatureLabel.setLabelFor(temperatureField);
Border compoundField1;
compoundField1 = BorderFactory.createCompoundBorder(
BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder());
temperatureField.setBorder(compoundField1);
noOfStepsField = new JTextField();
noOfStepsField.setColumns(10);
JLabel NoOfStepsLabel = new JLabel("Steps");
noOfStepsField.setText(Integer.toString(simEnvironmentObj.getNoOfSteps()));
NoOfStepsLabel.setLabelFor(noOfStepsField);
Border compoundField2;
compoundField2 = BorderFactory.createCompoundBorder(
BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder());
noOfStepsField.setBorder(compoundField2);
sigmaHSRefField = new JTextField[10];
sigmaHSRefLabel = new JLabel[10];
sigmaHSRefBorder = new Border[10];
for(int i=0;i<10;i++){
sigmaHSRefField[i] = new JTextField();
sigmaHSRefField[i].setColumns(10);
String index = Integer.toString(i+1);
sigmaHSRefLabel[i] = new JLabel("SigmaHSRef"+index);
sigmaHSRefLabel[i].setLabelFor(sigmaHSRefField[i]);
if(simEnvironmentObj.getSigmaHSRef(i) == 0.0){
sigmaHSRefField[i].setText("0.0");
sigmaHSRefField[i].setVisible(false);
sigmaHSRefLabel[i].setVisible(false);
}else{
sigmaHSRefField[i].setText(Double.toString(simEnvironmentObj.getSigmaHSRef(i)));
}
sigmaHSRefBorder[i] = BorderFactory.createCompoundBorder(
BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder());
sigmaHSRefField[i].setBorder(sigmaHSRefBorder[i]);
}
JComponent[] OtherParamLeft= {temperatureLabel, NoOfStepsLabel, sigmaHSRefLabel[0],sigmaHSRefLabel[1],sigmaHSRefLabel[2],sigmaHSRefLabel[3],
sigmaHSRefLabel[4],sigmaHSRefLabel[5],sigmaHSRefLabel[6],sigmaHSRefLabel[7],
sigmaHSRefLabel[8],sigmaHSRefLabel[9],saveValues};
JComponent[] OtherParamRight = { temperatureField,noOfStepsField,sigmaHSRefField[0],sigmaHSRefField[1],sigmaHSRefField[2],sigmaHSRefField[3],
sigmaHSRefField[4],sigmaHSRefField[5],sigmaHSRefField[6],sigmaHSRefField[7],
sigmaHSRefField[8],sigmaHSRefField[8],closeWindow};
addLeftRightComponents(OtherParamLeft,OtherParamRight,gridbagOtherParam,SimEnvParamPanel);
Border compound2;
compound2 = BorderFactory.createCompoundBorder(
BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder());
SimEnvParamPanel.setBorder(compound2);
}
示例13: createEditorComponent
import javax.swing.JTextField; //导入方法依赖的package包/类
/**
* Creates the internal editor component. Override this to provide
* a custom implementation.
*
* @return a new editor component
* @since 1.6
*/
protected JTextField createEditorComponent() {
JTextField editor = new BorderlessTextField("",9);
editor.setBorder(null);
return editor;
}