Java Code Examples for javax.swing.JFrame#getSize()
The following examples show how to use
javax.swing.JFrame#getSize() .
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 check out the related API usage on the sidebar.
Example 1
Source File: ToolSaving1Test.java From ghidra with Apache License 2.0 | 6 votes |
@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
Source File: CommonSwing.java From evosql with Apache License 2.0 | 5 votes |
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 3
Source File: CompositionArea.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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 4
Source File: WindowSettingsParameter.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
@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 5
Source File: ImportFromUrlDialog.java From zap-extensions with Apache License 2.0 | 5 votes |
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 6
Source File: GrammarvizOptionsDialog.java From grammarviz2_src with GNU General Public License v2.0 | 5 votes |
/** 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 7
Source File: CompositionArea.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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
Source File: RetroWeaverGui.java From CodenameOne with GNU General Public License v2.0 | 5 votes |
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 9
Source File: CompositionArea.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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 10
Source File: CompositionArea.java From hottub with GNU General Public License v2.0 | 5 votes |
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
Source File: CompositionArea.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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
Source File: CompositionArea.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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
Source File: CompositionArea.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 14
Source File: CompositionArea.java From Bytecoder with Apache License 2.0 | 5 votes |
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
Source File: GrammarvizGuesserDialog.java From grammarviz2_src with GNU General Public License v2.0 | 5 votes |
/** 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 16
Source File: CompositionArea.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 17
Source File: CompositionArea.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 18
Source File: FrontEndTool.java From ghidra with Apache License 2.0 | 5 votes |
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 19
Source File: AboutGrammarVizDialog.java From grammarviz2_src with GNU General Public License v2.0 | 4 votes |
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); }
Example 20
Source File: AbstractToolSavingTest.java From ghidra with Apache License 2.0 | 4 votes |
protected Dimension getToolSize(PluginTool tool) { JFrame toolFrame = tool.getToolFrame(); return toolFrame.getSize(); }