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

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

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

JTextField.getLocationOnScreen介绍

暂无

代码示例

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

public class DialogTest {
  public static void main(String[] args) {

    final JFrame frame = new JFrame("Frame");
    JTextField field = new JTextField("Click me to open dialog!");
    field.addMouseListener(new MouseAdapter() {

      @Override
      public void mousePressed(MouseEvent e) {
        JTextField f = (JTextField) e.getSource();
        Point l = f.getLocationOnScreen();

        JDialog d = new JDialog(frame, "Dialog", true);
        d.setLocation(l.x, l.y + f.getHeight());
        d.setSize(200, 200);
        d.setVisible(true);
      }
    });
    frame.add(field);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(200, 100);
    frame.setVisible(true);
  }
}

代码示例来源:origin: FellowTraveler/otapij

/**
 * Event handler that displays the DatePicker when the button is
 * clicked.
 * @param evt
 */
private void onButtonClick(final java.awt.event.ActionEvent evt) {
  if ("".equals(dateText.getText()))
    dp = new DatePicker();
  else
    dp = new DatePicker(stringToDate(dateText.getText()));
  dp.setHideOnSelect(true);
  dp.addComponentListener(new Listener());
  final Point p = dateText.getLocationOnScreen();
  p.setLocation(p.getX(), p.getY() - 1 + dateText.getSize().getHeight());
  dlg = new JDialog(new JFrame(), true);
  dlg.setLocation(p);
  dlg.setResizable(false);
  dlg.setUndecorated(true);
  dlg.getContentPane().add(dp);
  dlg.pack();
  dlg.show();
}

代码示例来源:origin: org.codehaus.mevenide/nb-project

private void showPopup() {
  hidePopup();
  if (completionListModel.getSize() == 0) {
    return;
  }
  // figure out where the text field is,
  // and where its bottom left is
  java.awt.Point los = field.getLocationOnScreen();
  int popX = los.x;
  int popY = los.y + field.getHeight();
  popup = PopupFactory.getSharedInstance().getPopup(field, listScroller, popX, popY);
  field.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),ACTION_HIDEPOPUP);
  field.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),ACTION_FILLIN);
  popup.show();
  if (completionList.getSelectedIndex() != -1) {
    completionList.ensureIndexIsVisible(completionList.getSelectedIndex());
  }
}

代码示例来源:origin: igniterealtime/Spark

popup.setSize(textField.getWidth(), SparkManager.getContactList().getHeight()-SparkManager.getSearchManager().getSearchServiceUI().getHeight()-14);
Point pt = textField.getLocationOnScreen();
pt.translate(0, textField.getHeight());
popup.setLocation(pt);

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

this.getSize().width + 1, timeMenuPanel.getSize().height));
int defaultX = timeTextField.getLocationOnScreen().x;
int defaultY = timeTextField.getLocationOnScreen().y + timeTextField.getSize().height - 1;

相关文章

JTextField类方法