Пример #1
0
  /**
   * Create the GUI and show it. For thread safety, this method should be invoked from the
   * event-dispatching thread.
   */
  private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("Automated File Mover");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            try {
              FileOutputStream f_out = new FileOutputStream(LOG_DIRECTORY + "save.data");

              // Write object with ObjectOutputStream
              ObjectOutputStream obj_out = new ObjectOutputStream(f_out);

              // Write object out to disk
              obj_out.writeObject(directoryList);
              obj_out.writeObject(ERROR_LOG_NAME);
              obj_out.writeObject(MOVE_LOG_NAME);
              obj_out.flush();
              obj_out.close();
              printer.printError(LOG_DIRECTORY);
            } catch (IOException x) {
              printer.printError(x.toString());
            }
          }
        });

    // Create and set up the content pane.
    JComponent newContentPane = new fileBackupProgram(frame);
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);

    // Display the window.
    frame.pack();
    frame.setVisible(true);
  }
  /** Simple test program. */
  public static void main(String[] args) {
    final JFrame frame = new JFrame("Testing AddPersonDialog");
    JButton button = new JButton("Click me");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            FamilyTree tree = new FamilyTree();
            AddPersonDialog dialog = new AddPersonDialog(frame, tree);
            dialog.pack();
            dialog.setLocationRelativeTo(frame);
            dialog.setVisible(true);

            Person newPerson = dialog.getPerson();
            if (newPerson != null) {
              tree.addPerson(newPerson);
              PrettyPrinter pretty = new PrettyPrinter(new PrintWriter(System.out, true));
              pretty.dump(tree);
            }
          }
        });
    frame.getContentPane().add(button);

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(1);
          }
        });
    frame.pack();
    frame.setVisible(true);
  }
  /** EdiDialog constructor comment. */
  public static void test() {
    JFrame frame = new JFrame();
    frame.addWindowListener(new CloseSaveWindowsListener());
    frame.setBackground(ConfigurableSystemSettings.backgroundColor.getAWTColor());
    frame.getContentPane().setLayout(new java.awt.BorderLayout());
    frame.setBounds(50, 50, 400, 400);
    frame.show();

    DialogNewElement dialog = new DialogNewElement(frame);
    dialog.show();
  }
Пример #4
0
  /** Create the entire GUI from scratch */
  private void createGUI() {

    clientFrame = new JFrame("LeetFTP");

    // Allow program to exit gracefully

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

    createTabs();
    createMenu();

    // Top Options Bar
    connectButton = new JButton("Connect");
    connectButton.addMouseListener(mouseHandler);

    optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));

    optionPanel.add(connectButton);
    optionPanel.add(new JLabel("Name Server Hostname"));
    optionPanel.add(serverTextField);
    optionPanel.add(new JLabel("Port #"));
    optionPanel.add(portTextField);
    optionPanel.add(new JLabel("UserName"));
    optionPanel.add(nameTextField);

    // Bottom Transfer Table

    transferTable = new JTable();
    transferPanel = new JPanel(new BorderLayout());
    transferPanel.add(new JLabel("Current Transfers:"), BorderLayout.NORTH);
    transferPanel.add(transferTable);

    // Make the tab pane the GUI pane
    clientFrame.getContentPane().setLayout(new BorderLayout());
    clientFrame.getContentPane().add(mainPanel);
    clientFrame.getContentPane().add(optionPanel, BorderLayout.NORTH);
    clientFrame.getContentPane().add(transferPanel, BorderLayout.SOUTH);

    // Set Client Window Properties
    clientFrame.setSize(800, 600);
    // clientFrame.setResizable(false);
    clientFrame.setLocationRelativeTo(null);
    clientFrame.setVisible(true);
  }
 /** Creates the JFrame that will contain everything. */
 protected JFrame createFrame() {
   JFrame retFrame = new JFrame("TreeTable III -- " + path);
   Dimension dimension = new Dimension(600, 400);
   retFrame.setSize(600, 600);
   retFrame.setMinimumSize(dimension);
   retFrame.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
           frame.dispose();
           if (--ttCount == 0) {
             System.exit(0);
           }
         }
       });
   return retFrame;
 }
Пример #6
0
  private void showVideo() throws IOException {
    if (videoFrame == null) {
      videoFrame = new JFrame("Remote Car Video");
      video = new VideoPanel(car.getIp(), car.getCameraPort());
      videoFrame.getContentPane().add(video);
      videoFrame.setResizable(false);
      videoFrame.addWindowListener(
          new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
              System.out.println("closing");
              super.windowClosed(e);
              video.disconnect();
              btnCamera.setSelected(false);
            }

            @Override
            public void windowOpened(WindowEvent e) {
              System.out.println("opened");
              super.windowOpened(e);
              try {
                video.connect();
              } catch (MalformedURLException e1) {
                e1.printStackTrace();
              }
              video.play();
            }

            @Override
            public void windowActivated(WindowEvent e) {
              video.play();
            }

            @Override
            public void windowIconified(WindowEvent e) {
              video.pause();
            }
          });
    }
    Point location = this.getLocation();
    Dimension dim = this.getSize();
    videoFrame.setLocation(location.x + dim.width + 2, location.y);
    videoFrame.setVisible(true);
    videoFrame.pack();
    sendCommand(Command.TOGGLE_CAMERA);
  }
Пример #7
0
 public BSInterface() {
   mainFrame.setSize(960, 720);
   mainFrame.setResizable(false);
   mainFrame.setIconImage(Toolkit.getDefaultToolkit().createImage("pic/ticket_16.png"));
   Container contentPane = mainFrame.getContentPane();
   contentPane.setLayout(new BorderLayout());
   contentPane.add(toolPanel, BorderLayout.NORTH);
   contentPane.add(operPanel, BorderLayout.CENTER);
   mainFrame.setContentPane(contentPane);
   mainFrame.setVisible(true);
   mainFrame.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
           // device_close();
           System.exit(0);
         }
       });
 }
 public static void main(String s[]) {
   if (s.length > 0) j2kfilename = s[0];
   else j2kfilename = "girl";
   System.out.println(j2kfilename);
   isApplet = false;
   JFrame f = new JFrame("ImageViewer");
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   JApplet applet = new ImageViewer();
   f.getContentPane().add("Center", applet);
   applet.init();
   f.pack();
   f.setSize(new Dimension(550, 550));
   f.show();
 }
Пример #9
0
  public void startGui() {
    JTerminalListener listener = new JTerminalListener();

    jFrame = new JFrame("Glowstone");
    jTerminal = new JTerminal();
    jInput =
        new JTextField(80) {
          @Override
          public void setBorder(Border border) {}
        };
    jInput.paint(null);
    jInput.setFont(new Font("Monospaced", Font.PLAIN, 12));
    jInput.setBackground(Color.BLACK);
    jInput.setForeground(Color.WHITE);
    jInput.setMargin(new Insets(0, 0, 0, 0));
    jInput.addKeyListener(listener);

    JLabel caret = new JLabel("> ");
    caret.setFont(new Font("Monospaced", Font.PLAIN, 12));
    caret.setForeground(Color.WHITE);

    JPanel ipanel = new JPanel();
    ipanel.add(caret, BorderLayout.WEST);
    ipanel.add(jInput, BorderLayout.EAST);
    ipanel.setBorder(BorderFactory.createEmptyBorder());
    ipanel.setBackground(Color.BLACK);
    ipanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    ipanel.setSize(jTerminal.getWidth(), ipanel.getHeight());

    jFrame.getContentPane().add(jTerminal, BorderLayout.NORTH);
    jFrame.getContentPane().add(ipanel, BorderLayout.SOUTH);
    jFrame.addWindowListener(listener);
    jFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    jFrame.setLocationRelativeTo(null);
    jFrame.pack();
    jFrame.setVisible(true);

    sender = new ColoredCommandSender();
    logger.removeHandler(consoleHandler);
    logger.addHandler(
        new StreamHandler(new TerminalOutputStream(), new DateOutputFormatter(CONSOLE_DATE)));
  }
Пример #10
0
  public Animation() {
    String[] keys = {"no Animator found"};
    if (tryDir(".")) // || tryDir("BLM305") || tryDir("CSE470"))
    keys = map.keySet().toArray(keys);
    System.out.println(map.size() + " classes loaded");
    menu = new JComboBox(keys);

    pan.setLayout(new BorderLayout(GAP, GAP - 4));
    pan.setBorder(new javax.swing.border.EmptyBorder(GAP, GAP, GAP, GAP));
    pan.setBackground(COLOR);

    last = new JPanel();
    last.setPreferredSize(DIM);
    pan.add(last, "Center");

    ref.setFont(NORM);
    ref.setEditable(false);
    ref.setColumns(35);
    ref.setDragEnabled(true);
    pan.add(ref, "North");

    pan.add(bottomPanel(), "South");

    pan.setToolTipText("A collective project for BLM320");
    menu.setToolTipText("Animator classes");
    who.setToolTipText("author()");
    ref.setToolTipText("description()");

    Closer ear = new Closer();
    menu.addActionListener(ear);
    stop.addActionListener(ear);
    frm.addWindowListener(ear);

    if (map.size() > 0) setItem(0);
    frm.setContentPane(pan);
    frm.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frm.setLocation(scaled(120), scaled(90));
    frm.pack(); // setSize() is called here
    frm.setVisible(true);
    start();
  }
Пример #11
0
  JFrame openMonitorGUI(String title) {
    try {
      MonitorGUI gui = new MonitorGUI(this, title);

      JFrame frame = new JFrame(title);
      frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      frame.addWindowListener(this);
      frame.getContentPane().add(gui);

      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      Rectangle r = ge.getMaximumWindowBounds();
      frame.setSize(400, 200);
      frame.setLocationRelativeTo(null);
      frame.pack();
      frame.setVisible(true);
      return frame;
    } catch (Exception e) {
      System.out.println("9\b" + getClass().getName() + "\n\t" + e);
      return null;
    }
  }
Пример #12
0
  public static void main(String args[]) throws Exception {

    JFrame ventana = new JFrame("Image");
    // int k=5;
    String n;
    int c[] = new int[9];

    n = "C:\\BORLANDC\\BIN\\CIMG1098.jpg";

    // n[1]="C:\\BORLANDC\\BIN\\sd";

    ventana.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            System.exit(0);
          }
        });
    ventana.getContentPane().add(new erosion(n), BorderLayout.CENTER);

    ventana.setSize(1000, 1000);

    ventana.setVisible(true);

    /*  ventana.addWindowListener( new WindowAdapter() {
         public void windowClosing( WindowEvent evt ){
    System.exit( 0 );
         }
       } );
       ventana.getContentPane().add( new GetImage(),BorderLayout.CENTER );
       ventana.setSize( 500,500 );

       ventana.setVisible( true );

    /*
    GetImage image = new GetImage();
       image.setSize(400, 340);
       image.setVisible(true);
       image.setLocation(200, 100);*/
  }
  // If the applet is called as an application
  public static void main(String[] args) {

    // Create the frame
    mainFrame = new JFrame("Uintah User Interface");

    // Add a window listener
    mainFrame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    // instantiate
    UintahGui uintahGui = new UintahGui();
    uintahGui.init();

    // Add the stuff to the frame
    mainFrame.setLocation(20, 50);
    mainFrame.setContentPane(uintahGui);
    mainFrame.pack();
    mainFrame.setVisible(true);
  }
Пример #14
0
  public static void main(String args[]) throws HTTPException {

    // prefs storage
    try {
      String prefStore =
          ucar.util.prefs.XMLStore.makeStandardFilename(".unidata", "TdsMonitor.xml");
      store = ucar.util.prefs.XMLStore.createFromFile(prefStore, null);
      prefs = store.getPreferences();
      Debug.setStore(prefs.node("Debug"));
    } catch (IOException e) {
      System.out.println("XMLStore Creation failed " + e);
    }

    // initializations
    BAMutil.setResourcePath("/resources/nj22/ui/icons/");

    // put UI in a JFrame
    frame = new JFrame("TDS Monitor");
    ui = new TdsMonitor(prefs, frame);

    frame.setIconImage(BAMutil.getImage("netcdfUI"));
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            if (!done) ui.exit();
          }
        });

    frame.getContentPane().add(ui);
    Rectangle bounds = (Rectangle) prefs.getBean(FRAME_SIZE, new Rectangle(50, 50, 800, 450));
    frame.setBounds(bounds);

    frame.pack();
    frame.setBounds(bounds);
    frame.setVisible(true);
  }
Пример #15
0
  /** Creates the debug process, which is a GUI window that displays XML traffic. */
  private void createDebug() {
    frame =
        new JFrame(
            "Smack Debug Window -- " + connection.getServiceName() + ":" + connection.getPort());

    // Add listener for window closing event
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            rootWindowClosing(evt);
          }
        });

    // We'll arrange the UI into four tabs. The first tab contains all data, the second
    // client generated XML, the third server generated XML, and the fourth is packet
    // data from the server as seen by Smack.
    JTabbedPane tabbedPane = new JTabbedPane();

    JPanel allPane = new JPanel();
    allPane.setLayout(new GridLayout(3, 1));
    tabbedPane.add("All", allPane);

    // Create UI elements for client generated XML traffic.
    final JTextArea sentText1 = new JTextArea();
    final JTextArea sentText2 = new JTextArea();
    sentText1.setEditable(false);
    sentText2.setEditable(false);
    sentText1.setForeground(new Color(112, 3, 3));
    sentText2.setForeground(new Color(112, 3, 3));
    allPane.add(new JScrollPane(sentText1));
    tabbedPane.add("Sent", new JScrollPane(sentText2));

    // Add pop-up menu.
    JPopupMenu menu = new JPopupMenu();
    JMenuItem menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(sentText1.getText()), null);
          }
        });

    JMenuItem menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            sentText1.setText("");
            sentText2.setText("");
          }
        });

    // Add listener to the text area so the popup menu can come up.
    MouseListener popupListener = new PopupListener(menu);
    sentText1.addMouseListener(popupListener);
    sentText2.addMouseListener(popupListener);
    menu.add(menuItem1);
    menu.add(menuItem2);

    // Create UI elements for server generated XML traffic.
    final JTextArea receivedText1 = new JTextArea();
    final JTextArea receivedText2 = new JTextArea();
    receivedText1.setEditable(false);
    receivedText2.setEditable(false);
    receivedText1.setForeground(new Color(6, 76, 133));
    receivedText2.setForeground(new Color(6, 76, 133));
    allPane.add(new JScrollPane(receivedText1));
    tabbedPane.add("Received", new JScrollPane(receivedText2));

    // Add pop-up menu.
    menu = new JPopupMenu();
    menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(receivedText1.getText()), null);
          }
        });

    menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            receivedText1.setText("");
            receivedText2.setText("");
          }
        });

    // Add listener to the text area so the popup menu can come up.
    popupListener = new PopupListener(menu);
    receivedText1.addMouseListener(popupListener);
    receivedText2.addMouseListener(popupListener);
    menu.add(menuItem1);
    menu.add(menuItem2);

    // Create UI elements for interpreted XML traffic.
    final JTextArea interpretedText1 = new JTextArea();
    final JTextArea interpretedText2 = new JTextArea();
    interpretedText1.setEditable(false);
    interpretedText2.setEditable(false);
    interpretedText1.setForeground(new Color(1, 94, 35));
    interpretedText2.setForeground(new Color(1, 94, 35));
    allPane.add(new JScrollPane(interpretedText1));
    tabbedPane.add("Interpreted", new JScrollPane(interpretedText2));

    // Add pop-up menu.
    menu = new JPopupMenu();
    menuItem1 = new JMenuItem("Copy");
    menuItem1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Get the clipboard
            Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            // Set the sent text as the new content of the clipboard
            clipboard.setContents(new StringSelection(interpretedText1.getText()), null);
          }
        });

    menuItem2 = new JMenuItem("Clear");
    menuItem2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            interpretedText1.setText("");
            interpretedText2.setText("");
          }
        });

    // Add listener to the text area so the popup menu can come up.
    popupListener = new PopupListener(menu);
    interpretedText1.addMouseListener(popupListener);
    interpretedText2.addMouseListener(popupListener);
    menu.add(menuItem1);
    menu.add(menuItem2);

    frame.getContentPane().add(tabbedPane);

    frame.setSize(550, 400);
    frame.setVisible(true);

    // Create a special Reader that wraps the main Reader and logs data to the GUI.
    ObservableReader debugReader = new ObservableReader(reader);
    readerListener =
        new ReaderListener() {
          public void read(String str) {
            int index = str.lastIndexOf(">");
            if (index != -1) {
              receivedText1.append(str.substring(0, index + 1));
              receivedText2.append(str.substring(0, index + 1));
              receivedText1.append(NEWLINE);
              receivedText2.append(NEWLINE);
              if (str.length() > index) {
                receivedText1.append(str.substring(index + 1));
                receivedText2.append(str.substring(index + 1));
              }
            } else {
              receivedText1.append(str);
              receivedText2.append(str);
            }
          }
        };
    debugReader.addReaderListener(readerListener);

    // Create a special Writer that wraps the main Writer and logs data to the GUI.
    ObservableWriter debugWriter = new ObservableWriter(writer);
    writerListener =
        new WriterListener() {
          public void write(String str) {
            sentText1.append(str);
            sentText2.append(str);
            if (str.endsWith(">")) {
              sentText1.append(NEWLINE);
              sentText2.append(NEWLINE);
            }
          }
        };
    debugWriter.addWriterListener(writerListener);

    // Assign the reader/writer objects to use the debug versions. The packet reader
    // and writer will use the debug versions when they are created.
    reader = debugReader;
    writer = debugWriter;

    // Create a thread that will listen for all incoming packets and write them to
    // the GUI. This is what we call "interpreted" packet data, since it's the packet
    // data as Smack sees it and not as it's coming in as raw XML.
    listener =
        new PacketListener() {
          public void processPacket(Packet packet) {
            interpretedText1.append(packet.toXML());
            interpretedText2.append(packet.toXML());
            interpretedText1.append(NEWLINE);
            interpretedText2.append(NEWLINE);
          }
        };
  }
Пример #16
0
  public static void main(String[] args) throws IOException {
    ServerSocket s = new ServerSocket(PORT);
    System.out.println("Started: " + s);
    frame.setPreferredSize(new Dimension(400, 400));
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    JMenuBar one = new JMenuBar();
    JMenu second = new JMenu("OPTIONS");
    //	JMenuItem third = new JMenuItem("NEW GAME");
    JMenuItem fourth = new JMenuItem("EXIT");
    fourth.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            try {
              exit(evt);
            } catch (IOException e) {
            }
          }
        });
    // second.add(third);
    second.add(fourth);
    one.add(second);
    frame.setJMenuBar(one);
    frame.setLayout(new java.awt.GridLayout(3, 3));
    button = new JButton[10];
    for (int i = 1; i < 10; i++) {
      button[i] = new JButton();
      button[i].setBackground(Color.lightGray);
      button[i].setActionCommand(Integer.toString(i));
      button[i].addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              print(evt.getActionCommand());
              try {
                func(socket, evt.getActionCommand());
                String check = win();
                finalresult(check);
                if (check != "") {
                  func(socket, check);
                } else {
                  func(socket, evt.getActionCommand());
                }
                ;
              } catch (IOException e) {
              }
            }
          });
      frame.add(button[i]);
    }

    try {
      socket = s.accept();
      frame.pack();
      frame.setVisible(true);
      try {
        System.out.println("Connection accepted: " + socket);
        BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        /*  while(true)
        {
        String str=in.readLine();
        print2(str);
        }*/
        while (true) {
          String str = in.readLine();
          if (str.equals("exit")) {
            System.exit(0);
          }
          if (str.equals("tie")) {
            JOptionPane.showMessageDialog(null, "It is a tie between the two");
            System.exit(0);
          } else {

            if (str.equals("winserver")) {
              System.out.println("server has won");
              JOptionPane.showMessageDialog(null, "the server has won the game");
              System.exit(0);
            } else {
              if (str.equals("winclient")) {
                JOptionPane.showMessageDialog(null, "the client has won the game");
                System.exit(0);
              } else {
                System.out.println(str);
                print2(str);
              }
            }
          }
        }
      } catch (Exception e) {
      } // finally {socket.close();
      // }
    } catch (Exception e) {
    } // finally {s.close();
    // }
  }
Пример #17
0
  static void buildGUI() {
    // Need this size to balance axes.
    frame.setSize(520, 690);
    frame.setTitle("DrawTool");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    Container cPane = frame.getContentPane();

    // Status label on top. Unused for now.
    statusLabel.setOpaque(true);
    statusLabel.setBackground(Color.white);
    cPane.add(statusLabel, BorderLayout.NORTH);

    // Build the input/output elements at the bottom.
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createLineBorder(Color.black));
    panel.setBackground(inputPanelColor);
    panel.setLayout(new GridLayout(2, 1));
    panel.add(outputLabel);
    JPanel bottomPanel = new JPanel();
    bottomPanel.setBackground(inputPanelColor);
    bottomPanel.add(inputField);
    bottomPanel.add(new JLabel("   "));
    JButton enterButton = new JButton("Enter");
    enterButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent a) {
            hasEntered = true;
          }
        });
    bottomPanel.add(enterButton);
    panel.add(bottomPanel);
    if (!sequencingOn) {
      cPane.add(panel, BorderLayout.SOUTH);
    }

    // Drawing in the center.
    drawArea = new DrawTool();
    if (sequencingOn) {
      frame.addKeyListener(
          new KeyAdapter() {
            public void keyTyped(KeyEvent e) {
              handleKeyTyped(e);
            }
          });
    }
    cPane.add(drawArea, BorderLayout.CENTER);

    drawArea.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            handleMouseClick(e);
          }

          public void mouseReleased(MouseEvent e) {
            handleMouseReleased(e);
          }
        });

    drawArea.addMouseMotionListener(
        new MouseMotionAdapter() {
          public void mouseDragged(MouseEvent e) {
            handleMouseDragged(e);
          }
        });
  }
Пример #18
0
  /* Build up the GUI using Swing magic. Nothing very exciting here - the
  BagPanel class makes the code a bit cleaner/easier to read. */
  private void guiInit() throws Exception {
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setMinimumSize(new Dimension(500, 250));
    mainPanel.setPreferredSize(new Dimension(500, 300));

    /* The message area */
    JScrollPane mssgPanel = new JScrollPane();
    mssgPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    mssgPanel.setAutoscrolls(true);
    mssgArea = new JTextArea();
    mssgArea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 20));
    mainPanel.add(mssgPanel, BorderLayout.CENTER);
    mssgPanel.getViewport().add(mssgArea, null);

    /* The button area */
    BagPanel buttonPanel = new BagPanel();
    GridBagConstraints c = buttonPanel.c;

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = GridBagConstraints.REMAINDER;

    buttonPanel.makeLabel("Detection", JLabel.CENTER);
    c.gridwidth = GridBagConstraints.RELATIVE;
    detDarkCb = buttonPanel.makeCheckBox("Dark", true);
    c.gridwidth = GridBagConstraints.REMAINDER;
    detAccelCb = buttonPanel.makeCheckBox("Movement", false);
    buttonPanel.makeSeparator(SwingConstants.HORIZONTAL);

    buttonPanel.makeLabel("Theft Reports", JLabel.CENTER);
    c.gridwidth = GridBagConstraints.RELATIVE;
    repLedCb = buttonPanel.makeCheckBox("LED", true);
    c.gridwidth = GridBagConstraints.REMAINDER;
    repSirenCb = buttonPanel.makeCheckBox("Siren", false);
    c.gridwidth = GridBagConstraints.RELATIVE;
    repServerCb = buttonPanel.makeCheckBox("Server", false);
    c.gridwidth = GridBagConstraints.REMAINDER;
    repNeighboursCb = buttonPanel.makeCheckBox("Neighbours", false);
    buttonPanel.makeSeparator(SwingConstants.HORIZONTAL);

    buttonPanel.makeLabel("Interval", JLabel.CENTER);
    fieldInterval = buttonPanel.makeTextField(10, null);
    fieldInterval.setText(Integer.toString(Constants.DEFAULT_CHECK_INTERVAL));

    ActionListener settingsAction =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateSettings();
          }
        };
    buttonPanel.makeButton("Update", settingsAction);

    mainPanel.add(buttonPanel, BorderLayout.EAST);

    /* The frame part */
    frame = new JFrame("AntiTheft");
    frame.setSize(mainPanel.getPreferredSize());
    frame.getContentPane().add(mainPanel);
    frame.setVisible(true);
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }
Пример #19
0
  public GUI() {
    // ===============================================loads data from savefiles (textfiles)
    Classes.LoadData();
    // =========================================== resets the arrayIndexes array so that the the GUI
    // will first show the records according to IDNumber
    Classes.resetArrayIndexes();
    // =========================================== Redeclaring GUI Components (this is part of GUI
    // Syntax for some reason)
    // =========================================== This also gives text to those GUI Components
    search = new JButton("search");
    clearSearchParameters = new JButton("clear Parameters");
    help = new JButton("Help");
    resetDatabase = new JButton("Reset Database");
    messageToUser = new JLabel("");
    emptyLabel = new JLabel[3];
    newRecordButton = new JButton(" New Record");
    editRecordButton = new JButton(" Edit Record");
    deleteRecordButton = new JButton("Delete Record");

    searchTextfield = new JTextField[7];
    fieldNames = new JButton[7];
    textfield = new JTextField[6][100];
    indexes = new JLabel[100];
    RecordsFieldButtons = new JPanel();
    scrollPane = new JScrollPane();

    emptyLabel[0] = new JLabel("");
    emptyLabel[1] = new JLabel("");
    emptyLabel[2] = new JLabel("");
    fieldNames[0] = new JButton("ID#");
    fieldNames[1] = new JButton("Movie Name");
    fieldNames[2] = new JButton("Movie Length");
    fieldNames[3] = new JButton("Movie Director");
    fieldNames[4] = new JButton("Movie Rating");
    fieldNames[5] = new JButton("Movie Release Year");
    fieldNames[6] = new JButton("Movie Review" + "Rating");
    // =========================================== All the searchTextfields will be preset to the
    // text "enter Search Parameter"
    for (int x = 0; x < 7; x++) {
      searchTextfield[x] = new JTextField("enter Search Parameter");
    }
    // =========================================== This for loop attaches the correct array value to
    // the GUI Components
    for (int x = 0; x < 7; x++) {
      for (int y = 0; y < 100; y++) {
        switch (x) {
          case 0:
            // =============================== This checks if the value of IDNumber[xxx] is blank
            // (which is noted by a -1)
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if (IDNumber[arrayIndexes[y]] == -1) {
              indexes[y] = new JLabel("");
            } else {
              indexes[y] = new JLabel(Integer.toString(IDNumber[arrayIndexes[y]]));
            }
            break;
          case 1:
            // =============================== This checks if the value of movieName[xxx] is blank
            // (which is noted by a "null")
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if (movieName[arrayIndexes[y]].equals("null") == true) {
              textfield[x - 1][y] = new JTextField("");
            } else {
              textfield[x - 1][y] = new JTextField(movieName[arrayIndexes[y]]);
            }
            break;
          case 2:
            // =============================== This checks if the value of movieLength[xxx] is blank
            // (which is noted by a -1)
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if (movieLength[arrayIndexes[y]] == -1) {
              textfield[x - 1][y] = new JTextField("");
            } else {
              textfield[x - 1][y] =
                  new JTextField(Integer.toString(movieLength[arrayIndexes[y]]) + " minutes");
            }
            break;
          case 3:
            // =============================== This checks if the value of movieDirector[xxx] is
            // blank (which is noted by a "null")
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if (movieDirector[arrayIndexes[y]].equals("null") == true) {
              textfield[x - 1][y] = new JTextField("");
            } else {
              textfield[x - 1][y] = new JTextField(movieDirector[arrayIndexes[y]]);
            }
            break;
          case 4:
            // =============================== This checks if the value of movieRating[xxx] is blank
            // (which is noted by a "null") or if it is unavailable "N/A"
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if ((movieRating[arrayIndexes[y]].equals("null") == true)
                || (movieRating[arrayIndexes[y]].equals("N/A") == true)) {
              textfield[x - 1][y] = new JTextField("");
            } else {
              textfield[x - 1][y] = new JTextField(movieRating[arrayIndexes[y]]);
            }
            break;
          case 5:
            // =============================== This checks if the value of movieReleaseYear[xxx] is
            // blank (which is noted by a -1)
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if (movieReleaseYear[arrayIndexes[y]] == -1) {
              textfield[x - 1][y] = new JTextField("");
            } else {
              textfield[x - 1][y] =
                  new JTextField(Integer.toString(movieReleaseYear[arrayIndexes[y]]));
            }
            break;
          case 6:
            // =============================== This checks if the value of movieReviewRating[xxx] is
            // blank (which is noted by a -0.1)
            // =============================== If it is, then it will set the text of its
            // corresponding Textfield to blank
            if (movieReviewRating[arrayIndexes[y]] == -0.1) {
              textfield[x - 1][y] = new JTextField("");
            } else {
              textfield[x - 1][y] =
                  new JTextField(Double.toString(movieReviewRating[arrayIndexes[y]]));
            }
            break;
        }
        // =============================== This disables the ability for the all the textfields to
        // be edited.
        if ((x <= 6) && (x >= 1)) {
          textfield[x - 1][y].setEditable(false);
        }
      }
    }
    // ======================================= Makes the layout of the panel (gridlayout)
    RecordsFieldButtons.setLayout(new GridLayout(103, 7));
    // ======================================= adds the GUI components to the GUI
    RecordsFieldButtons.add(newRecordButton);
    RecordsFieldButtons.add(editRecordButton);
    RecordsFieldButtons.add(deleteRecordButton);
    // RecordsFieldButtons.add(messageToUser);
    // RecordsFieldButtons.add(emptyLabel[0]);
    // RecordsFieldButtons.add(emptyLabel[1]);
    // RecordsFieldButtons.add(emptyLabel[2]);
    RecordsFieldButtons.add(search);
    RecordsFieldButtons.add(clearSearchParameters);
    RecordsFieldButtons.add(resetDatabase);
    RecordsFieldButtons.add(help);

    // ======================================= places the searchTextfield onto the GUI
    for (int x = 0; x < 7; x++) {
      RecordsFieldButtons.add(searchTextfield[x]);
    }
    // ======================================= places the fieldnames onto the GUI. (the fieldnames
    // are also the buttons for sort)
    for (int x = 0; x < 7; x++) {
      // fieldNames[x].setLineWrap(true);
      RecordsFieldButtons.add(fieldNames[x]);
    }
    // ======================================= places the rest of the array values( textfields) onto
    // the GUI
    for (int y = 0; y < 100; y++) {
      for (int x = 0; x < 7; x++) {
        if (x == 0) {
          RecordsFieldButtons.add(indexes[y]);
        } else {
          RecordsFieldButtons.add(textfield[x - 1][y]);
        }
      }
    }
    // ======================================= changes the color of the fields names to orange
    // ======================================= the point of this is to give a separation between the
    // arrayvalues and the function buttons
    for (int i = 0; i < 7; i++) {
      fieldNames[i].setBackground(Color.ORANGE);
    }
    // ======================================= adds actions to all the GUI Components( if any)
    fieldNames[0].addActionListener(new whenUserClickIDNumberButton());
    fieldNames[1].addActionListener(new whenUserClickMovieNameButton());
    fieldNames[2].addActionListener(new whenUserClickMovieLengthButton());
    fieldNames[3].addActionListener(new whenUserClickMovieDirectorButton());
    fieldNames[4].addActionListener(new whenUserClickMovieRatingButton());
    fieldNames[5].addActionListener(new whenUserClickMovieReleaseYearButton());
    fieldNames[6].addActionListener(new whenUserClickMovieReviewButton());
    search.addActionListener(new whenUserClickSearchButton());
    clearSearchParameters.addActionListener(new whenUserClickClearParametersButton());
    help.addActionListener(new helpFunction());
    resetDatabase.addActionListener(new whenUserClicksResetDatabse());
    newRecordButton.addActionListener(new whenUserClicksNewButton());
    editRecordButton.addActionListener(new whenUserClicksEditButton());
    deleteRecordButton.addActionListener(new whenUserClicksDeleteButton());
    JFrame frame = new JFrame("Movie Database");
    frame.addWindowListener(new whenUserClicksXOnTheCornerOfWindow());
    frame.setResizable(true);
    frame.add(new JScrollPane(RecordsFieldButtons));
    frame.setSize(100, 100);
    frame.setVisible(true);
    frame.pack();
  }
Пример #20
0
  public Ssys3() {
    store = new Storage();
    tableSorter = new TableRowSorter<Storage>(store);
    jobs = new LinkedList<String>();

    makeGUI();
    frm.setSize(800, 600);
    frm.addWindowListener(
        new WindowListener() {
          public void windowActivated(WindowEvent evt) {}

          public void windowClosed(WindowEvent evt) {
            try {
              System.out.println("joining EDT's");
              for (EDT edt : encryptDecryptThreads) {
                edt.weakStop();
                try {
                  edt.join();
                  System.out.println("  - joined");
                } catch (InterruptedException e) {
                  System.out.println("  - Not joined");
                }
              }
              System.out.println("saving storage");
              store.saveAll(tempLoc);
            } catch (IOException e) {
              e.printStackTrace();
              System.err.println(
                  "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\nFailed to save properly\n\n!!!!!!!!!!!!!!!!!!!!!!!!!");
              System.exit(1);
            }
            clean();
            System.exit(0);
          }

          public void windowClosing(WindowEvent evt) {
            windowClosed(evt);
          }

          public void windowDeactivated(WindowEvent evt) {}

          public void windowDeiconified(WindowEvent evt) {}

          public void windowIconified(WindowEvent evt) {}

          public void windowOpened(WindowEvent evt) {}
        });
    ImageIcon ico = new ImageIcon(ICON_NAME);
    frm.setIconImage(ico.getImage());
    frm.setLocationRelativeTo(null);
    frm.setVisible(true);

    // load config
    storeLocs = new ArrayList<File>();
    String ossl = "openssl";
    int numThreadTemp = 2;
    boolean priorityDecryptTemp = true;
    boolean allowExportTemp = false;
    boolean checkImportTemp = true;
    try {
      Scanner sca = new Scanner(CONF_FILE);
      while (sca.hasNextLine()) {
        String ln = sca.nextLine();
        if (ln.startsWith(CONF_SSL)) {
          ossl = ln.substring(CONF_SSL.length());
        } else if (ln.startsWith(CONF_THREAD)) {
          try {
            numThreadTemp = Integer.parseInt(ln.substring(CONF_THREAD.length()));
          } catch (Exception exc) {
            // do Nothing
          }
        } else if (ln.equals(CONF_STORE)) {
          while (sca.hasNextLine()) storeLocs.add(new File(sca.nextLine()));
        } else if (ln.startsWith(CONF_PRIORITY)) {
          try {
            priorityDecryptTemp = Boolean.parseBoolean(ln.substring(CONF_PRIORITY.length()));
          } catch (Exception exc) {
            // do Nothing
          }
        } else if (ln.startsWith(CONF_EXPORT)) {
          try {
            allowExportTemp = Boolean.parseBoolean(ln.substring(CONF_EXPORT.length()));
          } catch (Exception exc) {
            // do Nothing
          }
        } else if (ln.startsWith(CONF_CONFIRM)) {
          try {
            checkImportTemp = Boolean.parseBoolean(ln.substring(CONF_CONFIRM.length()));
          } catch (Exception exc) {
            // do Nothing
          }
        }
      }
      sca.close();
    } catch (IOException e) {

    }
    String osslWorks = OpenSSLCommander.test(ossl);
    while (osslWorks == null) {
      ossl =
          JOptionPane.showInputDialog(
              frm,
              "Please input the command used to run open ssl\n  We will run \"<command> version\" to confirm\n  Previous command: "
                  + ossl,
              "Find open ssl",
              JOptionPane.OK_CANCEL_OPTION);
      if (ossl == null) {
        System.err.println("Refused to provide openssl executable location");
        System.exit(1);
      }
      osslWorks = OpenSSLCommander.test(ossl);
      if (osslWorks == null)
        JOptionPane.showMessageDialog(
            frm, "Command " + ossl + " unsuccessful", "Unsuccessful", JOptionPane.ERROR_MESSAGE);
    }
    if (storeLocs.size() < 1)
      JOptionPane.showMessageDialog(
          frm,
          "Please select an initial sotrage location\nIf one already exists, or there are more than one, please select it");
    while (storeLocs.size() < 1) {
      JFileChooser jfc = new JFileChooser();
      jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      if (jfc.showOpenDialog(frm) != JFileChooser.APPROVE_OPTION) {
        System.err.println("Refused to provide an initial store folder");
        System.exit(1);
      }
      File sel = jfc.getSelectedFile();
      if (sel.isDirectory()) storeLocs.add(sel);
    }
    numThreads = numThreadTemp;
    priorityExport = priorityDecryptTemp;
    allowExport = allowExportTemp;
    checkImports = checkImportTemp;

    try {
      PrintWriter pw = new PrintWriter(CONF_FILE);
      pw.println(CONF_SSL + ossl);
      pw.println(CONF_THREAD + numThreads);
      pw.println(CONF_PRIORITY + priorityExport);
      pw.println(CONF_EXPORT + allowExport);
      pw.println(CONF_CONFIRM + checkImports);
      pw.println(CONF_STORE);
      for (File fi : storeLocs) {
        pw.println(fi.getAbsolutePath());
      }
      pw.close();
    } catch (IOException e) {
      System.err.println("Failed to save config");
    }

    File chk = null;
    for (File fi : storeLocs) {
      File lib = new File(fi, LIBRARY_NAME);
      if (lib.exists()) {
        chk = lib;
        // break;
      }
    }

    char[] pass = null;
    if (chk == null) {
      JOptionPane.showMessageDialog(
          frm,
          "First time run\n  Create your password",
          "Create Password",
          JOptionPane.INFORMATION_MESSAGE);
      char[] p1 = askPassword();
      char[] p2 = askPassword();
      boolean same = p1.length == p2.length;
      for (int i = 0; i < Math.min(p1.length, p2.length); i++) {
        if (p1[i] != p2[i]) same = false;
      }
      if (same) {
        JOptionPane.showMessageDialog(
            frm, "Password created", "Create Password", JOptionPane.INFORMATION_MESSAGE);
        pass = p1;
      } else {
        JOptionPane.showMessageDialog(
            frm, "Passwords dont match", "Create Password", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
      }
    } else {
      pass = askPassword();
    }
    sec = OpenSSLCommander.getCommander(chk, pass, ossl);
    if (sec == null) {
      System.err.println("Wrong Password");
      System.exit(1);
    }
    store.useSecurity(sec);
    store.useStorage(storeLocs);

    tempLoc = new File("temp");
    if (!tempLoc.exists()) tempLoc.mkdirs();
    // load stores
    try {
      store.loadAll(tempLoc);
      store.fireTableDataChanged();
    } catch (IOException e) {
      System.err.println("Storage loading failure");
      System.exit(1);
    }

    needsSave = false;
    encryptDecryptThreads = new EDT[numThreads];
    for (int i = 0; i < encryptDecryptThreads.length; i++) {
      encryptDecryptThreads[i] = new EDT(i);
      encryptDecryptThreads[i].start();
    }

    updateStatus();
    txaSearch.grabFocus();
  }
Пример #21
0
  //
  // Build installer window
  //
  public static void showInstallerWindow() {
    _installerFrame = new JFrame(Config.getWindowTitle());

    Container cont = _installerFrame.getContentPane();
    cont.setLayout(new BorderLayout());

    // North pane
    Box topPane = new Box(BoxLayout.X_AXIS);
    JLabel title = new JLabel(Config.getWindowHeading());
    Font titleFont = new Font("SansSerif", Font.BOLD, 22);
    title.setFont(titleFont);
    title.setForeground(Color.black);

    // Create Sun logo
    URL urlLogo = Main.class.getResource(Config.getWindowLogo());
    Image img = Toolkit.getDefaultToolkit().getImage(urlLogo);
    MediaTracker md = new MediaTracker(_installerFrame);
    md.addImage(img, 0);
    try {
      md.waitForAll();
    } catch (Exception ioe) {
      Config.trace(ioe.toString());
    }
    if (md.isErrorID(0)) Config.trace("Error loading image");
    Icon sunLogo = new ImageIcon(img);
    JLabel logoLabel = new JLabel(sunLogo);
    logoLabel.setOpaque(true);
    topPane.add(topPane.createHorizontalStrut(5));
    topPane.add(title);
    topPane.add(topPane.createHorizontalGlue());
    topPane.add(logoLabel);
    topPane.add(topPane.createHorizontalStrut(5));

    // West Pane
    Box westPane = new Box(BoxLayout.X_AXIS);
    westPane.add(westPane.createHorizontalStrut(10));

    // South Pane
    Box bottomPane = new Box(BoxLayout.X_AXIS);
    bottomPane.add(bottomPane.createHorizontalGlue());
    JButton abortButton = new JButton(Config.getWindowAbortButton());
    abortButton.setMnemonic(Config.getWindowAbortMnemonic());
    bottomPane.add(abortButton);
    bottomPane.add(bottomPane.createHorizontalGlue());
    bottomPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));

    // Center Pane
    Box centerPane = new Box(BoxLayout.Y_AXIS);
    JLabel hidden = new JLabel(Config.getWindowHiddenLabel());
    hidden.setVisible(false);
    centerPane.add(hidden);
    _stepLabels = new JLabel[5];
    for (int i = 0; i < _stepLabels.length; i++) {
      _stepLabels[i] = new JLabel(Config.getWindowStep(i));
      _stepLabels[i].setEnabled(false);
      centerPane.add(_stepLabels[i]);

      // install label's length will expand,so set a longer size.
      if (i == STEP_INSTALL) {
        Dimension dim = new JLabel(Config.getWindowStepWait(STEP_INSTALL)).getPreferredSize();
        _stepLabels[i].setPreferredSize(dim);
      }
    }
    hidden = new JLabel(Config.getWindowHiddenLabel());
    hidden.setVisible(false);
    centerPane.add(hidden);

    // Setup box layout
    cont.add(topPane, "North");
    cont.add(westPane, "West");
    cont.add(bottomPane, "South");
    cont.add(centerPane, "Center");

    _installerFrame.pack();
    Dimension dim = _installerFrame.getSize();

    // hard code to ensure title is completely visible on Sol/lin.
    if (dim.width < 400) {
      dim.width = 400;
      _installerFrame.setSize(dim);
    }

    Rectangle size = _installerFrame.getBounds();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    size.width = Math.min(screenSize.width, size.width);
    size.height = Math.min(screenSize.height, size.height);
    // Put window at 1/4, 1/4 of screen resoluion
    _installerFrame.setBounds(
        (screenSize.width - size.width) / 4,
        (screenSize.height - size.height) / 4,
        size.width,
        size.height);

    // Setup event listners
    _installerFrame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            installFailed("Window closed", null);
          }
        });

    abortButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            installFailed("Abort pressed", null);
          }
        });

    // Show window
    _installerFrame.show();
  }
Пример #22
0
  /**
   * Inizialize frame components
   *
   * @throws CMSException
   * @throws FileNotFoundException
   * @throws IOException
   * @throws GeneralSecurityException
   */
  private void initComponents()
      throws CMSException, FileNotFoundException, IOException, GeneralSecurityException {

    // *********************************

    panel4 = new JPanel();
    label2 = new JLabel();
    textPane1 = new JTextPane();
    panel5 = new JPanel();
    textArea1 = new JTextArea();
    textArea2 = new JTextArea();

    progressBar = new JProgressBar();

    textPane2 = new JTextPane();
    textField1 = new JTextField();
    button1 = new JButton();
    panel6 = new JPanel();
    button2 = new JButton();
    button3 = new JButton();
    button4 = new JButton();
    GridBagConstraints gbc;
    // ======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());
    ((GridBagLayout) contentPane.getLayout()).columnWidths = new int[] {165, 0, 0};
    ((GridBagLayout) contentPane.getLayout()).rowHeights = new int[] {105, 50, 0};
    ((GridBagLayout) contentPane.getLayout()).columnWeights = new double[] {0.0, 1.0, 1.0E-4};
    ((GridBagLayout) contentPane.getLayout()).rowWeights = new double[] {1.0, 0.0, 1.0E-4};

    // ======== panel4 ========
    {
      panel4.setBackground(Color.white);
      panel4.setLayout(new GridBagLayout());
      ((GridBagLayout) panel4.getLayout()).columnWidths = new int[] {160, 0};
      ((GridBagLayout) panel4.getLayout()).rowHeights = new int[] {0, 0, 0};
      ((GridBagLayout) panel4.getLayout()).columnWeights = new double[] {0.0, 1.0E-4};
      ((GridBagLayout) panel4.getLayout()).rowWeights = new double[] {1.0, 1.0, 1.0E-4};

      // ---- label2 ----
      label2.setIcon(
          new ImageIcon(
              "images" + System.getProperty("file.separator") + "logo-freesigner-piccolo.png"));
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.insets.bottom = 5;
      panel4.add(label2, gbc);

      // ---- textPane1 ----
      textPane1.setFont(new Font("Verdana", Font.BOLD, 12));
      textPane1.setText("Lettura\ncertificati\nda token");
      textPane1.setEditable(false);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 1;
      gbc.anchor = GridBagConstraints.NORTHWEST;
      panel4.add(textPane1, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets.bottom = 5;
    gbc.insets.right = 5;
    contentPane.add(panel4, gbc);

    // ======== panel5 ========
    {
      panel5.setBackground(Color.white);
      panel5.setLayout(new GridBagLayout());
      ((GridBagLayout) panel5.getLayout()).columnWidths = new int[] {0, 205, 0, 0};
      ((GridBagLayout) panel5.getLayout()).rowHeights = new int[] {100, 0, 30, 30, 0};
      ((GridBagLayout) panel5.getLayout()).columnWeights = new double[] {1.0, 0.0, 1.0, 1.0E-4};
      ((GridBagLayout) panel5.getLayout()).rowWeights = new double[] {0.0, 0.0, 1.0, 1.0, 1.0E-4};

      // ---- textArea1 ----
      textArea1.setFont(new Font("Verdana", Font.BOLD, 14));
      textArea1.setText("Lettura certificati da token");
      textArea1.setEditable(false);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.gridwidth = 3;
      gbc.fill = GridBagConstraints.VERTICAL;
      gbc.insets.bottom = 5;
      panel5.add(textArea1, gbc);

      // ---- textArea2 ----
      textArea2.setFont(new Font("Verdana", Font.PLAIN, 12));
      textArea2.setText("Ricerca certificati...\n");
      textArea2.setEditable(false);
      textArea2.setColumns(30);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 1;
      gbc.gridwidth = 3;
      gbc.fill = GridBagConstraints.BOTH;
      panel5.add(textArea2, gbc);
      progressBar.setValue(0);
      progressBar.setMaximum(1);
      progressBar.setStringPainted(true);
      progressBar.setBounds(0, 0, 300, 150);

      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 2;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.insets.bottom = 5;
      gbc.insets.right = 5;
      gbc.gridwidth = 3;
      panel5.add(progressBar, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets.bottom = 5;
    contentPane.add(panel5, gbc);

    // ======== panel6 ========
    {
      panel6.setBackground(Color.white);
      panel6.setLayout(new GridBagLayout());
      ((GridBagLayout) panel6.getLayout()).columnWidths = new int[] {0, 0, 0, 0};
      ((GridBagLayout) panel6.getLayout()).rowHeights = new int[] {0, 0};
      ((GridBagLayout) panel6.getLayout()).columnWeights = new double[] {1.0, 1.0, 1.0, 1.0E-4};
      ((GridBagLayout) panel6.getLayout()).rowWeights = new double[] {1.0, 1.0E-4};

      // ---- button2 ----
      button2.setText("Indietro");
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.insets.right = 5;
      button2.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {

              frame.hide();

              FreeSignerSignApplet nuovo = new FreeSignerSignApplet();
            }
          });

      // panel6.add(button2, gbc);

      // ---- button4 ----
      button4.setText("Annulla");
      gbc = new GridBagConstraints();
      gbc.gridx = 2;
      gbc.gridy = 0;
      // panel6.add(button4, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.BOTH;
    contentPane.add(panel6, gbc);
    contentPane.setBackground(Color.white);
    frame = new JFrame();
    frame.setContentPane(contentPane);
    frame.setTitle("Freesigner");
    frame.setSize(300, 150);
    frame.setResizable(false);
    frame.pack();
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((d.width - frame.getWidth()) / 2, (d.height - frame.getHeight()) / 2);

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    timer =
        new Timer(
            10,
            new ActionListener() {

              public void actionPerformed(ActionEvent evt) {
                frame.show();
                if (task.getMessage() != null) {
                  String s = new String();
                  s = task.getMessage();
                  s = s.substring(0, Math.min(60, s.length()));

                  textArea2.setText(s + " ");
                  progressBar.setValue(task.getStatus());
                }
                if (task.isDone()) {
                  timer.stop();

                  // Finalizzo la cryptoki, onde evitare
                  // successivi errori PKCS11 "cryptoki alreadi initialized"

                  if ((task != null)) task.libFinalize();

                  ArrayList slotInfos = task.getSlotInfos();
                  if ((slotInfos == null) || slotInfos.isEmpty()) {

                    frame.show();

                    JOptionPane.showMessageDialog(
                        frame,
                        "Controllare la presenza sul sistema\n"
                            + "della libreria PKCS11 impostata.",
                        "Nessun lettore rilevato",
                        JOptionPane.WARNING_MESSAGE);

                    frame.hide();

                  } else {
                    String st = task.getCRLerror();

                    if (st.length() > 0) {
                      timer.stop();

                      JOptionPane.showMessageDialog(
                          frame,
                          "C'è stato un errore nella verifica CRL.\n" + st,
                          "Errore verifica CRL",
                          JOptionPane.ERROR_MESSAGE);
                      frame.hide();
                      FreeSignerSignApplet nuovo = new FreeSignerSignApplet();
                    }
                    if (task.getDifferentCerts() == 0) {
                      if (task.getCIr() != null) {
                        JOptionPane.showMessageDialog(
                            frame,
                            "La carta "
                                + task.getCardDescription()
                                + " nel lettore "
                                + conf.getReader()
                                + " non contiene certificati",
                            "Attenzione",
                            JOptionPane.WARNING_MESSAGE);

                      } else
                        JOptionPane.showMessageDialog(
                            frame, task.getMessage(), "Errore:", JOptionPane.ERROR_MESSAGE);
                    }

                    frame.hide();

                    // confFrame.createTreeAndTokenNodes(task.getSlotInfos());

                  }
                }
              }
            });
  }
Пример #23
0
  public static void main() {
    // Main
    frame = new JFrame("Java Playground");
    frame.setSize(640, 480);
    // Make sure the divider is properly resized
    frame.addComponentListener(
        new ComponentAdapter() {
          public void componentResized(ComponentEvent c) {
            splitter.setDividerLocation(.8);
          }
        });
    // Make sure the JVM is reset on close
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosed(WindowEvent w) {
            new FrameAction().kill();
          }
        });

    // Setting up the keybinding
    // Ctrl+k or Cmd+k -> compile
    bind(KeyEvent.VK_K);

    // Ctrl+e or Cmd+e -> console
    bind(KeyEvent.VK_E);

    // Save, New file, Open file, Print.
    // Currently UNUSED until I figure out how normal java files and playground files will
    // interface.
    bind(KeyEvent.VK_S);
    bind(KeyEvent.VK_N);
    bind(KeyEvent.VK_O);
    bind(KeyEvent.VK_P);

    // Binds the keys to the action defined in the FrameAction class.
    frame.getRootPane().getActionMap().put("console", new FrameAction());

    // The main panel for typing code in.
    text = new JTextPane();
    textScroll = new JScrollPane(text);
    textScroll.setBorder(null);
    textScroll.setPreferredSize(new Dimension(640, 480));

    // Document with syntax highlighting. Currently unfinished.
    doc = text.getStyledDocument();
    doc.addDocumentListener(
        new DocumentListener() {
          public void changedUpdate(DocumentEvent d) {}

          public void insertUpdate(DocumentEvent d) {}

          public void removeUpdate(DocumentEvent d) {}
        });

    ((AbstractDocument) doc).setDocumentFilter(new NewLineFilter());

    // The output log; a combination compiler warning/error/runtime error/output log.
    outputText = new JTextPane();
    outputScroll = new JScrollPane(outputText);
    outputScroll.setBorder(null);

    // "Constant" for the error font
    error = new SimpleAttributeSet();
    error.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE);
    error.addAttribute(StyleConstants.Foreground, Color.RED);

    // "Constant" for the warning message font
    warning = new SimpleAttributeSet();
    warning.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE);
    warning.addAttribute(StyleConstants.Foreground, Color.PINK);

    // "Constant" for the debugger error font
    progErr = new SimpleAttributeSet();
    progErr.addAttribute(StyleConstants.Foreground, Color.BLUE);

    // Print streams to redirect System.out and System.err.
    out = new TextOutputStream(outputText, null);
    err = new TextOutputStream(outputText, error);
    System.setOut(new PrintStream(out));
    System.setErr(new PrintStream(err));

    // Sets up the output log
    outputText.setEditable(false);
    outputScroll.setVisible(true);

    // File input/output setup
    chooser = new JFileChooser();

    // Setting up miscellaneous stuff
    compiler = ToolProvider.getSystemJavaCompiler();
    JVMrunning = false;
    redirectErr = null;
    redirectOut = null;
    redirectIn = null;

    // Sets up the splitter pane and opens the program up
    splitter = new JSplitPane(JSplitPane.VERTICAL_SPLIT, textScroll, outputScroll);
    consoleDisplayed = false;
    splitter.remove(outputScroll); // Initially hides terminal until it is needed
    splitter.setOneTouchExpandable(true);
    frame.add(splitter);
    frame.setVisible(true);

    // Sets the divider to the proper one, for debugging
    // splitter.setDividerLocation(.8);
  }
Пример #24
0
  void createFrame() {
    /* see Preferences.java */
    int GUI_BIG = 13;
    int GUI_BETWEEN = 10;
    int GUI_SMALL = 6;
    int FIELD_SIZE = 30;

    int left = GUI_BIG;
    int top = GUI_BIG;
    int right = 0;

    Dimension d;

    frame = new JFrame("Directives Editor");
    Container pane = frame.getContentPane();
    pane.setLayout(null);

    JLabel label = new JLabel("Click here to read about directives.");
    label.addMouseListener(
        new MouseListener() {
          public void mouseClicked(MouseEvent e) {
            Base.openURL("http://processingjs.org/reference/pjs%20directive");
          }

          public void mouseEntered(MouseEvent e) {}

          public void mouseExited(MouseEvent e) {}

          public void mousePressed(MouseEvent e) {}

          public void mouseReleased(MouseEvent e) {}
        });
    pane.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_BETWEEN + GUI_BETWEEN;

    // CRISP

    crispBox = new JCheckBox("\"crisp\": disable antialiasing for line(), triangle() and rect()");
    pane.add(crispBox);
    d = crispBox.getPreferredSize();
    crispBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // FONTS

    label = new JLabel("\"font\": to load (comma separated)");
    pane.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_SMALL;

    fontField = new JTextField(FIELD_SIZE);
    pane.add(fontField);
    d = fontField.getPreferredSize();
    fontField.setBounds(left, top, d.width, d.height);

    JButton button = new JButton("scan");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            handleScanFonts();
          }
        });
    pane.add(button);
    Dimension d2 = button.getPreferredSize();
    button.setBounds(left + d.width + GUI_SMALL, top, d2.width, d2.height);
    right = Math.max(right, left + d.width + GUI_SMALL + d2.width);
    top += d.height + GUI_BETWEEN;

    // GLOBAL_KEY_EVENTS

    globalKeyEventsBox = new JCheckBox("\"globalKeyEvents\": receive global key events");
    pane.add(globalKeyEventsBox);
    d = globalKeyEventsBox.getPreferredSize();
    globalKeyEventsBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // PAUSE_ON_BLUR

    pauseOnBlurBox = new JCheckBox("\"pauseOnBlur\": pause if applet loses focus");
    pane.add(pauseOnBlurBox);
    d = pauseOnBlurBox.getPreferredSize();
    pauseOnBlurBox.setBounds(left, top, d.width + 10, d.height);
    right = Math.max(right, left + d.width);
    top += d.height + GUI_BETWEEN;

    // PRELOAD images

    label = new JLabel("\"preload\": images (comma separated)");
    pane.add(label);
    d = label.getPreferredSize();
    label.setBounds(left, top, d.width, d.height);
    top += d.height + GUI_SMALL;

    preloadField = new JTextField(FIELD_SIZE);
    pane.add(preloadField);
    d = preloadField.getPreferredSize();
    preloadField.setBounds(left, top, d.width, d.height);

    button = new JButton("scan");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            handleScanImages();
          }
        });
    pane.add(button);
    d2 = button.getPreferredSize();
    button.setBounds(left + d.width + GUI_SMALL, top, d2.width, d2.height);
    right = Math.max(right, left + d.width + GUI_SMALL + d2.width);
    top += d.height + GUI_BETWEEN;

    // TRANSPARENT

    /*transparentBox =
         new JCheckBox("\"transparent\": set applet background to be transparent");
       pane.add(transparentBox);
    d = transparentBox.getPreferredSize();
       transparentBox.setBounds(left, top, d.width + 10, d.height);
       right = Math.max(right, left + d.width);
       top += d.height + GUI_BETWEEN;*/

    // APPLY / OK

    button = new JButton("OK");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            applyDirectives();
            hide();
          }
        });
    pane.add(button);
    d2 = button.getPreferredSize();
    int BUTTON_HEIGHT = d2.height;
    int BUTTON_WIDTH = 80;

    int h = right - (BUTTON_WIDTH + GUI_SMALL + BUTTON_WIDTH);
    button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);
    h += BUTTON_WIDTH + GUI_SMALL;

    button = new JButton("Cancel");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            hide();
          }
        });
    pane.add(button);
    button.setBounds(h, top, BUTTON_WIDTH, BUTTON_HEIGHT);

    top += BUTTON_HEIGHT + GUI_BETWEEN;

    // frame.getContentPane().add(box);
    frame.pack();
    Insets insets = frame.getInsets();
    frame.setSize(
        right + GUI_BIG + insets.left + insets.right, top + GUI_SMALL + insets.top + insets.bottom);

    // frame.setResizable(false);

    frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            frame.setVisible(false);
          }
        });
    Toolkit.registerWindowCloseKeys(
        frame.getRootPane(),
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            frame.setVisible(false);
          }
        });
    Toolkit.setIcon(frame);
  }
Пример #25
0
  public static void main(String argv[]) {
    System.setErr(System.out);

    try {

      UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

    } catch (Exception e) {
      try {

        UIManager.setLookAndFeel("javax.swing.plaf.windows.WindowsLookAndFeel");

      } catch (Exception e1) {
        try {

          UIManager.setLookAndFeel("javax.swing.plaf.motif.MotifLookAndFeel");

        } catch (Exception e2) {
          try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          } catch (Exception e3) {
          }
        }
      }
    }

    UIManager.put("TextField.background", new Color(255, 255, 255));
    String strCreateTables = null,
        strRunTests = null,
        strCleanUp = null,
        strCreateProc = null,
        strCreateResult = null,
        strDropResult = null,
        strLogLevel = null;
    String strTPCCRun = null, strTPCCLoad = null;
    BenchMain.bench = new BenchMain();
    bench.m_bInApplet = false;

    if (argv.length > 0)
      for (int nArg = 0; nArg < argv.length; nArg++) {
        if (argv[nArg].toUpperCase().startsWith("URL="))
          bench.m_strURL = argv[nArg].substring(argv[nArg].indexOf("=") + 1);
        else if (argv[nArg].toUpperCase().startsWith("USER="******"=") + 1);
        else if (argv[nArg].toUpperCase().startsWith("PASSWORD="******"=") + 1);
        else if (argv[nArg].toUpperCase().startsWith("DRIVER="))
          bench.m_strDriver = argv[nArg].substring(argv[nArg].indexOf("=") + 1);
        else if (argv[nArg].toUpperCase().startsWith("DRIVERTYPE="))
          bench.m_nDriverType =
              Integer.valueOf(argv[nArg].substring(argv[nArg].indexOf("=") + 1)).intValue();
        else if (argv[nArg].toUpperCase().startsWith("CREATETABLES="))
          strCreateTables = argv[nArg].substring(argv[nArg].indexOf("=") + 1);
        else if (argv[nArg].toUpperCase().startsWith("RUNTEST="))
          strRunTests = argv[nArg].substring(argv[nArg].indexOf("=") + 1);
        else if (argv[nArg].toUpperCase().startsWith("CLEANUP")) strCleanUp = argv[nArg];
        else if (argv[nArg].toUpperCase().startsWith("CREATEPROC")) strCreateProc = argv[nArg];
        else if (argv[nArg].toUpperCase().startsWith("CREATERESULT")) strCreateResult = argv[nArg];
        else if (argv[nArg].toUpperCase().startsWith("DROPRESULT")) strDropResult = argv[nArg];
        else if (argv[nArg].toUpperCase().startsWith("LOGLEVEL="))
          strLogLevel = argv[nArg].substring(argv[nArg].indexOf("=") + 1);
        else if (argv[nArg].toUpperCase().startsWith("TPCCRUN="))
          strTPCCRun = argv[nArg].substring(argv[nArg].indexOf("=") + 1);
        else if (argv[nArg].toUpperCase().startsWith("TPCCLOAD="))
          strTPCCLoad = argv[nArg].substring(argv[nArg].indexOf("=") + 1);
      }
    bench.m_bInApplet = false;
    try {
      if (strCreateTables != null
          || strRunTests != null
          || strCleanUp != null
          || strCreateProc != null
          || strCreateResult != null
          || strDropResult != null
          || strTPCCRun != null
          || strTPCCLoad != null) {
        // batch
        TextProgress progress = new TextProgress();
        Bench.BenchPanel pane =
            new Bench.BenchPanel(
                bench.m_strDriver,
                bench.m_strURL,
                bench.m_strUserName,
                bench.m_strPassword,
                bench.m_nDriverType);
        Bench.Logger new_log =
            new Bench.Logger() {
              int m_nLogLevel = 0;

              public synchronized void log(String strMessage, int nLevel) {
                if (nLevel <= m_nLogLevel) System.out.print(strMessage);
              }

              public synchronized void taskDone() {
                notify();
              }

              public synchronized void waitOn() throws InterruptedException {
                wait();
              }

              public synchronized void setLogLevel(int nNewLogLevel) {
                m_nLogLevel = nNewLogLevel;
              }

              public synchronized int getLogLevel() {
                return m_nLogLevel;
              }
            };

        if (strLogLevel != null) new_log.setLogLevel(Integer.valueOf(strLogLevel).intValue());
        pane.setLogger(new_log);
        if (strCreateTables != null) {
          StringTokenizer createTokens = new StringTokenizer(strCreateTables, ",;/");
          int nBranchCount = 10, nTellerCount = 100, nAccountCount = 1000;
          if (createTokens.hasMoreTokens())
            nBranchCount = Integer.valueOf(createTokens.nextToken()).intValue();
          if (createTokens.hasMoreTokens())
            nTellerCount = Integer.valueOf(createTokens.nextToken()).intValue();
          if (createTokens.hasMoreTokens())
            nAccountCount = Integer.valueOf(createTokens.nextToken()).intValue();
          // FIXME               pane.setMaxTableLimits(nBranchCount,nTellerCount,nAccountCount);
          // FIXME               pane.doCreateTables(true,true,true,true,true,true,true,true);
        }
        // FIXME            if(strCreateProc != null)
        // pane.doLoadProcedures(pane.pool.getConnection(0));
        if (strRunTests != null) {
          int nNumThreads = 1, nNumRuns = 100, nTestType = 1, nWaitMinutes = -1;
          boolean bTrans = false, bQuery = true;
          StringTokenizer runTokens = new StringTokenizer(strRunTests, ",;/");
          if (runTokens.hasMoreTokens())
            nNumThreads = Integer.valueOf(runTokens.nextToken()).intValue();
          if (runTokens.hasMoreTokens())
            nNumRuns = Integer.valueOf(runTokens.nextToken()).intValue();
          if (runTokens.hasMoreTokens())
            bTrans = runTokens.nextToken().toUpperCase().equals("TRUE");
          if (runTokens.hasMoreTokens())
            bQuery = runTokens.nextToken().toUpperCase().equals("TRUE");
          if (runTokens.hasMoreTokens())
            nTestType = Integer.valueOf(runTokens.nextToken()).intValue();
          if (runTokens.hasMoreTokens())
            nWaitMinutes = Integer.valueOf(runTokens.nextToken()).intValue();
          // FIXME               pane.doRunTests(nNumThreads,nNumRuns,nWaitMinutes,nTestType ==
          // 1,nTestType == 2,nTestType == 3,bTrans,bQuery);
        }
        // FIXME            if(strCleanUp != null) pane.doCleanUp(pane.pool.getConnection(0),
        // true,true,true,true);
        if (strDropResult != null) pane.doDropResult();
        // FIXME            if(strCreateResult != null) pane.doCreateResult();
        // ========TPCCTest
        //            if(strTPCCLoad != null) {
        //               int n_ware = 1;
        //               StringTokenizer runTokens = new StringTokenizer(strTPCCLoad,",;/");
        //               //					System.out.println("tpcload = " + strTPCCLoad);
        //               if(runTokens.hasMoreTokens()) {
        //                  n_ware = Integer.valueOf(runTokens.nextToken()).intValue();
        //               //						System.out.println("N_ware = " + n_ware);
        //               }
        //               pane.doTpccLoadData(pane.pool.getConnection(0),
        // n_ware,Bench.TPCCBench.DIST_PER_WARE,Bench.TPCCBench.CUST_PER_DIST,Bench.TPCCBench.MAXITEMS,Bench.TPCCBench.ORD_PER_DIST);
        //            }
        //            if(strTPCCRun != null) {
        //               int n_rounds = 1, local_w_id = 1, n_ware = 1, n_threads = 1;
        //               StringTokenizer runTokens = new StringTokenizer(strTPCCRun,",;/");
        //               if(runTokens.hasMoreTokens())
        //                  n_rounds = Integer.valueOf(runTokens.nextToken()).intValue();
        //               if(runTokens.hasMoreTokens())
        //                  local_w_id = Integer.valueOf(runTokens.nextToken()).intValue();
        //               if(runTokens.hasMoreTokens())
        //                  n_ware = Integer.valueOf(runTokens.nextToken()).intValue();
        //               if(runTokens.hasMoreTokens())
        //                  n_threads = Integer.valueOf(runTokens.nextToken()).intValue();
        //               pane.doTpccRun(n_threads, n_rounds,local_w_id,n_ware);
        //            }
        pane.closeConnection(true);
        System.exit(0);
      }
    } catch (Exception e) {
      System.out.println(e.getMessage());
    }
    // go interactive
    JFrame frame = new JFrame("JBench - Generic JDBC Benchmark Utility");
    WindowListener l =
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            BenchMain.bench.m_pane.closeConnection(true);
            System.exit(0);
          }
        };

    frame.addWindowListener(l);
    bench.m_parentFrame = frame;
    bench.init();
    frame.getContentPane().add(bench);
    frame.setSize(675, 400);
    frame.validate();
    frame.setVisible(true);
  }