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

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

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

JTextField.add介绍

暂无

代码示例

代码示例来源:origin: abc9070410/JComicDownloader

private void setUrlFieldJPopupMenu() {
  pasteSystemClipboardItem = new JMenuItem("貼上網址"); // 開啟下載資料夾
  pasteSystemClipboardItem.addActionListener(this);
  urlFieldPopup = new JPopupMenu();
  urlFieldPopup.add(pasteSystemClipboardItem);
  urlField.add(urlFieldPopup); // 必須指定父元件,否則會拋出NullPointerException
}

代码示例来源: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: org.bidib.jbidib.swinglabs.swingx/swingx-core

private static void addToComponentHierarchy(Component c, Position pos, JTextField textField) {
  textField.add(c, pos.toString());
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

private static void addToComponentHierarchy(Component c, Position pos, JTextField textField) {
  textField.add(c, pos.toString());
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

private static void addToComponentHierarchy(Component c, Position pos, JTextField textField) {
  textField.add(c, pos.toString());
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

private static void addToComponentHierarchy(Component c, Position pos, JTextField textField) {
  textField.add(c, pos.toString());
}

代码示例来源: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: IanDarwin/javasrc

public TextFieldWithClearButton() {
  final JTextField tf = new JTextField(15);
  tf.setLayout(new FlowLayout(FlowLayout.RIGHT));
  final Dimension d = tf.getPreferredSize();
  d.height *= 2;
  tf.setPreferredSize(d);
  JButton b1 = new JButton("X");
  tf.add(b1);
  b1.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent event) {
      tf.setText("");
    }
  });
  final JPanel p = new JPanel();
  p.setBorder(BorderFactory.createTitledBorder("Scram"));
  p.add(tf);
  setContentPane(p);
  //setSize(200, 60);
  pack();
}

代码示例来源:origin: org.scijava/scijava-ui-swing

private void initPrompt(String text) {
  prompt.setText(text);
  prompt.setFont(textField.getFont().deriveFont(Font.ITALIC));
  prompt.setForeground(changeAlpha(textField.getForeground(), 128));
  prompt.setBorder(new EmptyBorder(textField.getInsets()));
  prompt.setHorizontalAlignment(SwingConstants.LEADING);
  textField.setLayout(new BorderLayout());
  textField.add(prompt);
  updatePromptVisibility();
}

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

textField.add(label, BorderLayout.EAST);
label.addMouseListener(new MouseAdapter() {
  @Override

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

private void optionsTab() {
  optionsPanel = new JPanel(new FlowLayout());
  //optionsPanel.setLayout(null);
  JLabel labelOptions = new JLabel("Change Company Name:");
  labelOptions.setBounds(120, 10, 150, 20);
  optionsPanel.add(labelOptions);
  final JTextField newTitle = new JTextField("Some Title");
  newTitle.setBounds(80, 40, 225, 20);
  optionsPanel.add(newTitle);
  final JTextField myTitle = new JTextField("My Title...");
  myTitle.setBounds(80, 40, 225, 20);
  myTitle.add(labelOptions);
  JButton newName = new JButton("Set New Name");
  newName.setBounds(60, 80, 150, 20);
  //newName.addActionListener(this);
  optionsPanel.add(newName);
  optionsPanel.add(createExitButton());
}

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

private void optionsTab() {
   optionsPanel = new JPanel(new FlowLayout());
   // optionsPanel.setLayout(null);
   JLabel labelOptions = new JLabel("Change Company Name:");
   labelOptions.setBounds(120, 10, 150, 20);
   optionsPanel.add(labelOptions);
   final JTextField newTitle = new JTextField("Some Title");
   newTitle.setBounds(80, 40, 225, 20);
   optionsPanel.add(newTitle);
   final JTextField myTitle = new JTextField("My Title...");
   myTitle.setBounds(80, 40, 225, 20);
   myTitle.add(labelOptions);
   JButton newName = new JButton("Set New Name");
   newName.setBounds(60, 80, 150, 20);
   newName.addActionListener(new ActionListener() {
     public void actionPerformed(ActionEvent e) {
       setTitle(newTitle.getText());
     }
   });
   // newName.addActionListener(this);
   optionsPanel.add(newName);
   optionsPanel.add(createExitButton());
 }

代码示例来源: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: IanDarwin/darwinsys-api

/** Construct the Search Box including its GUI.
 * @param borderStr The border title; if null, no titled border added
 */
public SearchBox(String borderStr) {
  super();
  setLayout(new FlowLayout()); // default
  
  if (borderStr != null) {
    this.setBorder(BorderFactory.createTitledBorder(borderStr));
  }
  add(text = new JTextField(10));
  clearButton = new JButton("X");
  if (imbed ) {
    text.setLayout(new FlowLayout(FlowLayout.RIGHT));
    Dimension d = text.getPreferredSize();
    d.height *= 1.7;
    text.setPreferredSize(d);
    final Font xFont = clearButton.getFont();
    Font newFont = xFont.deriveFont(xFont.getSize2D()*0.7f);
    clearButton.setFont(newFont);
    text.add(clearButton);
  } else {
    // Plain mode, add it beside the textfield
    add(clearButton);
  }
  clearButton.addActionListener(clearer);
}

代码示例来源:origin: com.darwinsys/darwinsys-api

/** Construct the Search Box including its GUI.
 * @param borderStr The border title; if null, no titled border added
 */
public SearchBox(String borderStr) {
  super();
  setLayout(new FlowLayout()); // default
  
  if (borderStr != null) {
    this.setBorder(BorderFactory.createTitledBorder(borderStr));
  }
  add(text = new JTextField(10));
  clearButton = new JButton("X");
  if (imbed ) {
    text.setLayout(new FlowLayout(FlowLayout.RIGHT));
    Dimension d = text.getPreferredSize();
    d.height *= 1.7;
    text.setPreferredSize(d);
    final Font xFont = clearButton.getFont();
    Font newFont = xFont.deriveFont(xFont.getSize2D()*0.7f);
    clearButton.setFont(newFont);
    text.add(clearButton);
  } else {
    // Plain mode, add it beside the textfield
    add(clearButton);
  }
  clearButton.addActionListener(clearer);
}

相关文章

JTextField类方法