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

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

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

JTextField.setAction介绍

暂无

代码示例

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

JTextField textField = new JTextField();
textField.setAction(sendAction);

代码示例来源:origin: apache/pdfbox

private void init()
{
  panel = new JPanel(new BorderLayout());
  statusField = new JTextField();
  statusField.setEditable(false);
  panel.add(statusField);
  defaultBorder = new BevelBorder(BevelBorder.LOWERED);
  errorBorder = new BevelBorder(BevelBorder.LOWERED, Color.RED, Color.RED);
  statusField.setAction(textInputAction);
  tree.addTreeSelectionListener(this);
}

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

public class View2 extends JPanel {
  private View1 view1;
  private JTextField textField = new JTextField(10);

  public View2(View1 view1) {
   Action addItemAction = new AddItemAction();
   this.view1 = view1;
   add(textField);
   add(new JButton(addItemAction));
   textField.setAction(addItemAction);
  }

  private class AddItemAction extends AbstractAction {
   public AddItemAction() {
     super("Add Item");
     putValue(MNEMONIC_KEY, KeyEvent.VK_A);
   }

   @Override
   public void actionPerformed(ActionEvent e) {
     view1.addItem(textField.getText()); // *** calls view1's method here
     textField.selectAll();
   }
  }
}

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

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import javax.swing.*;

public class AddJarDemo {

  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        final JTextField field = new JTextField(15);
        Action action = new AbstractAction("Hello Action"){
          public void actionPerformed(ActionEvent e) {
            System.out.println(field.getText());
          }
        };
        field.setAction(action);
        JButton button = new JButton(action);
        JPanel panel = new JPanel(new GridLayout(0, 1));
        panel.add(field);
        panel.add(button);
        JOptionPane.showMessageDialog(null, panel);
      }
    });
  }
}

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

inputField.setAction(action);
doActionButton.setAction(action);

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

Action fieldAction = new AbstractAction("fieldAction") {
   @Override
   public void actionPerformed(ActionEvent e) {
     System.out.println("hello " + ((JTextComponent) e.getSource()).getText());
   }
 };
 JTextField field = new JTextField("this is a normal field");
 MultiplexingTextField multiplexing = new MultiplexingTextField(20);
 multiplexing.addKeyStrokes(KeyStroke.getKeyStroke("ENTER"));
 field.setAction(fieldAction);
 multiplexing.setAction(fieldAction);
 Action action = new AbstractAction("default button action") {
   @Override
   public void actionPerformed(ActionEvent e) {
     System.out.println("hello - got default button");
   }
 };
 JButton button = new JButton(action);
 JPanel panel = new JPanel();
 panel.add(field);
 panel.add(multiplexing);
 panel.add(button);
 // this is swingx testing support, simply replace with normal frame creation
 JXFrame frame = wrapInFrame(panel, "multiplex");
 frame.getRootPane().setDefaultButton(button);

代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler

findField.setAction(getAction(FindAction.class));

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

JTextField field = new JTextField(20);
field.setName(": " + i);
field.setAction(textAction);
comp.add(field);

代码示例来源:origin: com.eas.platypus/platypus-js-forms

/**
 * Creates new form GridSearchView
 */
public GridSearchView(ModelGrid aGrid) {
  initComponents();
  grid = aGrid;
  //grid.getRowsSelectionModel().addListSelectionListener(this);
  btnClose.setAction(closeAction);
  btnFind.setAction(findAction);
  txtText2Find.setAction(new SurrogateFindAction());
  txtText2Find.getDocument().addDocumentListener(new SearchViewDocumentListener());
}

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

enterField.setAction(enterAction);

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

AddSongAction songAction = new AddSongAction("Add Song");
southPanel.add(new JButton(songAction));
songField.setAction(songAction);

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

entryField.setAction(entryAction);
JPanel bottomPanel = new JPanel();
bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.LINE_AXIS));

代码示例来源:origin: org.xworker/xworker_core

public static void createAction(ActionContext actionContext){
  Thing self = (Thing) actionContext.get("self");
  JTextField parent = (JTextField) actionContext.get("JTextField");
  
  for(Thing child : self.getChilds()){
    Action l = (Action) child.doAction("create", actionContext);
    if(l != null){
      parent.setAction(l);
      break;
    }
  }
}

代码示例来源:origin: omegat-org/omegat

field.setAction(new AbstractAction() {
  @Override
  public void actionPerformed(ActionEvent e) {

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

textField.setAction(addAction);

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

textField.setAction(addWordAction);
JPanel topPanel = new JPanel();
topPanel.add(textField);

代码示例来源:origin: com.github.haifengl/smile-plot

pageSizeField.setText(Integer.toString(getPageSize()));
pageSizeField.setHorizontalAlignment(JTextField.RIGHT);
pageSizeField.setAction(pageSizeAction);
pageSizeField.setMaximumSize(pageSizeField.getPreferredSize());
pageField.setText(Integer.toString(getPage() + 1));
pageField.setHorizontalAlignment(JTextField.RIGHT);
pageField.setAction(gotoPageAction);
pageField.setMaximumSize(pageField.getPreferredSize());

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

field.setAction(action);

代码示例来源:origin: org.jspresso/jspresso-swing-components

buttonSquareSize = textField.getPreferredSize().height;
if (textField.getAction() == null) {
 textField.setAction(action);

代码示例来源:origin: org.jspresso.framework/jspresso-swing-components

buttonSquareSize = textField.getPreferredSize().height;
if (textField.getAction() == null) {
 textField.setAction(action);

相关文章

JTextField类方法