当前位置: 首页>>代码示例>>Java>>正文


Java Frame.setLocation方法代码示例

本文整理汇总了Java中java.awt.Frame.setLocation方法的典型用法代码示例。如果您正苦于以下问题:Java Frame.setLocation方法的具体用法?Java Frame.setLocation怎么用?Java Frame.setLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Frame的用法示例。


在下文中一共展示了Frame.setLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: OverScrollTest

import java.awt.Frame; //导入方法依赖的package包/类
OverScrollTest() {
    try {
        robot = new Robot();
    } catch (Exception ex) {
        throw new RuntimeException(ex.getMessage());
    }

    mainFrame = new Frame();
    mainFrame.setSize(400, 200);
    mainFrame.setLocation(200, 200);
    mainFrame.setLayout(new FlowLayout());

    textField = new TextField(10);
    textField.setSize(300, 100);
    textField.setText("123456 789123");
    mainFrame.add(textField);
    mainFrame.setVisible(true);
    textField.requestFocusInWindow();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:OverScrollTest.java

示例2: createFrame

import java.awt.Frame; //导入方法依赖的package包/类
private static Frame createFrame(String title, int x, int y) {
    Frame frame = new Frame();
    frame.setSize(200, 200);
    frame.setLocation(x, y);
    frame.setTitle(title);
    frame.setVisible(true);
    return frame;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:MissingEventsOnModalDialogTest.java

示例3: start

import java.awt.Frame; //导入方法依赖的package包/类
public void start() {
    //Get things going.  Request focus, set size, et cetera
    setSize(200, 200);
    setVisible(true);
    validate();

    final Image image = new MultiResolutionCursor();

    int center = sizes[0] / 2;
    Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
            image, new Point(center, center), "multi-resolution cursor");

    Frame frame = new Frame("Test Frame");
    frame.setSize(300, 300);
    frame.setLocation(300, 50);
    frame.add(new Label("Move cursor here"));
    frame.setCursor(cursor);
    frame.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:MultiResolutionCursorTest.java

示例4: TextAreaScrolling

import java.awt.Frame; //导入方法依赖的package包/类
TextAreaScrolling() {
    try {
        robot = new Robot();
    } catch (Exception ex) {
        throw new RuntimeException("Robot Creation Failed");
    }

    mainFrame = new Frame();
    mainFrame.setSize(200, 200);
    mainFrame.setLocation(200, 200);

    textArea = new TextArea();
    textArea.setText("1234 5678");
    textArea.setSelectionStart(3);
    textArea.setSelectionEnd(4);
    mainFrame.add(textArea);
    mainFrame.setVisible(true);
    textArea.requestFocusInWindow();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:TextAreaScrolling.java

示例5: OverScrollTest

import java.awt.Frame; //导入方法依赖的package包/类
OverScrollTest() {
    try {
        robot = new Robot();
    } catch (Exception ex) {
        throw new RuntimeException(ex.getMessage());
    }

    mainFrame = new Frame();
    mainFrame.setSize(400, 200);
    mainFrame.setLocation(200, 200);
    mainFrame.setLayout(new FlowLayout());

    textArea = new TextArea(2, 10);
    textArea.setSize(300, 100);
    textArea.setText("123456 789123");
    mainFrame.add(textArea);
    mainFrame.setVisible(true);
    textArea.requestFocusInWindow();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:OverScrollTest.java

示例6: testChildPropertiesWithFrameAsParent

import java.awt.Frame; //导入方法依赖的package包/类
public void testChildPropertiesWithFrameAsParent() {

        parentFrame = new Frame("parent Frame");
        parentFrame.setSize(WIDTH, HEIGHT);
        parentFrame.setLocation(100, 400);
        parentFrame.setBackground(Color.BLUE);
        parentLabel = new Label("ParentForegroundAndFont");
        parentFont = new Font("Courier New", Font.ITALIC, 15);
        parentFrame.setForeground(Color.RED);
        parentFrame.setFont(parentFont);
        parentFrame.add(parentLabel);
        parentFrame.setVisible(true);

        frameChildWindow = new Window(parentFrame);
        frameChildWindow.setSize(WIDTH, HEIGHT);
        frameChildWindow.setLocation(WIDTH + 200, 400);
        childLabel = new Label("ChildForegroundAndFont");
        frameChildWindow.add(childLabel);
        frameChildWindow.setVisible(true);

        if (parentFrame.getBackground() == frameChildWindow.getBackground()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Frame's Background Color");
        }
        if (parentDialog.getForeground() == windowChild.getForeground()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Frame's Foreground Color");
        }
        if (parentDialog.getFont() == windowChild.getFont()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Frame's Font Color");
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:ChildWindowProperties.java

示例7: start

import java.awt.Frame; //导入方法依赖的package包/类
public void start() {
    //Get things going.  Request focus, set size, et cetera
    setSize(200, 200);
    setVisible(true);
    validate();

    final Image image = new BaseMultiResolutionImage(
            createResolutionVariant(0),
            createResolutionVariant(1),
            createResolutionVariant(2),
            createResolutionVariant(3)
    );

    int center = sizes[0] / 2;
    Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
            image, new Point(center, center), "multi-resolution cursor");

    Frame frame = new Frame("Test Frame");
    frame.setSize(300, 300);
    frame.setLocation(300, 50);
    frame.add(new Label("Move cursor here"));
    frame.setCursor(cursor);
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:MultiResolutionCursorTest.java

示例8: center

import java.awt.Frame; //导入方法依赖的package包/类
/**
 * Center {@link Frame} relative to monitor.
 *
 * @param frame
 *            the frame
 */
private void center(Frame frame) {
	Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
	int x = (int) ((dimension.getWidth() - frame.getWidth()) / 2);
	int y = (int) ((dimension.getHeight() - frame.getHeight()) / 2);
	frame.setLocation(x, y);
}
 
开发者ID:rekit-group,项目名称:rekit-game,代码行数:13,代码来源:GameView.java

示例9: main

import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String[] args) throws AWTException
{
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (gds.length < 2) {
        System.out.println("It's a multiscreen test... skipping!");
        return;
    }

    for (int i = 0; i < gds.length; ++i) {
        GraphicsDevice gd = gds[i];
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        Rectangle screen = gc.getBounds();
        Robot robot = new Robot(gd);

        // check Robot.mouseMove()
        robot.mouseMove(screen.x + mouseOffset.x, screen.y + mouseOffset.y);
        Point mouse = MouseInfo.getPointerInfo().getLocation();
        Point point = screen.getLocation();
        point.translate(mouseOffset.x, mouseOffset.y);
        if (!point.equals(mouse)) {
            throw new RuntimeException(getErrorText("Robot.mouseMove", i));
        }

        // check Robot.getPixelColor()
        Frame frame = new Frame(gc);
        frame.setUndecorated(true);
        frame.setSize(100, 100);
        frame.setLocation(screen.x + frameOffset.x, screen.y + frameOffset.y);
        frame.setBackground(color);
        frame.setVisible(true);
        robot.waitForIdle();
        Rectangle bounds = frame.getBounds();
        if (!Util.testBoundsColor(bounds, color, 5, 1000, robot)) {
            throw new RuntimeException(getErrorText("Robot.getPixelColor", i));
        }

        // check Robot.createScreenCapture()
        BufferedImage image = robot.createScreenCapture(bounds);
        int rgb = color.getRGB();
        if (image.getRGB(0, 0) != rgb
            || image.getRGB(image.getWidth() - 1, 0) != rgb
            || image.getRGB(image.getWidth() - 1, image.getHeight() - 1) != rgb
            || image.getRGB(0, image.getHeight() - 1) != rgb) {
                throw new RuntimeException(
                        getErrorText("Robot.createScreenCapture", i));
        }
        frame.dispose();
    }

    System.out.println("Test PASSED!");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:53,代码来源:MultiScreenLocationTest.java

示例10: testChildPropertiesWithFrameAsParent

import java.awt.Frame; //导入方法依赖的package包/类
public void testChildPropertiesWithFrameAsParent() {

        parentFrame = new Frame("parent Frame");
        parentFrame.setSize(WIDTH, HEIGHT);
        parentFrame.setLocation(100, 400);
        parentFrame.setBackground(Color.BLUE);
        parentLabel = new Label("ParentForegroundAndFont");
        parentFont = new Font("Courier New", Font.ITALIC, 15);
        parentFrame.setForeground(Color.RED);
        parentFrame.setFont(parentFont);
        parentFrame.add(parentLabel);
        parentFrame.setVisible(true);

        frameChildDialog = new Dialog(parentFrame, "Frame's child");
        frameChildDialog.setSize(WIDTH, HEIGHT);
        frameChildDialog.setLocation(WIDTH + 200, 400);
        childLabel = new Label("ChildForegroundAndFont");
        frameChildDialog.add(childLabel);
        frameChildDialog.setVisible(true);

        if (parentFrame.getBackground() == frameChildDialog.getBackground()) {
            dispose();
            throw new RuntimeException("Child Dialog Should NOT Inherit "
                    + "Parent Frame's Background Color");
        }

        if (parentFrame.getForeground() == frameChildDialog.getForeground()) {
            dispose();
            throw new RuntimeException("Child Dialog Should NOT Inherit "
                    + "Parent Frame's Foreground Color");
        }

        if (parentFrame.getFont() == frameChildDialog.getFont()) {
            dispose();
            throw new RuntimeException("Child Dialog Should NOT Inherit "
                    + "Parent Frame's Font Style/Color");
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:ChildDialogProperties.java

示例11: test

import java.awt.Frame; //导入方法依赖的package包/类
private static void test(final Point tmp) throws Exception {
    Choice choice = new Choice();
    for (int i = 1; i < 7; i++) {
        choice.add("Long-long-long-long-long text in the item-" + i);
    }
    Frame frame = new Frame();
    try {
        frame.setAlwaysOnTop(true);
        frame.setLayout(new FlowLayout());
        frame.add(choice);
        frame.pack();
        frameWidth = frame.getWidth();
        frame.setSize(frameWidth, SIZE);
        frame.setVisible(true);
        frame.setLocation(tmp.x, tmp.y);
        openPopup(choice);
    } finally {
        frame.dispose();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ChoicePopupLocation.java

示例12: getCenteredFrame

import java.awt.Frame; //导入方法依赖的package包/类
public static Frame getCenteredFrame() {
    Frame tempframe = new Frame();
    tempframe.setSize(0, 0);
    Toolkit tool = Toolkit.getDefaultToolkit();
    tempframe.setLocation(tool.getScreenSize().width / 2 - 200, tool
            .getScreenSize().height / 2 - 150);
    tempframe.setTitle("Dialog Box!");
    //tempframe.show();
    return tempframe;
}
 
开发者ID:addertheblack,项目名称:myster,代码行数:11,代码来源:AnswerDialog.java

示例13: main

import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
    OSInfo.OSType type = OSInfo.getOSType();
    if (type != OSInfo.OSType.LINUX && type != OSInfo.OSType.SOLARIS) {
        System.out.println("This test is for Solaris and Linux only..." +
                           "skipping!");
        return;
    }

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    if (gds.length < 2) {
        System.out.println("It's a multi-screen test... skipping!");
        return;
    }

    for (int screen = 0; screen < gds.length; ++screen) {
        GraphicsDevice gd = gds[screen];
        GraphicsConfiguration gc = gd.getDefaultConfiguration();
        Rectangle bounds = gc.getBounds();
        Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc);

        Frame frame = new Frame(gc);
        frame.setLocation(bounds.x + (bounds.width - SIZE) / 2,
                          bounds.y + (bounds.height - SIZE) / 2);
        frame.setSize(SIZE, SIZE);
        frame.setUndecorated(true);
        frame.setVisible(true);

        // Maximize Frame to reach the struts
        frame.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
        Thread.sleep(2000);

        Rectangle frameBounds = frame.getBounds();
        frame.dispose();
        if (bounds.x + insets.left != frameBounds.x
            || bounds.y + insets.top != frameBounds.y
            || bounds.width - insets.right - insets.left != frameBounds.width
            || bounds.height - insets.bottom - insets.top != frameBounds.height) {
            throw new RuntimeException("Test FAILED! Wrong screen #" +
                                       screen + " insets: " + insets);
        }
    }
    System.out.println("Test PASSED!");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:45,代码来源:MultiScreenInsetsTest.java

示例14: ComponentIsNotDrawnAfterRemoveAddTest

import java.awt.Frame; //导入方法依赖的package包/类
public ComponentIsNotDrawnAfterRemoveAddTest() {
    frame = new Frame("ComponentIsNotDrawnAfterRemoveAddTest");
    frame.setSize(500, 500);
    frame.setLocation(200, 200);
    frame.setLayout(null);
    frame.setBackground(Color.RED);

    panel = new Panel();
    panel.setLayout(null);
    panel.setBounds(25, 100, 455, 295);
    panel.setBackground(Color.GREEN);

    for (int i = 0; i < 10; i++) {
        TestCanvas canv1 = new TestCanvas();
        canv1.setBounds(i * 45 + 5, 15, 30 + i, 30 + i);
        panel.add(canv1);
        compList.add(canv1);

        TestButton btn1 = new TestButton();
        btn1.setBounds(i * 45 + 5, 60, 30 + i, 30 + i);
        panel.add(btn1);
        compList.add(btn1);

        TestCanvas canv2 = new TestCanvas();
        canv2.setBounds(i * 45 + 5, 105, 30 + i, 30 + i);
        panel.add(canv2);
        compList.add(canv2);

        TestButton btn2 = new TestButton();
        btn2.setBounds(i * 45 + 5, 150, 30 + i, 30 + i);
        panel.add(btn2);
        compList.add(btn2);

        TestCanvas canv3 = new TestCanvas();
        canv3.setBounds(i * 45 + 5, 195, 30 + i, 30 + i);
        panel.add(canv3);
        compList.add(canv3);

        TestButton btn3 = new TestButton();
        btn3.setBounds(i * 45 + 5, 240, 30 + i, 30 + i);
        panel.add(btn3);
        compList.add(btn3);
    }

    frame.add(panel);
    frame.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:48,代码来源:ComponentIsNotDrawnAfterRemoveAddTest.java

示例15: showRes

import java.awt.Frame; //导入方法依赖的package包/类
private static void showRes(String desc, final BufferedImage src) {
    final int w = src.getWidth();
    final int h = src.getHeight();

    Frame f = new Frame(desc+": dbl-click to exit");
    Component c;
    f.add(c = new Component() {
        public Dimension getPreferredSize() {
            return new Dimension(w,h);
        }

        public void paint(Graphics g) {
            g.clearRect(0, 0, getWidth(), getHeight());
            g.drawImage(src, 0,0, null);
        }
    });
    c.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
                System.exit(0);
            }
        }
    });
    f.pack();
    synchronized (JPEGsNotAcceleratedTest.class) {
        f.setLocation(frameX, frameY);
        frameX += f.getWidth();
        if ((frameX + f.getWidth()) >
            f.getGraphicsConfiguration().getBounds().width)
        {
            frameY += TEST_H;
            if ((frameY + f.getHeight()) >
                f.getGraphicsConfiguration().getBounds().height)
            {
                startY += 30;
                startX += 30;
                frameY = startY;
            }
            frameX = startX;
        }
    };
    f.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:44,代码来源:JPEGsNotAcceleratedTest.java


注:本文中的java.awt.Frame.setLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。