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 createView() { JPanel controlsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10)); serverTextField = new JTextField(""); serverTextField.setColumns(15); serverTextField.selectAll(); JPanel textPanel = new JPanel(new GridLayout(4, 2, 0, 10)); textPanel.add(new JLabel("Go Server Hostname or IP")); textPanel.add(serverTextField); textPanel.add(new JLabel("SSL Mode")); sslModeComponent = new SslModeComponent(); textPanel.add(sslModeComponent); textPanel.add(new JLabel("Server root certificate")); fileBrowser = new FileBrowser(); textPanel.add(fileBrowser); controlsPanel.add(textPanel); getContentPane().add(controlsPanel, BorderLayout.NORTH); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10)); okButton = new JButton("OK"); buttonPanel.add(okButton); getContentPane().add(buttonPanel, BorderLayout.SOUTH); }
public JTextField getFontStyleTextField() { if (fontStyleTextField == null) { fontStyleTextField = new JTextField(); fontStyleTextField.addFocusListener(new TextFieldFocusHandlerForTextSelection(fontStyleTextField)); fontStyleTextField.addKeyListener(new TextFieldKeyHandlerForListSelectionUpDown(getFontStyleList())); fontStyleTextField.getDocument() .addDocumentListener(new ListSearchTextFieldDocumentHandler(getFontStyleList())); fontStyleTextField.setFont(DEFAULT_FONT); } return fontStyleTextField; }
public void setEditable(boolean editable) { this.blocked = !editable; textField.setEditable(editable); textField.setFocusable(editable); if (!editable) { super.setBackground(backgroundColor); } }
Action action = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { System.out.println("some action"); } }; JTextField textField = new JTextField(10); textField.addActionListener( action );
@Override protected void openInit() { prepare(); String lastSearch = cache.getLastSearch(); if (lastSearch != null) { searchField.setText(lastSearch); searchField.selectAll(); searchEmitter.emitSearch(); } searchField.requestFocus(); }
@Override public void run () { JPanel panel = new JPanel(new FlowLayout()); JPanel textPanel = new JPanel() { public boolean isOptimizedDrawingEnabled () { return false; }; textPanel.setLayout(new OverlayLayout(textPanel)); panel.add(textPanel); final JTextField textField = new JTextField(20); textField.setText(text); textField.setAlignmentX(0.0f); textPanel.add(textField); textField.getDocument().addDocumentListener(new DocumentListener() { pane.setComponentOrientation(JOptionPane.getRootFrame().getComponentOrientation()); Border border = textField.getBorder(); placeholderLabel.setBorder(new EmptyBorder(border.getBorderInsets(textField))); listener.input(textField.getText()); } else { listener.canceled();
jPanel1 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); urlTextField = new javax.swing.JTextField(); jPanel2 = new javax.swing.JPanel(); openButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton(); browseButton = new javax.swing.JButton(); jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.Y_AXIS)); jPanel3.add(jLabel1); urlTextField.setMinimumSize(new java.awt.Dimension(100, 20)); urlTextField.setPreferredSize(new java.awt.Dimension(300, 20)); urlTextField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { enableOpenButton(); urlTextField.addActionListener(evt -> urlTextFieldActionPerformed(evt)); jPanel3.add(urlTextField); jPanel1.add(jPanel3); getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
public void afterPropertiesSet() throws Exception { ClassPathResource resource = new ClassPathResource("logo.png"); ImageIcon icon = new ImageIcon(resource.getURL()); JLabel logo = new JLabel(icon); valueField = new JTextField(20); updateValueLabel(); saveButton = new JButton("Save Value"); saveButton.addActionListener(this); refreshButton = new JButton("Refresh Value"); refreshButton.addActionListener(this); JPanel valuePanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); valuePanel.add(valueField); valuePanel.add(saveButton); valuePanel.add(refreshButton); methodPanel.add(secureMethod3Button); frame = new JFrame("Apache Shiro Sample Application"); frame.setSize(500, 200); Container panel = frame.getContentPane(); panel.setLayout(new BorderLayout()); panel.add(logo, BorderLayout.NORTH); panel.add(valuePanel, BorderLayout.CENTER); panel.add(methodPanel, BorderLayout.SOUTH);
super(jframe, title, true); JPanel bottom = new JPanel(); bottom.setLayout(new FlowLayout()); JPanel main = new JPanel(); main.setLayout(new FlowLayout()); main.add(new JLabel(label)); _textField = new JTextField(size); main.add(_textField); JButton ok = new JButton("Ok"); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { hide(); JButton cancel = new JButton("Cancel"); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { bottom.add(ok); bottom.add(cancel); getContentPane().add(main, BorderLayout.CENTER); getContentPane().add(bottom, BorderLayout.SOUTH); pack(); centerWindow(this);
public GUI() { frame = new JFrame("PMD Duplicate Code Detector (v " + PMDVersion.VERSION + ')'); timeField.setEditable(false); menuBar.add(fileMenu); menuBar.add(viewMenu); frame.setJMenuBar(menuBar); JButton browseButton = new JButton("Browse"); browseButton.setMnemonic('b'); browseButton.addActionListener(new BrowseListener()); goButton = new JButton("Go"); goButton.setMnemonic('g'); frame.getContentPane().setLayout(new BorderLayout()); JPanel topPanel = new JPanel(); topPanel.setLayout(new BorderLayout()); topPanel.add(settingsPanel, BorderLayout.NORTH); topPanel.add(progressPanel, BorderLayout.CENTER); setProgressControls(false); // not running now frame.getContentPane().add(topPanel, BorderLayout.NORTH); frame.getContentPane().add(resultsPanel, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack();
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 " + "files may cause errors and unexpected behavior.</html>"); text.setAlignmentX(SwingConstants.LEADING); JPanel textPanel = new JPanel(new BorderLayout()); textPanel.setPreferredSize(new Dimension(100,100)); textPanel.add(text); 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..."); if(setEncoding == null) System.out.println("encoding null!!"); setEncoding.setText(encoding); dialog.setVisible(false); });
scrollPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); final JPanel south = new JPanel(new BorderLayout()); final JLabel labelFileExtensions = new JLabel("File extensions: "); extensions.setText(getExtensions()); labelFileExtensions.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); CompoundBorder border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10), BorderFactory.createEtchedBorder()); border = BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(5, 5, 5, 5)); south.setBorder(border); south.add(labelFileExtensions, BorderLayout.WEST); south.add(extensions, BorderLayout.CENTER); south.add(changeDirButton, BorderLayout.SOUTH); getContentPane().add(south, BorderLayout.SOUTH); getContentPane().add(scrollPane, BorderLayout.CENTER); changeDirButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.err.println("Opening Directory Window"); extensions.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { changeExtensions(extensions.getText()); extensions.addFocusListener(new FocusListener() {
chatLog.setText("<html><body>"); getContentPane().add(new JScrollPane(chatLog), "Center"); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.add(new JLabel("Name:")); nameField = new JTextField(System.getProperty("user.name", "yourname")); Dimension d = nameField.getPreferredSize(); nameField.setMaximumSize(new Dimension(120, d.height + 6)); p.add(nameField); p.add(new JLabel(" Message:")); messageField = new JTextField(); p.add(messageField); p.add(new JButton(new SendAction(true))); p.add(new JButton(new SendAction(false))); getContentPane().add(p, "South");
private void initUI() { JLabel findLabel = new JLabel(NLS.str("search_dialog.open_by_name")); searchField = new JTextField(); searchField.setAlignmentX(LEFT_ALIGNMENT); new TextStandardActions(searchField); searchFieldSubscribe(); JCheckBox codeChBox = makeOptionsCheckBox(NLS.str("search_dialog.code"), SearchOptions.CODE); JPanel searchInPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); searchInPanel.setBorder(BorderFactory.createTitledBorder(NLS.str("search_dialog.search_in"))); searchInPanel.add(clsChBox); searchInPanel.add(mthChBox); searchInPanel.add(fldChBox); JPanel searchPane = new JPanel(); searchPane.setLayout(new BoxLayout(searchPane, BoxLayout.PAGE_AXIS)); findLabel.setLabelFor(searchField); searchPane.add(findLabel); searchPane.add(Box.createRigidArea(new Dimension(0, 5))); contentPane.add(searchPane, BorderLayout.PAGE_START); contentPane.add(resultsPanel, BorderLayout.CENTER); contentPane.add(buttonPane, BorderLayout.PAGE_END); searchField.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) {
= new TableRowSorter<>(jTable.getModel()); private JTextField jtfFilter = new JTextField(); private JButton jbtFilter = new JButton("Filter"); JPanel panel = new JPanel(new BorderLayout()); panel.add(new JLabel("Specify a word to match:"), BorderLayout.WEST); panel.add(jtfFilter, BorderLayout.CENTER); setLayout(new BorderLayout()); add(panel, BorderLayout.SOUTH); add(new JScrollPane(jTable), BorderLayout.CENTER); SwingUtilities.invokeLater(new Runnable(){ public void run() { JFrame frame = new JFrame("Row Filter"); frame.add(new TestTableSortFilter()); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true);
cluster.setAlignmentX(Component.LEFT_ALIGNMENT); main_box.add(Box.createVerticalStrut(10)); main_box.add(buttons); csLabel.setPreferredSize(new Dimension(85, 30)); input.add(csLabel); txtField=new JTextField(); txtField.setPreferredSize(new Dimension(200, 30)); txtField.setBackground(Color.white); input.add(txtField); buttons.add(clearButton); status.setForeground(Color.red); main_box.add(status); txtField.setFocusable(true); txtField.requestFocusInWindow(); txtField.setToolTipText("type and then press enter to send"); txtField.addActionListener(e -> { String cmd=e.getActionCommand(); if(cmd != null && !cmd.isEmpty()) { send(txtField.getText()); txtField.selectAll();
private WebEngine engine; private JFrame frame = new JFrame(); private JPanel panel = new JPanel(new BorderLayout()); private JLabel lblStatus = new JLabel(); private JButton btnGo = new JButton("Go"); private JTextField txtURL = new JTextField(); private JProgressBar progressBar = new JProgressBar(); txtURL.addActionListener(al); JPanel topBar = new JPanel(new BorderLayout(5, 0)); topBar.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5)); topBar.add(txtURL, BorderLayout.CENTER); topBar.add(btnGo, BorderLayout.EAST); panel.add(statusBar, BorderLayout.SOUTH); frame.getContentPane().add(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true);
private JTextField m_userInputTf = new JTextField(5); private JTextField m_totalTf = new JTextField(20); private JButton m_multiplyBtn = new JButton("Multiply"); private JButton m_clearBtn = new JButton("Clear"); JPanel content = new JPanel(); content.setLayout(new FlowLayout()); content.add(new JLabel("Input")); content.add(m_userInputTf); content.add(m_multiplyBtn); content.add(new JLabel("Total")); content.add(m_totalTf); content.add(m_clearBtn); this.setContentPane(content); this.pack(); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
private JPanel createSearchPanel(final FilteredJList classes) { JPanel search = new JPanel(); search.setLayout(new BorderLayout()); search.add(new JLabel("Choose a Demo to start: Find: "), BorderLayout.WEST); final javax.swing.JTextField jtf = new javax.swing.JTextField(); jtf.getDocument().addDocumentListener(new DocumentListener() { public void removeUpdate(DocumentEvent e) { classes.setFilter(jtf.getText()); jtf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectedClass = classes.getSelectedValuesList(); jtf.setPreferredSize(new Dimension(100, 25)); search.add(jtf, BorderLayout.CENTER); search.add(showSettingCheck, BorderLayout.EAST);