javax.swing.JTextField.setComponentPopupMenu()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中javax.swing.JTextField.setComponentPopupMenu()方法的一些代码示例,展示了JTextField.setComponentPopupMenu()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextField.setComponentPopupMenu()方法的具体详情如下:
包路径:javax.swing.JTextField
类名称:JTextField
方法名:setComponentPopupMenu

JTextField.setComponentPopupMenu介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

// 1. Let's add the initial popup to the text field.
JTextField textField = new JTextField();
JPopupMenu popup = new JPopupMenu();
textField.add(popup);
textField.setComponentPopupMenu(popup);

// 2. Let's create a sub-menu that "expands"
JMenu subMenu = new JMenu("m");
subMenu.add("m1");
subMenu.add("m2");

// 3. Finally, add the sub-menu and item to the popup
popup.add(subMenu);
popup.add("n");

代码示例来源:origin: stackoverflow.com

JTextField field = new JTextField("some popup owner");
JPopupMenu menu = new JPopupMenu();
menu.add("dummy");
field.setComponentPopupMenu(menu);
Action action = new AbstractAction("hit me!") {

  @Override
  public void actionPerformed(ActionEvent e) {
    LOG.info("got hit!");
  }
};
JComponent content = new JPanel();
content.add(new JButton(action));
content.add(field);

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

private void createCodeText() {
  codeTextField = new JTextField();

  // Add context menu to Url String
  JPopupMenu popup = new JPopupMenu();
  codeTextField.add(popup);
  codeTextField.setComponentPopupMenu(popup);

  JMenuItem copyMenu =
    new JMenuItem(AccountMessageBundle.message("login.copyandpaste.url.paste.text"));
  copyMenu.addActionListener(
    new ActionListener() {
     @Override
     public void actionPerformed(ActionEvent event) {
      codeTextField.paste();
     }
    });

  popup.add(copyMenu);
 }
}

代码示例来源:origin: SKCraft/Launcher

private void initComponents() {
  versionText.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
  manifestFilenameText.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
  JPanel container = new JPanel();
  container.setLayout(new MigLayout("insets dialog"));
  container.add(new JLabel("Version:"));
  container.add(versionText, "span");
  container.add(new JLabel("Manifest Filename:"));
  container.add(manifestFilenameText, "span");
  container.add(new JLabel("Output Directory:"));
  container.add(destDirField, "span");
  JButton buildButton = new JButton("Build");
  JButton cancelButton = new JButton("Cancel");
  container.add(buildButton, "tag ok, span, split 2, sizegroup bttn");
  container.add(cancelButton, "tag cancel, sizegroup bttn");
  add(container, BorderLayout.CENTER);
  getRootPane().setDefaultButton(buildButton);
  getRootPane().registerKeyboardAction(e -> cancelButton.doClick(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
  buildButton.addActionListener(e -> returnValue());
  cancelButton.addActionListener(e -> dispose());
}

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

private JTextField createUrlText() {
 final JTextField urlTextField = new JTextField(urlString);
 urlTextField.setBorder(null);
 urlTextField.setEditable(false);
 urlTextField.setBackground(UIUtil.getLabelBackground());
 // Add context menu to Url String
 JPopupMenu popup = new JPopupMenu();
 urlTextField.add(popup);
 urlTextField.setComponentPopupMenu(popup);
 JMenuItem copyMenu =
   new JMenuItem(AccountMessageBundle.message("login.copyandpaste.url.copy.text"));
 copyMenu.addActionListener(
   new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent event) {
     urlTextField.copy();
    }
   });
 popup.add(copyMenu);
 return urlTextField;
}

代码示例来源:origin: SKCraft/Launcher

public DirectoryField() {
  setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
  textField = new JTextField(30);
  textField.setMaximumSize(textField.getPreferredSize());
  add(textField);
  add(Box.createHorizontalStrut(3));
  browseButton = new JButton("Browse...");
  browseButton.setPreferredSize(new Dimension(
      browseButton.getPreferredSize().width,
      textField.getPreferredSize().height));
  add(browseButton);
  browseButton.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      browse();
    }
  });
  textField.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
}

代码示例来源:origin: raydac/netbeans-mmd-plugin

@SuppressWarnings("ResultOfObjectAllocationIgnored")
public FileEditPanel(@Nullable final File projectFolder, @Nullable final DataContainer initialData) {
 initComponents();
 this.projectFolder = projectFolder;
 this.textFieldFilePath.setText(initialData.getFilePathWithLine().toString()); //NOI18N
 this.checkBoxShowFileInSystem.setSelected(initialData == null ? false : initialData.isShowWithSystemTool());
 this.textFieldFilePath.setComponentPopupMenu(SwingUtils.addTextActions(UIComponentFactoryProvider.findInstance().makePopupMenu()));
 new Focuser(this.textFieldFilePath);
}

代码示例来源:origin: SKCraft/Launcher

private void initComponents() {
  nameText.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
  descArea.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
  includeArea.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);

代码示例来源:origin: SKCraft/Launcher

private void initComponents() {
  nameText.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
  titleText.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
  gameVersionText.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
  launchFlagsArea.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);
  userFilesIncludeArea.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);

代码示例来源:origin: raydac/netbeans-mmd-plugin

@SuppressWarnings("ResultOfObjectAllocationIgnored")
public UriEditPanel(final String uri) {
 initComponents();
 this.textFieldURI.setText(uri == null ? "" : uri); //NOI18N
 this.textFieldURI.setComponentPopupMenu(SwingUtils.addTextActions(UIComponentFactoryProvider.findInstance().makePopupMenu()));
 
 this.textFieldURI.getDocument().addDocumentListener(new DocumentListener() {
  @Override
  public void insertUpdate(DocumentEvent e) {
   validateUri();
  }
  @Override
  public void removeUpdate(DocumentEvent e) {
   validateUri();
  }
  @Override
  public void changedUpdate(DocumentEvent e) {
   validateUri();
  }
 });
 new Focuser(this.textFieldURI);
 
 validateUri();
}

代码示例来源:origin: org.geotools/gt-widgets-swing-pending

jLabel1.setText(bundle.getString("mouse_coord")); // NOI18N
jtf_coord.setComponentPopupMenu(menu);
jtf_coord.setEditable(false);
jtf_coord.setOpaque(false);

代码示例来源:origin: SKCraft/SKMCLauncher

form.addRow(new JLabel(_("createProfile.profileName")), nameField);
form.addRow(new JLabel(_("createProfile.version")), versionButton);
nameField.setComponentPopupMenu(TextFieldPopupMenu.INSTANCE);

代码示例来源:origin: blurpy/kouchat

add(clearMI);
textfield.setComponentPopupMenu(this);
clearMI.addActionListener(this);

代码示例来源:origin: sing-group/GC4S

fileName.setComponentPopupMenu(getPopupMenu());

相关文章

微信公众号

最新文章

更多

JTextField类方法