本文整理匯總了Java中java.awt.Frame.setVisible方法的典型用法代碼示例。如果您正苦於以下問題:Java Frame.setVisible方法的具體用法?Java Frame.setVisible怎麽用?Java Frame.setVisible使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Frame
的用法示例。
在下文中一共展示了Frame.setVisible方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import java.awt.Frame; //導入方法依賴的package包/類
public static void main(final String[] args) {
for (int i = 0; i < 10; ++i) {
final Frame frame = new Frame();
frame.setSize(300, 300);
frame.setLocationRelativeTo(null);
ListRepaint list = new ListRepaint();
list.add("1");
list.add("2");
list.add("3");
list.add("4");
list.select(0);
frame.add(list);
frame.setVisible(true);
sleep();
list.test();
frame.dispose();
}
}
示例2: createObjects
import java.awt.Frame; //導入方法依賴的package包/類
void createObjects() {
textArea = new TextArea( bigString() );
robot = Util.createRobot();
Panel panel = new Panel();
panel.setLayout( new GridLayout(3,3) );
for( int y=0; y<3; ++y ) {
for( int x=0; x<3; ++x ) {
if( x==1 && y==1 ) {
panel.add( textArea );
} else {
panel.add( new Panel() );
}
}
}
Frame frame = new Frame( "TextArea cursor icon test" );
frame.setSize( 300, 300 );
frame.add( panel );
frame.setVisible( true );
}
示例3: doTest
import java.awt.Frame; //導入方法依賴的package包/類
boolean doTest() {
Dimension beforeMaximizeCalled = new Dimension(300,300);
frame = new Frame("Test Frame");
frame.setUndecorated(true);
frame.setFocusable(true);
frame.setSize(beforeMaximizeCalled);
frame.setVisible(true);
frame.setExtendedState(Frame.MAXIMIZED_BOTH);
frame.setExtendedState(Frame.NORMAL);
Dimension afterMaximizedCalled= frame.getBounds().getSize();
frame.dispose();
if (beforeMaximizeCalled.equals(afterMaximizedCalled)) {
return true;
}
return false;
}
示例4: 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();
}
示例5: 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();
}
示例6: 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);
}
示例7: main
import java.awt.Frame; //導入方法依賴的package包/類
public static void main(String[] args) {
final Frame frame = new Frame("Test");
frame.setSize(400, 400);
frame.setBackground(FRAME_COLOR);
frame.setVisible(true);
final Dialog modalDialog = new Dialog(null, true);
modalDialog.setTitle("Modal Dialog");
modalDialog.setSize(400, 200);
modalDialog.setBackground(DIALOG_COLOR);
modalDialog.setModal(true);
new Thread(new Runnable() {
@Override
public void run() {
runTest(modalDialog, frame);
}
}).start();
modalDialog.setVisible(true);
}
示例8: main
import java.awt.Frame; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
Frame frame = new Frame();
frame.setSize(300, 200);
TextField textField = new TextField();
frame.add(textField);
frame.setVisible(true);
toolkit.realSync();
textField.requestFocus();
toolkit.realSync();
// Check that the system assertion dialog does not block Java
Robot robot = new Robot();
robot.setAutoDelay(50);
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
toolkit.realSync();
frame.setVisible(false);
frame.dispose();
}
示例9: main
import java.awt.Frame; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
Frame frame = new Frame();
frame.setSize(300, 300);
frame.setVisible(true);
Robot robot = new Robot();
robot.setAutoDelay(50);
robot.waitForIdle();
robot.keyPress(KeyEvent.VK_DELETE);
robot.keyRelease(KeyEvent.VK_DELETE);
robot.waitForIdle();
frame.dispose();
if (eventsCount != 3) {
throw new RuntimeException("Wrong number of key events: " + eventsCount);
}
}
示例10: 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 :(");
}
}
示例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: 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();
}
});
}
示例13: main
import java.awt.Frame; //導入方法依賴的package包/類
public static void main(final String[] args) {
final Frame frame = new Frame();
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
for (int i = 0; i < 1000; ++i) {
frame.setSize(100, 100);
frame.setSize(200, 200);
frame.setSize(300, 300);
}
frame.dispose();
}
示例14: 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);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
toolkit.realSync();
Robot robot = new Robot();
robot.setAutoDelay(50);
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);
toolkit.realSync();
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);
toolkit.realSync();
if (!textField.getSelectedText().endsWith(LAST_WORD)) {
throw new RuntimeException("Last word is not selected!");
}
}
示例15: 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);
}