本文整理了Java中javax.swing.JFrame.getWidth()
方法的一些代码示例,展示了JFrame.getWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFrame.getWidth()
方法的具体详情如下:
包路径:javax.swing.JFrame
类名称:JFrame
方法名:getWidth
暂无
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.setSize(200, 200);
// create the status bar panel and shove it down the bottom of the frame
JPanel statusPanel = new JPanel();
statusPanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
frame.add(statusPanel, BorderLayout.SOUTH);
statusPanel.setPreferredSize(new Dimension(frame.getWidth(), 16));
statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
JLabel statusLabel = new JLabel("status");
statusLabel.setHorizontalAlignment(SwingConstants.LEFT);
statusPanel.add(statusLabel);
frame.setVisible(true);
代码示例来源:origin: pmd/pmd
@Override
public void componentResized(ComponentEvent e) {
JFrame tmp = (JFrame) e.getSource();
if (tmp.getWidth() < 600 || tmp.getHeight() < 700) {
tmp.setSize(600, 700);
}
}
});
代码示例来源:origin: pmd/pmd
private void createRuleXML() {
CreateXMLRulePanel rulePanel = new CreateXMLRulePanel(xpathQueryArea, codeEditorPane);
JFrame xmlframe = new JFrame("Create XML Rule");
xmlframe.setContentPane(rulePanel);
xmlframe.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
xmlframe.setSize(new Dimension(600, 700));
xmlframe.addComponentListener(new java.awt.event.ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
JFrame tmp = (JFrame) e.getSource();
if (tmp.getWidth() < 600 || tmp.getHeight() < 700) {
tmp.setSize(600, 700);
}
}
});
int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height;
int screenWidth = Toolkit.getDefaultToolkit().getScreenSize().width;
xmlframe.pack();
xmlframe.setLocation((screenWidth - xmlframe.getWidth()) / 2, (screenHeight - xmlframe.getHeight()) / 2);
xmlframe.setVisible(true);
}
代码示例来源:origin: pmd/pmd
frame.setLocation((screenWidth - frame.getWidth()) / 2, (screenHeight - frame.getHeight()) / 2);
frame.setVisible(true);
int horozontalMiddleLocation = controlSplitPane.getMaximumDividerLocation() * 3 / 5;
代码示例来源:origin: RaiMan/SikuliX2
private int whichSide(int x, int y) {
if (isMiddle(box.getWidth(), x) && isLow(box.getHeight(), y)) return TOP;
if (isMiddle(box.getHeight(), y) && isLow(box.getWidth(), x)) return LEFT;
if (isMiddle(box.getWidth(), x) && isHigh(box.getHeight(), y)) return BOTTOM;
if (isMiddle(box.getHeight(), y) && isHigh(box.getWidth(), x)) return RIGHT;
return TOP;
}
代码示例来源:origin: RaiMan/SikuliX2
public Element whereShowing() {
return new Element(frame.getLocation().x, frame.getLocation().y, frame.getWidth(), frame.getHeight());
}
//</editor-fold>
代码示例来源:origin: stackoverflow.com
public Surface(JFrame frame) {
this.frame = frame;
frame.setContentPane(this); // add this line
rf = new RandomFrame(frame.getWidth(), frame.getHeight());
}
代码示例来源:origin: danfickle/openhtmltopdf
/**
* Description of the Method
*
* @param frame PARAM
*/
public static void center(JFrame frame) {
//p("centering");
Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((int) ((screen_size.getWidth() - frame.getWidth()) / 2),
(int) ((screen_size.getHeight() - frame.getHeight()) / 2));
}
代码示例来源:origin: stackoverflow.com
JFrame f = frameA; // or frameB
BufferedImage bi = new BufferedImage(f.getWidth(), f.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D g = bi.createGraphics();
f.paint(g);
g.dispose();
lab.setIcon(new IconImage(bi));
代码示例来源:origin: JetBrains/jediterm
@Override
public void run() {
Dimension d = myTerminal.getPreferredSize();
d.width += frame.getWidth() - frame.getContentPane().getWidth();
d.height += frame.getHeight() - frame.getContentPane().getHeight();
frame.setSize(d);
}
});
代码示例来源:origin: stackoverflow.com
public static void moveToCenterScreen(JFrame frame) {
Toolkit kit = frame.getToolkit();
GraphicsDevice[] gs = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
Insets in = kit.getScreenInsets(gs[0].getDefaultConfiguration());
Dimension d = kit.getScreenSize();
int max_width = (d.width - in.left - in.right);
int max_height = (d.height - in.top - in.bottom);
frame.setLocation((int) (max_width - frame.getWidth()) / 2, (int) (max_height - frame.getHeight() ) / 2);
}
代码示例来源:origin: gurkenlabs/litiengine
@Override
public void componentResized(ComponentEvent e) {
userPreferences.setWidth(window.getWidth());
userPreferences.setHeight(window.getHeight());
}
});
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-vmd-game
public static void center(JFrame frame) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Point center = ge.getCenterPoint();
Rectangle bounds = ge.getMaximumWindowBounds();
int w = Math.min(frame.getWidth(), bounds.width);
int h = Math.min(frame.getHeight(), bounds.height);
int x = center.x - w/2, y = center.y - h/2;
frame.setBounds(x, y, w, h);
if (w == bounds.width && h == bounds.height)
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
frame.validate();
}
代码示例来源:origin: AliView/AliView
public void show(){
dialog.setPreferredSize(this.preferredSize);
dialog.pack();
// center
if(parentFrame != null){
int newX = parentFrame.getX() + parentFrame.getWidth()/2 - dialog.getPreferredSize().width/2;
int newY = parentFrame.getY() + parentFrame.getHeight()/2 - dialog.getPreferredSize().height/2;
dialog.setLocation(newX, newY);
}
dialog.setVisible(true);
}
代码示例来源:origin: google/sagetv
public void windowClosing(java.awt.event.WindowEvent evt)
{
int numCols = tracerTable.getColumnCount();
for (int i = 0; i < numCols; i++)
uiMgr.putInt("studio/tracer_col_width/" + i, tracerTable.getColumnModel().getColumn(i).getWidth());
uiMgr.putInt("studio/tracer_win_pos_x", tracerFrame.getX());
uiMgr.putInt("studio/tracer_win_pos_y", tracerFrame.getY());
uiMgr.putInt("studio/tracer_win_pos_w", tracerFrame.getWidth());
uiMgr.putInt("studio/tracer_win_pos_h", tracerFrame.getHeight());
tracerFrame.dispose();
}
});
代码示例来源:origin: google/sagetv
public void windowClosing(java.awt.event.WindowEvent evt)
{
int numCols = conflictTable.getColumnCount();
for (int i = 0; i < numCols; i++)
uiMgr.putInt("studio/conflicts_col_width/" + i, conflictTable.getColumnModel().getColumn(i).getWidth());
uiMgr.putInt("studio/conflicts_win_pos_x", conflictsFrame.getX());
uiMgr.putInt("studio/conflicts_win_pos_y", conflictsFrame.getY());
uiMgr.putInt("studio/conflicts_win_pos_w", conflictsFrame.getWidth());
uiMgr.putInt("studio/conflicts_win_pos_h", conflictsFrame.getHeight());
conflictsFrame.dispose();
}
});
代码示例来源:origin: google/sagetv
public void windowClosing(java.awt.event.WindowEvent evt)
{
uiMgr.putInt("studio/uicomps_win_pos_x", uiCompsFrame.getX());
uiMgr.putInt("studio/uicomps_win_pos_y", uiCompsFrame.getY());
uiMgr.putInt("studio/uicomps_win_pos_w", uiCompsFrame.getWidth());
uiMgr.putInt("studio/uicomps_win_pos_h", uiCompsFrame.getHeight());
uiCompsFrame.dispose();
}
});
代码示例来源:origin: google/sagetv
public void windowClosing(java.awt.event.WindowEvent evt)
{
uiMgr.putInt("studio/diff_win_pos_x", diffFrame.getX());
uiMgr.putInt("studio/diff_win_pos_y", diffFrame.getY());
uiMgr.putInt("studio/diff_win_pos_w", diffFrame.getWidth());
uiMgr.putInt("studio/diff_win_pos_h", diffFrame.getHeight());
diffFrame.dispose();
}
});
代码示例来源:origin: google/sagetv
public void windowClosing(java.awt.event.WindowEvent evt)
{
// Ensure the debugger isn't paused/stepping
resumeExecution();
uiMgr.putInt("studio_win_pos_x", myFrame.getX());
uiMgr.putInt("studio_win_pos_y", myFrame.getY());
uiMgr.putInt("studio_win_pos_w", myFrame.getWidth());
uiMgr.putInt("studio_win_pos_h", myFrame.getHeight());
myFrame.dispose();
}
});
代码示例来源:origin: eu.mihosoft.vrl/vrl
/**
* @param parentFrame the parentFrame to set
*/
public void centerDialog(JFrame parentFrame) {
this.setLocation(
parentFrame.getLocation().x +
parentFrame.getWidth() / 2 - this.getWidth() / 2,
parentFrame.getLocation().y +
parentFrame.getHeight() / 2 - this.getHeight() / 2);
}
}
内容来源于网络,如有侵权,请联系作者删除!