public static void main(String[] args) {
   Frame f = new Frame("thread");
   f.setLayout(null);
   f.setBounds(300,60,300,200); f.setVisible(true);
   f.add(new MyTextArea(150,0,Thread.NORM_PRIORITY));
   f.add(new MyTextArea(0,0,Thread.MAX_PRIORITY));
 }  
Beispiel #2
0
  public static void view(DrawModel d) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    Composite composite = new Composite(shell, SWT.EMBEDDED | SWT.NO_BACKGROUND);
    Frame baseFrame = SWT_AWT.new_Frame(composite);

    baseFrame.setBounds(0, 0, 800, 600);

    Java3DViewer viewer = new Java3DViewer(baseFrame, d);
    baseFrame.add(viewer);

    shell.open();

    d.setFaceColor(Color.GREEN);
    d.circle(0.9);
    //		viewer.draw(d);

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }

    baseFrame.dispose();
    shell.dispose();
    composite.dispose();
    display.dispose();
    System.exit(0);
  }
Beispiel #3
0
 public void init() {
   f.setLayout(null);
   b1.setBounds(20, 30, 90, 28);
   f.add(b1);
   b2.setBounds(50, 45, 120, 35);
   f.add(b2);
   f.setBounds(50, 50, 200, 100);
   f.setVisible(true);
 }
 public static void main(String[] args) {
   Frame frame = new Frame("Test");
   ScrollPane scrollPane = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
   scrollPane.add(new TextField(20));
   scrollPane.add(new Button("hit me"));
   frame.add(scrollPane);
   frame.setBounds(100, 100, 250, 250);
   frame.setVisible(true);
 }
Beispiel #5
0
  public void init() {
    f = new Frame("My frame");
    f.setBounds(300, 100, 600, 500);
    f.setLayout(new FlowLayout());

    b = new Button("MyButton");

    f.add(b);
    // 加载事件
    myEvent();
    f.setVisible(true);
  }
  private void setPlayerScreen() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gs = ge.getScreenDevices();

    GraphicsDevice graphicsDevice =
        (screenNumber >= 0 && screenNumber < gs.length) ? gs[screenNumber] : gs[0];

    if (playerFrame != null) {
      Rectangle rectangle = graphicsDevice.getDefaultConfiguration().getBounds();

      playerFrame.setBounds(rectangle);
    }
  }
  public Bai2() {

    lbNumber1.setText("a =");
    lbNumber2.setText("b =");
    lbResult.setText("Kết quả:");
    txtNumber1.setText("0");
    txtNumber2.setText("0");
    txtResult.setText("0");
    btResult.setLabel("Thực hiện");
    choCalculator.add("Cộng");
    choCalculator.add("Trừ");
    choCalculator.add("Nhân");
    choCalculator.add("Chia");
    choCalculator.add("UCLN");
    choCalculator.add("BCNN");

    frMain.setBounds(100, 100, 400, 300);
    frMain.setBackground(Color.LIGHT_GRAY);
    frMain.setLayout(null);

    lbNumber1.setBounds(30, 50, 50, 20);
    lbNumber2.setBounds(30, 70, 50, 20);
    lbResult.setBounds(30, 140, 50, 20);

    choCalculator.setBounds(300, 70, 60, 20);

    btResult.setBounds(100, 100, 100, 20);

    txtNumber1.setBounds(100, 50, 150, 20);
    txtNumber2.setBounds(100, 70, 150, 20);
    txtResult.setBounds(100, 140, 150, 20);

    frMain.add(lbNumber1);
    frMain.add(lbNumber2);
    frMain.add(lbResult);
    frMain.add(txtNumber1);
    frMain.add(txtNumber2);
    frMain.add(txtResult);
    frMain.add(btResult);
    frMain.add(choCalculator);

    btResult.addActionListener(new ProcessButton());

    frMain.addWindowListener(
        new WindowAdapter() {
          public void windowsClosing(WindowEvent evt) {
            System.exit(0);
          }
        });
  }
  public void start() {
    Toolkit.getDefaultToolkit()
        .addAWTEventListener(
            new AWTEventListener() {
              public void eventDispatched(AWTEvent e) {
                System.out.println(e.toString());
              }
            },
            FocusEvent.FOCUS_EVENT_MASK
                | WindowEvent.WINDOW_FOCUS_EVENT_MASK
                | WindowEvent.WINDOW_EVENT_MASK);

    frame = new Frame("Frame");
    frame.setName("Frame-owner");
    frame.setBounds(100, 0, 100, 100);
    dialog = new Dialog(frame, "Dialog");
    dialog.setName("Dialog-owner");
    dialog.setBounds(100, 0, 100, 100);

    window1 = new Window(frame);
    window1.setName("1st child");
    window1.setBounds(100, 300, 100, 100);
    window2 = new Window(window1);
    window2.setName("2nd child");
    window2.setBounds(100, 500, 100, 100);

    test1(frame, window1);
    test2(frame, window1, window2);
    test3(frame, window1, window2);

    window1 = new Window(dialog);
    window1.setBounds(100, 300, 100, 100);
    window1.setName("1st child");
    window2 = new Window(window1);
    window2.setName("2nd child");
    window2.setBounds(100, 500, 100, 100);

    test1(dialog, window1);
    test2(dialog, window1, window2);
    test3(dialog, window1, window2);

    System.out.println("Test passed.");
  }
Beispiel #9
0
  void init() {
    mainFrame = new Frame();
    mainFrame.setBounds(400, 500, 800, 600);
    mainFrame.setLayout(new FlowLayout());
    mainFrame.setResizable(false);

    upPanel = new Panel();
    downPanel = new Panel();
    addressTextField = new TextField(75);
    gotoButton = new Button("转到");
    contentTextArea = new TextArea(30, 82);

    upPanel.add(addressTextField);
    upPanel.add(gotoButton);
    downPanel.add(contentTextArea);

    mainFrame.add(upPanel);
    mainFrame.add(downPanel);

    addEvent();

    mainFrame.setVisible(true);
  }
Beispiel #10
0
  public Configure() {
    int Width = 640;
    int Height = 480;
    cb = new Checkbox[128];
    final Frame f = new Frame("Configure gnu.io.rxtx.properties");
    String fileSep = System.getProperty("file.separator", "/");
    String devPath;
    if (fileSep.compareTo("/") != 0) {
      devPath = "COM";
    } else {
      devPath = "/dev/";
    }

    f.setBounds(100, 50, Width, Height);
    f.setLayout(new BorderLayout());
    p1 = new Panel();
    p1.setLayout(new GridLayout(16, 4));
    ActionListener l =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            {
              String res = e.getActionCommand();
              if (res.equals("Save")) {
                saveSpecifiedPorts();
              }
            }
          }
        };

    addCheckBoxes(devPath);
    TextArea t = new TextArea(EnumMessage, 5, 50, TextArea.SCROLLBARS_NONE);
    t.setSize(50, Width);
    t.setEditable(false);

    final Panel p2 = new Panel();
    p2.add(new Label("Port Name:"));
    TextField tf = new TextField(devPath, 8);
    tf.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addCheckBoxes(e.getActionCommand());
            f.setVisible(true);
          }
        });
    p2.add(tf);
    Checkbox Keep = new Checkbox("Keep Ports");
    p2.add(Keep);
    Button b[] = new Button[6];
    for (int j = 0, i = 4; i < 129; i *= 2, j++) {
      b[j] = new Button("1-" + i);
      b[j].addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              int k = Integer.parseInt(e.getActionCommand().substring(2));
              for (int x = 0; x < k; x++) {
                cb[x].setState(!cb[x].getState());
                f.setVisible(true);
              }
            }
          });
      p2.add(b[j]);
    }
    Button b1 = new Button("More");
    Button b2 = new Button("Save");
    b1.addActionListener(l);
    b2.addActionListener(l);
    p2.add(b1);
    p2.add(b2);
    f.add("South", p2);
    f.add("Center", p1);
    f.add("North", t);
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    f.setVisible(true);
  }
Beispiel #11
0
 private void setF(int x, int y) {
   f.setBounds(x, y, 250, 200);
   f.setVisible(true);
 }
Beispiel #12
0
  public TestXEmbedServer(boolean manual) {

    // Enable testing extensions in XEmbed server
    System.setProperty("sun.awt.xembed.testing", "true");

    f = new Frame("Main frame");
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            synchronized (TestXEmbedServer.this) {
              TestXEmbedServer.this.notifyAll();
            }
            dummy.dispose();
            f.dispose();
          }
        });

    f.setLayout(new BorderLayout());

    Container bcont = new Container();

    toFocus = new Button("Click to focus server");
    final TextField tf = new TextField(20);
    tf.setName("0");
    DragSource ds = new DragSource();
    final DragSourceListener dsl =
        new DragSourceAdapter() {
          public void dragDropEnd(DragSourceDropEvent dsde) {}
        };
    final DragGestureListener dgl =
        new DragGestureListener() {
          public void dragGestureRecognized(DragGestureEvent dge) {
            dge.startDrag(null, new StringSelection(tf.getText()), dsl);
          }
        };
    ds.createDefaultDragGestureRecognizer(tf, DnDConstants.ACTION_COPY, dgl);

    final DropTargetListener dtl =
        new DropTargetAdapter() {
          public void drop(DropTargetDropEvent dtde) {
            dtde.acceptDrop(DnDConstants.ACTION_COPY);
            try {
              tf.setText(
                  tf.getText()
                      + (String) dtde.getTransferable().getTransferData(DataFlavor.stringFlavor));
            } catch (Exception e) {
            }
          }
        };
    final DropTarget dt = new DropTarget(tf, dtl);

    Button b_add = new Button("Add client");
    b_add.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            addClient();
          }
        });
    Button b_remove = new Button("Remove client");
    b_remove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (clientCont.getComponentCount() != 0) {
              clientCont.remove(clientCont.getComponentCount() - 1);
            }
          }
        });
    b_close = new JButton("Close modal dialog");
    b_close.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            modal_d.dispose();
          }
        });
    b_modal = new Button("Show modal dialog");
    b_modal.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            modal_d = new JDialog(f, "Modal dialog", true);
            modal_d.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            modal_d.setBounds(0, 100, 200, 50);
            modal_d.getContentPane().add(b_close);
            modal_d.validate();
            modal_d.show();
          }
        });

    bcont.add(tf);
    bcont.add(toFocus);
    bcont.add(b_add);
    bcont.add(b_remove);
    bcont.add(b_modal);
    if (manual) {
      Button pass = new Button("Pass");
      pass.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              passed = true;
              synchronized (TestXEmbedServer.this) {
                TestXEmbedServer.this.notifyAll();
              }
            }
          });
      bcont.add(pass);
      Button fail = new Button("Fail");
      fail.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              passed = false;
              synchronized (TestXEmbedServer.this) {
                TestXEmbedServer.this.notifyAll();
              }
            }
          });
      bcont.add(fail);
    }
    b_modal.setName("2");
    bcont.setLayout(new FlowLayout());
    f.add(bcont, BorderLayout.NORTH);

    clientCont = Box.createVerticalBox();
    f.add(clientCont, BorderLayout.CENTER);

    dummy = new JFrame("Dummy");
    dummy.getContentPane().add(new JButton("Button"));
    dummy.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    dummy.setBounds(0, VERTICAL_POSITION, 100, 100);
    dummy.setVisible(true);

    f.setBounds(300, VERTICAL_POSITION, 800, 300);
    f.setVisible(true);
  }