List of usage examples for javax.swing JTextField setColumns
@BeanProperty(bound = false, description = "the number of columns preferred for display") public void setColumns(int columns)
TextField
, and then invalidate the layout. From source file:savant.plugin.ToolSettingsPanel.java
private void addArgumentToPanel(ToolArgument arg, int row) { GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(5, 5, 5, 5); gbc.gridy = row;/*ww w . j av a 2 s . c o m*/ JComponent widget = null; if (arg.type == ToolArgument.Type.BOOL) { gbc.gridx = 2; gbc.anchor = GridBagConstraints.WEST; addWidget(arg, new BoolCheck(arg), gbc); } else { gbc.gridx = 1; gbc.anchor = GridBagConstraints.EAST; JLabel nameLabel = new JLabel(arg.name + ":"); add(nameLabel, gbc); gbc.gridx = 2; gbc.anchor = GridBagConstraints.WEST; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; JTextField field = null; switch (arg.type) { case INT: field = new JFormattedTextField(); ((JFormattedTextField) field).setValue(Integer.valueOf(arg.value != null ? arg.value : "0")); field.setColumns(5); addField(arg, field, gbc); break; case FLOAT: field = new JFormattedTextField(); ((JFormattedTextField) field).setValue(Double.valueOf(arg.value != null ? arg.value : "0.0")); field.setColumns(10); addField(arg, field, gbc); break; case OUTPUT_FILE: gbc.gridwidth = 1; gbc.fill = GridBagConstraints.HORIZONTAL; field = new JTextField(arg.value); addField(arg, field, gbc); gbc.gridx = 3; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 0.0; JCheckBox loadCheck = new JCheckBox("Load upon Completion", true); loadCheck.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { tool.loadUponCompletion = ((JCheckBox) ae.getSource()).isSelected(); } }); add(loadCheck, gbc); break; case RANGE: field = new JTextField(); field.setColumns(25); LocationController.getInstance().addListener(new RangeUpdater(field)); addField(arg, field, gbc); break; case LIST: addWidget(arg, new StringCombo(arg), gbc); break; case MULTI: gbc.fill = GridBagConstraints.HORIZONTAL; addWidget(arg, new MultiCheckGrid(arg), gbc); break; case BAM_INPUT_FILE: TrackUtils.addTrackListener( (TrackCombo) addWidget(arg, new TrackCombo(arg, DataFormat.ALIGNMENT), gbc)); break; case FASTA_INPUT_FILE: TrackUtils.addTrackListener( (TrackCombo) addWidget(arg, new TrackCombo(arg, DataFormat.SEQUENCE), gbc)); break; } } }