Пример #1
0
  // Constructor
  public DeleteArchiveFrame(AmazonGlacierClient client, String vaultName, int region) {
    super("Delete Archive");

    int width = 200;
    int height = 170;

    Color wc = Color.WHITE;

    deleteClient = client;
    deleteVault = vaultName;

    JLabel label1 =
        new JLabel("ArchiveID to Delete from " + Endpoint.getTitleByIndex(region) + ":");
    jtfDeleteField = new JTextField(100);
    jbtDelete = new JButton("Delete");
    jbtBack = new JButton("Back");

    JPanel p1 = new JPanel();
    p1.setLayout(new FlowLayout());
    p1.add(label1);
    p1.setBackground(wc);

    JPanel p2 = new JPanel();
    p2.setLayout(new FlowLayout());
    p2.add(jtfDeleteField);
    jtfDeleteField.addMouseListener(new ContextMenuMouseListener());
    jtfDeleteField.setFocusable(true);
    p2.setBackground(wc);

    JPanel p3 = new JPanel();
    p3.setLayout(new FlowLayout());
    p3.add(jbtDelete);
    jbtDelete.addActionListener(this);
    jbtDelete.setBackground(wc);
    p3.add(jbtBack);
    jbtBack.addActionListener(this);
    jbtBack.setBackground(wc);
    p3.setBackground(wc);

    JPanel p4 = new JPanel();
    p4.setLayout(new BorderLayout());
    p4.setBackground(wc);
    p4.add(p1, BorderLayout.NORTH);
    p4.add(p2, BorderLayout.CENTER);
    p4.add(p3, BorderLayout.SOUTH);

    setContentPane(p4);

    // Prepare for display
    pack();
    if (width < getWidth()) // prevent setting width too small
    width = getWidth();
    if (height < getHeight()) // prevent setting height too small
    height = getHeight();
    centerOnScreen(width, height);
    jtfDeleteField.setText("");
    jtfDeleteField.requestFocus();
  }
Пример #2
0
  public SudokuGUI(String x) {
    setTitle(x);
    textfield1.setEditable(false);
    button5.setEnabled(false);
    button10.setEnabled(false);
    button13.setEnabled(false);
    button12.setEnabled(false);
    button15.setEnabled(false);
    button18.setEnabled(false);
    setLayout(new GridLayout(6, 4, 4, 4));
    setLocation(350, 300);

    button1.addMouseListener(this);
    button2.addMouseListener(this);
    button3.addMouseListener(this);
    button4.addMouseListener(this);
    button6.addMouseListener(this);
    button7.addMouseListener(this);
    button8.addMouseListener(this);
    button9.addMouseListener(this);
    button11.addMouseListener(this);
    button14.addMouseListener(this);
    button16.addMouseListener(this);
    button17.addMouseListener(this);
    button19.addMouseListener(this);
    button20.addMouseListener(this);
    textfield2.addMouseListener(this);

    add(button1);
    add(button2);
    add(button3);
    add(button4);
    add(button5);
    add(button6);
    add(button7);
    add(button8);
    add(button9);
    add(button10);
    add(button11);
    add(button12);
    add(button13);
    add(button14);
    add(button15);
    add(button16);
    add(button17);
    add(button18);
    add(button19);
    add(button20);
    add(textfield1);
    add(textfield2);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(700, 400);
  }
Пример #3
0
  // constructor of TextFrame
  public TextFrame() {
    // this.message = message;
    message = "Click to Edit Text";
    messageFont = new Font("Arial", Font.PLAIN, 30);
    foreground = Color.black;
    background = Color.white;

    // custom dialog (it's a private class inside TextFrame)
    cd = new CustomDialog(this);

    messageField = new JTextField();
    messageField.setPreferredSize(new Dimension(300, 200));
    messageField.setEditable(false);
    messageField.setHorizontalAlignment(SwingConstants.CENTER);
    messageField.setAlignmentX(Component.CENTER_ALIGNMENT);
    updateMessage();

    customize = new JButton("Customize");
    customize.setMaximumSize(customize.getPreferredSize());
    customize.setAlignmentX(Component.CENTER_ALIGNMENT);

    apply = new JButton("Apply");
    apply.setMaximumSize(customize.getPreferredSize());
    apply.setAlignmentX(Component.CENTER_ALIGNMENT);

    /*add the listeners*/
    customize.addActionListener(this);
    apply.addActionListener(this);
    messageField.addMouseListener(new PopUpClass());

    // customize
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(customize);
    p.add(Box.createRigidArea(new Dimension(0, 25)));
    p.add(messageField);
    p.add(Box.createRigidArea(new Dimension(0, 25)));
    p.add(apply);
    p.setBorder(BorderFactory.createEmptyBorder(25, 25, 25, 25));

    // make panel this JFrame's content pane

    this.setContentPane(p);
  }
Пример #4
0
  private JPanel buildSnipeSettings() {
    JPanel tp = new JPanel();
    JLabel jl = new JLabel("How close to snipe (in seconds):");

    tp.setBorder(BorderFactory.createTitledBorder("Snipe Timing"));
    tp.setLayout(new BorderLayout());

    snipeTime = new JTextField();
    snipeTime.addMouseListener(JPasteListener.getInstance());
    snipeTime.setToolTipText("Number of seconds prior to auction end to fire a snipe.");

    snipeTime.setEditable(true);
    snipeTime
        .getAccessibleContext()
        .setAccessibleName("Default number of seconds prior to auction end to fire a snipe.");
    tp.add(jl, BorderLayout.NORTH);
    tp.add(snipeTime, BorderLayout.SOUTH);

    return (tp);
  }
  /**
   * Creates a new <code>AddPersonDialog</code> with a given owner <code>JFrame</code> and <code>
   * FamilyTree</code>.
   */
  public AddPersonDialog(JFrame owner, FamilyTree tree) {
    super(owner, "Add New Person", true /* modal */);

    Container pane = this.getContentPane();
    pane.setLayout(new BorderLayout());

    JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new GridLayout(0, 2));
    Border infoBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5);
    infoPanel.setBorder(infoBorder);

    infoPanel.add(new JLabel("id:"));
    final JTextField idField = new JTextField();
    infoPanel.add(idField);

    final ButtonGroup group = new ButtonGroup();

    final JRadioButton male = new JRadioButton("male", true);
    group.add(male);
    infoPanel.add(male);

    final JRadioButton female = new JRadioButton("female");
    group.add(female);
    infoPanel.add(female);

    infoPanel.add(new JLabel("First name:"));
    final JTextField firstNameField = new JTextField();
    infoPanel.add(firstNameField);

    infoPanel.add(new JLabel("Middle name:"));
    final JTextField middleNameField = new JTextField();
    infoPanel.add(middleNameField);

    infoPanel.add(new JLabel("Last name:"));
    final JTextField lastNameField = new JTextField();
    infoPanel.add(lastNameField);

    infoPanel.add(new JLabel("Date of Birth:"));
    final JTextField dobField = new JTextField();
    infoPanel.add(dobField);

    infoPanel.add(new JLabel("Date of Death:"));
    final JTextField dodField = new JTextField();
    infoPanel.add(dodField);

    infoPanel.add(new JLabel("Father:"));
    JPanel fatherPanel = new JPanel();
    fatherPanel.setLayout(new FlowLayout());
    final JTextField fatherText = new JTextField("Click to choose");
    fatherText.setEditable(false);
    fatherText.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            // Pop up a PersonChooseDialog, place name in TextField
            System.out.println("Clicked father");
          }
        });
    fatherPanel.add(fatherText);
    infoPanel.add(fatherPanel);

    infoPanel.add(new JLabel("Mother:"));
    JPanel motherPanel = new JPanel();
    motherPanel.setLayout(new FlowLayout());
    final JTextField motherText = new JTextField("Click to choose");
    motherText.setEditable(false);
    motherText.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            // Pop up a PersonChooseDialog, place name in TextField
            System.out.println("Clicked mother");
          }
        });
    motherPanel.add(motherText);
    infoPanel.add(motherPanel);

    pane.add(infoPanel, BorderLayout.NORTH);

    // "Add" and "Cancel" buttons
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(Box.createHorizontalGlue());

    JButton addButton = new JButton("Add");
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Create a new person based on the information entered in
            // this dialog
            int id = 0;
            try {
              id = Integer.parseInt(idField.getText());

            } catch (NumberFormatException ex) {
              error("Invalid id: " + idField.getText());
              return;
            }

            String text = null;

            text = dobField.getText();
            Date dob = null;
            if (text != null && !text.equals("")) {
              dob = parseDate(dobField.getText());
              if (dob == null) {
                // Parse error
                return;
              }
            }

            text = dodField.getText();
            Date dod = null;
            if (text != null && !text.equals("")) {
              dod = parseDate(dodField.getText());
              if (dod == null) {
                // Parse error
                return;
              }
            }

            Person.Gender gender;
            if (group.getSelection().equals(male)) {
              gender = Person.MALE;

            } else {
              gender = Person.FEMALE;
            }

            // Okay, everything parsed alright
            newPerson = new Person(id, gender);
            newPerson.setFirstName(firstNameField.getText());
            newPerson.setMiddleName(middleNameField.getText());
            newPerson.setLastName(lastNameField.getText());
            newPerson.setDateOfBirth(dob);
            newPerson.setDateOfDeath(dod);

            if (mother != null) {
              newPerson.setMother(mother);
            }

            if (father != null) {
              newPerson.setFather(father);
            }

            // We're all happy
            AddPersonDialog.this.dispose();
          }
        });
    buttonPanel.add(addButton);

    buttonPanel.add(Box.createHorizontalGlue());

    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Read my lips, no new Person!

            AddPersonDialog.this.newPerson = null;

            AddPersonDialog.this.dispose();
          }
        });
    buttonPanel.add(cancelButton);

    buttonPanel.add(Box.createHorizontalGlue());

    pane.add(buttonPanel, BorderLayout.SOUTH);
  }