javax.swing.JFrame#getSize ( )源码实例Demo

下面列出了javax.swing.JFrame#getSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ghidra   文件: ToolSaving1Test.java
@Test
public void testExitGhidraWithOneTool() {
	PluginTool tool = launchTool(DEFAULT_TEST_TOOL_NAME);
	Dimension size = new Dimension(450, 550);
	setToolSize(tool, size);
	closeAndReopenProject();

	// we expect the *session* tool to be reopened with the project and to be our size
	JFrame window = getOpenedToolWindow(DEFAULT_TEST_TOOL_NAME);
	Dimension sessionToolSize = window.getSize();
	assertEquals("Session tool's size did not get saved with the project on Ghidra exit", size,
		sessionToolSize);

	// we also expect the tool in the tool chest to have the new size
	tool = launchTool(DEFAULT_TEST_TOOL_NAME);
	Dimension newSize = getToolSize(tool);
	assertTrue("Tool size was not saved. Expected: " + size + " and found: " + newSize,
		size.equals(newSize));
}
 
源代码2 项目: dragonwell8_jdk   文件: CompositionArea.java
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
源代码3 项目: ghidra   文件: FrontEndTool.java
private void ensureSize() {
	JFrame frame = getToolFrame();
	Dimension size = frame.getSize();
	if (size.height < MIN_HEIGHT) {
		size.height = MIN_HEIGHT;
		Point center = WindowUtilities.centerOnScreen(size);
		frame.setBounds(center.x, center.y, size.width, size.height);
	}
}
 
源代码4 项目: TencentKona-8   文件: CompositionArea.java
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
源代码5 项目: openjdk-jdk8u   文件: CompositionArea.java
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
源代码6 项目: grammarviz2_src   文件: GrammarvizGuesserDialog.java
/** Creates the reusable dialog. */
public GrammarvizGuesserDialog(JFrame topFrame, JPanel guesserPane, UserSession session) {

  super(topFrame, true);

  if (topFrame != null) {
    Dimension parentSize = topFrame.getSize();
    Point p = topFrame.getLocation();
    setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
  }

  this.setTitle("Sampler interval and parameter ranges verification");

  // this.session = session;

  this.guesserPane = (GrammarvizGuesserPane) guesserPane;

  MigLayout mainFrameLayout = new MigLayout("fill", "[grow,center]", "[grow]5[]");

  getContentPane().setLayout(mainFrameLayout);

  getContentPane().add(this.guesserPane, "h 200:200:,w 400:400:,growx,growy,wrap");

  JPanel buttonPane = new JPanel();
  JButton okButton = new JButton(OK_BUTTON_TEXT);
  JButton cancelButton = new JButton(CANCEL_BUTTON_TEXT);
  buttonPane.add(okButton);
  buttonPane.add(cancelButton);
  okButton.addActionListener(this);
  cancelButton.addActionListener(this);

  getContentPane().add(buttonPane, "wrap");

  pack();
}
 
源代码7 项目: Bytecoder   文件: CompositionArea.java
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
源代码8 项目: openjdk-jdk9   文件: CompositionArea.java
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
源代码9 项目: evosql   文件: CommonSwing.java
static void setFramePositon(JFrame inTargetFrame) {

        Dimension d    = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension size = inTargetFrame.getSize();

        // (ulrivo): full size on screen with less than 640 width
        if (d.width >= 640) {
            inTargetFrame.setLocation((d.width - size.width) / 2,
                                      (d.height - size.height) / 2);
        } else {
            inTargetFrame.setLocation(0, 0);
            inTargetFrame.setSize(d);
        }
    }
 
源代码10 项目: jdk8u-jdk   文件: CompositionArea.java
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
源代码11 项目: hottub   文件: CompositionArea.java
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
源代码12 项目: openjdk-8-source   文件: CompositionArea.java
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
源代码13 项目: CodenameOne   文件: RetroWeaverGui.java
private static void centerOnScreen(JFrame frame) {
	Dimension frameSize = frame.getSize();
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	int x = (screenSize.width - frameSize.width) / 2;
	int y = (screenSize.height - frameSize.height) / 2;
	frame.setLocation(x, y);
}
 
源代码14 项目: jdk8u_jdk   文件: CompositionArea.java
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
源代码15 项目: grammarviz2_src   文件: GrammarvizOptionsDialog.java
/** Creates the reusable dialog. */
public GrammarvizOptionsDialog(JFrame parentFrame, JPanel optionPanel, UserSession session) {

  super(parentFrame, true);

  if (parentFrame != null) {
    Dimension parentSize = parentFrame.getSize();
    Point p = parentFrame.getLocation();
    setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
  }

  this.session = session;

  this.optionPane = (GrammarvizOptionsPane) optionPanel;

  MigLayout mainFrameLayout = new MigLayout("fill", "[grow,center]", "[grow]5[]");

  getContentPane().setLayout(mainFrameLayout);

  getContentPane().add(this.optionPane, "h 200:300:,w 500:550:,growx,growy,wrap");

  JPanel buttonPane = new JPanel();
  JButton okButton = new JButton(OK_BUTTON_TEXT);
  JButton cancelButton = new JButton(CANCEL_BUTTON_TEXT);
  buttonPane.add(okButton);
  buttonPane.add(cancelButton);
  okButton.addActionListener(this);
  cancelButton.addActionListener(this);

  getContentPane().add(buttonPane, "wrap");

  pack();
}
 
源代码16 项目: zap-extensions   文件: ImportFromUrlDialog.java
public ImportFromUrlDialog(JFrame parent, ExtensionImportWSDL caller) {
    super(parent, Constant.messages.getString(MESSAGE_PREFIX + "actionName"), true);
    if (caller != null) {
        this.caller = caller;
    }
    if (parent != null) {
        Dimension parentSize = parent.getSize();
        Point p = parent.getLocation();
        setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
    }
    // set up layout
    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(5, 5, 5, 5);

    buttonImport.addActionListener(this);

    // add components to the frame
    constraints.gridx = 0;
    constraints.gridy = 0;
    add(labelURL, constraints);

    constraints.gridx = 1;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.weightx = 1.0;
    fieldURL = addContextMenu(fieldURL);
    add(fieldURL, constraints);

    constraints.gridy = 2;
    constraints.anchor = GridBagConstraints.CENTER;
    add(buttonImport, constraints);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    pack();
    setVisible(true);
}
 
源代码17 项目: mzmine2   文件: WindowSettingsParameter.java
@Override
public void componentResized(ComponentEvent e) {
  if (!(e.getComponent() instanceof JFrame))
    return;
  JFrame frame = (JFrame) e.getComponent();
  int state = frame.getExtendedState();
  isMaximized = ((state & Frame.MAXIMIZED_HORIZ) != 0) && ((state & Frame.MAXIMIZED_VERT) != 0);
  if (!isMaximized) {
    dimension = frame.getSize();
  }
}
 
源代码18 项目: jdk8u-jdk   文件: CompositionArea.java
CompositionArea() {
    // create composition window with localized title
    String windowTitle = Toolkit.getProperty("AWT.CompositionWindowTitle", "Input Window");
    compositionWindow =
        (JFrame)InputMethodContext.createInputMethodWindow(windowTitle, null, true);

    setOpaque(true);
    setBorder(LineBorder.createGrayLineBorder());
    setForeground(Color.black);
    setBackground(Color.white);

    // if we get the focus, we still want to let the client's
    // input context handle the event
    enableInputMethods(true);
    enableEvents(AWTEvent.KEY_EVENT_MASK);

    compositionWindow.getContentPane().add(this);
    compositionWindow.addWindowListener(new FrameWindowAdapter());
    addInputMethodListener(this);
    compositionWindow.enableInputMethods(false);
    compositionWindow.pack();
    Dimension windowSize = compositionWindow.getSize();
    Dimension screenSize = (getToolkit()).getScreenSize();
    compositionWindow.setLocation(screenSize.width - windowSize.width-20,
                                screenSize.height - windowSize.height-100);
    compositionWindow.setVisible(false);
}
 
源代码19 项目: ghidra   文件: AbstractToolSavingTest.java
protected Dimension getToolSize(PluginTool tool) {
	JFrame toolFrame = tool.getToolFrame();
	return toolFrame.getSize();
}
 
源代码20 项目: grammarviz2_src   文件: AboutGrammarVizDialog.java
public AboutGrammarVizDialog(JFrame parentFrame) {

    super(parentFrame, true);
    if (parentFrame != null) {
      Dimension parentSize = parentFrame.getSize();
      Point p = parentFrame.getLocation();
      setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
    }

    JEditorPane aboutTextPane = new JEditorPane();

    aboutTextPane.setEditable(false);
    java.net.URL helpURL = AboutGrammarVizDialog.class.getResource("/AboutText.html");
    if (helpURL != null) {
      try {
        aboutTextPane.setPage(helpURL);
      }
      catch (IOException e) {
        System.err.println("Attempted to read a bad URL: " + helpURL);
      }
    }
    else {
      System.err.println("Couldn't find file: AboutText.html");
    }

    // Put the editor pane in a scroll pane.
    JScrollPane editorScrollPane = new JScrollPane(aboutTextPane);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    MigLayout mainFrameLayout = new MigLayout("fill", "[grow,center]", "[grow]5[]");

    getContentPane().setLayout(mainFrameLayout);

    getContentPane().add(editorScrollPane, "h 200:300:,w 400:500:,growx,growy,wrap");

    JPanel buttonPane = new JPanel();
    JButton okButton = new JButton(OK_BUTTON_TEXT);

    buttonPane.add(okButton);
    okButton.addActionListener(this);

    getContentPane().add(buttonPane, "wrap");

    pack();
    setVisible(true);

  }