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


Java Frame.setLayout方法代码示例

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


在下文中一共展示了Frame.setLayout方法的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: init

import java.awt.Frame; //导入方法依赖的package包/类
private void init()
{
	f = new Frame("Demo");
	bt1 = new Button("SIN");
	bt2 = new Button("COS");
	bt3 = new Button("EXIT");
	mc = new MyCanvas();
	p = new Panel();
	
	
	f.setBounds(100, 100, 500, 500);
	f.setLayout(new BorderLayout());

	p.add(bt1);
	p.add(bt2);
	p.add(bt3);
	f.add(p, BorderLayout.NORTH);
	f.add(mc, BorderLayout.CENTER);
	
	addEvent();
	f.setVisible(true);
}
 
开发者ID:pwn-orz,项目名称:anti-fanmei,代码行数:23,代码来源:FunPlot.java

示例3: 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

示例4: createAndShowGUI

import java.awt.Frame; //导入方法依赖的package包/类
private static void createAndShowGUI() {
    frame = new Frame();
    frame.setLayout(new FlowLayout(FlowLayout.CENTER, 25, 0));
    frame.setSize(600, 600);
    frame.setLocationRelativeTo(null);
    for (int i = 1; i < 10001; ++i) {
        frame.add(new JButton("Button " + i));
    }
    frame.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:SetEnabledPerformance.java

示例5: main

import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException, java.lang.reflect.InvocationTargetException
{
    final Frame frame = new Frame("the test");
    frame.setLayout(new FlowLayout());
    final Button btn1 = new Button("button 1");
    frame.add(btn1);
    frame.add(new Button("button 2"));
    frame.add(new Button("button 3"));
    frame.pack();
    frame.setVisible(true);

    Robot r = Util.createRobot();
    Util.waitForIdle(r);
    Util.clickOnComp(btn1, r);
    Util.waitForIdle(r);
    KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
    if (kfm.getFocusOwner() != btn1) {
        throw new RuntimeException("test error: can not set focus on " + btn1 + ".");
    }

    EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                final int n_comps = frame.getComponentCount();
                for (int i = 0; i < n_comps; ++i) {
                    frame.getComponent(i).setVisible(false);
                }
            }
        });
    Util.waitForIdle(r);
    final Component focus_owner = kfm.getFocusOwner();

    if (focus_owner != null && !focus_owner.isVisible()) {
        throw new RuntimeException("we have invisible focus owner");
    }
    System.out.println("test passed");
    frame.dispose();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:RequestFocusAndHideTest.java

示例6: frameTest

import java.awt.Frame; //导入方法依赖的package包/类
private static void frameTest() {
    Panel panel =new Panel();

    print = new Button("PageDialog");
    print.setActionCommand("PageDialog");
    print.addActionListener((e) -> {
        PrinterJob job = PrinterJob.getPrinterJob();
            PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
            t.start();
            start = true;
            PageFormat pf = job.pageDialog(aset);
    });

    panel.add(print);

    frame = new Frame("Test Frame");
    frame.setLayout (new BorderLayout ());
    frame.add(panel,"South");
    frame.pack();
    frame.setVisible(true);

    t = new Thread (() -> {
        if (start) {
            try {
                Thread.sleep(5000);
            } catch (InterruptedException ex) {}
            frame.dispose();
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:TestPageDlgFrameAssociation.java

示例7: frameTest

import java.awt.Frame; //导入方法依赖的package包/类
private static void frameTest() {
    Panel panel =new Panel();

    print = new Button("PrintDialog");
    print.setActionCommand("PrintDialog");
    print.addActionListener((e) -> {
        PrinterJob job = PrinterJob.getPrinterJob();
        PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
        t.start();
        start = true;
        job.printDialog(aset);
    });

    panel.add(print);

    frame = new Frame("Test Frame");
    frame.setLayout (new BorderLayout ());
    frame.add(panel,"South");
    frame.pack();
    frame.setVisible(true);

    t = new Thread (() -> {
        if (start) {
            try {
                Thread.sleep(5000);
            } catch (InterruptedException ex) {}
            frame.dispose();
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:TestPrintDlgFrameAssociation.java

示例8: AutoScrollOnSelectAndAppend

import java.awt.Frame; //导入方法依赖的package包/类
public AutoScrollOnSelectAndAppend() {
    try {
        robot = new Robot();
    } catch (Exception ex) {
        throw new RuntimeException("Robot Creation Failed.");
    }
    frame = new Frame();
    frame.setSize(200, 200);
    frame.setLayout(new FlowLayout());

    textArea = new TextArea(5, 20);
    composeTextArea();
    frame.add(textArea);

    buttonHoldFocus = new Button("HoldFocus");
    frame.add(buttonHoldFocus);

    frame.setVisible(true);
    robot.waitForIdle();

    // Move mouse cursor on first row of text area.
    Point loc = textArea.getLocationOnScreen();
    robot.mouseMove(loc.x + 8, loc.y + 8);
    robot.waitForIdle();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:AutoScrollOnSelectAndAppend.java

示例9: EventBug

import java.awt.Frame; //导入方法依赖的package包/类
public EventBug() {
    super();
    testFrame = new Frame();
    testFrame.setLayout(new BorderLayout());
    this.setLayout(new BorderLayout());
    testFrame.add("Center", this);
    testFrame.pack();
    testFrame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:LightweightEventTest.java

示例10: ContainerOrderFTPTest

import java.awt.Frame; //导入方法依赖的package包/类
public ContainerOrderFTPTest() {
    expectedTraversal = "B1B2F1";
    b1 = new Button("B1");
    b2 = new Button("B2");
    frame = new Frame("F1");

    frame.setLayout(new FlowLayout());
    frame.setSize(200, 200);
    coftp = new ContainerOrderFocusTraversalPolicy();
    frame.setFocusTraversalPolicy(coftp);
    frame.add(b1);
    frame.add(b2);
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:ContainerOrderFTPTest.java

示例11: initializeGUI

import java.awt.Frame; //导入方法依赖的package包/类
private void initializeGUI() {
    frame = new Frame("Test frame");
    canvas = new Canvas();
    canvas.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) { focusGained = true; }
    });
    canvas.addKeyListener(this);
    frame.setLayout(new BorderLayout());
    frame.add(canvas);
    frame.setSize(200, 200);
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:ModifierRobotEnhancedKeyTest.java

示例12: initializeGUI

import java.awt.Frame; //导入方法依赖的package包/类
private void initializeGUI() {
    frame = new Frame("Test frame");
    canvas = new Canvas();
    canvas.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent event) { focusGained = true; }
    });
    canvas.addKeyListener(this);
    frame.setLayout(new BorderLayout());
    frame.add(canvas);
    frame.setBounds(200, 200, 200, 200);
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:ModifierRobotKeyTest.java

示例13: initTestWindow

import java.awt.Frame; //导入方法依赖的package包/类
public static void initTestWindow() {
    mainFrame = new Frame("ScrollSelectionTest frame");
    mainFrame.setBounds(500, 0, 400, 200);

    textField = new TextField(40);
    textField.setText("abcdefghijklmnopqrstuvwxyz");
    mainFrame.add(textField);
    mainFrame.setLayout(new FlowLayout());
    textField.select(0, 20);
    mainFrame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:ScrollSelectionTest.java

示例14: 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

示例15: 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


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