예제 #1
0
파일: Console.java 프로젝트: xanax/scratch
 /**
  * This method initializes jMenuItem
  *
  * @return javax.swing.JMenuItem
  */
 javax.swing.JMenuItem getExitMenuItem() {
   if (exitMenuItem == null) {
     exitMenuItem = new javax.swing.JMenuItem();
     exitMenuItem.setText("Exit");
     exitMenuItem.addActionListener(
         new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent e) {
             System.exit(0);
           }
         });
   }
   return exitMenuItem;
 }
예제 #2
0
파일: Console.java 프로젝트: xanax/scratch
  /**
   * This method initializes jMenuItem
   *
   * @return javax.swing.JMenuItem
   */
  javax.swing.JMenuItem getAboutMenuItem() {
    if (aboutMenuItem == null) {
      aboutMenuItem = new javax.swing.JMenuItem();
      aboutMenuItem.setText("About ECJ");
      aboutMenuItem.addActionListener(
          new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent e) {

              if (aboutFrame == null) {

                // construct the frame
                aboutFrame = new JFrame("About ECJ");
                JPanel p = new JPanel(); // 1.3.1 only has borders for JComponents, not Boxes
                p.setBorder(BorderFactory.createEmptyBorder(25, 30, 30, 30));
                Box b = new Box(BoxLayout.Y_AXIS);
                p.add(b, BorderLayout.CENTER);
                aboutFrame.getContentPane().add(p, BorderLayout.CENTER);
                aboutFrame.setResizable(false);
                Font small = new Font("Dialog", 0, 10);

                // start dumping in text
                JLabel j = new JLabel("ECJ");
                j.setFont(new Font("Serif", 0, 36));
                b.add(j);

                j = new JLabel("An Evolutionary Computation System");
                b.add(j);
                j = new JLabel("Version " + Version.version);
                b.add(j);
                JLabel spacer = new JLabel(" ");
                spacer.setFont(new Font("Dialog", 0, 6));
                b.add(spacer);

                j = new JLabel("By " + Version.author);
                b.add(j);

                spacer = new JLabel(" ");
                spacer.setFont(new Font("Dialog", 0, 6));
                b.add(spacer);

                j = new JLabel("Contributors:");
                b.add(j);
                j = new JLabel("     " + Version.contributors);
                b.add(j);
                j = new JLabel("     " + Version.contributors2);
                b.add(j);

                spacer = new JLabel(" ");
                spacer.setFont(new Font("Dialog", 0, 6));
                b.add(spacer);

                // can't figure out why I need a second one...
                spacer = new JLabel(" ");
                spacer.setFont(new Font("Dialog", 0, 6));
                b.add(spacer);

                j = new JLabel("ECJ's homepage is " + Version.authorURL);
                j.setFont(small);
                b.add(j);

                j =
                    new JLabel(
                        "For help, send mail to "
                            + Version.authorEmail0
                            + "@"
                            + Version.authorEmail1);
                j.setFont(small);
                b.add(j);

                j = new JLabel("     " + Version.authorEmail2);
                j.setFont(small);
                b.add(j);

                spacer.setFont(new Font("Dialog", 0, 6));
                b.add(spacer);

                j = new JLabel("Version " + Version.version + " released on " + Version.date + ".");
                j.setFont(small);
                b.add(j);

                String javaVersion = System.getProperties().getProperty("java.version");
                j = new JLabel("Current Java: " + javaVersion);
                j.setFont(small);
                b.add(j);

                j = new JLabel("Minimum Java: " + Version.minimumJavaVersion);
                j.setFont(small);
                b.add(j);

                aboutFrame.pack();
              }

              // if not on screen right now, move to center of screen
              if (!aboutFrame.isVisible()) {

                Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
                d.width -= aboutFrame.getWidth();
                d.height -= aboutFrame.getHeight();
                d.width /= 2;
                d.height /= 2;
                if (d.width < 0) d.width = 0;
                if (d.height < 0) d.height = 0;
                aboutFrame.setLocation(d.width, d.height);
              }

              // show it!
              aboutFrame.setVisible(true);
            }
          });
    }
    return aboutMenuItem;
  }