/** Show the filter dialog */
 public void showDialog() {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   include_panel =
       new ServiceFilterPanel("Include messages based on target service:", filter_include_list);
   exclude_panel =
       new ServiceFilterPanel("Exclude messages based on target service:", filter_exclude_list);
   status_box = new JCheckBox("Filter messages based on status:");
   status_box.addActionListener(this);
   status_active = new JRadioButton("Active messages only");
   status_active.setSelected(true);
   status_active.setEnabled(false);
   status_complete = new JRadioButton("Complete messages only");
   status_complete.setEnabled(false);
   status_group = new ButtonGroup();
   status_group.add(status_active);
   status_group.add(status_complete);
   if (filter_active || filter_complete) {
     status_box.setSelected(true);
     status_active.setEnabled(true);
     status_complete.setEnabled(true);
     if (filter_complete) {
       status_complete.setSelected(true);
     }
   }
   status_options = new JPanel();
   status_options.setLayout(new BoxLayout(status_options, BoxLayout.Y_AXIS));
   status_options.add(status_active);
   status_options.add(status_complete);
   status_options.setBorder(indent_border);
   status_panel = new JPanel();
   status_panel.setLayout(new BorderLayout());
   status_panel.add(status_box, BorderLayout.NORTH);
   status_panel.add(status_options, BorderLayout.CENTER);
   status_panel.setBorder(empty_border);
   ok_button = new JButton("Ok");
   ok_button.addActionListener(this);
   cancel_button = new JButton("Cancel");
   cancel_button.addActionListener(this);
   buttons = new JPanel();
   buttons.setLayout(new FlowLayout());
   buttons.add(ok_button);
   buttons.add(cancel_button);
   panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
   panel.add(include_panel);
   panel.add(exclude_panel);
   panel.add(status_panel);
   panel.add(buttons);
   dialog = new JDialog();
   dialog.setTitle("SOAP Monitor Filter");
   dialog.setContentPane(panel);
   dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
   dialog.setModal(true);
   dialog.pack();
   Dimension d = dialog.getToolkit().getScreenSize();
   dialog.setLocation((d.width - dialog.getWidth()) / 2, (d.height - dialog.getHeight()) / 2);
   ok_pressed = false;
   dialog.show();
 }
Exemple #2
0
 // Skapar de grafiska komponenterna för menyn
 public void createLabels() {
   // Skapar textfält för nick och intellegens och lägger till dem i en lista
   for (int i = 0; i < 4; i++) {
     textfields.add(new JTextField(20));
     intfields.add(new JTextField(20));
   }
   // Skapar checkboxes för att bestämma om spelaren är ett AI och lägger till den i en lista
   for (int i = 0; i < 4; i++) {
     boxes.add(new JCheckBox());
     boxes.get(i).addActionListener(this);
   }
   // Lägger till labels med förbestämd text i panelen
   for (int i = 0; i < 4; i++) {
     panel.add(new JLabel(labeltext[i]));
   }
   // Lägger till textfields och checkboxes i panelen
   for (int i = 4; i < 8; i++) {
     panel.add(new JLabel(labeltext[i]));
     panel.add(textfields.get(i - 4));
     panel.add(boxes.get(i - 4));
     panel.add(intfields.get(i - 4));
     intfields.get(i - 4).setVisible(false);
   }
   // Lägger till några tomma labels i panelen för att skapa mellanrum och symetri
   for (int i = 0; i < 5; i++) {
     panel.add(new JLabel(" "));
   }
   // Lägger till knapparna och lägger actionlisteners på dem
   panel.add(go);
   go.addActionListener(this);
   panel.add(help);
   help.addActionListener(this);
 }
Exemple #3
0
  /**
   * El constructor es el encargado de generar los diferentes componentes del JFrame (botones,
   * textos...).
   */
  public Menu() {

    setSize(250, 150);
    setTitle("Menu");
    setResizable(false);
    setLayout(new GridLayout(5, 5));
    setPreferredSize(new Dimension(250, 100));

    lblDecision = new JLabel("¿Que desea hacer?");
    add(lblDecision);

    butIngresarHora = new JButton("Ingresar Tiempo");
    butIngresarVehiculo = new JButton("Ingresar un Vehiculo");
    butRetirarVehiculo = new JButton("Retirar un Vehiculo");

    add(butIngresarHora);
    add(butIngresarVehiculo);
    add(butRetirarVehiculo);

    butIngresarHora.setActionCommand(IngresarHora);
    butIngresarVehiculo.setActionCommand(IngresarVehiculo);
    butRetirarVehiculo.setActionCommand(RetirarVehiculo);

    butIngresarHora.addActionListener(this);
    butIngresarVehiculo.addActionListener(this);
    butRetirarVehiculo.addActionListener(this);
  }
  /**
   * Constrcutor. Draws the dialog.
   *
   * @param parent the parent frame for this dialog.
   * @param oColour the starting colour to select;
   */
  public UIColorChooserDialog(JFrame parent, Color oColour) {
    super(parent, true);

    setTitle("Colour Chooser");

    oParent = parent;

    tcc = new JColorChooser(oColour);
    oContentPane = getContentPane();
    JPanel mainpanel = new JPanel(new BorderLayout());
    mainpanel.setBorder(new EmptyBorder(10, 10, 10, 10));

    mainpanel.add(tcc, BorderLayout.CENTER);

    JPanel buttonpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

    // Add export button
    pbSave = new UIButton("Save");
    pbSave.addActionListener(this);
    getRootPane().setDefaultButton(pbSave);
    buttonpanel.add(pbSave);

    // Add close button
    pbCancel = new UIButton("Cancel");
    pbCancel.addActionListener(this);
    buttonpanel.add(pbCancel);

    mainpanel.add(buttonpanel, BorderLayout.SOUTH);
    oContentPane.add(mainpanel);

    pack();
  }
  public CopyFileToTable() {
    JPanel jPane1 = new JPanel();
    jPane1.setLayout(new BorderLayout());
    jPane1.add(new JLabel("Filename"), BorderLayout.WEST);
    jPane1.add(jbtViewFile, BorderLayout.EAST);
    jPane1.add(jtfFilename, BorderLayout.CENTER);

    JPanel jPane2 = new JPanel();
    jPane2.setLayout(new BorderLayout());
    jPane2.setBorder(new TitledBorder("Source Text File"));
    jPane2.add(jPane1, BorderLayout.NORTH);
    jPane2.add(new JScrollPane(jtaFile), BorderLayout.CENTER);

    JPanel jPane3 = new JPanel();
    jPane3.setLayout(new GridLayout(5, 0));
    jPane3.add(new JLabel("JDBC Driver"));
    jPane3.add(new JLabel("Database URL"));
    jPane3.add(new JLabel("Username"));
    jPane3.add(new JLabel("Password"));
    jPane3.add(new JLabel("Table Name"));

    JPanel jPane4 = new JPanel();
    jPane4.setLayout(new GridLayout(5, 0));
    jcboDriver.setEditable(true);
    jPane4.add(jcboDriver);
    jcboURL.setEditable(true);
    jPane4.add(jcboURL);
    jPane4.add(jtfUsername);
    jPane4.add(jtfPassword);
    jPane4.add(jtfTableName);

    JPanel jPane5 = new JPanel();
    jPane5.setLayout(new BorderLayout());
    jPane5.setBorder(new TitledBorder("Target Database Table"));
    jPane5.add(jbtCopy, BorderLayout.SOUTH);
    jPane5.add(jPane3, BorderLayout.WEST);
    jPane5.add(jPane4, BorderLayout.CENTER);

    add(jlblStatus, BorderLayout.SOUTH);
    add(new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jPane2, jPane5), BorderLayout.CENTER);

    jbtViewFile.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            showFile();
          }
        });

    jbtCopy.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            try {
              copyFile();
            } catch (Exception ex) {
              jlblStatus.setText(ex.toString());
            }
          }
        });
  }
  public AddNewStudent() // constructor
      {
    // initializing buttons
    btnok = new JButton("OK");
    btnok.addActionListener(this);
    btnexit = new JButton("Exit");
    btnexit.addActionListener(this);
    btnaddnew = new JButton("AddNew");
    btnaddnew.addActionListener(this);

    // initializing textfields
    tf1 = new JTextField(12);
    tf2 = new JTextField(12);
    // initializing labels

    lblname = new JLabel("Name:");
    lbladd = new JLabel("Address:");
    lblmsg = new JLabel("", JLabel.CENTER);

    // initializing panels
    p1 = new JPanel();
    p2 = new JPanel();
    p3 = new JPanel();
    psouth = new JPanel();

    // adding buttons and label to panel p1
    // setting flowlayout
    p1.setLayout(new FlowLayout());

    p1.add(btnok);
    p1.add(btnexit);
    p1.add(btnaddnew);
    // adding lblmsg to panel p3
    p3.add(lblmsg);

    // adding both the panels to new panel,psouth
    // settin layout 2:1
    psouth.setLayout(new GridLayout(2, 1));
    psouth.add(p3);
    psouth.add(p1);

    // adding label and textfields to panel p2
    p2.setLayout(new GridLayout(3, 1));
    // setting line and titled border for panel p2
    p2.setBorder(BorderFactory.createLineBorder(Color.red));
    p2.setBorder(BorderFactory.createTitledBorder("Enter Your Details"));
    p2.add(lblname);
    p2.add(tf1);
    p2.add(lbladd);
    p2.add(tf2);

    // adding panel to container
    this.getContentPane().add(p2, "Center");
    this.getContentPane().add(psouth, "South");

    this.setSize(300, 300);
    this.setLocation(100, 200);
    this.show();
  }
Exemple #7
0
  void initComponents() {
    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    Color bgColor = Color.getHSBColor(0.58f, 0.17f, 0.95f);
    buttonPanel.setBackground(bgColor);
    Border empty = BorderFactory.createEmptyBorder(5, 5, 5, 5);
    buttonPanel.setBorder(empty);

    textField = new JTextField(75);
    buttonPanel.add(textField);

    buttonPanel.add(Box.createHorizontalStrut(10));
    searchPHI = new JButton("Search PHI");
    searchPHI.addActionListener(this);
    buttonPanel.add(searchPHI);

    buttonPanel.add(Box.createHorizontalStrut(10));
    searchTrial = new JButton("Search Trial IDs");
    searchTrial.addActionListener(this);
    buttonPanel.add(searchTrial);

    buttonPanel.add(Box.createHorizontalStrut(20));
    buttonPanel.add(Box.createHorizontalGlue());
    saveAs = new JCheckBox("Save As...");
    saveAs.setBackground(bgColor);
    buttonPanel.add(saveAs);

    mainPanel.add(buttonPanel, BorderLayout.NORTH);

    JScrollPane scrollPane = new JScrollPane();
    textPane = new ColorPane();
    // textPane.setEditable(false);
    scrollPane.setViewportView(textPane);
    mainPanel.add(scrollPane, BorderLayout.CENTER);

    JPanel footerPanel = new JPanel();
    footerPanel.setLayout(new BoxLayout(footerPanel, BoxLayout.X_AXIS));
    footerPanel.setBackground(bgColor);
    message = new JLabel("Ready...");
    footerPanel.add(message);
    mainPanel.add(footerPanel, BorderLayout.SOUTH);

    setTitle(windowTitle);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            System.exit(0);
          }
        });
    getContentPane().add(mainPanel, BorderLayout.CENTER);
    pack();
    centerFrame();
  }
 /** Constructor */
 public ServiceFilterPanel(String text, Vector list) {
   empty_border = new EmptyBorder(5, 5, 0, 5);
   indent_border = new EmptyBorder(5, 25, 5, 5);
   service_box = new JCheckBox(text);
   service_box.addActionListener(this);
   service_data = new Vector();
   if (list != null) {
     service_box.setSelected(true);
     service_data = (Vector) list.clone();
   }
   service_list = new JList(service_data);
   service_list.setBorder(new EtchedBorder());
   service_list.setVisibleRowCount(5);
   service_list.addListSelectionListener(this);
   service_list.setEnabled(service_box.isSelected());
   service_scroll = new JScrollPane(service_list);
   service_scroll.setBorder(new EtchedBorder());
   remove_service_button = new JButton("Remove");
   remove_service_button.addActionListener(this);
   remove_service_button.setEnabled(false);
   remove_service_panel = new JPanel();
   remove_service_panel.setLayout(new FlowLayout());
   remove_service_panel.add(remove_service_button);
   service_area = new JPanel();
   service_area.setLayout(new BorderLayout());
   service_area.add(service_scroll, BorderLayout.CENTER);
   service_area.add(remove_service_panel, BorderLayout.EAST);
   service_area.setBorder(indent_border);
   add_service_field = new JTextField();
   add_service_field.addActionListener(this);
   add_service_field.getDocument().addDocumentListener(this);
   add_service_field.setEnabled(service_box.isSelected());
   add_service_button = new JButton("Add");
   add_service_button.addActionListener(this);
   add_service_button.setEnabled(false);
   add_service_panel = new JPanel();
   add_service_panel.setLayout(new BorderLayout());
   JPanel dummy = new JPanel();
   dummy.setBorder(empty_border);
   add_service_panel.add(dummy, BorderLayout.WEST);
   add_service_panel.add(add_service_button, BorderLayout.EAST);
   add_service_area = new JPanel();
   add_service_area.setLayout(new BorderLayout());
   add_service_area.add(add_service_field, BorderLayout.CENTER);
   add_service_area.add(add_service_panel, BorderLayout.EAST);
   add_service_area.setBorder(indent_border);
   setLayout(new BorderLayout());
   add(service_box, BorderLayout.NORTH);
   add(service_area, BorderLayout.CENTER);
   add(add_service_area, BorderLayout.SOUTH);
   setBorder(empty_border);
 }
Exemple #9
0
  protected void initBtn() {
    bOk.setText("确定");
    bOk.setToolTipText("确定");
    bOk.setMargin(new Insets(0, 0, 0, 0));
    bOk.setIcon(ExplorerIcons.getExplorerIcon("jprofiler/checkbox_16.png"));
    bOk.addActionListener(this);

    bExit.setText("取消");
    bExit.setToolTipText("取消");
    bExit.setMargin(new Insets(0, 0, 0, 0));
    bExit.setIcon(ExplorerIcons.getExplorerIcon("jprofiler/delete.png"));
    bExit.addActionListener(this);
  }
  // {{{ init() method
  private void init() {
    EditBus.addToBus(this);

    /* Setup panes */
    JPanel content = new JPanel(new BorderLayout(12, 12));
    content.setBorder(new EmptyBorder(12, 12, 12, 12));
    setContentPane(content);

    tabPane = new JTabbedPane();
    tabPane.addTab(jEdit.getProperty("manage-plugins.title"), manager = new ManagePanel(this));
    tabPane.addTab(
        jEdit.getProperty("update-plugins.title"), updater = new InstallPanel(this, true));
    tabPane.addTab(
        jEdit.getProperty("install-plugins.title"), installer = new InstallPanel(this, false));
    EditBus.addToBus(installer);
    content.add(BorderLayout.CENTER, tabPane);

    tabPane.addChangeListener(new ListUpdater());

    /* Create the buttons */
    Box buttons = new Box(BoxLayout.X_AXIS);

    ActionListener al = new ActionHandler();
    mgrOptions = new JButton(jEdit.getProperty("plugin-manager.mgr-options"));
    mgrOptions.addActionListener(al);
    pluginOptions = new JButton(jEdit.getProperty("plugin-manager.plugin-options"));
    pluginOptions.addActionListener(al);
    done = new JButton(jEdit.getProperty("plugin-manager.done"));
    done.addActionListener(al);

    buttons.add(Box.createGlue());
    buttons.add(mgrOptions);
    buttons.add(Box.createHorizontalStrut(6));
    buttons.add(pluginOptions);
    buttons.add(Box.createHorizontalStrut(6));
    buttons.add(done);
    buttons.add(Box.createGlue());

    getRootPane().setDefaultButton(done);

    content.add(BorderLayout.SOUTH, buttons);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setIconImage(GUIUtilities.getPluginIcon());

    pack();
    GUIUtilities.loadGeometry(this, parent, "plugin-manager");
    GUIUtilities.addSizeSaver(this, parent, "plugin-manager");
    setVisible(true);
  } // }}}
  /**
   * Constructor of class Wizard
   *
   * @param parent the parent frame
   * @param name the title of the dialog
   * @param modal whether the dialog should be modal
   */
  public Wizard(JFrame parent, String name, boolean modal) {
    super(parent, name, modal);

    // Code inspired by http://java.sun.com/developer/technicalArticles/GUI/swing/wizard/

    listeners = new LinkedList<WizardListener>();
    returnCode = -1;
    this.parent = parent;

    panelMap = new HashMap<Object, WizardPanel>();
    panels = new Vector<WizardPanel>();
    firstPanel = null;
    currentPanel = null;

    handler = new EventHandler();

    // Create the main panel

    JPanel buttonPanel = new JPanel();
    Box buttonBox = new Box(BoxLayout.X_AXIS);

    cardPanel = new JPanel();
    cardPanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));

    cardLayout = new CardLayout();
    cardPanel.setLayout(cardLayout);
    backButton = new JButton("Back");
    nextButton = new JButton("Next");
    cancelButton = new JButton("Cancel");

    backButton.addActionListener(handler);
    nextButton.addActionListener(handler);
    cancelButton.addActionListener(handler);

    backButton.setEnabled(false);

    buttonPanel.setLayout(new BorderLayout());
    buttonPanel.add(new JSeparator(), BorderLayout.NORTH);

    buttonBox.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));
    buttonBox.add(backButton);
    buttonBox.add(Box.createHorizontalStrut(10));
    buttonBox.add(nextButton);
    buttonBox.add(Box.createHorizontalStrut(30));
    buttonBox.add(cancelButton);
    buttonPanel.add(buttonBox, java.awt.BorderLayout.EAST);
    getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH);
    getContentPane().add(cardPanel, java.awt.BorderLayout.CENTER);

    pack();
  }
  /**
   * Constrcutor. Draws the dialog.
   *
   * @param parent the parent frame for this dialog.
   * @param oColour the starting colour to select;
   */
  public UIColorChooserDialog(JFrame parent, Color oColour) {
    super(parent, true);

    setTitle(
        LanguageProperties.getString(
            LanguageProperties.DIALOGS_BUNDLE, "UIColorChooserDialog.title")); // $NON-NLS-1$

    tcc = new JColorChooser(oColour);
    oContentPane = getContentPane();
    JPanel mainpanel = new JPanel(new BorderLayout());
    mainpanel.setBorder(new EmptyBorder(10, 10, 10, 10));

    mainpanel.add(tcc, BorderLayout.CENTER);

    JPanel buttonpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));

    // Add export button
    pbSave =
        new UIButton(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIColorChooserDialog.saveButton")); //$NON-NLS-1$
    pbSave.setMnemonic(
        LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE, "UIColorChooserDialog.saveButtonMnemonic")
            .charAt(0)); // $NON-NLS-1$
    pbSave.addActionListener(this);
    getRootPane().setDefaultButton(pbSave);
    buttonpanel.add(pbSave);

    // Add close button
    pbCancel =
        new UIButton(
            LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE,
                "UIColorChooserDialog.cancelButton")); //$NON-NLS-1$
    pbCancel.setMnemonic(
        LanguageProperties.getString(
                LanguageProperties.DIALOGS_BUNDLE, "UIColorChooserDialog.cancelButtonMnemonic")
            .charAt(0)); // $NON-NLS-1$
    pbCancel.addActionListener(this);
    buttonpanel.add(pbCancel);

    mainpanel.add(buttonpanel, BorderLayout.SOUTH);
    oContentPane.add(mainpanel);

    pack();
  }
  public ScaleMainFrame() {
    super(new BorderLayout());

    nameTF = new JTextField();
    JPanel top = new JPanel(new BorderLayout());
    top.add(new JLabel("Scale Name:"), BorderLayout.WEST);
    top.add(nameTF, BorderLayout.CENTER);

    PlayButton pb = new PlayButton("PLAY");
    tempoP = new IntSetPanel(1, 10000, "Tempo");
    tempoP.setValue(120);
    JPanel botL = new JPanel(new BorderLayout());
    botL.add(pb, BorderLayout.EAST);
    botL.add(tempoP, BorderLayout.CENTER);
    PianoKeyB kb = new PianoKeyB();
    kb.setPreferredSize(new Dimension(150, 40));
    // JPanel botTop = new JPanel(new GridLayout(1, 2));
    JPanel botTop = new JPanel(new FlowLayout());
    botTop.add(botL);
    botTop.add(kb);

    JButton newB = new JButton("New");
    saveB = new JButton("Save");
    JButton loadB = new JButton("Load");
    newB.addActionListener(this);
    saveB.addActionListener(this);
    loadB.addActionListener(this);
    pb.addActionListener(this);
    JPanel botBot = new JPanel(new GridLayout(1, 3));
    botBot.add(newB);
    botBot.add(saveB);
    botBot.add(loadB);
    JPanel bottom = new JPanel(new BorderLayout());
    bottom.add(botTop, BorderLayout.CENTER);
    bottom.add(botBot, BorderLayout.SOUTH);

    sp = new ScalePanel(this, kb);

    add(top, BorderLayout.NORTH);
    add(sp, BorderLayout.CENTER);
    add(bottom, BorderLayout.SOUTH);
    setPreferredSize(new Dimension(500, 300));

    fileChooser = new JFileChooser(new File("Features/Scales"));
    filter = new ScaleFilter();
    fileChooser.addChoosableFileFilter(filter);
    fileChooser.setFileFilter(filter);
  }
 // Component initialization
 private void jbInit() throws Exception {
   image1 = new ImageIcon(com.worldwizards.nwn.resbrowse.MainFrame.class.getResource("about.png"));
   imageLabel.setIcon(image1);
   this.setTitle("About");
   panel1.setLayout(borderLayout1);
   panel2.setLayout(borderLayout2);
   insetsPanel1.setLayout(flowLayout1);
   insetsPanel2.setLayout(flowLayout1);
   insetsPanel2.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
   gridLayout1.setRows(4);
   gridLayout1.setColumns(1);
   label1.setText(product);
   label2.setText(version);
   label3.setText(copyright);
   label4.setText(comments);
   insetsPanel3.setLayout(gridLayout1);
   insetsPanel3.setBorder(BorderFactory.createEmptyBorder(10, 60, 10, 10));
   button1.setText("Ok");
   button1.addActionListener(this);
   insetsPanel2.add(imageLabel, null);
   panel2.add(insetsPanel2, BorderLayout.WEST);
   this.getContentPane().add(panel1, null);
   insetsPanel3.add(label1, null);
   insetsPanel3.add(label2, null);
   insetsPanel3.add(label3, null);
   insetsPanel3.add(label4, null);
   panel2.add(insetsPanel3, BorderLayout.CENTER);
   insetsPanel1.add(button1, null);
   panel1.add(insetsPanel1, BorderLayout.SOUTH);
   panel1.add(panel2, BorderLayout.NORTH);
   setResizable(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);
  }
Exemple #16
0
 // Metoden createLabels - Skapar de grafiska komponenterna för scorelistan
 public void createLabels() {
   // Om det är fler än en spelare, sortera listan efter score
   if (players.size() > 1) {
     players = sortPlayers(players);
   }
   // Lägg till labels med förbestämd text
   for (int i = 0; i < 3; i++) {
     panel.add(new JLabel(labeltext[i]));
   }
   // Lägg till labels med placering, nick och poäng för spelarna
   for (int i = 3; i < 7; i++) {
     if (players.size() > i - 3) {
       panel.add(new JLabel(labeltext[i]));
       panel.add(new JLabel(players.get(i - 3).nick));
       panel.add(new JLabel(players.get(i - 3).score + ""));
     }
   }
   // Lägger till några tomma labels i panelen för att skapa mellanrum och symetri
   for (int i = 0; i < 4; i++) {
     panel.add(new JLabel(" "));
   }
   // Lägger till avslutaknappen
   panel.add(exit);
   exit.addActionListener(this);
 }
  /*
   * The following method creates the textfield to change the text
   *     and the button to update the label.
   * postcondition: returns the panel containing the textfield and button.
   */
  public JPanel createUpdateButton() {
    JLabel textLabel = new JLabel(new String("Change text to: "));

    textField = new JTextField(new String("Big Java"), 20);
    textField.setFont(new Font(("Times"), Font.PLAIN, 12));

    update = new JButton(new String("Update"));
    update.setDefaultCapable(true);

    // This class is used to create a special ActionListener for this menu item
    class ButtonListener implements ActionListener {
      /*
       * This method is called when the update button is clicked
       */
      public void actionPerformed(ActionEvent event) {
        // Call the method to change the text on the screen.
        setSampleFont();
      } // end actionPerformed method
    }
    ActionListener listener = new ButtonListener();
    update.addActionListener(listener);

    JPanel panel = new JPanel();

    panel.add(textLabel);
    panel.add(textField);
    panel.add(update);

    return panel;
  } // end createUpdateButton method
    protected void initComponents() {
      int border = 2;
      this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
      this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

      // Description label
      JPanel descriptionPanel = new JPanel(new GridLayout(0, 1, 0, 0));
      descriptionPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border));
      String text = thread.getRetrievable().getName();
      text = text.length() > 40 ? text.substring(0, 37) + "..." : text;
      descriptionLabel = new JLabel(text);
      descriptionPanel.add(descriptionLabel);
      this.add(descriptionPanel);

      // Progrees and cancel button
      JPanel progressPanel = new JPanel();
      progressPanel.setLayout(new BoxLayout(progressPanel, BoxLayout.X_AXIS));
      progressPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border));
      progressBar = new JProgressBar(0, 100);
      progressBar.setPreferredSize(new Dimension(100, 16));
      progressPanel.add(progressBar);
      progressPanel.add(Box.createHorizontalStrut(8));
      cancelButton = new JButton("Cancel");
      cancelButton.setBackground(Color.RED);
      cancelButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              cancelButtonActionPerformed(event);
            }
          });
      progressPanel.add(cancelButton);
      this.add(progressPanel);
    }
  /**
   * Create a button to go inside of the toolbar. By default this will load an image resource. The
   * image filename is relative to the classpath (including the '.' directory if its a part of the
   * classpath), and may either be in a JAR file or a separate file.
   *
   * @param key The key in the resource file to serve as the basis of lookups.
   */
  protected JButton createToolbarButton(String key) {
    URL url = getResource(key + imageSuffix);
    JButton b =
        new JButton(new ImageIcon(url)) {
          public float getAlignmentY() {
            return 0.5f;
          }
        };
    b.setRequestFocusEnabled(false);
    b.setMargin(new Insets(1, 1, 1, 1));

    String astr = getResourceString(key + actionSuffix);
    if (astr == null) {
      astr = key;
    }
    Action a = getAction(astr);
    if (a != null) {
      b.setActionCommand(astr);
      b.addActionListener(a);
    } else {
      b.setEnabled(false);
    }

    String tip = getResourceString(key + tipSuffix);
    if (tip != null) {
      b.setToolTipText(tip);
    }

    return b;
  }
 // 定义添加一行格式化文本框的方法
 private void addRow(String labelText, final JFormattedTextField field) {
   mainPanel.add(new JLabel(labelText));
   mainPanel.add(field);
   final JLabel valueLabel = new JLabel();
   mainPanel.add(valueLabel);
   // 为"确定"按钮添加事件监听器
   // 当用户单击“确定”按钮时,文本框后显示文本框内的值
   okButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           Object value = field.getValue();
           // 如果该值是数组,使用Arrays的toString方法输出数组
           if (value.getClass().isArray()) {
             StringBuilder builder = new StringBuilder();
             builder.append('{');
             for (int i = 0; i < Array.getLength(value); i++) {
               if (i > 0) builder.append(',');
               builder.append(Array.get(value, i).toString());
             }
             builder.append('}');
             valueLabel.setText(builder.toString());
           } else {
             // 输出格式化文本框的值
             valueLabel.setText(value.toString());
           }
         }
       });
 }
  /*
   * The following method creates the color chooser dialog box
   */
  public void createColorDialog() {
    colorDialog = new JDialog(this, new String("Choose a color"), true);
    colorDialog.getContentPane().add(createColorPicker(), BorderLayout.CENTER);

    JButton okButton = new JButton("OK");

    // This class is used to create a special ActionListener for
    //    the ok button
    class ButtonListener implements ActionListener {
      /*
       * This method is called whenever the ok button is clicked
       */
      public void actionPerformed(ActionEvent event) {
        currentChoice.changeColor(color_panel.getColor());
        currentChoice.repaint();
        fontColor = color_panel.getColor();
        colorDialog.hide();
      } // end actionPerformed method
    }
    ActionListener listener = new ButtonListener();
    okButton.addActionListener(listener);

    // Add the four font control panels to one big panel using
    //  a grid layout
    JPanel buttonPanel = new JPanel();

    buttonPanel.add(okButton);

    // Add the button panel to the content pane of the ColorDialogue
    colorDialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    colorDialog.pack();
  }
    /** Returns the tool bar for the panel. */
    protected JComponent getToolBar() {
      JToolBar tbarDir = new JToolBar();
      JButton btnNew = new JButton();
      // m_btnSave = new JButton("Save File");
      // i118n
      // btnNew.setText("New Label");
      btnNew.setText(Util.getAdmLabel("_adm_New_Label"));
      btnNew.setActionCommand("new");
      // m_btnSave.setActionCommand("save");

      ActionListener alTool =
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              doAction(e);
            }
          };

      btnNew.addActionListener(alTool);
      // m_btnSave.addActionListener(alTool);

      tbarDir.setFloatable(false);
      tbarDir.add(btnNew);
      /*tbarDir.add(new JLabel("        "));
      tbarDir.add(m_btnSave);*/

      return tbarDir;
    }
Exemple #23
0
  private JButton makeToolbarButton(String name, String toolTipText, String action) {
    // Create and initialize the button.
    JButton button = new JButton(makeImageIcon(name));
    button.setToolTipText(toolTipText);
    button.setActionCommand(action);
    button.addActionListener(this);

    return button;
  }
  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);
          }
        });
  }
Exemple #25
0
  /** Add listeners to components. */
  private void addListeners() {
    dirBttn.addActionListener(this);
    backupBttn.addActionListener(this);
    runBttn.addActionListener(this);

    recursiveCheckBox.addItemListener(this);
    templateCh.addItemListener(this);

    dirTF.addActionListener(this);

    staticVersioningRadioButton.addItemListener(this);
    dynamicVersioningRadioButton.addItemListener(this);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            quit();
          }
        });
  }
  public EtchedBorderEditor() {

    initialize();

    highlight = new ColorHolder();
    shadow = new ColorHolder();

    setCaption(getEditorLocaleString("Etched"));
    assignValueToParameters();

    selType = new RiseLowPanel(etchType, EtchedBorder.RAISED, EtchedBorder.LOWERED);
    selType.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            etchType = selType.getType();
            fireChange();
          }
        });

    JButton bHigh = new JButton(getEditorLocaleString("Highlight"));
    ColorChooseAction colorChooseAction =
        new ColorChooseAction(highlight, getEditorLocaleString("Highlight"), this);
    colorChooseAction.addPropertyChangeListener(this);
    bHigh.addActionListener(colorChooseAction);

    JButton bShadow = new JButton(getEditorLocaleString("Shadow"));
    colorChooseAction = new ColorChooseAction(shadow, getEditorLocaleString("Shadow"), this);
    colorChooseAction.addPropertyChangeListener(this);
    bShadow.addActionListener(colorChooseAction);

    setLayout(new BorderLayout());
    JPanel totalPane = new JPanel(new GridLayout(2, 1));
    totalPane.add(selType);
    JPanel buttonPane = new JPanel(new GridLayout(1, 2));
    buttonPane.add(getCenteredPane(bHigh));
    buttonPane.add(getCenteredPane(bShadow));
    totalPane.add(buttonPane);
    add(totalPane, BorderLayout.NORTH);

    refreshInterface();
  }
  public BorderedComponent(String text, JComponent comp, boolean collapsible) {
    super(null);

    this.comp = comp;

    // Only add border if text is not null
    if (text != null) {
      TitledBorder border;
      if (collapsible) {
        final JLabel textLabel = new JLabel(text);
        JPanel borderLabel =
            new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0)) {
              public int getBaseline(int w, int h) {
                Dimension dim = textLabel.getPreferredSize();
                return textLabel.getBaseline(dim.width, dim.height) + textLabel.getY();
              }
            };
        borderLabel.add(textLabel);
        border = new LabeledBorder(borderLabel);
        textLabel.setForeground(border.getTitleColor());

        if (IS_WIN) {
          collapseIcon = new ImageIcon(getImage("collapse-winlf"));
          expandIcon = new ImageIcon(getImage("expand-winlf"));
        } else {
          collapseIcon = new ArrowIcon(SOUTH, textLabel);
          expandIcon = new ArrowIcon(EAST, textLabel);
        }

        moreOrLessButton = new JButton(collapseIcon);
        moreOrLessButton.setContentAreaFilled(false);
        moreOrLessButton.setBorderPainted(false);
        moreOrLessButton.setMargin(new Insets(0, 0, 0, 0));
        moreOrLessButton.addActionListener(this);
        String toolTip = Messages.BORDERED_COMPONENT_MORE_OR_LESS_BUTTON_TOOLTIP;
        moreOrLessButton.setToolTipText(toolTip);
        borderLabel.add(moreOrLessButton);
        borderLabel.setSize(borderLabel.getPreferredSize());
        add(borderLabel);
      } else {
        border = new TitledBorder(text);
      }
      setBorder(new CompoundBorder(new FocusBorder(this), border));
    } else {
      setBorder(new FocusBorder(this));
    }
    if (comp != null) {
      add(comp);
    }
  }
Exemple #28
0
    public SelectServerDialog() {
      super();
      setTitle("Select Server");

      JLabel lblServer = new JLabel("IP or Name:");
      txtServer = new JTextField();
      txtServer.setMaximumSize(new Dimension(10000, 20));
      Box boxServer = new Box(BoxLayout.X_AXIS);

      cmdConnect = new JButton("Connect");
      cmdConnect.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {}
          });

      cmdCancel = new JButton("Cancel");
      cmdCancel.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              dispose();
            }
          });
    }
  public FindSynonymsActionHandler(String word, int position, Chapter c, AbstractEditorPanel p) {

    this.word = word;
    this.position = position;
    // this.chapter = c;
    this.editorPanel = p;
    this.projectViewer = this.editorPanel.getViewer();

    final FindSynonymsActionHandler _this = this;

    // Show a panel of all the items.
    this.popup =
        new QPopup(
            "Synonyms for: " + word,
            Environment.getIcon(Constants.FIND_ICON_NAME, Constants.ICON_POPUP),
            null);

    JButton close =
        UIUtils.createButton(
            Constants.CLOSE_ICON_NAME, Constants.ICON_MENU, "Click to close", null);

    List<JButton> buts = new ArrayList();
    buts.add(close);

    this.popup.getHeader().setControls(UIUtils.createButtonBar(buts));

    close.addActionListener(
        new ActionAdapter() {

          public void actionPerformed(ActionEvent ev) {

            _this.popup.setVisible(false);

            _this.editorPanel.getEditor().removeHighlight(_this.highlight);
          }
        });

    p.addPopup(this.popup, true, true);
    /*
          this.highlight = this.editorPanel.getEditor ().addHighlight (position,
                                                                       position + word.length (),
                                                                       null,
                                                                       true);
    */
    this.popup.setOpaque(false);
    this.popup.setVisible(false);

    this.popup.setDraggable(this.editorPanel);
  }
  private void initComponents() {
    setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

    messagePane.setBackground(contentPane.getBackground());
    messagePane.setEditorKit(new HTMLEditorKit());
    messagePane.setForeground(contentPane.getForeground());

    setSize(450, 360);

    // center the window
    int x = (int) (Toolkit.getDefaultToolkit().getScreenSize().getWidth() - getWidth()) / 2;
    int y = (int) (Toolkit.getDefaultToolkit().getScreenSize().getHeight() - getHeight()) / 2;
    setLocation(x, y);

    okButton.addActionListener(this);
  }