예제 #1
0
  // Method to build the dialog box for help.
  private void buildDialogBox() {
    // Set the JDialog window properties.
    setTitle("Stack Trace Detail");
    setResizable(false);
    setSize(dialogWidth, dialogHeight);

    // Append the stack trace output to the display area.
    displayArea.append(eStackTrace);

    // Create horizontal and vertical scrollbars for box.
    displayBox = Box.createHorizontalBox();
    displayBox = Box.createVerticalBox();

    // Add a JScrollPane to the Box.
    displayBox.add(new JScrollPane(displayArea));

    // Define behaviors of container.
    c.setLayout(null);
    c.add(displayBox);
    c.add(okButton);

    // Set scroll pane bounds.
    displayBox.setBounds(
        (dialogWidth / 2) - ((displayAreaWidth / 2) + 2),
        (top + (offsetMargin / 2)),
        displayAreaWidth,
        displayAreaHeight);

    // Set the behaviors, bounds and action listener for the button.
    okButton.setBounds(
        (dialogWidth / 2) - (buttonWidth / 2),
        (displayAreaHeight + 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));

    // 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.
    setLocation((dim.width / 2) - (dialogWidth / 2), (dim.height / 2) - (dialogHeight / 2));

    // Display JDialog.
    show();
  } // End of buildDialogBox method.
예제 #2
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.
예제 #3
0
    ModiPanel(MemberPane mp, BusinessPane bp) {
      this.member_pane = mp;
      this.busi_pane = bp;
      setLayout(null);
      add(member_title);
      member_title.setBounds(20, 10, 80, 20);
      add(member_id);
      member_id.setBounds(20, 35, 80, 20);
      add(member_name);
      member_name.setBounds(20, 60, 80, 20);
      add(member_tele);
      member_tele.setBounds(20, 85, 80, 20);
      add(member_level);
      member_level.setBounds(20, 110, 80, 20);
      add(member_bal);
      member_bal.setBounds(20, 135, 80, 20);
      add(text_id);
      text_id.setBounds(100, 35, 180, 20);
      add(text_name);
      text_name.setBounds(100, 60, 180, 20);
      add(text_tele);
      text_tele.setBounds(100, 85, 180, 20);
      /*add(text_level);
      text_level.setBounds(100,90,180,20);*/
      add(text_bal);
      text_bal.setBounds(100, 135, 180, 20);
      add(spinner_level);
      spinner_level.setBounds(100, 110, 180, 20);

      add(trans_title);
      trans_title.setBounds(20, 220, 80, 20);
      add(trans_member);
      trans_member.setBounds(20, 245, 80, 20);
      add(trans_money);
      trans_money.setBounds(20, 270, 80, 20);
      add(text_member);
      text_member.setBounds(100, 245, 180, 20);
      add(text_money);
      text_money.setBounds(100, 270, 180, 20);

      add(button_add);
      button_add.setBounds(100, 165, 100, 25);
      button_add.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                System.out.println("add");
                mm.addMember(
                    text_id.getText(),
                    text_name.getText(),
                    text_tele.getText(),
                    spinner_level.getValue().toString(),
                    text_bal.getText());
                member_pane.update_table();
              } catch (Exception ex) {
                JOptionPane.showMessageDialog(
                    mainFrame, "Adding Failure!", "ERROR", JOptionPane.ERROR_MESSAGE);
              }

              // dialog_send.setVisible(false);
            }
          });

      add(button_add_trans);
      button_add_trans.setBounds(100, 305, 100, 25);
      button_add_trans.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                System.out.println("add transaction");
                Business busi =
                    new Business(
                        text_member.getText(), Float.valueOf(text_money.getText()).floatValue());
                busi.addBusi();
                busi_pane.update_table();
              } catch (Exception ex) {
                JOptionPane.showMessageDialog(
                    mainFrame, "Adding Failure!", "ERROR", JOptionPane.ERROR_MESSAGE);
              }

              // dialog_send.setVisible(false);
            }
          });

      // set font;
      member_title.setFont(font_title);
      member_id.setFont(font);
      member_name.setFont(font);
      member_tele.setFont(font);
      member_level.setFont(font);
      member_bal.setFont(font);
      button_add.setFont(font);
      trans_title.setFont(font_title);
      trans_member.setFont(font);
      trans_money.setFont(font);
      button_add_trans.setFont(font);
    }