Example #1
0
  /**
   * Creates a new connection to the specified host of specified type. <br>
   * <br>
   * type: Type of connection to create <br>
   * destination: Host to connect to (in "host:port" or "host" syntax)
   */
  public Connection(java.net.InetAddress host, int port, PluginContext ctx)
      throws MessagingNetworkException, java.io.IOException {
    if (TRAKTOR_USED) {
      if (traktorConnectionDown) throw new IOException("network is down");

      traktor = new Frame("" + host + ":" + port + " - Traktor");
      final Checkbox c = new Checkbox("break this & ALL future connections");
      c.setState(traktorConnectionDown);
      c.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
              traktorConnectionDown = c.getState();
              try {
                if (traktorConnectionDown) closeSocket();
              } catch (Exception ex) {
              }
            }
          });
      traktor.add(c);
      traktor.setSize(100, 50);
      traktor.setLocation(230, 450);
      traktor.setVisible(true);
    } else {
      traktor = null;
    }
  }
  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();
  }
Example #3
0
  public void launchCalc() {
    f.add(tf, BorderLayout.NORTH);
    p2 = new Panel();
    p2.setLayout(new GridLayout(4, 5));
    p2.add(b1);
    p2.add(b2);
    p2.add(b3);
    p2.add(b18);
    p2.add(b10);
    p2.add(b6);
    p2.add(b7);
    p2.add(b8);
    p2.add(b19);
    p2.add(b4);
    p2.add(b11);
    p2.add(b12);
    p2.add(b13);
    p2.add(b14);
    p2.add(b9);
    p2.add(b16);
    p2.add(b17);
    p2.add(b20);
    p2.add(b15);
    p2.add(b5);

    f.add(p2, BorderLayout.CENTER);
    f.pack();
    f.setSize(250, 200);
    f.setVisible(true);
  }
Example #4
0
 public static void main(String[] args) {
   try {
     if (args.length != 1) throw new IllegalArgumentException("Wrong number of arguments");
     FileReader in = new FileReader(args[0]);
     HardcopyWriter out = null;
     Frame f = new Frame("PrintFile: " + args[0]);
     f.setSize(200, 50);
     f.show();
     try {
       out = new HardcopyWriter(f, args[0], 10, .75, .75, .75, .75);
     } catch (HardcopyWriter.PrintCanceledException e) {
       System.exit(0);
     }
     f.setVisible(false);
     char[] buffer = new char[4096];
     int numchars;
     while ((numchars = in.read(buffer)) != -1) out.write(buffer, 0, numchars);
     out.close();
   } catch (Exception e) {
     System.err.println(e);
     System.err.println("Usage: java HardcopyWriter$PrintFile <filename>");
     System.exit(1);
   }
   System.exit(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;
  }
 demo5() {
   f = new Frame();
   f.setSize(300, 300);
   // f.setBackground(Color.red);
   f.setLayout(null);
   s1 = new Scrollbar(Scrollbar.VERTICAL, 0, 5, 0, 260);
   s1.setBackground(Color.red);
   s1.setBounds(30, 35, 20, 255);
   s2 = new Scrollbar(Scrollbar.VERTICAL, 0, 5, 0, 260);
   s2.setBackground(Color.green);
   s2.setBounds(60, 35, 20, 255);
   s3 = new Scrollbar(Scrollbar.VERTICAL, 0, 5, 0, 260);
   s3.setBackground(Color.blue);
   s3.setBounds(90, 35, 20, 255);
   f.add(s1);
   f.add(s2);
   f.add(s3);
   s1.addAdjustmentListener(this);
   s2.addAdjustmentListener(this);
   s3.addAdjustmentListener(this);
   p1 = new Panel();
   p1.setBounds(120, 35, 170, 255);
   f.add(p1);
   f.setVisible(true);
 }
Example #7
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);
 }
Example #8
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()
Example #9
0
 public static void main(String[] args) {
   // TODO 自动生成的方法存根
   int pause = 5;
   int grid = 8;
   Frame f = new ColorBoxes2(pause, grid);
   f.setSize(500, 400);
   f.setVisible(true);
 }
  public static void main(String args[]) {
    Frame f = new SampleFrame("File Dialog Demo");
    f.setVisible(true);
    f.setSize(200, 200);

    FileDialog fd = new FileDialog(f, "File Dialog");

    fd.setVisible(true);
  }
Example #11
0
 public static void main(String[] args) {
   Frame f = new Frame("Test");
   Button b = new Button("Press me!");
   Monitor bh = new Monitor();
   b.addActionListener(bh);
   f.add(b, BorderLayout.CENTER);
   f.pack();
   f.setVisible(true);
 }
Example #12
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);
 }
Example #13
0
 MyF2() {
   Frame f = new Frame("graphics");
   Button b = new Button("line");
   f.add(m);
   f.add(b);
   b.addActionListener(this);
   f.setSize(400, 400);
   f.setLayout(new GridLayout(2, 1));
   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);
          }
        });
  }
  public static void main(String s[]) {
    initParams(s);
    initAdapters();
    f = new Frame();
    final int[] modifiers = {InputEvent.SHIFT_MASK, InputEvent.CTRL_MASK};
    final String[] modifierNames = {"InputEvent.SHIFT_MASK", "InputEvent.CTRL_MASK"};
    f.setLayout(new FlowLayout());
    f.addMouseWheelListener(
        new MouseWheelListener() {
          public void mouseWheelMoved(MouseWheelEvent e) {
            System.out.println("WHEEL " + e);
          }
        });
    f.setSize(300, 300);
    f.setVisible(true);

    try {
      robot = new Robot();
      robot.delay(500);
      robot.mouseMove(
          f.getLocationOnScreen().x + f.getWidth() / 2,
          f.getLocationOnScreen().y + f.getHeight() / 2);
      if (autorun) {
        // testing buttons 1, 2, 3 only
        testPlainButtons();
        robot.delay(500);

        // testing buttons 1, 2, 3 with SHIFT, CTRL, ALT keyboard modifiers
        testButtonsWithShift();
        robot.delay(500);

        testButtonsWithControl();
        robot.delay(500);

        testButtonsWithAlt();
        robot.delay(500);
      } else {
        switch (testModifier) {
          case SHIFT:
            f.addMouseListener(adapterTest2);
            break;
          case CTRL:
            f.addMouseListener(adapterTest3);
            break;
          case ALT:
            f.addMouseListener(adapterTest4);
            break;
          default: // NONE inclusive
            f.addMouseListener(adapterTest1);
        }
      }
    } catch (Exception e) {
      throw new RuntimeException("Test failed.");
    }
  }
Example #16
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);
 }
 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);
 }
Example #18
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);
         }
       });
 }
 public void start() {
   // Get things going.  Request focus, set size, et cetera
   setSize(200, 200);
   setVisible(true);
   validate();
   Frame f = new Frame("Set action for Robot here.");
   f.setLayout(new FlowLayout());
   f.add(buttonNumber);
   f.add(pressOn);
   f.add(releaseOn);
   f.add(clickOn);
   f.add(target);
   f.pack();
   f.setVisible(true);
 } // start()
Example #20
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);
 }
Example #21
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);
  }
Example #22
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); // 设置窗体可见
 }
Example #23
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);
  }
Example #24
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);
  }
  public void actionPerformed(ActionEvent e) {
    Object ob = e.getSource();
    if (ob.equals(rules)) {
      p1.showMessageDialog(
          null,
          "THIS IS A SIMPLE SOFTWARE FOR CONDUCTING EXAMINATION.\n"
              + "SPECIALLY DESIGN FOR SOIL OF GNDU REGIONAL CAMPUS JAL.\n"
              + "YOU HAVE TO SELECT YOUR YEAR AND THE PARTICULAR EXAM WILL BE DISPLAYED.\n"
              + "THERE ARE FOUR OPTIONS OUT OF WHICH ONLY ONE IS CORRECT.\n"
              + "MARKING SCHEME WILL DEPEND UPON THE EXAM SETTER IT WILL BE DISCLOSED TO U BEFORE THE EXAM.\n"
              + "ALL THE BEST \n"
              + "REGARDS \n"
              + "SAURABH BHATIA (CSE (2010-2014))");

    } else if (ob.equals(conti)) {
      Cheating o = new Cheating(email);
      f.setVisible(false);
    }
  }
 /**
  * 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);
   }
 }
Example #27
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();
 }
Example #28
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);
 }
Example #29
0
 public void init() {
   Panel p = new Panel();
   p.add(btCopy);
   p.add(btPaste);
   btCopy.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           // 将一个多行文本域里的字符串封装成StringSelection对象
           StringSelection contents = new StringSelection(jtaCopyTo.getText());
           // 将StringSelection对象放入剪贴板
           clipboard.setContents(contents, null);
         }
       });
   btPaste.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           // 如果剪贴板中包含stringFlavor内容
           if (clipboard.isDataFlavorAvailable(DataFlavor.stringFlavor)) {
             try {
               // 取出剪贴板中stringFlavor内容
               String content = (String) clipboard.getData(DataFlavor.stringFlavor);
               jtaPaste.append(content);
             } catch (Exception e) {
               e.printStackTrace();
             }
           }
         }
       });
   // 创建一个水平排列的Box容器
   Box box = new Box(BoxLayout.X_AXIS);
   // 将两个多行文本域放在Box容器中
   box.add(jtaCopyTo);
   box.add(jtaPaste);
   // 将按钮所在Panel、Box容器添加到Frame窗口中
   f.add(p, BorderLayout.SOUTH);
   f.add(box, BorderLayout.CENTER);
   f.pack();
   f.setVisible(true);
 }
Example #30
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);
  }