本文整理汇总了Java中java.awt.Frame.add方法的典型用法代码示例。如果您正苦于以下问题:Java Frame.add方法的具体用法?Java Frame.add怎么用?Java Frame.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Frame
的用法示例。
在下文中一共展示了Frame.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Picking
import java.awt.Frame; //导入方法依赖的package包/类
Picking()
{
Frame frame = new Frame("Picking Example");
GLCapabilities capabilities = new GLCapabilities(null);
GLCanvas drawable = new GLCanvas(capabilities);
final Renderer renderer = new Renderer();
drawable.addGLEventListener(renderer);
drawable.addMouseListener(renderer);
drawable.addMouseMotionListener(renderer);
frame.add(drawable);
frame.setSize(400, 400);
final Animator animator = new Animator(drawable);
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
animator.stop();
System.exit(0);
}
});
frame.setVisible(true);
animator.start();
}
示例2: main
import java.awt.Frame; //导入方法依赖的package包/类
public static void main(final String[] args) throws HeadlessException {
final Frame frame = new Frame("Test Frame");
final List list = new List();
frame.setSize(300, 200);
list.add(ITEM_NAME);
list.select(0);
frame.add(list);
frame.validate();
frame.setVisible(true);
sleep();
if (!ITEM_NAME.equals(list.getSelectedItem())) {
throw new RuntimeException("List item not selected item.");
}
list.removeAll();
frame.dispose();
}
示例3: main
import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
Frame frame = new Frame("Frame Minimize Test");
Button b = new Button("Focus ownder");
frame.add("South", b);
frame.pack();
frame.setVisible(true);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after showing :(");
}
frame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(null);
frame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(null);
if (!b.hasFocus()) {
throw new RuntimeException("button is not a focus owner after restoring :(");
}
}
示例4: 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);
}
示例5: main
import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Frame frame = new Frame();
frame.setSize(300, 200);
TextField textField = new TextField();
frame.add(textField);
Robot robot = new Robot();
robot.setAutoDelay(50);
frame.setVisible(true);
robot.waitForIdle();
textField.requestFocus();
robot.waitForIdle();
// Check that the system assertion dialog does not block Java
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
robot.waitForIdle();
frame.setVisible(false);
frame.dispose();
}
示例6: 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);
}
示例7: main
import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String args[]) {
Frame f = new Frame("DitherTest");
DitherTest ditherTest = new DitherTest();
ditherTest.init();
f.add("Center", ditherTest);
f.pack();
f.setVisible(true);
ditherTest.start();
}
示例8: main
import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String args[]) {
Frame f = new Frame("DrawTest");
DrawTest drawTest = new DrawTest();
drawTest.init();
drawTest.start();
f.add("Center", drawTest);
f.setSize(300, 300);
f.setVisible(true);
}
示例9: main
import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Frame frame = new Frame();
frame.setSize(300, 200);
TextField textField = new TextField(TEXT + LAST_WORD, 30);
Panel panel = new Panel(new FlowLayout());
panel.add(textField);
frame.add(panel);
frame.setVisible(true);
Robot robot = new Robot();
robot.setAutoDelay(50);
robot.waitForIdle();
Point point = textField.getLocationOnScreen();
int x = point.x + textField.getWidth() / 2;
int y = point.y + textField.getHeight() / 2;
robot.mouseMove(x, y);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.waitForIdle();
robot.mousePress(InputEvent.BUTTON1_MASK);
int N = 10;
int dx = textField.getWidth() / N;
for (int i = 0; i < N; i++) {
x += dx;
robot.mouseMove(x, y);
}
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.waitForIdle();
if (!textField.getSelectedText().endsWith(LAST_WORD)) {
throw new RuntimeException("Last word is not selected!");
}
}
示例10: setUp
import java.awt.Frame; //导入方法依赖的package包/类
public void setUp() {
frame = new Frame();
panel = new Panel();
frame.add(panel);
frame.setSize(400,400);
panel.setSize(400,400);
gsys = new G3DSys(panel);
}
示例11: 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();
}
});
}
示例12: main
import java.awt.Frame; //导入方法依赖的package包/类
public static void main(String[] args) {
final DrawXORModeTest c = new DrawXORModeTest();
final Frame f = new Frame("XOR mode test");
f.add(c);
f.pack();
f.setVisible(true);
try {
c.checkResult();
} finally {
f.dispose();
}
}
示例13: TextFieldEditing
import java.awt.Frame; //导入方法依赖的package包/类
private TextFieldEditing() {
testFailMessage = new StringBuilder();
mainFrame = new Frame();
mainFrame.setSize(200, 200);
textField = new TextField();
mainFrame.add(textField);
mainFrame.setVisible(true);
}
示例14: 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);
}
示例15: main
import java.awt.Frame; //导入方法依赖的package包/类
public static void main(final String[] args) throws AWTException {
robot = new Robot();
Frame bigOne = new Frame();
bigOne.setSize(200, 200);
bigOne.setLocationRelativeTo(null);
bigOne.setVisible(true);
Frame f = new Frame();
f.setLayout(new BorderLayout());
f.setSize(120, 150);
f.setLocationRelativeTo(null);
Canvas c = new MyCanvas();
f.add(c, BorderLayout.CENTER);
c.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
switch(state) {
case 0: // the first event should be (0,0)
if (e.getX() != 0 || e.getY() != 0) {
System.out.println("state 0: wrong location" + e);
break;
}
state++;
break;
case 1: // the second event should be (1,1)
if (e.getX() != 1 || e.getY() != 1) {
System.out.println("state 1: wrong location " + e);
break;
}
state++;
break;
case 2: // this should never happen
System.out.println("state 2: wrong location " + e);
}
}
});
f.pack();
f.setVisible(true);
bigPause();
Point p = c.getLocationOnScreen();
doPress(p);
p.x += 1;
p.y += 1;
doPress(p);
p.x -= 2;
p.y -= 2;
doPress(p);
bigPause();
f.dispose();
bigOne.dispose();
// ...and at the end the state should be 2
if (state != 2) {
throw new RuntimeException("wrong state: " + state);
}
}