private void setup() { setLayout(new BorderLayout()); JPanel panel = new JPanel(); add(jl, BorderLayout.SOUTH); add(panel, BorderLayout.CENTER); panel.setLayout(new GridLayout(6, 2)); panel.add(new JLabel("Name")); panel.add(jtFields[0]); panel.add(new JLabel("Contact Number")); panel.add(jtFields[1]); panel.add(new JLabel("Address")); panel.add(jtAreas[0]); panel.add(new JLabel("Deposit Number")); panel.add(processButton); clearButton.addActionListener(e -> { for (JTextArea i : jtAreas) { i.setText(""); i.setText(""); processButton.addActionListener(e -> { Order order = new Order(jtFields[0].getText(), jtFields[1].getText(), jtAreas[0].getText(), jtFields[2].getText(), jtAreas[1].getText()); jl.setText(sendRequest(order));
private void doEncodingPrompt(final String encoding, final String oldEncoding) { final JPanel encodingPanel = new JPanel(); encodingPanel.setLayout(new BoxLayout(encodingPanel, BoxLayout.PAGE_AXIS)); JLabel text = new JLabel("<html>A head finder or tree reader was selected that has the default encoding " + encoding + "; this differs from " + oldEncoding + ", which was being used. If the encoding is changed, all newly loaded" + "treebanks will be read using the new encoding. Choosing an encoding that is not the true encoding of your tree " + JPanel textPanel = new JPanel(new BorderLayout()); textPanel.setPreferredSize(new Dimension(100,100)); textPanel.add(text); encodingPanel.add(textPanel); encodingPanel.add(Box.createVerticalStrut(5)); final JOptionPane fileFilterDialog = new JOptionPane(); fileFilterDialog.setMessage(encodingPanel); JButton[] options = new JButton[3]; JButton useNewEncoding = new JButton("Use " + encoding); JButton useOldEncoding = new JButton("Use " + oldEncoding); JButton useAnotherEncoding = new JButton("Use encoding..."); useNewEncoding.addActionListener(arg0 -> { FileTreeModel.setCurEncoding(encoding); if(setEncoding == null) System.out.println("encoding null!!"); setEncoding.setText(encoding); dialog.setVisible(false); }); useOldEncoding.addActionListener(e -> dialog.setVisible(false)); useAnotherEncoding.addActionListener(e -> {
this.setHideOnEscapeButton(); JLabel label = new JLabel("Find What:"); textField = new JTextField(); textField.setText(pane.getSelectedText()); wrap = new JCheckBox("Wrap"); findButton = new JButton("Find"); findButton.addActionListener(new FindButton()); this.getRootPane().setDefaultButton(findButton);
private JPanel createArtifactRow(final String ext, final String serv, final String mainClass, final String args) { final JLabel extLabel = new JLabel(EXT_LABEL); final JTextField extField = new JTextField(); extField.setToolTipText(EXT_TOOLTIP); extField.setText(ext); final JLabel packgeLabel = new JLabel("Artifact"); final JTextField packgeField = new JTextField(); packgeField.setToolTipText("e.g. ch.epfl.lamp:dotty-language-server_0.3:0.3.0-RC2"); packgeField.setText(serv); final JLabel mainClassLabel = new JLabel("Main class"); final JTextField mainClassField = new JTextField(); mainClassField.setToolTipText("e.g. dotty.tools.languageserver.Main"); mainClassField.setText(mainClass); final JLabel argsLabel = new JLabel("Args"); final JTextField argsField = new JTextField(); argsField.setToolTipText("e.g. -stdio"); argsField.setText(args); final List<JComponent> components = Arrays.asList(extLabel, extField, packgeLabel, packgeField, mainClassLabel, mainClassField, argsLabel, argsField); final JPanel panel = createRow(components, ArtifactLanguageServerDefinition$.MODULE$.getPresentableTyp()); final scala.collection.mutable.LinkedHashMap<String, JComponent> map = new scala.collection.mutable.LinkedHashMap<>(); map.put(EXT, extField); map.put(PACKGE, packgeField); map.put(MAINCLASS, mainClassField); map.put(ARGS, argsField); rows.add(new ServersGUIRow(panel, ArtifactLanguageServerDefinition$.MODULE$.typ(), map)); return panel; }
public MyUI() { super(new BorderLayout()); JPanel north = new JPanel(); north.add(source); north.add(destination); JPanel south = new JPanel(); JButton go = new JButton("Go!"); south.add(go); String greeting = "Hello, %s!"; go.addActionListener(e -> destination.setText( String.format(greeting, source.getText()))); this.add(north, BorderLayout.NORTH); this.add(south, BorderLayout.SOUTH); }
final JTextField textField = new JTextField("cat"); JButton button = new JButton("Click"); // Code button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if(textField.getText().equals("cat")) { textField.setText("Changes"); } else { textField.setText("Already Changed"); } } });
JTabbedPane tabbePane = new JTabbedPane(); JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); JTextField field = new JTextField(); JButton button = new JButton(); tabbedPane.addTab("tab1", panel1); field.setText("Your text here"); panel2.add(field); button.setText("Save"); panel2.add(button); tabbePane.addTab("tab2", panel2);
final JTextField textField = new JTextField("Enabled"); final JCheckBox checkBox = new JCheckBox("Enable", true); checkBox.addItemListener(new ItemListener(){ if(e.getStateChange() == ItemEvent.SELECTED){ textField.setEnabled(true); textField.setText("Enabled"); textField.setText("Disabled");
@NotNull private JPanel createRowLimitPanel() { rowLimitField.setText(Integer.toString(configuration.getDefaultRowLimit())); rowLimitField.setColumns(5); rowLimitField.setDocument(new NumberDocument()); rowLimitField.setText(Integer.toString(configuration.getDefaultRowLimit())); JPanel rowLimitPanel = new NonOpaquePanel(); rowLimitPanel.add(new JLabel("Row limit:"), BorderLayout.WEST); rowLimitPanel.add(rowLimitField, BorderLayout.CENTER); rowLimitPanel.add(Box.createHorizontalStrut(5), BorderLayout.EAST); return rowLimitPanel; }
public class Console extends JFrame { private static JTextField consoleTextField; public Console() { consoleTextField = new JTextField(); // ... } public static feedChar(char c) { consoleTextField.setText(consoleTextField.getText() + c.toString()); } }
JTextField text=new JTextField(); text.setText("this is textfield"); text.setBounds(20,0,100,20); JPanel panel=new JPanel(); panel.addLayout(new FlowLayout()); panel.setBackground(Color.blue); panel.add(text);
sdkLocationText.setText(System.getenv("ANDROID_HOME")); sdkLocationText.setText(prefs.getString("ANDROID_HOME")); checkBox.setSelected(true); subProjectsPanel.add(checkBox); checkBox.addItemListener(new ItemListener() { @Override JPanel extensionPanel = new JPanel(new GridLayout(1, 5)); while (depCounter < ProjectDependency.values().length) { if (ProjectDependency.values()[depCounter] != null) { depCheckBox.setSelected(true); extensionPanel.add(depCheckBox); depCheckBox.addItemListener(new ItemListener() { @Override extensionPanel.add(Box.createHorizontalBox());
final JTextField input1; ... final ActionListener l = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { input1.setText(input1.getText() + ((JButton) e.getSource()).getText()); } }; for (char c = 'A'; c <= 'Z'; c++) { final JButton jButton = new JButton(String.valueOf(c)); panel.add(jButton); jButton.addActionListener(l); }
textTranslationKey.setText(defaultKey); getRootPane().setDefaultButton(buttonOK); buttonOK.addActionListener(e -> onOK()); buttonCancel.addActionListener(e -> onCancel()); tableView.setModelAndUpdateColumns(listTableModel); panelTableView.add(ToolbarDecorator.createDecorator(tableView) .disableAddAction() .disableDownAction()
String fieldContents = ""; JTextField field = new JTextField; ActionListener acLi = new ActionListener() { public void actionPerformed(ActionEvent ae) { JButton btn = (JButton) ae.getSource(); fieldContents += btn.getText(); field.setText(fieldContents); } }; JButton button0 = new JButton("0"); button0.addActionListener(acLi); ... JButton button9 = new JButton("9"); button9.addActionListener(acLi);
final JTextField textField = new JTextField(20); final JFrame frame = new JFrame("Test JFrame"); JButton button = new JButton( new AbstractAction("Press Me to Show Dialog") { @Override public void actionPerformed(ActionEvent arg0) { String result = JDialogTest.getInput("Get Input", frame); textField.setText(result); } });
getRootPane().setDefaultButton(buttonOK); buttonOK.addActionListener(e -> onSave()); buttonCancel.addActionListener(e -> onCancel()); buttonTest.addActionListener(e -> { try { Object eval = JavascriptServiceNameStrategy.run(project, textClass.getText(), textJavascript.getText()); if(!(eval instanceof String)) { textResult.setText("Error: invalid string response"); return; textResult.setText((String) eval); } catch (ScriptException e1) { textResult.setText("Error: " + e1.getMessage());
private void initRoutingSubpanel() { JPanel routingPanel = new JPanel(); routingPanel.setLayout(new GridLayout(0, 2)); leftPanel.add(routingPanel, BorderLayout.NORTH); JButton setSourceVertexButton = new JButton("set source"); setSourceVertexButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object selected = nearbyVertices.getSelectedValue(); routingPanel.add(setSourceVertexButton); sourceVertex = new JTextField(); routingPanel.add(sourceVertex); routingPanel.add(setSinkVertexButton); sinkVertex = new JTextField(); routingPanel.add(sinkVertex); routingPanel.add(resetSearchDateButton); searchDate = new JTextField(); searchDate.setText(dateFormat.format(new Date())); routingPanel.add(searchDate); searchTimeElapsedLabel = new JLabel("search time elapsed:"); routingPanel.add(searchTimeElapsedLabel);