Java Code Examples for javax.swing.JTextField#setComponentPopupMenu()
The following examples show how to use
javax.swing.JTextField#setComponentPopupMenu() .
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 File: CustomCellEditor.java From ermasterr with Apache License 2.0 | 5 votes |
public CustomCellEditor(final JTable table) { super(new JTextField()); final JTextField component = (JTextField) getComponent(); component.setName("Table.editor"); component.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { if ((e.getModifiers() & InputEvent.CTRL_MASK) != 0) { if (e.getKeyCode() == ';') { final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); component.setText(format.format(new Date())); } else if (e.getKeyCode() == 'v' || e.getKeyCode() == 'V') { component.paste(); } else if (e.getKeyCode() == 'c' || e.getKeyCode() == 'C') { component.copy(); } else if (e.getKeyCode() == 'x' || e.getKeyCode() == 'X') { component.cut(); } } super.keyPressed(e); } }); component.setComponentPopupMenu(new TextFieldPopupMenu()); }
Example 2
Source File: ImportFromAbstractDialog.java From zap-extensions with Apache License 2.0 | 5 votes |
private static void setContextMenu(JTextField field) { JMenuItem paste = new JMenuItem(Constant.messages.getString(MESSAGE_PREFIX + "pasteaction")); paste.addActionListener(e -> field.paste()); JPopupMenu jPopupMenu = new JPopupMenu(); jPopupMenu.add(paste); field.setComponentPopupMenu(jPopupMenu); }
Example 3
Source File: ImportFromAbstractDialog.java From zap-extensions with Apache License 2.0 | 5 votes |
private static void setContextMenu(JTextField field) { JMenuItem paste = new JMenuItem(Constant.messages.getString(MESSAGE_PREFIX + "pasteaction")); paste.addActionListener(e -> field.paste()); JPopupMenu jPopupMenu = new JPopupMenu(); jPopupMenu.add(paste); field.setComponentPopupMenu(jPopupMenu); }
Example 4
Source File: CustomCellEditor.java From erflute with Apache License 2.0 | 5 votes |
public CustomCellEditor(final JTable table) { super(new JTextField()); final JTextField component = (JTextField) getComponent(); component.setName("Table.editor"); component.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) { if (e.getKeyCode() == ';') { final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); component.setText(format.format(new Date())); } else if (e.getKeyCode() == 'v' || e.getKeyCode() == 'V') { component.paste(); } else if (e.getKeyCode() == 'c' || e.getKeyCode() == 'C') { component.copy(); } else if (e.getKeyCode() == 'x' || e.getKeyCode() == 'X') { component.cut(); } } super.keyPressed(e); } }); component.setComponentPopupMenu(new TextFieldPopupMenu()); }
Example 5
Source File: CustomCellEditor.java From ermaster-b with Apache License 2.0 | 5 votes |
public CustomCellEditor(final JTable table) { super(new JTextField()); final JTextField component = (JTextField) getComponent(); component.setName("Table.editor"); component.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) { if (e.getKeyCode() == ';') { SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss.SSS"); component.setText(format.format(new Date())); } else if (e.getKeyCode() == 'v' || e.getKeyCode() == 'V') { component.paste(); } else if (e.getKeyCode() == 'c' || e.getKeyCode() == 'C') { component.copy(); } else if (e.getKeyCode() == 'x' || e.getKeyCode() == 'X') { component.cut(); } } super.keyPressed(e); } }); component.setComponentPopupMenu(new TextFieldPopupMenu()); }
Example 6
Source File: NetAdmin.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Init login screen */ private void initLoginUI() { // Main panel JPanel mpLoginOwner = new JPanel(new BorderLayout()); this.getContentPane().add(mpLoginOwner, SCREENCARD_NAMES[SCREENCARD_LOGIN]); JPanel mpLogin = new JPanel(); mpLogin.setLayout(new BoxLayout(mpLogin, BoxLayout.Y_AXIS)); mpLoginOwner.add(mpLogin, BorderLayout.NORTH); // * Login Message label labelLoginMessage = new JLabel(getUIText("Login_Message_Default")); labelLoginMessage.setAlignmentX(0f); mpLogin.add(labelLoginMessage); // * Server panel JPanel spServer = new JPanel(new BorderLayout()); spServer.setAlignmentX(0f); mpLogin.add(spServer); // ** Server label JLabel lServer = new JLabel(getUIText("Login_Server")); spServer.add(lServer, BorderLayout.WEST); // ** Server textbox txtfldServer = new JTextField(30); txtfldServer.setText(propConfig.getProperty("login.server", "")); txtfldServer.setComponentPopupMenu(new TextComponentPopupMenu(txtfldServer)); spServer.add(txtfldServer, BorderLayout.EAST); // * Username panel JPanel spUsername = new JPanel(new BorderLayout()); spUsername.setAlignmentX(0f); mpLogin.add(spUsername); // ** Username label JLabel lUsername = new JLabel(getUIText("Login_Username")); spUsername.add(lUsername, BorderLayout.WEST); // ** Username textbox txtfldUsername = new JTextField(30); txtfldUsername.setText(propConfig.getProperty("login.username", "")); txtfldUsername.setComponentPopupMenu(new TextComponentPopupMenu(txtfldUsername)); spUsername.add(txtfldUsername, BorderLayout.EAST); // * Password panel JPanel spPassword = new JPanel(new BorderLayout()); spPassword.setAlignmentX(0f); mpLogin.add(spPassword); // ** Password label JLabel lPassword = new JLabel(getUIText("Login_Password")); spPassword.add(lPassword, BorderLayout.WEST); // ** Password textbox passfldPassword = new JPasswordField(30); String strPassword = propConfig.getProperty("login.password", ""); if(strPassword.length() > 0) { passfldPassword.setText(NetUtil.decompressString(strPassword)); } passfldPassword.setComponentPopupMenu(new TextComponentPopupMenu(passfldPassword)); spPassword.add(passfldPassword, BorderLayout.EAST); // * Remember Username checkbox chkboxRememberUsername = new JCheckBox(getUIText("Login_RememberUsername")); chkboxRememberUsername.setSelected(propConfig.getProperty("login.rememberUsername", false)); chkboxRememberUsername.setAlignmentX(0f); mpLogin.add(chkboxRememberUsername); // * Remember Password checkbox chkboxRememberPassword = new JCheckBox(getUIText("Login_RememberPassword")); chkboxRememberPassword.setSelected(propConfig.getProperty("login.rememberPassword", false)); chkboxRememberPassword.setAlignmentX(0f); mpLogin.add(chkboxRememberPassword); // * Buttons panel JPanel spButtons = new JPanel(); spButtons.setLayout(new BoxLayout(spButtons, BoxLayout.X_AXIS)); spButtons.setAlignmentX(0f); mpLogin.add(spButtons); // ** Login button btnLogin = new JButton(getUIText("Login_Login")); btnLogin.setMnemonic('L'); btnLogin.setMaximumSize(new Dimension(Short.MAX_VALUE, btnLogin.getMaximumSize().height)); btnLogin.setActionCommand("Login_Login"); btnLogin.addActionListener(this); spButtons.add(btnLogin); // ** Quit button JButton btnQuit = new JButton(getUIText("Login_Quit")); btnQuit.setMnemonic('Q'); btnQuit.setMaximumSize(new Dimension(Short.MAX_VALUE, btnQuit.getMaximumSize().height)); btnQuit.setActionCommand("Login_Quit"); btnQuit.addActionListener(this); spButtons.add(btnQuit); }