下面列出了javax.swing.JFrame#getSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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));
}
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);
}
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);
}
}
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);
}
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);
}
/** 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();
}
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);
}
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);
}
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);
}
}
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);
}
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);
}
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);
}
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);
}
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);
}
/** 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();
}
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);
}
@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();
}
}
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);
}
protected Dimension getToolSize(PluginTool tool) {
JFrame toolFrame = tool.getToolFrame();
return toolFrame.getSize();
}
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);
}