Esempio n. 1
0
 public void go() {
   f = new Frame("좋아하는 선수 고르기");
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           f.setVisible(false);
           f.dispose();
           System.exit(0);
         }
       });
   lstSunsu = new List(4, true); // 4개 보여주고,여러명 선택가능
   lstSunsu.addItemListener(this); // 2. step
   lstSunsu.add("==선수선택==");
   lstSunsu.add("조오련");
   lstSunsu.add("박찬호");
   lstSunsu.add("박세리");
   lstSunsu.add("안정환");
   lstSunsu.add("이천수");
   lstSunsu.add("이영표");
   lstSunsu.add("차범근");
   lstSunsu.add("김남일");
   lstSunsu.add("차두리");
   tf = new TextField();
   f.add(new Label("좋아하는 선수를 여러명 선택하세요"), "North");
   f.add(lstSunsu, "Center");
   f.add(tf, "South");
   f.setSize(200, 300);
   f.setVisible(true);
 }
Esempio n. 2
0
  private static void init() {
    // *** Create instructions for the user here ***
    String[] instructions = {
      "This is an AUTOMATIC test, simply wait until it is done.",
      "The result (passed or failed) will be shown in the",
      "message window below."
    };
    Sysout.createDialog();
    Sysout.printInstructions(instructions);

    Frame frame = new Frame("test for 6418028");
    frame.setLayout(new FlowLayout());
    Button btn1 = new Button("Button1");
    frame.add(btn1);
    TestButton btn2 = new TestButton("Button2");
    frame.add(btn2);
    frame.pack();
    frame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent we) {
            we.getWindow().dispose();
          }
        });
    frame.setVisible(true);

    Util.waitForIdle(null);

    btn2.instrumentPeer();
    btn2.requestFocusInWindow();
    btn2.restorePeer();
    frame.dispose();
    RequestOnCompWithNullParent1.pass();
  } // End  init()
  public SimpleLiteMStandard(INyARMarkerSystemConfig i_config) throws NyARException {
    JmfCaptureDeviceList devlist = new JmfCaptureDeviceList();
    JmfCaptureDevice d = devlist.getDevice(0);
    d.setCaptureFormat(i_config.getScreenSize(), 30.0f);
    this._camera = new NyARJmfCamera(d); // create sensor system
    this._nyar = new NyARGlMarkerSystem(i_config); // create MarkerSystem
    this.ids[0] = this._nyar.addARMarker(ARCODE_FILE2, 16, 25, 80);
    this.ids[1] = this._nyar.addARMarker(ARCODE_FILE, 16, 25, 80);

    Frame frame = new Frame("NyARTK program");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    GLCanvas canvas = new GLCanvas();
    frame.add(canvas);
    canvas.addGLEventListener(this);
    NyARIntSize s = i_config.getNyARParam().getScreenSize();

    frame.setVisible(true);
    Insets ins = frame.getInsets();
    frame.setSize(s.w + ins.left + ins.right, s.h + ins.top + ins.bottom);
    canvas.setBounds(ins.left, ins.top, s.w, s.h);

    this._camera.start();
  }
Esempio n. 4
0
  public SingleARMarker(NyARParam i_cparam) throws Exception {
    JmfCaptureDeviceList devlist = new JmfCaptureDeviceList();
    this._ar_param = i_cparam;

    // キャプチャリソースの準備
    this._capture = devlist.getDevice(0);
    if (!this._capture.setCaptureFormat(SCREEN_X, SCREEN_Y, 30.0f)) {
      throw new NyARException();
    }
    this._capture.setOnCapture(this);
    this._cap_image = new JmfNyARRGBRaster(this._capture.getCaptureFormat());

    this._code_table[0] = NyARCode.createFromARPattFile(new FileInputStream(CARCODE_FILE1), 16, 16);
    this._code_table[1] = NyARCode.createFromARPattFile(new FileInputStream(CARCODE_FILE2), 16, 16);

    // OpenGLフレームの準備(OpenGLリソースの初期化、カメラの撮影開始は、initコールバック関数内で実行)
    Frame frame = new Frame("NyARToolkit[" + this.getClass().getName() + "]");
    GLCanvas canvas = new GLCanvas();
    frame.add(canvas);
    canvas.addGLEventListener(this);
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    // ウインドウサイズの調整
    frame.setVisible(true);
    Insets ins = frame.getInsets();
    frame.setSize(SCREEN_X + ins.left + ins.right, SCREEN_Y + ins.top + ins.bottom);
    canvas.setBounds(ins.left, ins.top, SCREEN_X, SCREEN_Y);
    return;
  }
Esempio n. 5
0
 public static void main(String[] args) {
   Frame f = new Frame("Viewer");
   Viewer view = new Viewer();
   f.addWindowListener(view);
   f.add(view);
   f.setSize(300, 300);
   view.init();
   view.start();
   f.setVisible(true);
 }
  // Color gre;
  Rules(String se) {
    email = se;
    conti = new Button("Continue");
    rules = new Button("ClicK Here For Rules");
    p1 = new JOptionPane();
    Icon image = new ImageIcon("books.jpg");
    Icon image1 = new ImageIcon("girl.jpg");
    Icon image2 = new ImageIcon("uit.jpg");
    gl = new GridBagLayout();
    gbc = new GridBagConstraints();
    conti.addActionListener(this);
    rules.addActionListener(this);
    // gre=new Color(117,102,185);
    p = new Panel();
    p2 = new Panel();
    p3 = new Panel();
    p4 = new Panel();
    f = new Frame();
    pic = new JLabel(image);
    pic1 = new JLabel(image1);
    pic2 = new JLabel(image2);
    gbc.anchor = GridBagConstraints.SOUTHWEST;
    gl.setConstraints(pic1, gbc);
    gbc.anchor = GridBagConstraints.SOUTHEAST;
    gl.setConstraints(pic, gbc);
    Insets is = new Insets(30, 30, 30, 30);
    gbc.insets = is;
    gbc.ipadx = 14;
    gbc.ipady = 8;
    gl.setConstraints(rules, gbc);
    gl.setConstraints(conti, gbc);
    p2.setLayout(gl);
    p4.add(pic2);
    p2.add(pic);
    p3.setLayout(gl);
    p3.add(pic1);
    p.add(conti);
    p.add(rules);
    p.setLayout(gl);
    f.add(p4, "North");
    f.add(p3, "East");
    f.add(p2, "West");

    f.add(p, "Center");
    f.setTitle("RULES BOOK");
    // f.setBackground(gre);
    f.setVisible(true);
    f.setSize(900, 600);
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            System.exit(0);
          }
        });
  }
Esempio n. 7
0
 public static void main(String[] args) {
   Frame f = new ToeTestNew();
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   f.setSize(200, 100);
   f.setVisible(true);
 }
Esempio n. 8
0
 public static void main(String[] args) {
   // TODO 自动生成的方法存根
   Frame f = new DynamicEvents();
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   f.setSize(300, 200);
   f.show();
 }
Esempio n. 9
0
 public static void main(String args[]) {
   Frame F = new Frame();
   Mouse1 P = new Mouse1(args[0]);
   F.add(P, BorderLayout.CENTER);
   F.setSize(500, 200);
   F.setVisible(true);
   F.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
 }
Esempio n. 10
0
 public void init() {
   // 以匿名内部类的形式来创建事件监听器对象
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           ta.append("用户试图关闭窗口!\n");
           System.exit(0);
         }
       });
   f.add(ta);
   f.pack();
   f.setVisible(true);
 }
Esempio n. 11
0
  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);
          }
        });
  }
Esempio n. 12
0
 public static void main(String[] args) {
   Counterl applet = new Counterl();
   Frame aFrame = new Frame("Counter1");
   aFrame.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   aFrame.add(applet, BorderLayout.CENTER);
   aFrame.setSize(300, 200);
   applet.init();
   applet.start();
   aFrame.setVisible(true);
 }
Esempio n. 13
0
  public static void main(String[] args) {
    Frame f = new JFrame("YAY it Works");
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            System.exit(0);
          }
        });
    JApplet applet = new midapp();
    ((RootPaneContainer) f).getContentPane().add("Center", applet);
    f.add(p2, BorderLayout.EAST);

    applet.init();
    f.pack();
    f.setSize(new Dimension(653, 437));
    f.setVisible(true);
  }
Esempio n. 14
0
  /**
   * This method is called if the applet is run as an standalone program. It creates a frame for the
   * applet and adds the applet to that frame.
   */
  public static void main(String args[]) {
    Evaluator a = new Evaluator();
    a.init();
    a.start();

    Frame f = new Frame("Evaluator");
    f.add("Center", a);
    f.setSize(400, 200);
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    //		f.show();
    f.setVisible(true);
  }
Esempio n. 15
0
  public static void main(String[] args) {
    Frame frame = new Frame("Tetris");
    Tetris tetris = new Tetris();
    frame.add(tetris);
    tetris.init();
    tetris.start();

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    frame.setSize(489, 441);
    frame.setResizable(false);
    frame.setVisible(true);
  }
Esempio n. 16
0
 public static void main(String[] args) {
   Frame f = new Frame();
   f.setLocation(300, 200);
   f.setSize(200, 200);
   f.setLayout(null); // 取消布局管理器
   bt.addMouseListener(new MouseMove()); // 注册鼠标事件监听器
   bt.setBackground(Color.cyan);
   bt.setBounds(new Rectangle(45, 100, 90, 30));
   f.add(bt);
   f.pack();
   f.addWindowListener(
       new WindowAdapter() { // 关闭窗口
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   f.setVisible(true); // 设置窗体可见
 }
 /**
  * main entrypoint - starts the part when it is run as an application
  *
  * @param args java.lang.String[]
  */
 public static void main(java.lang.String[] args) {
   try {
     Frame frame = new java.awt.Frame();
     AddressBookSelectionUI aAddressBookSelectionUI;
     aAddressBookSelectionUI = new AddressBookSelectionUI();
     frame.add("Center", aAddressBookSelectionUI);
     frame.setSize(aAddressBookSelectionUI.getSize());
     frame.addWindowListener(
         new java.awt.event.WindowAdapter() {
           public void windowClosing(java.awt.event.WindowEvent e) {
             System.exit(0);
           };
         });
     frame.setVisible(true);
   } catch (Throwable exception) {
     System.err.println("Exception occurred in main() of java.awt.Panel");
     exception.printStackTrace(System.out);
   }
 }
Esempio n. 18
0
 public static void main(String[] args) {
   final GLCanvas canvas = new GLCanvas();
   final Frame frame = new Frame("Jogl Quad drawing");
   final Animator animator = new Animator(canvas);
   canvas.addGLEventListener(new Test());
   frame.add(canvas);
   frame.setSize(640, 480);
   frame.setResizable(false);
   frame.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           animator.stop();
           frame.dispose();
           System.exit(0);
         }
       });
   frame.setVisible(true);
   animator.start();
   canvas.requestFocus();
 }
Esempio n. 19
0
 public void go() {
   f = new Frame("This is a FileDialog Test");
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0); // 종료하기
         }
       });
   f.setLayout(new FlowLayout());
   bOpen = new Button("Open");
   bOpen.addActionListener(this);
   bSave = new Button("Save");
   bSave.addActionListener(this);
   // 열기 다이얼로그 박스만들기
   fdOpen = new FileDialog(f, "I'm a Open Dialog", FileDialog.LOAD);
   // 저장 다이얼로그 박스 만들기
   fdSave = new FileDialog(f, "I'm a Save Dialog", FileDialog.SAVE);
   f.add(bOpen);
   f.add(bSave);
   f.setSize(200, 200);
   f.setVisible(true);
 }
Esempio n. 20
0
  void addEvent() {
    mainFrame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    addressTextField.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            int keyCode = e.getKeyCode();

            if (keyCode == KeyEvent.VK_ENTER) {
              showContent();
            }
          }
        });

    gotoButton.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            int keyCode = e.getKeyCode();

            if (keyCode == KeyEvent.VK_ENTER) {
              showContent();
            }
          }
        });

    gotoButton.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            showContent();
          }
        });
  }
Esempio n. 21
0
  OuterEventDemo(String s) {
    f = new Frame(s);
    f.addWindowListener(new WindowsEventListner());
    b = new Button("OK");
    b1 = new Button("CANCEL");
    b.setBounds(20, 100, 40, 40);
    b1.setBounds(20, 180, 40, 40);
    f.add(b);
    f.add(b1);

    b.addMouseListener(new MouseEventListener(this));
    b1.addMouseListener(new MouseEventListener(this));
    Outer o = new Outer(this);
    b.addActionListener(o);
    b1.addActionListener(o);

    tf = new TextField();
    tf.setBounds(20, 40, 100, 40);
    f.add(tf);
    tf.addKeyListener(new KeyEventListener());
    f.setLayout(null);
    f.setSize(400, 400);
    f.setVisible(true);
  }
  public static void main(String[] args) {

    Frame AFrame = new Frame("Frame with components");

    Label lblOne = new Label("This is a label");
    Button btn1 = new Button("This is a button");
    TextField tf1 = new TextField();
    TextArea ta1 = new TextArea(12, 40);

    tf1.setText("This is a textbox");
    ta1.setText("Number of columns in this textarea: " + ta1.getColumns());

    // the add() method of the Frame class is
    // used to add components to the frame
    AFrame.add(lblOne);
    AFrame.add(btn1);
    AFrame.add(tf1);
    AFrame.add(ta1);

    AFrame.setSize(450, 300);
    AFrame.setLayout(new FlowLayout());
    AFrame.setVisible(true);
    AFrame.addWindowListener(new demo());
  }
  /** Method declaration */
  void main() {

    fMain = new Frame("HSQL Database Manager");
    imgEmpty = createImage(new MemoryImageSource(2, 2, new int[4 * 4], 2, 2));

    fMain.setIconImage(imgEmpty);
    fMain.addWindowListener(this);

    MenuBar bar = new MenuBar();

    // used shortcuts: CERGTSIUDOLM
    String fitems[] = {
      "-Connect...", "--", "-Open Script...", "-Save Script...", "-Save Result...", "--", "-Exit"
    };

    addMenu(bar, "File", fitems);

    String vitems[] = {
      "RRefresh Tree", "--", "GResults in Grid", "TResults in Text",
      "--", "1Shrink Tree", "2Enlarge Tree", "3Shrink Command",
      "4Enlarge Command"
    };

    addMenu(bar, "View", vitems);

    String sitems[] = {
      "SSELECT",
      "IINSERT",
      "UUPDATE",
      "DDELETE",
      "--",
      "-CREATE TABLE",
      "-DROP TABLE",
      "-CREATE INDEX",
      "-DROP INDEX",
      "--",
      "-CHECKPOINT",
      "-SCRIPT",
      "-SET",
      "-SHUTDOWN",
      "--",
      "-Test Script"
    };

    addMenu(bar, "Command", sitems);

    Menu recent = new Menu("Recent");

    mRecent = new Menu("Recent");

    bar.add(mRecent);

    String soptions[] = {
      "-AutoCommit on",
      "-AutoCommit off",
      "OCommit",
      "LRollback",
      "--",
      "-Disable MaxRows",
      "-Set MaxRows to 100",
      "--",
      "-Logging on",
      "-Logging off",
      "--",
      "-Insert test data"
    };

    addMenu(bar, "Options", soptions);

    /* NB - 26052002 Restore is not implemented yet in the transfer tool */
    String stools[] = {"-Dump", /*"-Restore",*/ "-Transfer"};

    addMenu(bar, "Tools", stools);
    fMain.setMenuBar(bar);
    fMain.setSize(640, 480);
    fMain.add("Center", this);
    initGUI();

    sRecent = new String[iMaxRecent];

    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension size = fMain.getSize();

    // (ulrivo): full size on screen with less than 640 width
    if (d.width >= 640) {
      fMain.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
    } else {
      fMain.setLocation(0, 0);
      fMain.setSize(d);
    }

    fMain.show();

    // (ulrivo): load query from command line
    if (defScript != null) {
      if (defDirectory != null) {
        defScript = defDirectory + File.separator + defScript;
      }

      txtCommand.setText(DatabaseManagerCommon.readFile(defScript));
    }

    txtCommand.requestFocus();
  }
Esempio n. 24
0
  public MovingBalls() {
    f = new Frame();
    b = new Button("ok");
    b1 = new Button("go");
    p =
        new Panel() {
          public void paint(Graphics g) {

            Color c1 =
                new Color(
                    (int) (Math.random() * 255),
                    (int) (Math.random() * 255),
                    (int) (Math.random() * 255));
            g.setColor(c1);
            g.fillOval(bx[0], by[0], 2 * br[0], 2 * br[0]);
            Color c2 =
                new Color(
                    (int) (Math.random() * 255),
                    (int) (Math.random() * 255),
                    (int) (Math.random() * 255));
            g.setColor(c2);
            g.fillOval(bx[1], by[1], 2 * br[1], 2 * br[1]);
            Color c3 =
                new Color(
                    (int) (Math.random() * 255),
                    (int) (Math.random() * 255),
                    (int) (Math.random() * 255));
            g.setColor(c3);
            g.fillOval(bx[2], by[2], 2 * br[2], 2 * br[2]);
            Color c4 =
                new Color(
                    (int) (Math.random() * 255),
                    (int) (Math.random() * 255),
                    (int) (Math.random() * 255));
            g.setColor(c4);
            g.fillOval(bx[3], by[3], 2 * br[3], 2 * br[3]);
            Color c5 =
                new Color(
                    (int) (Math.random() * 255),
                    (int) (Math.random() * 255),
                    (int) (Math.random() * 255));
            g.setColor(c5);
            g.fillOval(bx[4], by[4], 2 * br[4], 2 * br[4]);
            Color c6 =
                new Color(
                    (int) (Math.random() * 255),
                    (int) (Math.random() * 255),
                    (int) (Math.random() * 255));
            g.setColor(c6);
            g.fillOval(bx[5], by[5], 2 * br[5], 2 * br[5]);
          }
        };
    p1 = new Panel();
    f.add(p1, BorderLayout.SOUTH);
    f.add(p, BorderLayout.CENTER);
    p1.add(b);
    p1.add(b1);
    b.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (i < 6) {
              x = 100;
              y = 100;
              r = (int) (Math.random() * 50);
              bx[i] = x + (int) (Math.random() * 50);
              by[i] = y + (int) (Math.random() * 50);
              br[i] = r;
              i++;
              p.repaint();
            } else if (i == 6) {
              i = 0;
            }
          }
        });
    b1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            while (true) {

              for (int l = 0; l < 6; l++) {
                bx[l] = bx[l] + dx_m[l];
                by[l] = by[l] + dy_m[l];
                if (by[l] > p.getHeight()) {
                  dy_m[l] = -dy_m[l];
                }
                if (bx[l] > p.getWidth()) {
                  dx_m[l] = -dx_m[l];
                }
                if (by[l] < 0) {
                  dy_m[l] = -dy_m[l];
                }
                if (bx[l] < 0) {
                  dx_m[l] = -dx_m[l];
                }
              }
              /*
              bx[0] = bx[0] + dx;
              by[0] = by[0] + dy;
              if(by[0]>p.getHeight() ) {
              	dy=-dy;
              	}
              if(bx[0]>p.getWidth()) {
              	dx=-dx;
              }
              if(by[0]<0 ) {
              	dy=-dy;
              	}
              if(bx[0]<0) {
              	dx=-dx;
              	}

              */

              /*
              bx[1] = bx[1] + dx1;
              by[1] = by[1] - dy1;
              if(by[1]>p.getHeight() ) {
              	dy1=-dy1;
              	}
              if(bx[1]>p.getWidth()) {
              	dx1=-dx1;
              }
              if(by[1]<0 ) {
              	dy1=-dy1;
              	}
              if(bx[1]<0) {
              	dx1=-dx1;
              	}
              bx[2] = bx[2] - dx2;
              by[2] = by[2] + dy2;
              if(by[2]>p.getHeight() ) {
              	dy2=-dy2;
              	}
              if(bx[2]>p.getWidth()) {
              	dx2=-dx2;
              }
              if(by[2]<0 ) {
              	dy2=-dy2;
              	}
              if(bx[2]<0) {
              	dx2=-dx2;
              	}
              bx[3] = bx[3] - dx3;
              by[3] = by[3] - dy3;
              if(by[3]>p.getHeight() ) {
              	dy3=-dy3;
              	}
              if(bx[3]>p.getWidth()) {
              	dx3=-dx3;
              }
              if(by[3]<0 ) {
              	dy3=-dy3;
              	}
              if(bx[3]<0) {
              	dx3=-dx3;
              	}
              bx[4] = bx[4];
              by[4] = by[4] - dy4;
              if(by[4]>p.getHeight() ) {
              	dy4=-dy4;
              	}
              if(bx[4]>p.getWidth()) {
              	dx4=-dx4;
              }
              if(by[4]<0 ) {
              	dy4=-dy4;
              	}
              if(bx[4]<0) {
              	dx4=-dx4;
              	}
              bx[5] = bx[5] - dx5;
              by[5] = by[5] ;
              if(by[5]>p.getHeight() ) {
              	dy5=-dy5;
              	}
              if(bx[5]>p.getWidth()) {
              	dx5=-dx5;
              }
              if(by[5]<0 ) {
              	dy5=-dy5;
              	}
              if(bx[5]<0) {
              	dx5=-dx5;
              	}
              	*/
              for (int i = 0; i < 10000000; i++) {}
              p.update(p.getGraphics());
            }
          }
        });
    f.addWindowListener(this);
    f.addMouseMotionListener(this);
    p.addMouseListener(this);
    f.setSize(600, 600);
    f.setVisible(true);
  }
Esempio n. 25
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);
  }
Esempio n. 26
0
  public void run(String arg) {
    GenericDialog gd = new GenericDialog("Options");
    double sfreq = 20000.0;
    gd.addNumericField("Sampling Frequency?", sfreq, 1, 10, null);
    String[] psfchoice = {"3D Gaussian", "Gaus-Lorentz^2", "2D Gaussian"};
    gd.addChoice("PSF Type?", psfchoice, psfchoice[0]);
    String[] filetypechoice = {
      "Confocor 3 raw", "Short binary trajectory", "PlotWindow trajectory", "Ascii Text File"
    };
    gd.addChoice("File Type?", filetypechoice, filetypechoice[0]);
    boolean ch2green = true;
    gd.addCheckbox("Ch2 is green?", ch2green);
    gd.showDialog();
    if (gd.wasCanceled()) {
      return;
    }
    sfreq = gd.getNextNumber();
    int psfflag = gd.getNextChoiceIndex();
    int fileflag = gd.getNextChoiceIndex();
    ch2green = gd.getNextBoolean();
    int nfiles = 0;
    Object[] histograms = null;
    int xmax = 0;
    int ymax = 0;
    String[] names = null;
    if (fileflag < 2) {
      jdataio ioclass = new jdataio();
      File[] filearray = ioclass.openfiles(OpenDialog.getDefaultDirectory(), IJ.getInstance());
      if (filearray.length == 0) {
        return;
      }
      String dir = filearray[0].getAbsolutePath();
      int sepindex = dir.lastIndexOf(File.separator);
      String newdir = dir.substring(0, sepindex + 1);
      OpenDialog.setDefaultDirectory(newdir);
      nfiles = filearray.length / 2;
      if (nfiles > 25) {
        nfiles = 25;
      }
      histograms = new Object[nfiles];
      names = organize_c3_files(filearray);
      for (int i = 0; i < nfiles; i++) {
        try {
          int length1 = (int) (((double) filearray[2 * i].length() - 128.0) / 4.0);
          int length2 = (int) (((double) filearray[2 * i + 1].length() - 128.0) / 4.0);
          int length3 = (int) (((double) filearray[2 * i].length()) / 2.0);
          int length4 = (int) (((double) filearray[2 * i + 1].length()) / 2.0);
          InputStream instream = new BufferedInputStream(new FileInputStream(filearray[2 * i]));
          InputStream instream2 =
              new BufferedInputStream(new FileInputStream(filearray[2 * i + 1]));
          if (fileflag == 0) {
            int[] pmdata = new int[length1];
            int[] pmdata2 = new int[length2];
            if (!ioclass.skipstreambytes(instream, 128)) {
              showioerror();
              instream.close();
              return;
            }
            if (!ioclass.skipstreambytes(instream2, 128)) {
              showioerror();
              instream2.close();
              return;
            }
            if (!ioclass.readintelintfile(instream, length1, pmdata)) {
              showioerror();
              instream.close();
              return;
            }
            if (!ioclass.readintelintfile(instream2, length2, pmdata2)) {
              showioerror();
              instream2.close();
              return;
            }
            if (ch2green) {
              histograms[i] = (new pmodeconvert()).pm2pch(pmdata2, pmdata, sfreq, 20000000);
            } else {
              histograms[i] = (new pmodeconvert()).pm2pch(pmdata, pmdata2, sfreq, 20000000);
            }
          } else {
            float[] tmdata = new float[length3];
            float[] tmdata2 = new float[length4];
            if (!ioclass.readintelshortfile(instream, length3, tmdata)) {
              showioerror();
              instream.close();
              return;
            }
            if (!ioclass.readintelshortfile(instream2, length4, tmdata2)) {
              showioerror();
              instream2.close();
              return;
            }
            if (ch2green) {
              histograms[i] = (new pmodeconvert()).create_2Dhistogram(tmdata2, tmdata);
            } else {
              histograms[i] = (new pmodeconvert()).create_2Dhistogram(tmdata, tmdata2);
            }
          }
          if (((float[][]) histograms[i]).length > xmax) {
            xmax = ((float[][]) histograms[i]).length;
          }
          if (((float[][]) histograms[i])[0].length > ymax) {
            ymax = ((float[][]) histograms[i])[0].length;
          }
          instream.close();
          instream2.close();
        } catch (IOException e) {
          showioerror();
          return;
        }
      }
    } else {
      if (fileflag == 2) {
        ImageWindow iw = WindowManager.getCurrentWindow();
        float[][] trajectories = (float[][]) jutils.runPW4VoidMethod(iw, "getYValues");
        float[][] tempxvals = (float[][]) jutils.runPW4VoidMethod(iw, "getXValues");
        sfreq = 1.0 / ((double) tempxvals[0][1]);
        nfiles = trajectories.length / 2;
        if (nfiles > 25) {
          nfiles = 25;
        }
        names = new String[nfiles + 1];
        names[nfiles] = "avg";
        histograms = new Object[nfiles];
        for (int i = 0; i < nfiles; i++) {
          names[i] = "trajectory " + (i + 1);
          if (ch2green) {
            histograms[i] =
                (new pmodeconvert())
                    .create_2Dhistogram(trajectories[2 * i + 1], trajectories[2 * i]);
          } else {
            histograms[i] =
                (new pmodeconvert())
                    .create_2Dhistogram(trajectories[2 * i], trajectories[2 * i + 1]);
          }
          if (((float[][]) histograms[i]).length > xmax) {
            xmax = ((float[][]) histograms[i]).length;
          }
          if (((float[][]) histograms[i])[0].length > ymax) {
            ymax = ((float[][]) histograms[i])[0].length;
          }
        }
      } else {
        // here we read tab delimited lines from files
        jdataio ioclass = new jdataio();
        File[] filearray = ioclass.openfiles(OpenDialog.getDefaultDirectory(), IJ.getInstance());
        if (filearray.length == 0) {
          return;
        }
        String dir = filearray[0].getAbsolutePath();
        int sepindex = dir.lastIndexOf(File.separator);
        String newdir = dir.substring(0, sepindex + 1);
        OpenDialog.setDefaultDirectory(newdir);
        nfiles = filearray.length;
        if (nfiles > 25) {
          nfiles = 25;
        }
        histograms = new Object[nfiles];
        names = new String[nfiles + 1];
        names[nfiles] = "avg";
        for (int i = 0; i < nfiles; i++) {
          try {
            names[i] = filearray[i].getName();
            BufferedReader d = new BufferedReader(new FileReader(filearray[i]));
            String[] lines = new String[256];
            int counter = 0;
            do {
              lines[counter] = d.readLine();
              counter++;
            } while ((lines[counter - 1] != null && lines[counter - 1] != "") && counter < 256);
            int numcolumns = 0;
            for (int j = 0; j < counter - 1; j++) {
              int temp = getncolumns(lines[j]);
              if (temp > numcolumns) {
                numcolumns = temp;
              }
            }
            float[][] temphist2 = null;
            if (ch2green) {
              temphist2 = new float[numcolumns][counter - 1];
            } else {
              temphist2 = new float[counter - 1][numcolumns];
            }
            for (int k = 0; k < counter - 1; k++) {
              float[] temp = tab_delim2float(lines[k]);
              for (int j = 0; j < numcolumns; j++) {
                if (ch2green) {
                  temphist2[j][k] = temp[j];
                } else {
                  temphist2[k][j] = temp[j];
                }
              }
            }
            histograms[i] = temphist2;
            d.close();
          } catch (IOException e) {
            showioerror();
            return;
          }
        }
        for (int i = 0; i < nfiles; i++) {
          if (((float[][]) histograms[i]).length > xmax) {
            xmax = ((float[][]) histograms[i]).length;
          }
          if (((float[][]) histograms[i])[0].length > ymax) {
            ymax = ((float[][]) histograms[i])[0].length;
          }
        }
      }
    }
    // note that here x is green and y is red
    float[][][] pch = new float[nfiles][xmax][ymax];
    for (int i = 0; i < nfiles; i++) {
      for (int j = 0; j < ((float[][]) histograms[i]).length; j++) {
        for (int k = 0; k < ((float[][]) histograms[i])[j].length; k++) {
          pch[i][j][k] = ((float[][]) histograms[i])[j][k];
        }
      }
    }

    final PCH2DFitWindow cw = new PCH2DFitWindow();
    cw.init(names, pch, psfflag);

    final Frame f = new Frame("PCH 2D Analysis");
    f.setLocation(10, 10);
    f.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            f.dispose();
          }
        });

    f.add(cw);
    f.pack();
    f.setResizable(false);
    Insets ins = f.getInsets();
    cw.totalSize.height = PCH2DFitWindow.H + ins.bottom + ins.top + 65;
    cw.totalSize.width = PCH2DFitWindow.WR + ins.left + ins.right;
    f.setSize(cw.totalSize);
    f.setVisible(true);
    cw.requestFocus();
  }
Esempio n. 27
0
  public CalculatorSergii() {
    f = new Frame("Calculator");

    b1 = new Button("7");
    b2 = new Button("8");
    b3 = new Button("9");
    b4 = new Button("*");
    b5 = new Button("sqrt;");
    b6 = new Button("4");
    b7 = new Button("5");
    b8 = new Button("6");
    b9 = new Button("/");
    b10 = new Button("del");
    b11 = new Button("1");
    b12 = new Button("2");
    b13 = new Button("3");
    b14 = new Button("-");
    b15 = new Button("1/x ");
    b16 = new Button("0");
    b17 = new Button(".");
    b18 = new Button("C");
    b19 = new Button("+");
    b20 = new Button("=");

    b18.setBackground(Color.white);
    b10.setBackground(Color.white);
    b20.setBackground(Color.gray);
    b15.setBackground(Color.gray);
    b5.setBackground(Color.gray);
    b9.setBackground(Color.lightGray);
    b19.setBackground(Color.lightGray);
    b14.setBackground(Color.lightGray);
    b4.setBackground(Color.lightGray);

    f.addWindowListener(this);
    tf = new TextField("0");
    // работа кнопок-цифр
    b11.addActionListener(this);
    b12.addActionListener(this);
    b13.addActionListener(this);
    b1.addActionListener(this);
    b2.addActionListener(this);
    b3.addActionListener(this);
    b6.addActionListener(this);
    b7.addActionListener(this);
    b8.addActionListener(this);
    b16.addActionListener(this);

    // работа кнопки С
    b18.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            tf.setText("0");
            zn = 0;
            check = true;
          }
        });
    // возможность ставить точки в числе после арифм. знака
    b17.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (tf.getText().indexOf('.') == -1) tf.setText(tf.getText() + e.getActionCommand());
          }
        });
    // возможность ставить только один +
    b19.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (arifm == false) {
              if (zn == 0) {

                operand = Double.parseDouble(tf.getText());
                check = true;
              } else {

                if (zn == 1) operand = operand + Double.parseDouble(tf.getText());
                if (zn == 2) operand = operand * Double.parseDouble(tf.getText());
                if (zn == 3) operand = operand / Double.parseDouble(tf.getText());
                if (zn == 4) operand = operand - Double.parseDouble(tf.getText());
              }
              tf.setText(operand + "");
              check = true;
              arifm = true;
              zn = 1;
            } else zn = 1;
          }
        });
    // /--/ *
    b4.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (arifm == false) {
              if (zn == 0) {

                operand = Double.parseDouble(tf.getText());
                check = true;
              } else {

                if (zn == 1) operand = operand + Double.parseDouble(tf.getText());
                if (zn == 2) operand = operand * Double.parseDouble(tf.getText());
                if (zn == 3) operand = operand / Double.parseDouble(tf.getText());
                if (zn == 4) operand = operand - Double.parseDouble(tf.getText());
              }
              tf.setText(operand + "");
              check = true;
              arifm = true;
              zn = 2;
            } else zn = 2;
          }
        });
    // /--/ /
    b9.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (arifm == false) {
              if (zn == 0) {

                operand = Double.parseDouble(tf.getText());
                check = true;
              } else {
                if (zn == 1) operand = operand + Double.parseDouble(tf.getText());
                if (zn == 2) operand = operand * Double.parseDouble(tf.getText());
                if (zn == 3) operand = operand / Double.parseDouble(tf.getText());
                if (zn == 4) operand = operand - Double.parseDouble(tf.getText());
              }
              tf.setText(operand + "");
              check = true;
              arifm = true;
              zn = 3;
            } else zn = 3;
          }
        });
    // /--/ -
    b14.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (arifm == false) {
              if (zn == 0) {
                operand = Double.parseDouble(tf.getText());
                check = true;
              } else {
                if (zn == 1) operand = operand + Double.parseDouble(tf.getText());
                if (zn == 2) operand = operand * Double.parseDouble(tf.getText());
                if (zn == 3) operand = operand / Double.parseDouble(tf.getText());
                if (zn == 4) operand = operand - Double.parseDouble(tf.getText());
              }
              tf.setText(operand + "");
              check = true;
              arifm = true;
              zn = 4;
            } else zn = 4;
          }
        });
    // операции при нажатии кнопки =
    b20.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (zn != 0 && arifm != true) {
              if (zn == 1) operand = operand + Double.parseDouble(tf.getText());
              if (zn == 2) operand = operand * Double.parseDouble(tf.getText());
              if (zn == 3) operand = operand / Double.parseDouble(tf.getText());
              if (zn == 4) operand = operand - Double.parseDouble(tf.getText());
              tf.setText(operand + "");
            }
            zn = 0;
          }
        });
  }