Example #1
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getSource() == btnBlue) {
     contentPane.setBackground(Color.BLUE);
   } else if (e.getSource() == btnYellow) {
     contentPane.setBackground(Color.YELLOW);
   } else if (e.getSource() == btnExit) {
     System.exit(0);
   }
 }
Example #2
0
  public hostelStatus() {
    setTitle("Hostel");
    connect();
    updateRecord();

    JFrame fr = new JFrame();
    Toolkit tkt = fr.getToolkit();
    Dimension frsize = tkt.getScreenSize();
    setBounds(frsize.width / 4, frsize.height / 12, frsize.width / 2, frsize.height / 8);
    setLayout(null);

    cn = getContentPane();
    cn.setBackground(new Color(190, 180, 170));

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    tl = new JLabel("Current Hostels Status");
    tl.setFont(new Font("Engravers MT", 1, 25));
    tl.setForeground(new Color(247, 251, 249));

    p1 = new JPanel();
    p1.setBounds(0, 0, 600, 50);
    p1.add(tl);
    p1.setBackground(new Color(31, 88, 166));
    cn.add(p1);

    b1 = new JButton("LOAD");
    b1.setMnemonic('L');
    b1.addActionListener(new dispListener());
    b1.setBounds(230, 320, 120, 30);

    b2 = new JButton("EXIT");
    b2.setMnemonic('X');
    b2.addActionListener(new exitListener());
    b2.setBounds(350, 320, 100, 30);

    cn.add(b1);
    cn.add(b2);

    table = new JTable(data, col);
    table.setFont(new Font("Serif", Font.BOLD, 16));
    table.setBackground(new Color(250, 250, 250));
    table.setEnabled(false);

    JScrollPane jsp = new JScrollPane(table);
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setBounds(5, 100, 590, 200);
    cn.add(jsp);

    screensize = Toolkit.getDefaultToolkit().getScreenSize();

    setSize(600, 400);
    setVisible(true);
    setVisible(true);
    setResizable(true);
    connect();
  }
  public void initComponents() {
    /** ******************** The main container *************************** */
    Container container = this.getContentPane();
    container.setLayout(new BorderLayout());
    container.setBackground(Color.black);
    this.setSize(650, 600);
    this.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {}
        });

    /** ************************* MAIN PANEL ******************************* */
    mainPanel = new JPanel();
    // If put to False: we see the container's background
    mainPanel.setOpaque(false);
    mainPanel.setLayout(new BorderLayout());
    container.add(mainPanel, BorderLayout.CENTER);

    allmessagesTextArea = new TextArea();
    allmessagesTextArea.setEditable(false);
    allmessagesTextArea.setFont(new Font("Dialog", 1, 12));
    allmessagesTextArea.setForeground(Color.black);
    allmessagesTextArea.append("Select a session in the list to view its messages");
    mainPanel.add(allmessagesTextArea, BorderLayout.CENTER);

    sessionsList = new List();
    sessionsList.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            showMessages(e);
          }
        });
    sessionsList.setForeground(Color.black);
    sessionsList.setFont(new Font("Dialog", 1, 14));
    mainPanel.add(sessionsList, BorderLayout.WEST);

    okButton = new JButton("  OK  ");
    okButton.setToolTipText("Returns to the main frame");
    okButton.setFont(new Font("Dialog", 1, 16));
    okButton.setFocusPainted(false);
    okButton.setBackground(Color.lightGray);
    okButton.setBorder(new BevelBorder(BevelBorder.RAISED));
    okButton.setVerticalAlignment(SwingConstants.CENTER);
    okButton.setHorizontalAlignment(SwingConstants.CENTER);
    container.add(okButton, BorderLayout.SOUTH);
    okButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            setVisible(false);
          }
        });
  }
Example #4
0
  /**
   * Cr�e une nouvelle instance de CreeTrans
   *
   * @param mf fenetre principale de l'application
   * @param zg Zone graphique
   * @param auto automate
   * @param be barre d'�tat
   */
  public TransCreator(MainFrame mf, GraphicZone g, Automate auto, StateBar be) {

    super(JOptionPane.getFrameForComponent(mf), "Creating interaction", true);

    this.setResizable(false);

    this.gz = g;
    this.auto = auto;
    this.bar = be;
    this.mf = mf;

    be.displayInfo("Creating interaction");

    tfJPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    tfJPanel1.setBackground(Color.lightGray);
    tfJPanel1.add(new JLabel("Type  : "));
    groupe = new CheckboxGroup();
    plus = new Checkbox("activator", groupe, true);
    tfJPanel1.add(plus);
    minus = new Checkbox("inhibitor", groupe, false);
    tfJPanel1.add(minus);

    tfJPanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    tfJPanel2.setBackground(Color.lightGray);
    tfJPanel2.add(new JLabel("Threshold  = "));
    tf = new JTextField(auto.nbrCharTransLabel);
    tf.setText("1");
    tfJPanel2.add(tf);

    btJPanel = new JPanel(new GridLayout(1, 2, 0, 0));
    btJPanel.setBackground(Color.lightGray);
    ok = new Button("Ok");
    ok.setBackground(Color.lightGray);
    ok.addActionListener(this);
    cancel = new Button("Cancel");
    cancel.setBackground(Color.lightGray);
    cancel.addActionListener(this);
    btJPanel.add(ok);
    btJPanel.add(cancel);

    content = this.getContentPane();
    content.setLayout(new BorderLayout());
    content.setBackground(Color.lightGray);
    content.add(tfJPanel1, BorderLayout.NORTH);
    content.add(tfJPanel2, BorderLayout.CENTER);
    content.add(btJPanel, BorderLayout.SOUTH);

    this.pack();
    this.setLocationRelativeTo(this.mf);

    tf.requestFocusInWindow();

    // rendre la fenetre visible
    setVisible(true);
  }
Example #5
0
 // Set up the quiz window
 Quiz() {
   initializeData();
   setTitle("FOSS Quiz App");
   setDefaultCloseOperation(EXIT_ON_CLOSE);
   setSize(440, 400);
   setLocation(300, 100);
   setResizable(true);
   Container cont = getContentPane();
   cont.setLayout(null);
   cont.setBackground(Color.WHITE);
   bg = new ButtonGroup();
   choice1 = new JRadioButton("Choice1", true);
   choice2 = new JRadioButton("Choice2", false);
   choice3 = new JRadioButton("Choice3", false);
   choice4 = new JRadioButton("Choice4", false);
   bg.add(choice1);
   bg.add(choice2);
   bg.add(choice3);
   bg.add(choice4);
   lblmess = new JLabel("Choose a correct anwswer");
   lblmess.setForeground(Color.BLACK);
   lblmess.setFont(new Font("Sans_Serif", Font.BOLD, 15));
   btnext = new JButton("Next");
   btnext.setForeground(Color.WHITE);
   btnext.setFont(new Font("Sans_Serif", Font.BOLD, 17));
   btnext.setBackground(Color.DARK_GRAY);
   btnext.addActionListener(this);
   panel = new JPanel();
   panel.setBackground(Color.WHITE);
   panel.setLocation(10, 60);
   panel.setSize(400, 300);
   panel.setLayout(new GridLayout(0, 1));
   title = new JPanel();
   title.setBackground(Color.WHITE);
   title.setLocation(10, 10);
   title.setSize(1000, 50);
   title.setLayout(new GridLayout(1, 0));
   title.add(lblmess);
   panel.add(choice1);
   panel.add(choice2);
   panel.add(choice3);
   panel.add(choice4);
   panel.add(btnext);
   cont.add(title);
   cont.add(panel);
   setVisible(true);
   quizAnswerID = 0;
   readQuestionAnswer(quizAnswerID);
 }
Example #6
0
    // Method to build the dialog box for help.
    private void buildDialogBox() {
      // Set the JDialog window properties.
      setTitle("Learning about Java");
      setResizable(false);
      setSize(dialogWidth, dialogHeight);

      // Define behaviors of container.
      c.setLayout(null);
      c.setBackground(Color.cyan);
      c.add(image);
      c.add(okButton);

      // Set the bounds for the image.
      image.setBounds(
          (dialogWidth / 2) - (imageWidth / 2),
          (top + (offsetMargin / 2)),
          imageWidth,
          imageHeight);

      // Set the behaviors, bounds and action listener for the button.
      okButton.setBounds(
          (dialogWidth / 2) - (buttonWidth / 2),
          (imageHeight + (int) 1.5 * offsetMargin),
          buttonWidth,
          buttonHeight);

      // Set the font to the platform default Font for the object with the
      // properties of bold and font size of 11.
      okButton.setFont(new Font(okButton.getFont().getName(), Font.BOLD, 11));

      // Set foreground and background of JButton(s).
      okButton.setForeground(Color.white);
      okButton.setBackground(Color.blue);

      // The class implements the ActionListener interface and therefore
      // provides an implementation of the actionPerformed() method.  When a
      // class implements ActionListener, the instance handler returns an
      // ActionListener.  The ActionListener then performs actionPerformed()
      // method on an ActionEvent.
      okButton.addActionListener(this);

      // Set the screen and display dialog window in relation to screen size.
      dim = tk.getScreenSize();
      setLocation((dim.width / 2) - (dialogWidth / 2), (dim.height / 2) - (dialogHeight / 2));

      // Display the dialog.
      show();
    } // End of buildDialogBox method.
Example #7
0
  public MapViewer(String title) {
    super(title);
    setSize(800, 600);
    // setExtendedState(Frame.MAXIMIZED_BOTH);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    edgeCnt = 0;
    startMap();
    Container cp = getContentPane();
    cp.setLayout(new BorderLayout());
    cp.setBackground(Color.lightGray);
    // vv.getModel().getRelaxer().setSleepTime(500);
    vv.setGraphMouse(new DefaultModalGraphMouse<Number, Number>());

    vv.getRenderer()
        .getVertexLabelRenderer()
        .setPosition(edu.uci.ics.jung.visualization.renderers.Renderer.VertexLabel.Position.CNTR);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>());
    vv.setForeground(Color.white);
    cp.add(vv, BorderLayout.CENTER);
    getContentPane().setFont(new Font("Serif", Font.PLAIN, 12));
    setVisible(true);
    JMenuBar jb = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    jb.add(fileMenu);
    JMenuItem exitMenu = new JMenuItem("Exit");
    fileMenu.add(exitMenu);
    exitMenu.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            MapViewer.this.dispose();
          }
        });
    JMenu helpMenu = new JMenu("Help");
    jb.add(helpMenu);
    JMenuItem aboutItem = new JMenuItem("About");
    helpMenu.add(aboutItem);
    aboutItem.addActionListener(new AboutActionListener());
    this.setJMenuBar(jb);
    setLocationRelativeTo(null);
  }
  public HistogramGUI() {
    Container cp = getContentPane();
    cp.setBackground(Color.red);
    cp.setLayout(new FlowLayout());

    lblTitle = new JLabel("HistoGram Client");
    btnRun = new JButton("   Run!   ");
    txtWord = new JTextField(30);

    btnRun.setFont(new Font("Comic Sans MS", Font.BOLD, 25));
    lblTitle.setFont(new Font("Comic Sans MS", Font.BOLD, 40));

    listener = new ButtonListener();

    btnRun.addActionListener(listener);

    cp.add(lblTitle);
    cp.add(txtWord);
    cp.add(btnRun);

    setSize(400, 200);
    setVisible(true);
    setResizable(false);
  }
  /** This method is called from within the constructor to initialize the form. */
  public void initComponents() {
    /** *************** The main frame ************************************** */
    // width, height
    this.setSize(560, 370);
    Container container = this.getContentPane();
    container.setLayout(new BoxLayout(getContentPane(), 1));
    container.setBackground(containerBackGroundColor);
    this.setLocation(0, 0);
    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            new AlertInstantMessaging(
                "Your changes will not be checked: use the Submit button!!!",
                JOptionPane.WARNING_MESSAGE);
            hideFrame();
          }
        });

    /** **************** The components ********************************* */
    firstPanel = new JPanel();
    firstPanel.setBorder(BorderFactory.createEmptyBorder(15, 4, 15, 4));
    // If put to False: we see the container's background
    firstPanel.setOpaque(false);
    // rows, columns, horizontalGap, verticalGap
    firstPanel.setLayout(new GridLayout(11, 2, 2, 2));
    container.add(firstPanel);

    outboundProxyAddressLabel = new JLabel("Outbound proxy IP address:");
    outboundProxyAddressLabel.setForeground(Color.black);
    outboundProxyAddressTextField = new JTextField(20);
    outboundProxyAddressLabel.setBorder(labelBorder);
    outboundProxyAddressLabel.setOpaque(true);
    outboundProxyAddressLabel.setBackground(labelBackGroundColor);
    firstPanel.add(outboundProxyAddressLabel);
    firstPanel.add(outboundProxyAddressTextField);

    outboundProxyPortLabel = new JLabel("Outbound proxy port:");
    outboundProxyPortLabel.setForeground(Color.black);
    outboundProxyPortTextField = new JTextField(20);
    outboundProxyPortLabel.setBorder(labelBorder);
    outboundProxyPortLabel.setOpaque(true);
    outboundProxyPortLabel.setBackground(labelBackGroundColor);
    firstPanel.add(outboundProxyPortLabel);
    firstPanel.add(outboundProxyPortTextField);

    registrarAddressLabel = new JLabel("Registrar IP address:");
    registrarAddressLabel.setForeground(Color.black);
    registrarAddressTextField = new JTextField(20);
    registrarAddressLabel.setBorder(labelBorder);
    registrarAddressLabel.setOpaque(true);
    registrarAddressLabel.setBackground(labelBackGroundColor);
    firstPanel.add(registrarAddressLabel);
    firstPanel.add(registrarAddressTextField);

    registrarPortLabel = new JLabel("Registrar port:");
    registrarPortLabel.setForeground(Color.black);
    registrarPortTextField = new JTextField(20);
    registrarPortLabel.setBorder(labelBorder);
    registrarPortLabel.setOpaque(true);
    registrarPortLabel.setBackground(labelBackGroundColor);
    firstPanel.add(registrarPortLabel);
    firstPanel.add(registrarPortTextField);

    imAddressLabel = new JLabel("Contact IP address:");
    imAddressLabel.setForeground(Color.black);
    imAddressTextField = new JTextField(20);
    imAddressLabel.setBorder(labelBorder);
    imAddressLabel.setOpaque(true);
    imAddressLabel.setBackground(labelBackGroundColor);
    firstPanel.add(imAddressLabel);
    firstPanel.add(imAddressTextField);

    imPortLabel = new JLabel("Contact port:");
    imPortLabel.setForeground(Color.black);
    imPortTextField = new JTextField(20);
    imPortLabel.setBorder(labelBorder);
    imPortLabel.setOpaque(true);
    imPortLabel.setBackground(labelBackGroundColor);
    firstPanel.add(imPortLabel);
    firstPanel.add(imPortTextField);

    imProtocolLabel = new JLabel("Contact transport:");
    imProtocolLabel.setForeground(Color.black);
    imProtocolTextField = new JTextField(20);
    imProtocolLabel.setBorder(labelBorder);
    imProtocolLabel.setOpaque(true);
    imProtocolLabel.setBackground(labelBackGroundColor);
    firstPanel.add(imProtocolLabel);
    firstPanel.add(imProtocolTextField);

    outputFileLabel = new JLabel("Output file:");
    outputFileLabel.setForeground(Color.black);
    outputFileTextField = new JTextField(20);
    outputFileLabel.setBorder(labelBorder);
    outputFileLabel.setOpaque(true);
    outputFileLabel.setBackground(labelBackGroundColor);
    firstPanel.add(outputFileLabel);
    firstPanel.add(outputFileTextField);

    buddiesFileLabel = new JLabel("Buddies file:");
    buddiesFileLabel.setForeground(Color.black);
    buddiesFileTextField = new JTextField(20);
    buddiesFileLabel.setBorder(labelBorder);
    buddiesFileLabel.setOpaque(true);
    buddiesFileLabel.setBackground(labelBackGroundColor);
    firstPanel.add(buddiesFileLabel);
    firstPanel.add(buddiesFileTextField);

    authenticationFileLabel = new JLabel("Authentication file:");
    authenticationFileLabel.setForeground(Color.black);
    authenticationFileTextField = new JTextField(20);
    authenticationFileLabel.setBorder(labelBorder);
    authenticationFileLabel.setOpaque(true);
    authenticationFileLabel.setBackground(labelBackGroundColor);
    firstPanel.add(authenticationFileLabel);
    firstPanel.add(authenticationFileTextField);

    defaultRouterLabel = new JLabel("Default router class name:");
    defaultRouterLabel.setForeground(Color.black);
    defaultRouterTextField = new JTextField(20);
    defaultRouterLabel.setBorder(labelBorder);
    defaultRouterLabel.setOpaque(true);
    defaultRouterLabel.setBackground(labelBackGroundColor);
    firstPanel.add(defaultRouterLabel);
    firstPanel.add(defaultRouterTextField);

    thirdPanel = new JPanel();
    thirdPanel.setOpaque(false);
    // top, left, bottom, right
    thirdPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

    submitButton = new JButton(" Submit ");
    submitButton.setToolTipText("Submit your changes!");
    submitButton.setFocusPainted(false);
    submitButton.setFont(new Font("Dialog", 1, 16));
    submitButton.setBackground(buttonBackGroundColor);
    submitButton.setBorder(buttonBorder);
    submitButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            submitButtonActionPerformed(evt);
          }
        });
    thirdPanel.add(submitButton);
    container.add(thirdPanel);
  }
Example #10
0
  private Startpage(String title) {
    super(title);
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    int frameWidth = 800;
    int frameHeight = 600;
    setSize(frameWidth, frameHeight);
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (d.width - getSize().width) / 2;
    int y = (d.height - getSize().height) / 2;
    setLocation(x, y);
    setResizable(false);
    this.setLayout(null);
    image = (BufferedImage) ImageManager.get("Background");

    Container c =
        new Container() {
          @Override
          public void paint(Graphics g) {
            g.drawImage(image, 0, 0, null);
            super.paint(g);
          }
        };
    c.setBackground(new Color(0, 0, 0, 0));
    this.setContentPane(c);

    names[0] = new JTextField();
    mode[0] = new JComboBox<>();
    names[1] = new JTextField();
    mode[1] = new JComboBox<>();
    names[2] = new JTextField();
    mode[2] = new JComboBox<>();
    names[3] = new JTextField();
    mode[3] = new JComboBox<>();

    names[0].setBounds(25, 300, 150, 25);
    names[0].setFont(new Font("Consolas", Font.PLAIN, 12));
    names[0].setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
    names[0].setBackground(Color.WHITE);
    names[0].setToolTipText("Enter your name, program!");
    names[0].addActionListener(
        (ActionEvent evt) -> {
          Configs.setPlayerName(names[0].getText(), 1);
        });
    this.add(names[0]);

    mode[0].setBounds(25, 275, 150, 25);
    mode[0].addItem(PlayerStartConfig.MODE.TWOKEY);
    mode[0].addItem(PlayerStartConfig.MODE.FOURKEY);
    mode[0].addItem(PlayerStartConfig.MODE.BOT);
    this.add(mode[0]);

    names[1].setBounds(225, 300, 150, 25);
    names[1].setFont(new Font("Consolas", Font.PLAIN, 12));
    names[1].setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
    names[1].setBackground(Color.WHITE);
    names[1].setToolTipText("Enter your name, program!");
    names[1].addActionListener(
        (ActionEvent evt) -> {
          Configs.setPlayerName(names[1].getText(), 2);
        });
    this.add(names[1]);

    mode[1].setBounds(225, 275, 150, 25);
    mode[1].addItem(PlayerStartConfig.MODE.TWOKEY);
    mode[1].addItem(PlayerStartConfig.MODE.FOURKEY);
    mode[1].addItem(PlayerStartConfig.MODE.BOT);
    this.add(mode[1]);

    names[2].setBounds(425, 300, 150, 25);
    names[2].setFont(new Font("Consolas", Font.PLAIN, 12));
    names[2].setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
    names[2].setBackground(Color.WHITE);
    names[2].setToolTipText("Enter your name, program!");
    names[2].addActionListener(
        (ActionEvent evt) -> {
          Configs.setPlayerName(names[2].getText(), 3);
        });
    this.add(names[2]);

    mode[2].setBounds(425, 275, 150, 25);
    mode[2].addItem(PlayerStartConfig.MODE.TWOKEY);
    mode[2].addItem(PlayerStartConfig.MODE.FOURKEY);
    mode[2].addItem(PlayerStartConfig.MODE.BOT);
    this.add(mode[2]);

    names[3].setBounds(625, 300, 150, 25);
    names[3].setFont(new Font("Consolas", Font.PLAIN, 12));
    names[3].setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
    names[3].setBackground(Color.WHITE);
    names[3].setToolTipText("Enter your name, program!");
    names[3].addActionListener(
        (ActionEvent evt) -> {
          Configs.setPlayerName(names[3].getText(), 4);
        });
    this.add(names[3]);

    mode[3].setBounds(625, 275, 150, 25);
    mode[3].addItem(PlayerStartConfig.MODE.TWOKEY);
    mode[3].addItem(PlayerStartConfig.MODE.FOURKEY);
    mode[3].addItem(PlayerStartConfig.MODE.BOT);
    this.add(mode[3]);

    Ok.setBounds(300, 352, 75, 25);
    Ok.setText("Ok");
    Ok.setMargin(new Insets(2, 2, 2, 2));
    Ok.addActionListener(
        (ActionEvent evt) -> {
          for (int i = 0; i < 4; i++) {
            Configs.setPlayerName(names[i].getText(), i + 1);
            Configs.setControlMode((PlayerStartConfig.MODE) mode[i].getSelectedItem(), i + 1);
          }
          setVisible(false);
          Tron.getInstance().startGame();
        });
    this.add(Ok);

    Back.setBounds(425, 352, 75, 25);
    Back.setText("Back");
    Back.setMargin(new Insets(2, 2, 2, 2));
    Back.addActionListener(
        (ActionEvent evt) -> {
          MainMenue.getInstance().setVisible(true);
          setVisible(false);
        });
    this.add(Back);

    TRON.setBounds(320, 50, 160, 90);
    TRON.setText("TRON");
    TRON.setFont(new Font("Consolas", Font.BOLD, 72));
    TRON.setForeground(Color.WHITE);
    this.add(TRON);

    setVisible(true);
  }
Example #11
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());

                  }
                }
              }
            });
  }
  public vehicle() {
    message = new JLabel("VEHICLE  DETAILS");
    mname = new JLabel("Model Name");
    cap = new JLabel("Capacity");
    cc = new JLabel("CC");
    eng = new JLabel("Engine");
    stroke = new JLabel("Stroke");
    bhp = new JLabel("BHP");
    volt = new JLabel("Volts");
    rpm = new JLabel("RPM");
    weight = new JLabel("Weight");
    kg = new JLabel("Kg");
    gear = new JLabel("Gears");
    color = new JLabel("Color");

    jcmname = new JComboBox();

    tfcap = new JTextField(30);
    tfeng = new JTextField(20);
    tfbhp = new JTextField(10);
    tfvolt = new JTextField(20);
    tfrpm = new JTextField(20);
    tfweight = new JTextField(20);
    tfgear = new JTextField(30);

    jccolor = new JComboBox();

    ok = new JButton("OK");
    can = new JButton("CANCEL");

    can.addActionListener(this);
    can.setActionCommand("can");
    ok.addActionListener(this);
    ok.setActionCommand("Ok");

    Container c = getContentPane();

    setSize(800, 600);
    setTitle("Vehicle Details");
    c.setLayout(null);
    setVisible(true);

    c.add(message);
    c.add(mname);
    c.add(cap);
    c.add(cc);
    c.add(eng);
    c.add(stroke);
    c.add(bhp);
    c.add(volt);
    c.add(rpm);
    c.add(weight);
    c.add(kg);
    c.add(gear);
    c.add(color);

    c.add(jcmname);

    c.add(tfcap);
    c.add(tfeng);
    c.add(tfbhp);
    c.add(tfvolt);
    c.add(tfrpm);
    c.add(tfweight);
    c.add(tfgear);

    c.add(jccolor);

    c.add(ok);
    c.add(can);
    c.setBackground(Color.pink);

    message.setBounds(300, 40, 200, 50);
    mname.setBounds(50, 100, 100, 30);
    cap.setBounds(50, 150, 100, 30);
    cc.setBounds(275, 150, 50, 30);
    eng.setBounds(50, 200, 50, 30);
    stroke.setBounds(275, 200, 100, 30);
    bhp.setBounds(50, 250, 100, 30);
    volt.setBounds(50, 300, 100, 30);
    rpm.setBounds(50, 350, 100, 30);
    weight.setBounds(50, 400, 50, 30);
    kg.setBounds(275, 400, 100, 30);
    gear.setBounds(450, 150, 150, 30);
    color.setBounds(450, 200, 100, 30);

    jcmname.setBounds(200, 100, 100, 30);
    jcmname.addItem(" -- Select --");
    jcmname.addItem("Pulsar");
    jcmname.addItem("CT 100");
    jcmname.addItem("Discover DTS-i");
    jcmname.addItem("Wave DTS-i");

    tfcap.setBounds(200, 150, 70, 30);
    tfeng.setBounds(200, 200, 70, 30);
    tfbhp.setBounds(200, 250, 70, 30);
    tfvolt.setBounds(200, 300, 70, 30);
    tfrpm.setBounds(200, 350, 70, 30);
    tfweight.setBounds(200, 400, 70, 30);
    tfgear.setBounds(500, 150, 70, 30);

    jccolor.setBounds(500, 200, 100, 30);
    jccolor.addItem("Black");
    jccolor.addItem("Blue");
    jccolor.addItem("Red");
    jccolor.addItem("Grey");

    ok.setBounds(270, 480, 85, 30);
    can.setBounds(370, 480, 85, 30);
  }
Example #13
0
  // ------------------------------------------------------------------------
  TextViewer(JFrame inParentFrame) {
    // super(true); //is double buffered - only for panels

    textViewerFrame = this;
    parentFrame = inParentFrame;
    lastViewedDirStr = "";
    lastViewedFileStr = "";

    setTitle(resources.getString("Title"));
    addWindowListener(new AppCloser());
    pack();
    setSize(500, 600);

    warningPopup = new WarningDialog(this);
    okCancelPopup = new WarningDialogOkCancel(this);
    messagePopup = new MessageDialog(this);
    okCancelMessagePopup = new MessageDialogOkCancel(this);

    // Force SwingSet to come up in the Cross Platform L&F
    try {
      UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
      // If you want the System L&F instead, comment out the above line and
      // uncomment the following:
      // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception exc) {
      String errstr = "TextViewer:Error loading L&F: " + exc;
      warningPopup.display(errstr);
    }

    Container cf = getContentPane();
    cf.setBackground(Color.lightGray);
    // Border etched=BorderFactory.createEtchedBorder();
    // Border title=BorderFactory.createTitledBorder(etched,"TextViewer");
    // cf.setBorder(title);
    cf.setLayout(new BorderLayout());

    // create the embedded JTextComponent
    editor1 = createEditor();
    editor1.setFont(new Font("monospaced", Font.PLAIN, 12));
    // aa -added next line
    setPlainDocument((PlainDocument) editor1.getDocument()); // sets doc1

    // install the command table
    commands = new Hashtable();
    Action[] actions = getActions();
    for (int i = 0; i < actions.length; i++) {
      Action a = actions[i];
      commands.put(a.getValue(Action.NAME), a);
      // System.out.println("Debug:TextViewer: actionName:"+a.getValue(Action.NAME));
    }
    // editor1.setPreferredSize(new Dimension(,));
    // get setting from user preferences
    if (UserPref.keymapType.equals("Word")) {
      editor1 = updateKeymapForWord(editor1);
    } else {
      editor1 = updateKeymapForEmacs(editor1);
    }

    scroller1 = new JScrollPane();
    viewport1 = scroller1.getViewport();
    viewport1.add(editor1);
    scroller1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scroller1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    try {
      String vpFlag = resources.getString("ViewportBackingStore");
      Boolean bs = new Boolean(vpFlag);
      viewport1.setBackingStoreEnabled(bs.booleanValue());
    } catch (MissingResourceException mre) {
      System.err.println("TextViewer:missing resource:" + mre.getMessage());
      // just use the viewport1 default
    }

    menuItems = new Hashtable();

    menubar = createMenubar();

    lowerPanel = new JPanel(true); // moved double buffering to here
    lowerPanel.setLayout(new BorderLayout());
    lowerPanel.add("North", createToolbar());
    lowerPanel.add("Center", scroller1);

    cf.add("North", menubar);
    cf.add("Center", lowerPanel);
    cf.add("South", createStatusbar());

    // for the find/search utilities
    mySearchDialog = new SearchDialog(this);

    // System.out.println("Debug:TextViewer: end of TextViewer constructor");

  }
Example #14
0
  public MyFrame(String title, Color col) {
    setTitle(title); // title is set in main method
    setSize(500, 500); // this may need changed but looks ok
    setLocationRelativeTo(null); // sets the location as the centre of the screen
    setResizable(false);

    Container c = getContentPane(); // container to hold the different panels
    c.setBackground(Color.white); // col from main
    c.setLayout(null); // no layout selected so we can place anywhere

    // add to container

    ImageIcon gameLogo =
        new ImageIcon(
            new ImageIcon(getClass().getResource("GameLogobBlank.png"))
                .getImage()
                .getScaledInstance(360, 80, java.awt.Image.SCALE_SMOOTH));
    JPanel logoPanel = new JPanel();
    JLabel logoLabel = new JLabel("", gameLogo, JLabel.CENTER);
    logoPanel.setBounds(50, 45, gameLogo.getIconWidth() + 20, gameLogo.getIconHeight() + 20);
    logoPanel.setBackground(Color.white);
    logoPanel.add(logoLabel);
    c.add(logoPanel);

    ImageIcon qubLogo =
        new ImageIcon(new ImageIcon(getClass().getResource("QUBLogo.png")).getImage());
    JPanel qubLogoPanel = new JPanel();
    JLabel qubLogoLabel = new JLabel("", qubLogo, JLabel.CENTER);
    qubLogoPanel.setBounds(15, 380, qubLogo.getIconWidth() + 10, qubLogo.getIconHeight() + 10);
    qubLogoPanel.setBackground(Color.white);
    qubLogoPanel.add(qubLogoLabel);
    c.add(qubLogoPanel);

    ImageIcon seseLogo =
        new ImageIcon(
            new ImageIcon(getClass().getResource("seseLogo.png"))
                .getImage()
                .getScaledInstance(120, 45, java.awt.Image.SCALE_SMOOTH));
    JPanel seseLogoPanel = new JPanel();
    JLabel seseLogoLabel = new JLabel("", seseLogo, JLabel.CENTER);
    seseLogoPanel.setBounds(350, 390, seseLogo.getIconWidth() + 10, seseLogo.getIconHeight() + 10);
    seseLogoPanel.setBackground(Color.white);
    seseLogoPanel.add(seseLogoLabel);
    c.add(seseLogoPanel);

    JPanel playerPanel = new JPanel(); // new panel for players
    playerPanel.setBounds(92, 200, 316, 27); // location
    playerPanel.setLayout(new GridLayout(1, 2)); // layout as grid
    playerPanel.setOpaque(false);
    c.add(playerPanel); // add to container

    combo.setBackground(Color.white);
    playerPanel.add(numOfP); // label to tell to select num of players
    playerPanel.add(combo); // drop down menu

    players.setEditable(false);
    players.setHorizontalAlignment(JLabel.CENTER);

    combo.addItemListener(
        new ItemListener() { // this is to set the number of players to be displayed
          public void itemStateChanged(ItemEvent ie) {

            if (ie.getStateChange() == ItemEvent.SELECTED) {
              String str =
                  (String)
                      combo
                          .getSelectedItem(); // if the number changes then change the number of
                                              // player message

              if (str == "2") {
                players.setText("2 players selected");
              }

              if (str == "3") {
                players.setText("3 players selected");
              }

              if (str == "4") {
                players.setText("4 players selected");
              }

              if (str == "5") {
                players.setText("5 players selected");
              }

              if (str == "6") {
                players.setText("6 players selected");
              }
            } // closes if statements
          } // closes method
        } // closes action listener
        ); // closes action listener

    JPanel startPanel = new JPanel(); // start panel for start button
    startPanel.setBounds(123, 239, 254, 70); // location
    startPanel.setLayout(new GridLayout(2, 1)); // using a grid layout
    startPanel.add(players); // text box says number of payers
    startPanel.setBackground(Color.white);

    startButton = new JButton();
    startButton.setText(
        "Start Game!"); // button has the label start												// actual start button
    startPanel.add(startButton); // button added
    startButton.addActionListener(startButtonActionListener); // added actionlistener
    c.add(startPanel); // added to container

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // close when closed
    setVisible(true); // takes off invisability cloak
  } // MyFrame constructor
Example #15
0
  // Constructora
  public Principal() {

    // Titulo de la ventana y tamaño
    setTitle("Práctica 4");
    setSize(new Dimension(425, 500));
    super.setResizable(false);

    // Contenedor del editor
    panel = this.getContentPane();
    panel.setBackground(Color.blue);
    panel.setLayout(new BorderLayout());

    // Generamos el menu
    menu = new JMenuBar();
    archivo = new JMenu("Archivo");
    nuevo = new JMenuItem("Nuevo");
    salir = new JMenuItem("Salir");
    sobre = new JMenu("Sobre..");
    autores = new JMenuItem("Autores");

    menu.add(archivo);
    archivo.add(nuevo);
    archivo.add(salir);

    menu.add(sobre);
    sobre.add(autores);

    setJMenuBar(menu);

    // Creamos los botones
    this.panelBotones = new JPanel();
    panelBotones.setLayout(new GridLayout(3, 3));
    panel.add(panelBotones, BorderLayout.SOUTH);

    botonDefinirPuntos = new JButton("Definir Perfil");
    botonDefinirPuntos.setVisible(true);
    panelBotones.add(botonDefinirPuntos);

    botonAplicarSplines = new JButton("BSplines");
    botonAplicarSplines.setVisible(true);
    panelBotones.add(botonAplicarSplines);

    botonGenerarMallaRevolucion = new JButton("Revolución");
    botonGenerarMallaRevolucion.setVisible(true);
    panelBotones.add(botonGenerarMallaRevolucion);

    botonGenerarMallaExtrusion = new JButton("Extrusión");
    botonGenerarMallaExtrusion.setVisible(true);
    panelBotones.add(botonGenerarMallaExtrusion);

    botonCambiarModo = new JButton("Cambiar Modo");
    botonCambiarModo.setVisible(true);
    panelBotones.add(botonCambiarModo);

    botonDibujarNormales = new JButton("Activa Normales");
    botonDibujarNormales.setVisible(true);
    panelBotones.add(botonDibujarNormales);

    // Definimos el tipo de malla actual a representar
    this.tipoMalla = 0;

    // Definimos un perfil por defecto
    this.perfil = new ArrayList<PuntoVector3D>();
    this.perfil.add(new PuntoVector3D(250, 330, 0, 1));
    this.perfil.add(new PuntoVector3D(250, 300, 0, 1));
    this.perfil.add(new PuntoVector3D(230, 270, 0, 1));
    this.perfil.add(new PuntoVector3D(200, 240, 0, 1));
    this.perfil.add(new PuntoVector3D(200, 210, 0, 1));
    this.perfil.add(new PuntoVector3D(200, 180, 0, 1));
    this.perfil.add(new PuntoVector3D(200, 150, 0, 1));
    this.perfil.add(new PuntoVector3D(230, 120, 0, 1));

    // Creamos el canvas de dibujo
    canvas = new GLJPanel();
    escena = new GL3D(425, 425);
    canvas.addGLEventListener(escena);
    canvas.addMouseListener(new ManejadorRaton());
    panel.add(canvas, BorderLayout.CENTER);

    // Transformamos el perfil a coordenadas de la escena
    this.perfil = escena.transformarPerfil(this.perfil);
    escena.setPerfil(this.perfil);

    // Animación de la escena
    animacion = new Animator(canvas);
    animacion.start();

    // Entrada de datos desactivada
    entradaDatos = false;

    // Acción por defecto al cerrar la ventana
    this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    // Evento Oyente para la barra de menu "nuevo"
    nuevo.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            perfil = new ArrayList<PuntoVector3D>();
            escena.actualizarPerfil(tipoMalla, perfil);
          }
        });

    // Evento Oyente para la barra de menu "Autores"
    autores.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(
                null, "Iván Romero\nPedro Sánchez", "Autores", JOptionPane.INFORMATION_MESSAGE);
          }
        });

    // Evento Oyente para el boton "Definir Perfil"
    botonDefinirPuntos.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            perfil = new ArrayList<PuntoVector3D>();
            escena.setPerfil(perfil);
            entradaDatos = true;
          }
        });

    // Evento Oyente para el boton "Aplicar Splines"
    botonAplicarSplines.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {

            String dato =
                JOptionPane.showInputDialog(
                    null,
                    "Numero de puntos de control. Rango[" + perfil.size() + "...N]",
                    "Datos de Entrada",
                    1);
            if (dato != null) {
              int num = Integer.parseInt(dato);
              perfil = new Calculos().calculaPuntosBSplines(perfil, num);
              if (perfil.size() > num) {
                ArrayList<PuntoVector3D> perfilAux = new ArrayList<PuntoVector3D>();
                for (int i = 0; i < num - 2; i++) {
                  perfilAux.add(perfil.get(i));
                }
                perfil = (ArrayList<PuntoVector3D>) perfilAux.clone();
              }
              escena.setPerfil(perfil);
              entradaDatos = false;
            }
          }
        });

    // Evento Oyente para el boton "Malla Revolución"
    botonGenerarMallaRevolucion.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {

            // String datoNumVertices = "4";
            String datoAng = JOptionPane.showInputDialog("Ángulo de rotación: ", "0.15");
            if (datoAng != null) {

              Object[] opciones = {"3", "4"};
              int eleccion =
                  JOptionPane.showOptionDialog(
                      null,
                      "Número de Vértices de la cara: ",
                      "Datos de Entrada",
                      JOptionPane.DEFAULT_OPTION,
                      JOptionPane.WARNING_MESSAGE,
                      null,
                      opciones,
                      opciones[0]);

              int numVerticesCara = Integer.parseInt((String) opciones[eleccion]);
              double anguloRadianes = Double.parseDouble(datoAng);

              mallaActual = new MallaPorRevolucion(perfil, numVerticesCara, anguloRadianes);
              //  mallaRevolucion = new MallaPorRevolucion(perfil, numVerticesCara, anguloRadianes);

              //  escena.actualizarMallaRev(2, mallaRevolucion);
              escena.actualizarMalla(2, mallaActual);
              escena.setGenerado(true);
              entradaDatos = false;
            }
          }
        });

    // Evento Oyente para el boton "Malla Extrusión"
    botonGenerarMallaExtrusion.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {

            String SnP =
                JOptionPane.showInputDialog(
                    "Número de lados que aproximan la sección del toroide", "10");
            String SnQ = JOptionPane.showInputDialog("Número de capas del toroide", "50");
            String Sr1 = JOptionPane.showInputDialog("Radio del toro", "150");
            String Sr2 = JOptionPane.showInputDialog("Radio de la sección del toro", "20");

            int nP = Integer.parseInt(SnP);
            int nQ = Integer.parseInt(SnQ);
            float r1 = Float.parseFloat(Sr1);
            float r2 = Float.parseFloat(Sr2);

            mallaActual = new Toro(nP, nQ, r1, r2);
            escena.actualizarMalla(3, mallaActual);

            escena.setGenerado(true);
            entradaDatos = false;
          }
        });

    // Evento Oyente para el botón "Cambiar Modo"
    botonCambiarModo.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {

            Object[] opciones = {"Puntos", "Líneas", "Sólidos"};
            int eleccion =
                JOptionPane.showOptionDialog(
                    null,
                    "Cambiar Modo de Representación a: ",
                    "Datos de Entrada",
                    JOptionPane.DEFAULT_OPTION,
                    JOptionPane.WARNING_MESSAGE,
                    null,
                    opciones,
                    opciones[0]);

            mallaActual.setTipoMalla(eleccion);
          }
        });

    // Evento Oyente para el botón "Dibujar Normales"
    botonDibujarNormales.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {

            if (botonDibujarNormales.getText().equals("Activa Normales")) {
              botonDibujarNormales.setText("DesactivaNormales");
              mallaActual.setNormales(true);
            } else {
              botonDibujarNormales.setText("Activa Normales");
              mallaActual.setNormales(false);
            }
          }
        });

    // Añadimos un evento para la acción de salida
    addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowClosing(WindowEvent e) {
            new Thread(
                    new Runnable() {

                      public void run() {
                        animacion.stop();
                        System.exit(0);
                      }
                    })
                .start();
          }
        });
  }
Example #16
0
  /** Initializes the graphical components */
  public void init() {
    username = getParameter("username");
    if (username == null) {
      username =
          JOptionPane.showInputDialog(
              this, "Please enter a username", "Login", JOptionPane.QUESTION_MESSAGE);
    }
    try {
      PORT = Integer.valueOf(getParameter("port")).intValue();
    } catch (NumberFormatException e) {
      PORT = 42412;
    }

    URL url = getDocumentBase();
    site = url.getHost();
    locationURL = "http://" + site + ":" + url.getPort() + "/" + url.getPath();

    setSize(615, 362);
    c = getContentPane();

    c.setBackground(new Color(224, 224, 224));

    if (site == null || locationURL == null) {
      c.add(new JLabel("ERROR: did not recieve needed data from page"));
    }

    myAction = new MyAction();
    myKeyListener = new MyKeyListener();
    myMouseListener = new MyMouseListener();
    myHyperlinkListener = new MyHyperlinkListener();

    c.setLayout(null);

    cboChannels = new JComboBox();
    cboChannels.setBounds(5, 5, 150, 24);

    butChannel = new JButton("Join");
    butChannel.setToolTipText("Join channel");
    butChannel.addActionListener(myAction);
    butChannel.setBounds(160, 5, 60, 24);

    butCreate = new JButton("Create");
    butCreate.setToolTipText("Create new channel");
    butCreate.addActionListener(myAction);
    butCreate.setBounds(230, 5, 100, 24);
    butCreate.setEnabled(false);

    butInvite = new JButton("Invite");
    butInvite.setToolTipText("Invite Friend");
    butInvite.addActionListener(myAction);
    butInvite.setBounds(340, 5, 80, 24);

    mainChat = new ChatPane(this);
    textScroller =
        new JScrollPane(
            mainChat,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    textScroller.setBounds(5, 34, 500, 270);

    userList = new JList();
    userList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    userList.setCellRenderer(new MyCellRenderer());
    userList.setBackground(new Color(249, 249, 250));
    JScrollPane userScroller = new JScrollPane(userList);
    userScroller.setBounds(510, 34, 100, 297);

    messageText = new JTextField();
    messageText.setBounds(5, 309, 500, 22);
    messageText.setColumns(10);
    messageText.setBackground(new Color(249, 249, 250));

    JMenuItem item;
    popup = new JPopupMenu("test");
    popup.add("whisper").addActionListener(myAction);
    popup.add("private message").addActionListener(myAction);
    popup.add("ignore").addActionListener(myAction);
    popup.add("clear ignore list").addActionListener(myAction);

    conNo = new ImageIcon(getURL("images/connect_no.gif"));
    conYes = new ImageIcon(getURL("images/connect_established.gif"));
    secNo = new ImageIcon(getURL("images/decrypted.gif"));
    secYes = new ImageIcon(getURL("images/encrypted.gif"));

    conIcon = new JLabel(conNo);
    conIcon.setBorder(new EtchedBorder());
    secIcon = new JLabel(secNo);
    secIcon.setBorder(new EtchedBorder());

    conIcon.setBounds(563, 334, 22, 22);
    secIcon.setBounds(588, 334, 22, 22);

    bottomText =
        new JLabel(
            "<html><body><font color=#445577><b>"
                + "LlamaChat "
                + VERSION
                + "</b></font> &nbsp;&copy; "
                + "<a href=\""
                + linkURL
                + "\">Joseph Monti</a> 2002-2003"
                + "</body></html>");
    bottomText.setBounds(5, 336, 500, 20);

    c.add(cboChannels);
    c.add(butChannel);
    c.add(butCreate);
    c.add(butInvite);
    c.add(textScroller);
    c.add(userScroller);
    c.add(messageText);
    c.add(conIcon);
    c.add(secIcon);
    c.add(bottomText);

    userList.addMouseListener(myMouseListener);
    messageText.addKeyListener(myKeyListener);
    bottomText.addMouseListener(myMouseListener);

    users = new ArrayList();
    ignores = new ArrayList(5);
    afks = new ArrayList(5);
    admins = new ArrayList(5);
    history = new CommandHistory(10);
    admin = false;
    channels = new Hashtable();
    privates = new PrivateMsg(this);
    showUserStatus = false;

    myColors[0] = new Color(200, 0, 0);
    myColors[1] = new Color(0, 150, 0);
    myColors[2] = new Color(0, 0, 200);

    rect = new Rectangle(0, 0, 1, 1);

    String opening =
        "<font color=#333333>"
            + "==================================<br>"
            + "Welcome to LlamaChat "
            + VERSION
            + "<br>"
            + "If you need assistance, type \\help<br>"
            + "Enjoy your stay!<br>"
            + "Maestria Aplicada en Redes<br>"
            + "==================================<br></font>";
    HTMLDocument doc = (HTMLDocument) mainChat.getDocument();
    HTMLEditorKit kit = (HTMLEditorKit) mainChat.getEditorKit();
    try {
      kit.insertHTML(doc, doc.getLength(), opening, 0, 0, HTML.Tag.FONT);
    } catch (Throwable t) {
      t.printStackTrace(System.out);
    }

    // validate the name
    if (!username.matches("[\\w_-]+?")) {
      error(
          "username contains invalid characters, changing to "
              + "'invalid' for now. "
              + "Type \\rename to chose a new name");
      username = "******";
    }
    if (username.length() > 10) {
      username = username.substring(0, 10);
      error("username too long, changed to " + username);
    }

    connect();
  }
Example #17
0
  // gui constructor
  public Gui() throws IOException {

    // sets frame text and features
    super("Doge Clicker 1.0");
    this.setIconImage(new ImageIcon("Images//doge.jpg").getImage());

    // initializes sound files
    Sounds.initialize();

    // gui dimensions and features
    setSize(1000, 700);
    setResizable(false);
    setLayout(null);
    Container c = getContentPane();
    c.setBackground(new Color(255, 255, 255));
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    // timer for doge per second run method runs every millisecond
    timer = new Timer();
    timer.schedule(new RemindTask(), 1000, 10);

    // bolded title
    title = new JLabel("Doge Clicker v1.0");
    title.setBounds(0, 0, getWidth(), 40);
    title.setFont(new Font("Comic Sans MS", Font.BOLD, 26));
    title.setForeground(Color.white);
    title.setHorizontalAlignment(JLabel.CENTER);
    add(title);

    // reads news.txt to have import text to array
    String filePath = "Data\\news.txt";
    BufferedReader fileIn = new BufferedReader(new FileReader(filePath));
    for (int i = 0; i < line.length; i++) {

      // reads lines and saves until done reading
      if ((line[i] = fileIn.readLine()) != null) {}
    }
    fileIn.close(); // close file

    // read flavor text.txt to import text to array
    filePath = "Data\\flavourtext.txt";
    fileIn = new BufferedReader(new FileReader(filePath));
    for (int i = 0; i < flavourText.length; i++) {

      // reads lines until complety reading
      if ((flavourText[i] = fileIn.readLine()) != null) {}
    }
    fileIn.close();

    // flavour label that pops up randomly when doge is clicked
    flavourClick = new JLabel("Wow! Such click!");
    flavourClick.setBounds(400, 100, getWidth(), getHeight());
    flavourClick.setFont(new Font("Comic Sans MS", Font.BOLD, 25));
    flavourClick.setForeground(Color.white);
    flavourClick.setOpaque(false);
    add(flavourClick);

    // label for achievements
    achievementText = new JLabel("These are your achievements");
    achievementText.setBounds(75, 2, getWidth(), 15);
    achievementText.setFont(new Font("Comic Sans MS", Font.BOLD, 13));
    achievementText.setForeground(Color.white);
    add(achievementText);

    // label for doge buying and click upgrades
    dogeProducers = new JLabel("Buy to make more doge");
    dogeProducers.setBounds(50, 160, getWidth(), 40);
    dogeProducers.setFont(new Font("Comic Sans MS", Font.BOLD, 13));
    dogeProducers.setForeground(Color.white);
    add(dogeProducers);
    dogeClickers = new JLabel("Miscellaneous upgrades wow");
    dogeClickers.setBounds(700, 160, getWidth(), 40);
    dogeClickers.setFont(new Font("Comic Sans MS", Font.BOLD, 13));
    dogeClickers.setForeground(Color.white);
    add(dogeClickers);

    // doge click button
    dogeClick = new JButton(new ImageIcon("Images/doge.jpg"));
    dogeClick.addActionListener(this);
    dogeClick.setBounds(450, 100, 100, 100);
    dogeClick.setOpaque(false);
    dogeClick.setBorder(BorderFactory.createLineBorder(Color.black));
    dogeClick.setToolTipText("Each click gives you " + clickUpgrade + " doge. wow");
    add(dogeClick);

    // click multiplier
    clickMultiplier = new JLabel(multiplier + "x");
    clickMultiplier.setBounds(570, 120, getWidth(), 50);
    clickMultiplier.setFont(new Font("Comic Sans MS", Font.BOLD, 30));
    clickMultiplier.setForeground(Color.white);
    add(clickMultiplier);
    // clicks per second indicator
    cpsIndicator = new JLabel(cps + " clicks per second");
    cpsIndicator.setBounds(570, 150, getWidth(), 50);
    cpsIndicator.setFont(new Font("Comic Sans MS", Font.BOLD, 10));
    cpsIndicator.setForeground(Color.white);
    add(cpsIndicator);

    // event indicator
    eventIndicator = new JLabel("Welcome to doge clicker!");
    eventIndicator.setBounds(700, 530, getWidth(), 50);
    eventIndicator.setFont(new Font("Comic Sans MS", Font.BOLD, 15));
    eventIndicator.setForeground(Color.white);
    add(eventIndicator);

    // states the num of doge and doge per second
    dogeCount = new JLabel("Doge: " + doge);
    dogeCount.setBounds(0, 0, getWidth(), 120);
    dogeCount.setFont(new Font("Comic Sans MS", Font.BOLD, 20));
    dogeCount.setForeground(Color.white);
    dogeCount.setHorizontalAlignment(JLabel.CENTER);
    add(dogeCount);
    dogePerSecond = new JLabel("You get " + dps + " doge per second");
    dogePerSecond.setBounds(0, 25, getWidth(), 120);
    dogePerSecond.setFont(new Font("Comic Sans MS", Font.BOLD, 11));
    dogePerSecond.setForeground(Color.white);
    dogePerSecond.setHorizontalAlignment(JLabel.CENTER);
    add(dogePerSecond);
    dogeClicktext = new JLabel("Click for more doge");
    dogeClicktext.setBounds(400, 185, 200, 50);
    dogeClicktext.setFont(new Font("Comic Sans MS", Font.BOLD, 13));
    dogeClicktext.setForeground(Color.white);
    dogeClicktext.setHorizontalAlignment(JLabel.CENTER);
    add(dogeClicktext);
    // doge button testing button
    devButton = new JButton(new ImageIcon());
    devButton.addActionListener(this);
    devButton.setBounds(0, 0, 50, 50);
    devButton.setToolTipText("Such Secret");
    devButton.setOpaque(false);
    devButton.setContentAreaFilled(false);
    devButton.setBorderPainted(false);
    add(devButton);

    // options and save buttons
    options = new JButton(new ImageIcon("Images/option.png"));
    options.addActionListener(this);
    options.setBounds(900, 10, 70, 70);
    options.setOpaque(false);
    options.setBorder(BorderFactory.createLineBorder(Color.black));
    options.setToolTipText("Go to options");
    add(options);
    save = new JButton(new ImageIcon("Images/save.png"));
    save.addActionListener(this);
    save.setBounds(820, 10, 70, 70);
    save.setOpaque(false);
    save.setBorder(BorderFactory.createLineBorder(Color.black));
    save.setToolTipText("Save a file");
    add(save);
    open = new JButton(new ImageIcon("Images/open.png"));
    open.addActionListener(this);
    open.setBounds(740, 10, 70, 70);
    open.setOpaque(false);
    open.setBorder(BorderFactory.createLineBorder(Color.black));
    open.setToolTipText("Open a file");
    add(open);

    // news headline label that will move
    for (int i = 0; i < 3; i++) {

      newsHeadline[i] = new JLabel("Welcome to Doge clicker this is a news headline!");
      newsHeadline[i].setBounds(-200 - (475 * i), 615, getWidth(), 40);
      newsHeadline[i].setFont(new Font("Comic Sans MS", Font.BOLD, 13));
      newsHeadline[i].setForeground(Color.white);
      add(newsHeadline[i]);
    }

    // create all buttons and button stats and labels for producers
    for (int i = 0; i < MAX_UPGRADES; i++) {

      producerStats[i] = new Producers(i);
      producers[i] = new JButton(new ImageIcon(producerStats[i].getImage()));
      producers[i].addActionListener(this);
      producers[i].setOpaque(false);
      producers[i].setBorder(BorderFactory.createLineBorder(Color.black));
      producers[i].setToolTipText(
          "Your "
              + producerStats[i].getButtonName()
              + " gives "
              + producerStats[i].getDogeProduction() * producerStats[i].getCount()
              + " doge per second");
      producers[i].setBounds(0, 0, 70, 70);

      buyProducers[i] =
          new JLabel(
              "Buy "
                  + producerStats[i].getButtonName()
                  + " for "
                  + producerStats[i].getCost()
                  + " doge");
      buyProducers[i].setBounds(0, 0, getWidth(), 100);
      buyProducers[i].setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
      buyProducers[i].setForeground(Color.white);

      buyDetails[i] =
          new JLabel(
              "You have: " + producerStats[i].getCount() + " " + producerStats[i].getButtonName());
      buyDetails[i].setBounds(0, 0, getWidth(), 100);
      buyDetails[i].setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
      buyDetails[i].setForeground(Color.white);
    }
    // buttons and labels for click upgrades clickers
    for (int i = 0; i < MAX_CLICK; i++) {

      clickerStats[i] = new Clickers(i);
      clickers[i] = new JButton(new ImageIcon(clickerStats[i].getImage()));
      clickers[i].addActionListener(this);
      if (clickerStats[i].getClickMultiplier() == 1) {
        clickers[i].setToolTipText(
            "Buy this "
                + clickerStats[i].getButtonName()
                + " to get +"
                + clickerStats[i].getClickBonus()
                + " doge per click");
      } else {
        clickers[i].setToolTipText(
            "Buy this "
                + clickerStats[i].getButtonName()
                + " to get x"
                + clickerStats[i].getClickMultiplier()
                + " doge per click");
      }
      clickers[i].setOpaque(false);
      clickers[i].setBorder(BorderFactory.createLineBorder(Color.black));
      clickers[i].setBounds(0, 0, 70, 70);

      buyClickers[i] =
          new JLabel(
              "Buy "
                  + clickerStats[i].getButtonName()
                  + " for "
                  + clickerStats[i].getCost()
                  + " doge");
      buyClickers[i].setBounds(0, 0, getWidth(), 100);
      buyClickers[i].setFont(new Font("Comic Sans MS", Font.PLAIN, 12));
      buyClickers[i].setForeground(Color.white);
    }

    // labels for achievements
    for (int i = 0; i < MAX_ACHIEVEMENTS; i++) {
      achievementStats[i] = new Achievements(i);
      achievements[i] = new JLabel(new ImageIcon(achievementStats[i].getImage()));
      achievements[i].setBorder(BorderFactory.createLineBorder(Color.black));
      achievements[i].setToolTipText("Achievement: " + achievementStats[i].getButtonName());
      achievements[i].setBounds(0, 0, 70, 70);
    }

    // JPanel containing achievements
    JPanel achievementPanel = new JPanel();
    achievementPanel.setPreferredSize(new Dimension(350, 70));
    achievementPanel.setLayout(null);
    achievementPanel.setOpaque(false);

    // JScrollpane containing JPanel for achievements
    JScrollPane achievementDisplay = new JScrollPane();
    achievementDisplay.setViewportBorder(new LineBorder(Color.black));
    achievementDisplay.setSize(280, 90);
    achievementDisplay.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    achievementDisplay.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    achievementDisplay.getVerticalScrollBar().setUnitIncrement(10);
    achievementDisplay.setLocation(50, 20);
    achievementDisplay.setOpaque(false);
    add(achievementDisplay);

    // adds the panel
    achievementDisplay.getViewport().add(achievementPanel);
    achievementDisplay.getViewport().setOpaque(false);

    // adds all achievements
    for (int i = 0; i < MAX_ACHIEVEMENTS; i++) {

      achievementPanel.add(achievements[i]);
      achievements[i].setLocation(0 + i * 70, 0);
      achievements[i].setVisible(false);
    }

    // jpanel containing upgrades for producers
    JPanel upgradePanel = new JPanel();
    upgradePanel.setPreferredSize(new Dimension(350, 770));
    upgradePanel.setLayout(null);
    upgradePanel.setOpaque(false);

    // Jscrollpane containing jpanel for producers
    JScrollPane producerUpgrades = new JScrollPane();
    producerUpgrades.setViewportBorder(new LineBorder(Color.black));
    producerUpgrades.setSize(350, 300);
    producerUpgrades.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    producerUpgrades.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    producerUpgrades.getVerticalScrollBar().setUnitIncrement(10);
    producerUpgrades.setLocation(0, 200);
    producerUpgrades.setOpaque(false);
    add(producerUpgrades);

    producerUpgrades.getViewport().setOpaque(false);
    producerUpgrades.getViewport().add(upgradePanel);

    // adds all upgrades
    for (int i = 0; i < MAX_UPGRADES; i++) {

      upgradePanel.add(producers[i]);
      producers[i].setLocation(0, (i) * 70);
      upgradePanel.add(buyProducers[i]);
      buyProducers[i].setLocation(90, (i * 70) - 35);
      upgradePanel.add(buyDetails[i]);
      buyDetails[i].setLocation(90, (i * 70) - 20);
    }

    // jpanel containing upgrades for clickers
    JPanel clickPanel = new JPanel();
    clickPanel.setPreferredSize(new Dimension(350, 350));
    clickPanel.setLayout(null);
    clickPanel.setOpaque(false);

    // Jscrollpane containing jpanel for clickers
    JScrollPane clickUpgrades = new JScrollPane();
    clickUpgrades.setViewportBorder(new LineBorder(Color.black));
    clickUpgrades.setSize(350, 300);
    clickUpgrades.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    clickUpgrades.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    clickUpgrades.getVerticalScrollBar().setUnitIncrement(10);
    clickUpgrades.setLocation(650, 200);
    clickUpgrades.setOpaque(false);
    add(clickUpgrades);
    clickUpgrades.getViewport().add(clickPanel);
    clickUpgrades.getViewport().setOpaque(false);

    // adds all click upgrades
    for (int i = 0; i < MAX_CLICK; i++) {

      clickPanel.add(clickers[i]);
      clickers[i].setLocation(0, (i) * 70);
      clickPanel.add(buyClickers[i]);
      buyClickers[i].setLocation(80, (i * 70) - 30);
    }

    // dancing snoop dog image
    JLabel snoop = new JLabel(new ImageIcon("Images//snoop.gif"));
    snoop.setBounds(450, 370, 150, 308);
    snoop.setOpaque(false);
    add(snoop);

    // background image
    JLabel background = new JLabel(new ImageIcon("Images//dogebackground.png"));
    background.setBounds(0, 0, 1000, 700);
    add(background);

    // makes everything above visible
    setVisible(true);
    // flavour click will remain invisible
    flavourClick.setVisible(false);

    // timer for news headline, runs every 20 milliseconds
    MyTimerTask task = new MyTimerTask();
    Timer newsTimer = new Timer();
    newsTimer.scheduleAtFixedRate(task, 0, 20);
  }
Example #18
0
  public TestBattle() {
    super("Battle");
    setSize(450, 500);

    Container pane = getContentPane();
    pane.setBackground(Color.GREEN);
    pane.setLayout(new FlowLayout());

    createDefenders();
    createInvaders();

    textD = new JTextArea("monospaced", Font.PLAIN, 14);
    textD.setText(ta.toString() + "\n" + in.toString());
    pane.add(textD);

    textI = new JTextArea("monospaced", Font.PLAIN, 14);
    textI.setText(bo.toString() + "\n" + fs.toString());
    pane.add(textI);

    tankShootTheBomber = new JButton("Tank Shoots Bomber");
    tankShootTheBomber.addActionListener(this);
    pane.add(tankShootTheBomber);

    infantryShootTheBomber = new JButton("Infantry Shoots Bomber");
    infantryShootTheBomber.addActionListener(this);
    pane.add(infantryShootTheBomber);

    tankShootTheFootsoldier = new JButton("Tank Shoots Footsoldier");
    tankShootTheFootsoldier.addActionListener(this);
    pane.add(tankShootTheFootsoldier);

    infantryShootTheFootsoldier = new JButton("Infantry Shoots Footsoldier");
    infantryShootTheFootsoldier.addActionListener(this);
    pane.add(infantryShootTheFootsoldier);

    bomberShootTheTank = new JButton("Bomber Shoots Tank");
    bomberShootTheTank.addActionListener(this);
    pane.add(bomberShootTheTank);

    bomberShootTheInfantry = new JButton("Bomber Shoots Infantry");
    bomberShootTheInfantry.addActionListener(this);
    pane.add(bomberShootTheInfantry);

    footsoldierShootTheTank = new JButton("Footsoldier Shoots Tank");
    footsoldierShootTheTank.addActionListener(this);
    pane.add(footsoldierShootTheTank);

    footsoldierShootTheInfantry = new JButton("Footsoldier Shoots Infantry");
    footsoldierShootTheInfantry.addActionListener(this);
    pane.add(footsoldierShootTheInfantry);

    reloadTank = new JButton("Reload Tank");
    reloadTank.addActionListener(this);
    pane.add(reloadTank);

    reloadInfantry = new JButton("Reload Infantry");
    reloadInfantry.addActionListener(this);
    pane.add(reloadInfantry);

    reloadBomber = new JButton("Reload Bomber");
    reloadBomber.addActionListener(this);
    pane.add(reloadBomber);

    reloadFootsoldier = new JButton("Reload Footsoldier");
    reloadFootsoldier.addActionListener(this);
    pane.add(reloadFootsoldier);

    setVisible(true);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }