예제 #1
0
파일: Reaction.java 프로젝트: aq2/GUIs
  public static void main(String[] args) {
    JFrame frame = new JFrame("Reaction Timer");
    frame.setSize(280, 120);

    final TextField disp = new TextField();
    final JButton btn = new JButton("Go");

    btn.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            u = System.currentTimeMillis();
            if (u - t < ONE_SECOND) {
              disp.setText("" + (u - t));
            }
            t = u;
          }
        });

    frame.setLayout(null);
    disp.setBounds(10, 10, 230, 20);
    frame.add(disp);
    btn.setBounds(10, 40, 210, 40);
    frame.add(btn);

    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
    frame.setResizable(false);
  }
예제 #2
0
 public static void main(String[] args) {
   JFrame mainFrame = new JFrame("TestPopupWindow");
   mainFrame.getContentPane().add(new TestPopupWindow());
   mainFrame.pack();
   mainFrame.setLocationRelativeTo(null);
   mainFrame.setVisible(true);
 }
  public static void main(String[] args) {
    final JPopupMenu menu = new JPopupMenu();
    menu.setLayout(new GridLayout(0, 3, 5, 5));

    final MenuedButton button = new MenuedButton("Icons", menu);

    for (int i = 0; i < 9; i++) {
      // replace "print.gif" with your own image
      final JLabel label = new JLabel("" + i); // new ImageIcon("resources/images/print.gif") );
      label.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
              button.getMainButton().setIcon(label.getIcon());
              menu.setVisible(false);
            }
          });
      menu.add(label);
    }

    JFrame frame = new JFrame("Button Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new JLabel("Click Arrow Button To Show Popup"), BorderLayout.NORTH);
    frame.getContentPane().add(button, BorderLayout.CENTER);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
예제 #4
0
  public void go() throws IOException {
    // DefaultRouteTable route = new DefaultRouteTable();
    // System.out.println(route.routeInfo());
    // route.routeInfo();
    totalSize = Toolkit.getDefaultToolkit().getScreenSize(); // getting screen size
    int width = totalSize.width;
    int height = totalSize.height;
    frame = new JFrame(); // creating frame
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            FileInput data = null;
            try {
              data = new FileInput("input.txt");
            } catch (Exception e) {

            }
            String[][] origRoutes =
                convertArrayListTo2DArray(data.routeArrayList(data.routesToken), 1);
            String[][] routesList = Main.convertArrayListTo2DArray(routesInfo, 1);
            Main.changesCheck(origRoutes, routesList);
          }
        });
    frame.setTitle("Air Route Planner");
    frame.add(Panels());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize((width * 3 / 4), (height * 3 / 4));
    frame.setJMenuBar(menuBar());
    frame.setResizable(false);
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
  }
예제 #5
0
 Main() {
   f = new JFrame("Wiki Seach");
   JPanel p = new JPanel();
   JPanel p1 = new JPanel();
   b = new JButton("Search");
   b1 = new JButton("Exit");
   t = new JTextField(30);
   b.addActionListener(this);
   b1.addActionListener(this);
   p1.add(b);
   p1.add(b1);
   p.add(t);
   f.setLayout(new GridLayout(2, 1));
   f.add(p);
   f.add(p1);
   f.pack();
   f.setLocationRelativeTo(null);
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   f.setVisible(true);
 }
  public void show() {
    FloorcJson floorcJson = null;
    try {
      floorcJson = Settings.get();
    } catch (Throwable ignored) {
    }

    HashMap<String, String> auth =
        floorcJson != null ? floorcJson.auth.get(Constants.defaultHost) : null;
    String username = "******";
    if (auth != null) {
      username = auth.get("username");
    }
    usernameInput.setText(username);
    frame = new JFrame();
    frame.getContentPane().add(contentContainer);
    frame.setMinimumSize(new Dimension(650, 500));
    frame.setResizable(false);
    frame.setLocationRelativeTo(null);
    frame.pack();
    contentContainer.setBorder(new EmptyBorder(5, 5, 5, 5));
    frame.setVisible(true);
    String contents =
        "<html><body><p>When you submit an "
            + "issue we will be notified right away. If we have contact information for you<br/> we will respond. You can also "
            + "contact us via [email protected], on IRC in #floobits<br/> "
            + "on Freenode, or via @floobits Twitter. If you run into "
            + "a bug it may help us if you send us your <br/>log. You can find it by going to Help -&gt; Find "
            + "log....     </p></body></html>";

    instructionsLabel.setText(contents);
    instructionsLabel.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
  }
예제 #7
0
  public static void main(String[] args) {
    final Browser browser = new Browser();
    BrowserView browserView = new BrowserView(browser);

    final JTextField addressBar = new JTextField("http://www.teamdev.com/jxbrowser");
    addressBar.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            browser.loadURL(addressBar.getText());
          }
        });

    JPanel addressPane = new JPanel(new BorderLayout());
    addressPane.add(new JLabel(" URL: "), BorderLayout.WEST);
    addressPane.add(addressBar, BorderLayout.CENTER);

    JFrame frame = new JFrame("JxBrowser - Hello World");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.add(addressPane, BorderLayout.NORTH);
    frame.add(browserView, BorderLayout.CENTER);
    frame.setSize(800, 500);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    browser.loadURL(addressBar.getText());
  }
  public static void main(String[] args) {
    int i = 3; // Default to 3
    if (args.length >= 1) {
      try {
        i = Integer.parseInt(args[0]);
      } catch (NumberFormatException e) {
        System.out.println("Usage: 'java SierpinskyTriangle [level]'\nNow setting level to " + i);
      }
    }
    final int level = i;

    JFrame frame = new JFrame("Sierpinsky Triangle - Java");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel =
        new JPanel() {
          @Override
          public void paintComponent(Graphics g) {
            g.setColor(Color.BLACK);
            drawSierpinskyTriangle(level, 20, 20, 360, (Graphics2D) g);
          }
        };

    panel.setPreferredSize(new Dimension(400, 400));

    frame.add(panel);
    frame.pack();
    frame.setResizable(false);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
예제 #9
0
  private void create() {
    JFrame f = new JFrame("JSplitPane");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    MyPanel p1 = new MyPanel(Color.red);
    MyPanel p2 = new MyPanel(Color.blue);
    final JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, p1, p2);
    Timer timer =
        new Timer(
            200,
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                ratio += delta;
                if (ratio >= 1.0) {
                  ratio = 1.0;
                  delta = -delta;
                } else if (ratio <= 0) {
                  delta = -delta;
                  ratio = 0;
                }
                jsp.setDividerLocation(ratio);
              }
            });

    f.add(jsp);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setVisible(true);
    timer.start();
  }
  public static void main(String[] args) {
    Browser browser = new Browser();
    BrowserView browserView = new BrowserView(browser);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.add(browserView, BorderLayout.CENTER);
    frame.setSize(800, 600);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    browser.setDownloadHandler(
        new DownloadHandler() {
          public boolean allowDownload(DownloadItem download) {
            download.addDownloadListener(
                new DownloadListener() {
                  public void onDownloadUpdated(DownloadEvent event) {
                    DownloadItem download = event.getDownloadItem();
                    if (download.isCompleted()) {
                      System.out.println("Download is completed!");
                    }
                  }
                });
            System.out.println(
                "Destination file: " + download.getDestinationFile().getAbsolutePath());
            return true;
          }
        });

    browser.loadURL("ftp://ftp.teamdev.com/updates/jxbrowser-4.0-beta.zip");
  }
  /** Example panel. Animate an example file (E short) and play a tone (D long). */
  public static void main(String[] args) {
    try {
      JFrame f = new JFrame(AnimationPanel.class.getName());
      f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      AnimationRenderer ani = new AnimationRenderer();

      final AnimationPanel view = new AnimationPanel(ani);

      f.getContentPane().add(view, BorderLayout.CENTER);
      f.pack();
      f.setLocationRelativeTo(null);
      f.setVisible(true);

      File file = new File("datafiles/examples/vis/es_.txt");

      final AnimationSequence animation = AnimationParser.parseFile(file);

      String filename =
          NotesEnum.D.toString().toLowerCase() + "_" + DurationEnum.LONG.codeString() + ".wav";
      // System.out.printf("sound clip filename = %s\n", filename);

      File dir = new File("datafiles/examples/aud");

      final Playable audio = SoundClip.findPlayable(filename, dir, false);

      Runnable r =
          new Runnable() {
            @Override
            public void run() {
              audio.play();
            }
          };

      long currentTime = System.nanoTime();
      ani.setAnimationSource(
          new AnimationSource() {
            public AnimationSequence getAnimationSequence() {
              return animation;
            }

            public int getNumPoints() {
              return 5;
            }

            public float getDiskRadius() {
              return 0.3f;
            }

            public boolean isConnected() {
              return true;
            }
          });

      ani.setNanoStartTime(currentTime);
      SwingUtilities.invokeLater(r);
    } catch (Throwable ex) {
      ex.printStackTrace();
    }
  }
예제 #12
0
 public static void main(String[] args) {
   JFrame frame = new Exercise15_6();
   frame.setSize(300, 300);
   frame.setTitle("Exercise15_6");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLocationRelativeTo(null); // Center the frame
   frame.setVisible(true);
 }
예제 #13
0
 public static void main(String[] args) {
   JFrame frame = new TestImageIcon();
   frame.setTitle("Test ImageIcon");
   frame.setSize(500, 300);
   frame.setLocationRelativeTo(null);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setVisible(true);
 }
예제 #14
0
 public static void main(String[] args) {
   JFrame frame = new JFrame();
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.add(new URLField());
   frame.pack();
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
예제 #15
0
 public static void main(String args[]) {
   JFrame frame = new CopyFileToTable();
   frame.setTitle("CopyFileToTable");
   frame.setSize(700, 200);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
예제 #16
0
 /** Main method */
 public static void main(String[] args) {
   JFrame frame = new SimpleEventDemo2();
   frame.setTitle("SimpleEventDemo2");
   frame.setLocationRelativeTo(null); // Center the frame
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setSize(100, 80);
   frame.setVisible(true);
 }
예제 #17
0
파일: test.java 프로젝트: Recoskie/3D
 public void Window() {
   JFrame f = new JFrame("test");
   f.setSize(570, 383);
   f.add(new test());
   f.setLocationRelativeTo(null);
   f.setResizable(false);
   f.setVisible(true);
 }
예제 #18
0
 public static void main(String[] args) {
   JFrame frame = new JFrame("AVLTreeAnimation");
   JApplet applet = new AVLTreeAnimation();
   frame.add(applet);
   frame.setSize(500, 300);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
예제 #19
0
 /** Main method */
 public static void main(String[] args) {
   JFrame frame = new JFrame("ClockAnimation");
   ClockAnimation clock = new ClockAnimation();
   frame.add(clock);
   frame.setLocationRelativeTo(null); // Center the frame
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setSize(200, 200);
   frame.setVisible(true);
 }
예제 #20
0
 /** Constructs the browser as a standalone frame. */
 private void constructStandalone() {
   frame = new JFrame("Issues");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setSize(1024, 600);
   frame.setLocationRelativeTo(null);
   frame.getContentPane().setLayout(new BorderLayout());
   frame.getContentPane().add(constructView(), BorderLayout.CENTER);
   frame.setVisible(true);
 }
예제 #21
0
 private void run() {
   JFrame window = new JFrame();
   window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   window.setTitle("Analog Clock");
   ClockAnalogBuf contentPane = new ClockAnalogBuf();
   window.setContentPane(contentPane);
   window.pack(); // Layout components
   window.setLocationRelativeTo(null); // Center window.
   window.setVisible(true);
 }
예제 #22
0
  /** main method allows us to run as a standalone demo. */
  public static void main(String[] args) {
    JFrame frame = new JFrame(ProgressBarDemo.class.getAnnotation(DemoProperties.class).value());

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().add(new ProgressBarDemo());
    frame.setPreferredSize(new Dimension(800, 600));
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
예제 #23
0
 public static void main(String[] args) {
   JFrame frame = new JFrame("Exercise01");
   JApplet applet = new Exercise01();
   frame.add(applet);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setSize(640, 480);
   frame.setMinimumSize(new Dimension(frame.getWidth(), frame.getHeight()));
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
예제 #24
0
파일: MainForm.java 프로젝트: andsp/oou
 public static void start() {
   JFrame frame = new JFrame("MainForm");
   MainForm form = new MainForm();
   frame.setContentPane(form.pnMain);
   frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
   form.initUI();
   frame.pack();
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
예제 #25
0
  private static void createAndShowGUI() {
    final JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // work with the layer as with any other Swing component
    frame.add(createLayer());

    frame.setSize(200, 200);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
예제 #26
0
 /**
  * You can ignore this method. This method gets called by the subclass's constructor when it has
  * finished initializing, but that call is already written in <code>MyGame.java</code>.
  */
 protected void ready() {
   if (applet) {
     add(canvas);
   } else {
     frame.add(canvas);
     frame.pack();
     frame.setLocationRelativeTo(null);
     frame.setResizable(false);
     frame.setVisible(true);
   }
 }
예제 #27
0
  public static void main(String[] args) {
    JFrame frame = new JFrame("Click on a tutorial to run it");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel tutorialsViewer = new TutorialChooser();
    frame.setContentPane(tutorialsViewer);

    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
예제 #28
0
  public static void main(String[] args) {
    JFrame game = new JFrame();
    game.setTitle("2048 Game");
    game.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    game.setSize(340, 400);
    game.setResizable(false);

    game.add(new Game2048());

    game.setLocationRelativeTo(null);
    game.setVisible(true);
  }
예제 #29
0
 public static void main(String[] args) {
   ProgressBarDemo applet = new ProgressBarDemo();
   JFrame frame = new JFrame();
   frame.setTitle("ProgressBarDemo");
   frame.getContentPane().add(applet, BorderLayout.CENTER);
   applet.init();
   applet.start();
   frame.setSize(400, 200);
   frame.setLocationRelativeTo(null); // Center the frame
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setVisible(true);
 }
예제 #30
0
 private static void createAndShowMain() {
   JFrame.setDefaultLookAndFeelDecorated(true);
   JFrame frame = new JFrame("RT Prune Algorithm Simulator");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLocationRelativeTo(null);
   Main newContentPane = new Main(frame);
   newContentPane.setOpaque(true);
   frame.setContentPane(newContentPane);
   frame.pack();
   frame.setExtendedState(Frame.MAXIMIZED_BOTH);
   frame.setVisible(true);
 }