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

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

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

JTextField.getParent介绍

暂无

代码示例

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

private void updateField(JTextField field) {
  field.getParent().revalidate();
}

代码示例来源:origin: us.ihmc/RobotDataCommunication

@Override
  public void actionPerformed(ActionEvent e)
  {
   try
   {
     int readEveryNTicks = Integer.parseInt(textField.getText());
     robot.setReadEveryNTicks(readEveryNTicks);
   }
   catch (NumberFormatException exception)
   {
   }
   setReadEveryNTicksTextFieldToCurrentValue(textField);
   textField.getParent().requestFocus();
  }
});

代码示例来源:origin: us.ihmc/ihmc-robot-data-visualizer

@Override
  public void actionPerformed(ActionEvent e)
  {
   try
   {
     int readEveryNTicks = Integer.parseInt(textField.getText());
     robot.setReadEveryNTicks(readEveryNTicks);
   }
   catch (NumberFormatException exception)
   {
   }
   setReadEveryNTicksTextFieldToCurrentValue(textField);
   textField.getParent().requestFocus();
  }
});

代码示例来源:origin: us.ihmc/IHMCRobotDataVisualizer

@Override
  public void actionPerformed(ActionEvent e)
  {
   try
   {
     int readEveryNTicks = Integer.parseInt(textField.getText());
     robot.setReadEveryNTicks(readEveryNTicks);
   }
   catch (NumberFormatException exception)
   {
   }
   setReadEveryNTicksTextFieldToCurrentValue(textField);
   textField.getParent().requestFocus();
  }
});

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-vmd-game

/** Creates new form ResourceImageEditor */
public ResourceImageEditor() {
  initComponents();
  this.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ResourceImageEditor.class, "ResourceImageEditor.accessible.name"));
  this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ResourceImageEditor.class, "ResourceImageEditor.accessible.description"));
  
  this.textFieldImage.setBackground(this.textFieldImage.getParent().getBackground());
  this.textFieldNumTiles.setBackground(this.textFieldNumTiles.getParent().getBackground());
  this.textFieldSize.setBackground(this.textFieldSize.getParent().getBackground());
  this.resourceComponent = new ResourceImageList();
  this.panelResourceList.add(new JScrollPane(this.resourceComponent));
}

代码示例来源:origin: net.sf.mmax2/mmax2

public void mouseClicked(java.awt.event.MouseEvent e)
{
  JTextField source = (JTextField) e.getSource();        
  Color c = JColorChooser.showDialog(source.getParent(),"Choose markable level color",source.getForeground());
  source.setForeground(c);               
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public void keyTyped(KeyEvent evt) {
  if (evt.getKeyChar() == '\n') {
    findButtons[0].doClick(20);
    evt.consume();
    ((JComboBox)((JTextField)evt.getSource()).getParent()).hidePopup();
  } else {
    postChangeCombos();
  }
}

代码示例来源:origin: com.tourgeek.thin.app/com.tourgeek.thin.app.booking

Container parent = m_tfDate.getParent();
while (parent != null)

代码示例来源:origin: joel-costigliola/assertj-swing

@RunsInCurrentThread
static @Nonnull Pair<Point, Container> pointAndParentForScrolling(final @Nonnull JTextField textField) {
 Point origin = new Point(textField.getX(), textField.getY());
 Container parent = textField.getParent();
 while (parent != null && !(parent instanceof JComponent) && !(parent instanceof CellRendererPane)) {
  origin = addRectangleToPoint(checkNotNull(parent.getBounds()), origin);
  parent = parent.getParent();
 }
 return Pair.of(origin, parent);
}

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

String key = null;
 final JTextField txtKey = new JTextField();
 txtKey.addKeyListener(new KeyAdapter() {
  @Override
  public void keyPressed(KeyEvent e) {
   int keyCode = e.getKeyCode();
   if (keyCode == 10) { //enter key
    Container parent = txtKey.getParent();              
    while (!(parent instanceof JOptionPane)) {
     parent = parent.getParent();
    }
    JOptionPane pane = (JOptionPane) parent;
    final JPanel pnlBottom = (JPanel) pane.getComponent(pane.getComponentCount() - 1);
    for (int i = 0; i < pnlBottom.getComponents().length; i++) {
     Component component = pnlBottom.getComponents()[i];
     if (component instanceof JButton) {
      final JButton okButton = ((JButton)component);
      if (okButton.getText().equalsIgnoreCase(okCaption)) {
       ActionListener[] actionListeners = okButton.getActionListeners();
       if (actionListeners.length > 0) {
        actionListeners[0].actionPerformed(null);
       }
      }
     }
    }
   }
  }
 });

代码示例来源:origin: org.terracotta.modules/tim-hibernate-cache-provider-3.2

private static XSpinner createIntegerField() {
 final XSpinner spinner = new XSpinner();
 JTextField editor = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
 editor.setColumns(10);
 spinner.setUI(new javax.swing.plaf.basic.BasicSpinnerUI() {
  @Override
  protected Component createNextButton() {
   Component c = new JButton();
   c.setPreferredSize(new Dimension(0, 0));
   c.setFocusable(false);
   return c;
  }
  @Override
  protected Component createPreviousButton() {
   Component c = new JButton();
   c.setPreferredSize(new Dimension(0, 0));
   c.setFocusable(false);
   return c;
  }
 });
 spinner.setBorder(null);
 ((DefaultFormatter) ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().getFormatter())
   .setAllowsInvalid(false);
 ((JComponent) editor.getParent()).setBorder(UIManager.getBorder("TextField.border"));
 return spinner;
}

代码示例来源:origin: org.terracotta.modules/tim-ehcache-2.0-hibernate-ui

private static XSpinner createIntegerField() {
 final XSpinner spinner = new XSpinner();
 JTextField editor = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
 editor.setColumns(10);
 spinner.setUI(new javax.swing.plaf.basic.BasicSpinnerUI() {
  @Override
  protected Component createNextButton() {
   Component c = new JButton();
   c.setPreferredSize(new Dimension(0, 0));
   c.setFocusable(false);
   return c;
  }
  @Override
  protected Component createPreviousButton() {
   Component c = new JButton();
   c.setPreferredSize(new Dimension(0, 0));
   c.setFocusable(false);
   return c;
  }
 });
 spinner.setBorder(null);
 ((DefaultFormatter) ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().getFormatter())
   .setAllowsInvalid(false);
 ((JComponent) editor.getParent()).setBorder(UIManager.getBorder("TextField.border"));
 return spinner;
}

代码示例来源:origin: org.terracotta.modules/tim-ehcache-2.x-ui

private static XSpinner createIntegerField() {
 final XSpinner spinner = new XSpinner();
 JTextField editor = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
 editor.setColumns(10);
 spinner.setUI(new javax.swing.plaf.basic.BasicSpinnerUI() {
  @Override
  protected Component createNextButton() {
   Component c = new JButton();
   c.setPreferredSize(new Dimension(0, 0));
   c.setFocusable(false);
   return c;
  }
  @Override
  protected Component createPreviousButton() {
   Component c = new JButton();
   c.setPreferredSize(new Dimension(0, 0));
   c.setFocusable(false);
   return c;
  }
 });
 spinner.setBorder(null);
 ((DefaultFormatter) ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().getFormatter())
   .setAllowsInvalid(false);
 ((JComponent) editor.getParent()).setBorder(UIManager.getBorder("TextField.border"));
 return spinner;
}

代码示例来源:origin: org.terracotta.modules/tim-ehcache-2.0

private static XSpinner createIntegerField() {
 final XSpinner spinner = new XSpinner();
 JTextField editor = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
 editor.setColumns(10);
 spinner.setUI(new javax.swing.plaf.basic.BasicSpinnerUI() {
  @Override
  protected Component createNextButton() {
   Component c = new JButton();
   c.setPreferredSize(new Dimension(0, 0));
   c.setFocusable(false);
   return c;
  }
  @Override
  protected Component createPreviousButton() {
   Component c = new JButton();
   c.setPreferredSize(new Dimension(0, 0));
   c.setFocusable(false);
   return c;
  }
 });
 spinner.setBorder(null);
 ((DefaultFormatter) ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().getFormatter())
   .setAllowsInvalid(false);
 ((JComponent) editor.getParent()).setBorder(UIManager.getBorder("TextField.border"));
 return spinner;
}

代码示例来源:origin: org.terracotta.modules/tim-ehcache-2.x-hibernate-ui

private static XSpinner createIntegerField() {
 final XSpinner spinner = new XSpinner();
 JTextField editor = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
 editor.setColumns(10);
 spinner.setUI(new javax.swing.plaf.basic.BasicSpinnerUI() {
  @Override
  protected Component createNextButton() {
   Component c = new JButton();
   c.setPreferredSize(new Dimension(0, 0));
   c.setFocusable(false);
   return c;
  }
  @Override
  protected Component createPreviousButton() {
   Component c = new JButton();
   c.setPreferredSize(new Dimension(0, 0));
   c.setFocusable(false);
   return c;
  }
 });
 spinner.setBorder(null);
 ((DefaultFormatter) ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField().getFormatter())
   .setAllowsInvalid(false);
 ((JComponent) editor.getParent()).setBorder(UIManager.getBorder("TextField.border"));
 return spinner;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-vmd-game

this.textFieldName.setBackground(this.textFieldName.getParent().getBackground());
this.textFieldRows.setBackground(this.textFieldRows.getParent().getBackground());
this.textFieldCols.setBackground(this.textFieldCols.getParent().getBackground());

相关文章

JTextField类方法