本文整理匯總了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();
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
});
}
示例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();
}
});
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}