Java Code Examples for javax.swing.JTextField
The following examples show how to use
javax.swing.JTextField.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: JByteMod-Beta Author: GraxCode File: MyMenuBar.java License: GNU General Public License v2.0 | 6 votes |
protected void searchLDC() { final JPanel panel = new JPanel(new BorderLayout(5, 5)); final JPanel input = new JPanel(new GridLayout(0, 1)); final JPanel labels = new JPanel(new GridLayout(0, 1)); panel.add(labels, "West"); panel.add(input, "Center"); panel.add(new JLabel(JByteMod.res.getResource("big_string_warn")), "South"); labels.add(new JLabel(JByteMod.res.getResource("find"))); JTextField cst = new JTextField(); input.add(cst); JCheckBox exact = new JCheckBox(JByteMod.res.getResource("exact")); JCheckBox regex = new JCheckBox("Regex"); JCheckBox snstv = new JCheckBox(JByteMod.res.getResource("case_sens")); labels.add(exact); labels.add(regex); input.add(snstv); input.add(new JPanel()); if (JOptionPane.showConfirmDialog(this.jbm, panel, "Search LDC", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, searchIcon) == JOptionPane.OK_OPTION && !cst.getText().isEmpty()) { jbm.getSearchList().searchForConstant(cst.getText(), exact.isSelected(), snstv.isSelected(), regex.isSelected()); } }
Example #2
Source Project: nanoleaf-desktop Author: rowak File: SingleEntryDialog.java License: MIT License | 6 votes |
public SingleEntryDialog(Component parent, String entryLabel, String buttonLabel, ActionListener buttonListener) { super(); entry = new JTextField(entryLabel); entry.setForeground(Color.WHITE); entry.setBackground(Color.DARK_GRAY); entry.setBorder(new LineBorder(Color.GRAY)); entry.setCaretColor(Color.WHITE); entry.setFont(new Font("Tahoma", Font.PLAIN, 22)); entry.addFocusListener(new TextFieldFocusListener(entry)); contentPanel.add(entry, "cell 0 1, grow, gapx 2 2"); JButton btnConfirm = new ModernButton(buttonLabel); btnConfirm.setFont(new Font("Tahoma", Font.PLAIN, 18)); btnConfirm.addActionListener(buttonListener); contentPanel.add(btnConfirm, "cell 0 3, alignx center"); JLabel spacer = new JLabel(" "); contentPanel.add(spacer, "cell 0 4"); finalize(parent); btnConfirm.requestFocus(); }
Example #3
Source Project: netbeans Author: apache File: AdminPropertiesPanel.java License: Apache License 2.0 | 6 votes |
private void chooseFile(JTextField txtField) { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(null); chooser.setFileSelectionMode (JFileChooser.FILES_ONLY); String path = txtField.getText().trim(); if (path != null && path.length() > 0) { chooser.setSelectedFile(new File(path)); } else if (recentDirectory != null) { chooser.setCurrentDirectory(new File(recentDirectory)); } if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) { return; } File selectedFile = chooser.getSelectedFile(); recentDirectory = selectedFile.getParentFile().getAbsolutePath(); txtField.setText(selectedFile.getAbsolutePath()); }
Example #4
Source Project: netbeans Author: apache File: EjbFacadeVisualPanel2.java License: Apache License 2.0 | 6 votes |
public EjbFacadeVisualPanel2(Project project, WizardDescriptor wizard) { this.wizard = wizard; this.project = project; initComponents(); packageComboBoxEditor = ((JTextField) packageComboBox.getEditor().getEditorComponent()); packageComboBoxEditor.getDocument().addDocumentListener(this); handleCheckboxes(); J2eeProjectCapabilities projectCap = J2eeProjectCapabilities.forProject(project); if (projectCap.isEjb31LiteSupported()){ boolean serverSupportsEJB31 = ProjectUtil.getSupportedProfiles(project).contains(Profile.JAVA_EE_6_FULL) || ProjectUtil.getSupportedProfiles(project).contains(Profile.JAVA_EE_7_FULL) || ProjectUtil.getSupportedProfiles(project).contains(Profile.JAVA_EE_8_FULL); if (!projectCap.isEjb31Supported() && !serverSupportsEJB31){ remoteCheckBox.setVisible(false); remoteCheckBox.setEnabled(false); } } else { localCheckBox.setSelected(true); } updateInProjectCombo(false); }
Example #5
Source Project: CQL Author: CategoricalData File: SqlLoader.java License: GNU Affero General Public License v3.0 | 6 votes |
private void doLoad() { try { if (!input.getText().trim().isEmpty()) { throw new RuntimeException("Cannot load if text entered"); } JPanel pan = new JPanel(new GridLayout(2, 2)); pan.add(new JLabel("JDBC Driver Class")); JTextField f1 = new JTextField("com.mysql.jdbc.Driver"); pan.add(f1); JTextField f2 = new JTextField("jdbc:mysql://localhost/buzzbuilder?user=root&password=whasabi"); pan.add(new JLabel("JDBC Connection String")); pan.add(f2); int i = JOptionPane.showConfirmDialog(null, pan); if (i != JOptionPane.OK_OPTION) { return; } Class.forName(f1.getText().trim()); conn = DriverManager.getConnection(f2.getText().trim()); populate(); } catch (ClassNotFoundException | RuntimeException | SQLException ex) { ex.printStackTrace(); handleError(ex.getLocalizedMessage()); } }
Example #6
Source Project: netbeans Author: apache File: PropertyPanel.java License: Apache License 2.0 | 6 votes |
/** Creates new form PropertyPanel */ public PropertyPanel(PropertiesPanel.PropertiesParamHolder propParam, boolean add, String propName, String propValue) { initComponents(); provider = propParam.getProvider(); // The comb box only contains the property names that are not defined yet when adding if (add) { nameComboBox.setModel(new DefaultComboBoxModel(Util.getAvailPropNames(provider, propParam.getPU()).toArray(new String[]{}))); } else { nameComboBox.setModel(new DefaultComboBoxModel(Util.getPropsNamesExceptGeneral(provider).toArray(new String[]{}))); nameComboBox.setSelectedItem(propName); } valueTextField = new JTextField(); valueComboBox = new JComboBox(); // Add the appropriate component for the value String selectedPropName = (String) nameComboBox.getSelectedItem(); addValueComponent(selectedPropName, propValue); nameComboBox.addActionListener((ActionListener) this); // Disable the name combo box for editing nameComboBox.setEnabled(add); }
Example #7
Source Project: FoxTelem Author: ac2cz File: SettingsFrame.java License: GNU General Public License v3.0 | 6 votes |
private JTextField addSettingsRow(JPanel column, int length, String name, String tip, String value) { JPanel panel = new JPanel(); column.add(panel); panel.setLayout(new GridLayout(1,2,5,5)); JLabel lblDisplayModuleFont = new JLabel(name); lblDisplayModuleFont.setToolTipText(tip); panel.add(lblDisplayModuleFont); JTextField textField = new JTextField(value); panel.add(textField); textField.setColumns(length); textField.addActionListener(this); textField.addFocusListener(this); // column.add(new Box.Filler(new Dimension(10,5), new Dimension(10,5), new Dimension(10,5))); return textField; }
Example #8
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Test6968363.java License: GNU General Public License v2.0 | 6 votes |
@Override public void run() { if (this.frame == null) { Thread.setDefaultUncaughtExceptionHandler(this); this.frame = new JFrame(getClass().getSimpleName()); this.frame.add(NORTH, new JLabel("Copy Paste a HINDI text into the field below")); this.frame.add(SOUTH, new JTextField(new MyDocument(), "\u0938", 10)); this.frame.pack(); this.frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.frame.setLocationRelativeTo(null); this.frame.setVisible(true); } else { this.frame.dispose(); this.frame = null; } }
Example #9
Source Project: sc2gears Author: icza File: MiscSettingsDialog.java License: Apache License 2.0 | 6 votes |
public void storeSetting() { if ( component instanceof JSpinner ) Settings.set( settingKey, ( (JSpinner) component ).getValue() ); else if ( component instanceof JSlider ) Settings.set( settingKey, ( (JSlider) component ).getValue() ); else if ( component instanceof JTextField ) Settings.set( settingKey, ( (JTextField) component ).getText() ); else if ( component instanceof JCheckBox ) Settings.set( settingKey, ( (JCheckBox) component ).isSelected() ); else if ( component instanceof JComboBox ) { Settings.set( settingKey, ( (JComboBox< ? >) component ).getSelectedIndex() ); final JComboBox< ? > comboBox = (JComboBox< ? >) component; if ( comboBox.isEditable() ) // It's a pre-defined list combo box Settings.set( settingKey, comboBox.getSelectedItem() ); else // Normal combo box Settings.set( settingKey, comboBox.getSelectedIndex() ); } }
Example #10
Source Project: iBioSim Author: MyersResearchGroup File: SBOLDescriptorPanel2.java License: Apache License 2.0 | 6 votes |
public void constructPanel(Set<String> sbolFilePaths) { idText = new JTextField("", 40); nameText = new JTextField("", 40); descriptionText = new JTextField("", 40); saveFilePaths = new LinkedList<String>(sbolFilePaths); saveFilePaths.add("Save to New File"); saveFileIDBox = new JComboBox(); for (String saveFilePath : saveFilePaths) { saveFileIDBox.addItem(GlobalConstants.getFilename(saveFilePath)); } add(new JLabel("SBOL ComponentDefinition ID:")); add(idText); add(new JLabel("SBOL ComponentDefinition Name:")); add(nameText); add(new JLabel("SBOL ComponentDefinition Description:")); add(descriptionText); }
Example #11
Source Project: marathonv5 Author: jalian-systems File: JComboBoxJavaElement.java License: Apache License 2.0 | 6 votes |
@Override public boolean marathon_select(final String value) { final String text = JComboBoxOptionJavaElement.stripHTMLTags(value); int selectedItem = findMatch(value, new Predicate() { @Override public boolean isValid(JComboBoxOptionJavaElement e) { if (!text.equals(e.getAttribute("text"))) { return false; } return true; } }); if (selectedItem == -1) { if (((JComboBox) getComponent()).isEditable()) { ((JTextField) ((JComboBox) getComponent()).getEditor().getEditorComponent()).setText(value); return true; } return false; } ((JComboBox) getComponent()).setSelectedIndex(selectedItem); return true; }
Example #12
Source Project: atdl4j Author: atdl4j File: SwingNullableSpinner.java License: MIT License | 6 votes |
private NumberEditorNull(JSpinner spinner, DecimalFormat format) { super(spinner); if (!(spinner.getModel() instanceof SpinnerNumberModelNull)) { return; } SpinnerNumberModelNull model = (SpinnerNumberModelNull) spinner.getModel(); NumberFormatter formatter = new NumberEditorFormatterNull(model, format); DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); JFormattedTextField ftf = getTextField(); ftf.setEditable(true); ftf.setFormatterFactory(factory); ftf.setHorizontalAlignment(JTextField.RIGHT); try { String maxString = formatter.valueToString(model.getMinimum()); String minString = formatter.valueToString(model.getMaximum()); ftf.setColumns(Math.max(maxString.length(), minString.length())); } catch (ParseException e) { // TBD should throw a chained error here } }
Example #13
Source Project: wildfly-core Author: wildfly File: OperationDialog.java License: GNU Lesser General Public License v2.1 | 6 votes |
private void setInputComponent() { this.label = makeLabel(); if (type == ModelType.BOOLEAN && !expressionsAllowed) { this.valueComponent = new JCheckBox(makeLabelString(false)); this.valueComponent.setToolTipText(description); this.label = new JLabel(); // checkbox doesn't need a label } else if (type == ModelType.UNDEFINED) { JLabel jLabel = new JLabel(); this.valueComponent = jLabel; } else if (props.get("allowed").isDefined()) { JComboBox comboBox = makeJComboBox(props.get("allowed").asList()); this.valueComponent = comboBox; } else if (type == ModelType.LIST) { ListEditor listEditor = new ListEditor(OperationDialog.this); this.valueComponent = listEditor; } else if (type == ModelType.BYTES) { this.valueComponent = new BrowsePanel(OperationDialog.this); } else { JTextField textField = new JTextField(30); this.valueComponent = textField; } }
Example #14
Source Project: marvinproject Author: gabrielarchanjo File: MarvinAttributesPanel.java License: GNU Lesser General Public License v3.0 | 5 votes |
/** * Adds TextField * @param id component id. * @param attrID attribute id. * @param attr MarivnAttributes Object. */ public void addTextField(String id, String attrID, MarvinAttributes attr) { JComponent comp = new JTextField(5); ((JTextField)(comp)).setText(attr.get(attrID).toString()); plugComponent(id, comp, attrID, attr, ComponentType.COMPONENT_TEXTFIELD); }
Example #15
Source Project: openjdk-8-source Author: keerath File: TableExample.java License: GNU General Public License v2.0 | 5 votes |
/** * Creates the connectionPanel, which will contain all the fields for * the connection information. */ public void createConnectionDialog() { // Create the labels and text fields. userNameLabel = new JLabel("User name: ", JLabel.RIGHT); userNameField = new JTextField("app"); passwordLabel = new JLabel("Password: ", JLabel.RIGHT); passwordField = new JTextField("app"); serverLabel = new JLabel("Database URL: ", JLabel.RIGHT); serverField = new JTextField("jdbc:derby://localhost:1527/sample"); driverLabel = new JLabel("Driver: ", JLabel.RIGHT); driverField = new JTextField("org.apache.derby.jdbc.ClientDriver"); connectionPanel = new JPanel(false); connectionPanel.setLayout(new BoxLayout(connectionPanel, BoxLayout.X_AXIS)); JPanel namePanel = new JPanel(false); namePanel.setLayout(new GridLayout(0, 1)); namePanel.add(userNameLabel); namePanel.add(passwordLabel); namePanel.add(serverLabel); namePanel.add(driverLabel); JPanel fieldPanel = new JPanel(false); fieldPanel.setLayout(new GridLayout(0, 1)); fieldPanel.add(userNameField); fieldPanel.add(passwordField); fieldPanel.add(serverField); fieldPanel.add(driverField); connectionPanel.add(namePanel); connectionPanel.add(fieldPanel); }
Example #16
Source Project: ghidra Author: NationalSecurityAgency File: StructureEditorFlexAlignmentTest.java License: Apache License 2.0 | 5 votes |
public void checkByValueAlignedStructure(int value, int alignment, int length) throws Exception { emptyStructure.setInternallyAligned(true); emptyStructure.setMinimumAlignment(value); emptyStructure.add(ByteDataType.dataType); emptyStructure.add(CharDataType.dataType); emptyStructure.setFlexibleArrayComponent(DWordDataType.dataType, null, null); init(emptyStructure, pgmRootCat, false); CompEditorPanel editorPanel = (CompEditorPanel) getPanel(); JRadioButton byValueMinAlignButton = (JRadioButton) getInstanceField("byValueMinAlignButton", editorPanel); assertNotNull(byValueMinAlignButton); assertEquals(true, byValueMinAlignButton.isSelected()); JTextField minAlignField = (JTextField) getInstanceField("minAlignValueTextField", editorPanel); assertNotNull(minAlignField); assertEquals("" + value, minAlignField.getText()); assertEquals(false, structureModel.viewComposite.isDefaultAligned()); assertEquals(false, structureModel.viewComposite.isMachineAligned()); assertEquals(value, structureModel.getMinimumAlignment()); assertEquals(2, structureModel.getNumComponents()); assertEquals(4, structureModel.getRowCount()); checkRow(0, 0, 1, "db", ByteDataType.dataType, "", ""); checkRow(1, 1, 1, "char", CharDataType.dataType, "", ""); checkBlankRow(2); checkRow(3, length, 0, "ddw[0]", DWordDataType.dataType, "", ""); assertLength(length); assertActualAlignment(alignment); }
Example #17
Source Project: binnavi Author: google File: UserInputTypeValidation.java License: Apache License 2.0 | 5 votes |
/** * Determines whether the given text field represents a valid type name and that the corresponding * does not already exist. * * @param parent The component that is used as a parent to display error messages. * @param typeManager The type manager that holds the type system. * @param name The text field that needs to be validated. * @return True iff the name does not already exist and is a valid type name. */ public static boolean validateTypeName( final Component parent, final TypeManager typeManager, final JTextField name) { if (validateTypeName(typeManager, name)) { return true; } else { CMessageBox.showWarning(parent, String.format( "Unable to create empty or existing type.")); return false; } }
Example #18
Source Project: pega-tracerviewer Author: pegasystems File: TracerViewerSettingsDialog.java License: Apache License 2.0 | 5 votes |
protected void populateSettingsJPanel() { JTextField recentItemsJTextField = getRecentItemsJTextField(); JComboBox<String> charsetJComboBox = getCharsetJComboBox(); JCheckBox reloadPreviousFilesJComboBox = getReloadPreviousFilesJComboBox(); String text = String.valueOf(tracerViewerSetting.getRecentItemsCount()); recentItemsJTextField.setText(text); String charset = tracerViewerSetting.getCharset(); charsetJComboBox.setSelectedItem(charset); boolean reloadPreviousFiles = tracerViewerSetting.isReloadPreviousFiles(); reloadPreviousFilesJComboBox.setSelected(reloadPreviousFiles); }
Example #19
Source Project: Bytecoder Author: mirkosertic File: SynthTreeUI.java License: Apache License 2.0 | 5 votes |
@Override protected TreeCellEditor createTreeCellEditor() { @SuppressWarnings("serial") // anonymous class JTextField tf = new JTextField() { @Override public String getName() { return "Tree.cellEditor"; } }; DefaultCellEditor editor = new DefaultCellEditor(tf); // One click to edit. editor.setClickCountToStart(1); return editor; }
Example #20
Source Project: openjdk-jdk8u-backup Author: AdoptOpenJDK File: TreePosTest.java License: GNU General Public License v2.0 | 5 votes |
/** Create a test field. */ private JTextField createTextField(int width) { JTextField f = new JTextField(width); f.setEditable(false); f.setBorder(null); return f; }
Example #21
Source Project: openAGV Author: tcrct File: KeyValuePropertyEditorPanel.java License: Apache License 2.0 | 5 votes |
/** * Creates new instance. * * @param propertySuggestions The properties that are suggested. */ @Inject public KeyValuePropertyEditorPanel(MergedPropertySuggestions propertySuggestions) { this.propertySuggestions = requireNonNull(propertySuggestions, "propertySuggestions"); initComponents(); valueComboBox.addPopupMenuListener(new BoundsPopupMenuListener()); keyComboBox.addPopupMenuListener(new BoundsPopupMenuListener()); fProperty = new KeyValueProperty(null, "", ""); keyTextField = (JTextField) (keyComboBox.getEditor().getEditorComponent()); valueTextField = (JTextField) (valueComboBox.getEditor().getEditorComponent()); }
Example #22
Source Project: netbeans Author: apache File: WizardsTest.java License: Apache License 2.0 | 5 votes |
/** Test new project wizard using generic WizardOperator. */ public void testGenericWizards() { // open new project wizard NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke(); npwo.selectCategory("Java Web"); npwo.selectProject("Web Application"); npwo.next(); // create operator for next page WizardOperator wo = new WizardOperator("Web Application"); JTextFieldOperator txtName = new JTextFieldOperator((JTextField) new JLabelOperator(wo, "Project Name:").getLabelFor()); txtName.clearText(); txtName.typeText("MyApp"); wo.cancel(); }
Example #23
Source Project: Swing9patch Author: JackJiang2011 File: Demo.java License: Apache License 2.0 | 5 votes |
private void initGUI() { // init components txtPhotoframeDialogWidth = new JTextField(); txtPhotoframeDialogHeight = new JTextField(); txtPhotoframeDialogWidth.setText("530"); txtPhotoframeDialogHeight.setText("450"); txtPhotoframeDialogWidth.setColumns(10); txtPhotoframeDialogHeight.setColumns(10); btnShowInFrame = new JButton("Show in new frame..."); btnShowInFrame.setUI(new BEButtonUI().setNormalColor(BEButtonUI.NormalColor.blue)); btnShowInFrame.setForeground(Color.white); btnHideTheFrame = new JButton("Hide the frame"); btnHideTheFrame.setEnabled(false); panePhotoframe = createPhotoframe(); panePhotoframe.add( new JLabel(new ImageIcon(org.jb2011.swing9patch.photoframe.Demo.class.getResource("imgs/girl.png"))) , BorderLayout.CENTER); // init layout JPanel paneBtn = new JPanel(new FlowLayout(FlowLayout.CENTER)); paneBtn.setBorder(BorderFactory.createEmptyBorder(12,0,0,0)); paneBtn.add(new JLabel("Frame width:")); paneBtn.add(txtPhotoframeDialogWidth); paneBtn.add(new JLabel("Frame height:")); paneBtn.add(txtPhotoframeDialogHeight); paneBtn.add(btnShowInFrame); paneBtn.add(btnHideTheFrame); this.setBorder(BorderFactory.createEmptyBorder(12,20,10,20)); this.add(panePhotoframe, BorderLayout.CENTER); this.add(paneBtn, BorderLayout.SOUTH); // drag panePhotoframe to move its parent window DragToMove.apply(new Component[]{panePhotoframe}); }
Example #24
Source Project: pgptool Author: pgptool File: UiUtils.java License: GNU General Public License v3.0 | 5 votes |
private static JScrollPane getScrollableMessage(String msg) { JTextArea textArea = new JTextArea(msg); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setEditable(false); textArea.setMargin(new Insets(5, 5, 5, 5)); textArea.setFont(new JTextField().getFont()); // dirty fix to use better font JScrollPane scrollPane = new JScrollPane(); scrollPane.setPreferredSize(new Dimension(700, 150)); scrollPane.getViewport().setView(textArea); return scrollPane; }
Example #25
Source Project: tda Author: irockel File: EditCustomCategoryDialog.java License: GNU Lesser General Public License v2.1 | 5 votes |
private JPanel createNamePanel() { JPanel panel = new JPanel(new BorderLayout()); name = new JTextField(30); JPanel innerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); innerPanel.add(new JLabel(ResourceManager.translate("customcategory.name.label"))); innerPanel.add(name); panel.add(innerPanel, BorderLayout.CENTER); return(panel); }
Example #26
Source Project: openjdk-8-source Author: keerath File: XTextFieldEditor.java License: GNU General Public License v2.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { super.actionPerformed(e); if ((e.getSource() instanceof JMenuItem) || (e.getSource() instanceof JTextField)) { fireEditingStopped(); } }
Example #27
Source Project: netbeans Author: apache File: Utils.java License: Apache License 2.0 | 5 votes |
public static void stepSetDir( TestData data, String label, String dir ) { JFrameOperator installerMain = new JFrameOperator( MAIN_FRAME_TITLE ); if( null == dir ) { String sDefaultPath = new JTextFieldOperator( ( JTextField )( new JLabelOperator( installerMain, label ).getLabelFor( ) ) ).getText( ); // Set default path to data data.SetDefaultPath( sDefaultPath ); } else { try { new JTextFieldOperator( ( JTextField )( new JLabelOperator( installerMain, label ).getLabelFor( ) ) ).setText( ( new File( dir ) ).getCanonicalPath( ) ); } catch( IOException ex ) { ex.printStackTrace( ); } } new JButtonOperator( installerMain, NEXT_BUTTON_LABEL ).push( ); }
Example #28
Source Project: netbeans Author: apache File: FmtOptions.java License: Apache License 2.0 | 5 votes |
private void addListener(JComponent jc) { if (jc instanceof JTextField) { JTextField field = (JTextField) jc; field.addActionListener(this); field.getDocument().addDocumentListener(this); } else if (jc instanceof JCheckBox) { JCheckBox checkBox = (JCheckBox) jc; checkBox.addActionListener(this); } else if (jc instanceof JComboBox) { JComboBox cb = (JComboBox) jc; cb.addActionListener(this); } }
Example #29
Source Project: TencentKona-8 Author: Tencent File: SynthTreeUI.java License: GNU General Public License v2.0 | 5 votes |
@Override protected TreeCellEditor createTreeCellEditor() { JTextField tf = new JTextField() { @Override public String getName() { return "Tree.cellEditor"; } }; DefaultCellEditor editor = new DefaultCellEditor(tf); // One click to edit. editor.setClickCountToStart(1); return editor; }
Example #30
Source Project: megamek Author: MegaMek File: CommonSettingsDialog.java License: GNU General Public License v2.0 | 5 votes |
private JPanel getAdvancedSettingsPanel() { JPanel p = new JPanel(); String[] s = GUIPreferences.getInstance().getAdvancedProperties(); AdvancedOptionData[] opts = new AdvancedOptionData[s.length]; for (int i = 0; i < s.length; i++) { s[i] = s[i].substring(s[i].indexOf("Advanced") + 8, s[i].length()); opts[i] = new AdvancedOptionData(s[i]); } Arrays.sort(opts); keys = new JList<>(opts); keys.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); keys.addListSelectionListener(this); keys.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { int index = keys.locationToIndex(e.getPoint()); if (index > -1) { AdvancedOptionData dat = keys.getModel().getElementAt(index); if (dat.hasTooltipText()) { keys.setToolTipText(dat.getTooltipText()); } else { keys.setToolTipText(null); } } } }); p.add(keys); value = new JTextField(10); value.addFocusListener(this); p.add(value); return p; }