Java Code Examples for javax.swing.JFrame#getSize()

The following examples show how to use javax.swing.JFrame#getSize() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: ghidra   File: ToolSaving1Test.java    License: Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example 2
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);
}
 
Example 3
Source Project: ghidra   File: FrontEndTool.java    License: Apache License 2.0 5 votes vote down vote up
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);
	}
}
 
Example 4
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);
}
 
Example 5
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);
}
 
Example 6
/** 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();
}
 
Example 7
Source Project: Bytecoder   File: CompositionArea.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 8
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);
}
 
Example 9
Source Project: evosql   File: CommonSwing.java    License: Apache License 2.0 5 votes vote down vote up
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);
        }
    }
 
Example 10
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);
}
 
Example 11
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);
}
 
Example 12
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);
}
 
Example 13
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);
}
 
Example 14
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);
}
 
Example 15
/** 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();
}
 
Example 16
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);
}
 
Example 17
@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();
  }
}
 
Example 18
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);
}
 
Example 19
Source Project: ghidra   File: AbstractToolSavingTest.java    License: Apache License 2.0 4 votes vote down vote up
protected Dimension getToolSize(PluginTool tool) {
	JFrame toolFrame = tool.getToolFrame();
	return toolFrame.getSize();
}
 
Example 20
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);

  }