本文整理汇总了Java中javax.swing.JFrame.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java JFrame.getSize方法的具体用法?Java JFrame.getSize怎么用?Java JFrame.getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFrame
的用法示例。
在下文中一共展示了JFrame.getSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: displayCalibrationStatus
import javax.swing.JFrame; //导入方法依赖的package包/类
@Override
protected void displayCalibrationStatus(JFrame frame) throws Exception {
CalibrationStatusDisplay calibDisplay =
new CalibrationStatusDisplay(frame, calibrationPoints,new java.awt.geom.Point2D.Double[9]);
frame.setMinimumSize(new Dimension(600,300));
frame.add(calibDisplay);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setVisible(true);
frame.setTitle("Calibration: "+new Date());
Insets insets = frame.getInsets();
int width = frame.getSize().width-(insets.left+insets.right);
int height = frame.getSize().height-(insets.top+insets.bottom);
calibDisplay.windowDimension = new Dimension(width,height);
frame.toFront();
calibDisplay.repaint();
}
示例2: setFramePositon
import javax.swing.JFrame; //导入方法依赖的package包/类
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);
}
}
示例3: CompositionArea
import javax.swing.JFrame; //导入方法依赖的package包/类
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);
}
示例4: saveScreenAndDimensions
import javax.swing.JFrame; //导入方法依赖的package包/类
private void saveScreenAndDimensions(JFrame frame) {
if (!frame.isVisible()) {
return;
}
// check multiple displays
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] screens = ge.getScreenDevices();
Point pos = frame.getLocationOnScreen();
Dimension size = frame.getSize();
if (screens.length == 1) {
Config.instance().to().setProperty(Config.Entry.POS_X.key(), pos.x);
Config.instance().to().setProperty(Config.Entry.POS_Y.key(), pos.y);
Config.instance().to().setProperty(Config.Entry.POS_WIDTH.key(), size.width);
Config.instance().to().setProperty(Config.Entry.POS_HEIGHT.key(), size.height);
logger.info("Saved window dimensions to config file (single screen found)");
} else {
Rectangle screenBounds = frame.getGraphicsConfiguration().getBounds();
pos.x -= screenBounds.x;
pos.y -= screenBounds.y;
GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
Config.instance().to().setProperty(Config.Entry.SCREEN_POS_X.key(), pos.x);
Config.instance().to().setProperty(Config.Entry.SCREEN_POS_Y.key(), pos.y);
Config.instance().to().setProperty(Config.Entry.SCREEN_POS_WIDTH.key(), size.width);
Config.instance().to().setProperty(Config.Entry.SCREEN_POS_HEIGHT.key(), size.height);
Config.instance().to().setProperty(Config.Entry.SCREEN.key(), device.getIDstring());
logger.info("Saved window dimensions to config file (multi screen found)");
}
}
示例5: center
import javax.swing.JFrame; //导入方法依赖的package包/类
/**
* Center JFrame.
*/
public static void center(JFrame frame) {
Dimension frameSize = frame.getSize();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((screenSize.width - frameSize.width) >> 1, (screenSize.height - frameSize.height) >> 1);
}
示例6: displayCalibrationStatus
import javax.swing.JFrame; //导入方法依赖的package包/类
protected void displayCalibrationStatus(JFrame frame) throws Exception {
double[] pointsNormalized = jniGetCalibration();
if (pointsNormalized == null)
throw new IOException("Can't get calibration data!");
int zeros = 0;
for( double ord: pointsNormalized){
if( ord <= 0 || ord > 1) zeros++;
}
ArrayList<Point2D.Double> points = new ArrayList<Point2D.Double>();
ArrayList<Point2D.Double> invalidpoints = new ArrayList<Point2D.Double>();
//if( zeros > 0 ) throw new IOException("zeros in points: "+zeros+"/"+pointsNormalized.length);
int itemCount = pointsNormalized.length/4;
for( int i=0; i < itemCount; i++ ){
points.add(new Point2D.Double(pointsNormalized[i],pointsNormalized[i+itemCount]));
points.add(new Point2D.Double(pointsNormalized[(2*itemCount)+i],pointsNormalized[i+(itemCount*3)]));
}
Rectangle2D.Double rect = new Rectangle2D.Double(0.0,0.0,1.0,1.0);
for(Point2D.Double p: points){
if( !rect.contains(p) ) invalidpoints.add(p);
}
for (int i = 0; i < pointsNormalized.length; i++) {
if (pointsNormalized[i] < 0.0001) {
pointsNormalized[i] = 0.0001;
} else if (pointsNormalized[i] > 0.9999) {
pointsNormalized[i] = 0.9999;
} else {
//do nothing
}
}
Point2D.Double[] calibrationData = new Point2D.Double[itemCount+1];
for (int j = 0; j < itemCount; j+=2) {
calibrationData[j] = (new Point2D.Double(pointsNormalized[j],pointsNormalized[itemCount+j]));
if(j != itemCount)
calibrationData[j+1] = (new Point2D.Double(pointsNormalized[2*itemCount+j],pointsNormalized[3*itemCount+j]));
}
JFrame calibFrame = frame;
CalibrationStatusDisplay calibDisplay =
new CalibrationStatusDisplay(calibFrame,calibrationPoints,calibrationData);
calibFrame.add(calibDisplay);
calibFrame.setUndecorated(false);
calibFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
calibFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
calibFrame.setMinimumSize(new Dimension(600,300));
calibFrame.setTitle("Calibration: "+new Date());
Insets insets = calibFrame.getInsets();
int width = calibFrame.getSize().width-(insets.left+insets.right);
int height = calibFrame.getSize().height-(insets.top+insets.bottom);
calibDisplay.windowDimension = new Dimension(width,height);
calibFrame.setVisible(true);
calibFrame.toFront();
calibDisplay.repaint();
}
示例7: displayCalibrationStatus
import javax.swing.JFrame; //导入方法依赖的package包/类
protected void displayCalibrationStatus(JFrame frame) throws Exception {
double[] pointsNormalized = jniGetCalibration();
if (pointsNormalized == null)
throw new IOException("Can't get calibration data!");
int zeros = 0;
for( double ord: pointsNormalized){
if( ord <= 0 || ord > 1) zeros++;
}
ArrayList<Point2D.Double> points = new ArrayList<Point2D.Double>();
ArrayList<Point2D.Double> invalidpoints = new ArrayList<Point2D.Double>();
//if( zeros > 0 ) throw new IOException("zeros in points: "+zeros+"/"+pointsNormalized.length);
int itemCount = pointsNormalized.length/4;
for( int i=0; i < itemCount; i++ ){
points.add(new Point2D.Double(pointsNormalized[i],pointsNormalized[i+itemCount]));
points.add(new Point2D.Double(pointsNormalized[(2*itemCount)+i],pointsNormalized[i+(itemCount*3)]));
}
Rectangle2D.Double rect = new Rectangle2D.Double(0.0,0.0,1.0,1.0);
for(Point2D.Double p: points){
if( !rect.contains(p) ) invalidpoints.add(p);
}
for (int i = 0; i < pointsNormalized.length; i++) {
if (pointsNormalized[i] < 0.0001) {
pointsNormalized[i] = 0.0001;
} else if (pointsNormalized[i] > 0.9999) {
pointsNormalized[i] = 0.9999;
} else {
//do nothing
}
}
Point2D.Double[] calibrationData = new Point2D.Double[itemCount+1];
for (int j = 0; j < itemCount; j+=2) {
calibrationData[j] = (new Point2D.Double(pointsNormalized[j],pointsNormalized[itemCount+j]));
if(j != itemCount)
calibrationData[j+1] = (new Point2D.Double(pointsNormalized[2*itemCount+j],pointsNormalized[3*itemCount+j]));
}
JFrame calibFrame = frame;
CalibrationStatusDisplay calibDisplay =
new CalibrationStatusDisplay(calibFrame,calibrationPoints,calibrationData);
calibFrame.add(calibDisplay);
calibFrame.setUndecorated(false);
calibFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
calibFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
calibFrame.setMinimumSize(new Dimension(600,300));
calibFrame.setTitle("Calibration: "+new Date());
Insets insets = calibFrame.getInsets();
int width = calibFrame.getSize().width-(insets.left+insets.right);
int height = calibFrame.getSize().height-(insets.top+insets.bottom);
calibDisplay.windowDimension = new Dimension(width,height);
calibFrame.setVisible(true);
calibDisplay.repaint();
}