Exemplo n.º 1
0
 private OffsetPanel(Component comp) {
   this.setLayout(new BorderLayout(0, 0));
   TitledBorder tb = BorderFactory.createTitledBorder(b.getString("kOffsetBy"));
   if (JOAConstants.ISMAC) {
     // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
   }
   this.setBorder(tb);
   JPanel controls = new JPanel();
   controls.setLayout(new GridLayout(3, 1, 5, 0));
   b1 = new JOAJRadioButton(b.getString("kSequence"));
   b2 = new JOAJRadioButton(b.getString("kDistance"), true);
   b3 = new JOAJRadioButton(b.getString("kTime"));
   controls.add(b2);
   controls.add(b1);
   controls.add(b3);
   controls.add(new JOAJLabel("       "));
   ButtonGroup bg = new ButtonGroup();
   bg.add(b1);
   bg.add(b2);
   bg.add(b3);
   this.add("Center", controls);
   b1.addItemListener((ItemListener) comp);
   b2.addItemListener((ItemListener) comp);
   b3.addItemListener((ItemListener) comp);
 }
Exemplo n.º 2
0
    public DisplayUserDirectory() {
      GridBagLayout gbl = new GridBagLayout();
      GridBagConstraints gbc = new GridBagConstraints();
      setLayout(gbl);

      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      hmlabel.setForeground(Color.black);
      add(hmlabel, gbc);
      add(Box.createHorizontalStrut(10), gbc);
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(hmdir, gbc);
      add(Box.createVerticalStrut(15), gbc);

      gbc.gridwidth = 1;
      vjlabel.setForeground(Color.black);
      add(vjlabel, gbc);
      add(Box.createHorizontalStrut(10), gbc);
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(vjdir, gbc);
      add(Box.createVerticalStrut(0), gbc);

      gbc.gridwidth = 1;
      vjlabel2.setForeground(Color.black);
      add(vjlabel2, gbc);
      setBorder(
          new CompoundBorder(
              // i18n
              // BorderFactory.createTitledBorder(" User_Directories "),
              BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
Exemplo n.º 3
0
    public DisplayResults() {
      GridBagLayout gbl = new GridBagLayout();
      GridBagConstraints gbc = new GridBagConstraints();
      setLayout(gbl);

      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      text.setForeground(Color.black);
      add(text, gbc);
      gbc.gridy = 0;
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(emptyLabel, gbc);
      add(Box.createVerticalStrut(0), gbc);
      add(emptyLabel, gbc);

      /*	 gbc.gridy = 1;
      VTextMsg result = new VTextMsg(sshare, vnmrif, null);
      result.setPreferredSize(new Dimension(300, 30));
      result.setForeground(Color.black);
      add( result, gbc );
      */
      setBorder(
          new CompoundBorder(
              BorderFactory.createTitledBorder("  Results  "),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
  StatsPanel(String title) {
    TitledBorder tBorder = BorderFactory.createTitledBorder(title);
    setBorder(tBorder);
    setLayout(new GridLayout(0, 2));

    minLabel = new JLabel("Min");
    min = new JLabel("" + 0);
    meanLabel = new JLabel("Mean");
    mean = new JLabel("" + 0);
    maxLabel = new JLabel("Max");
    max = new JLabel("" + 0);
    stdDevLabel = new JLabel("StdDev");
    stdDev = new JLabel("" + 0);

    add(minLabel);
    add(min);
    add(meanLabel);
    add(mean);
    add(maxLabel);
    add(max);
    add(stdDevLabel);
    add(stdDev);

    setSize(width, height);
    setMinimumSize(new Dimension(width, height));
  }
Exemplo n.º 5
0
 private JComponent makeTitledPanel(String title, JTree tree) {
   JPanel p = new JPanel(new BorderLayout());
   p.setBorder(BorderFactory.createTitledBorder(title));
   p.add(new JScrollPane(tree));
   tree.setRowHeight(0);
   return p;
 }
Exemplo n.º 6
0
  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();
  }
Exemplo n.º 7
0
 /*
  *Creates the JTextField for the GUI.
  */
 private JTextField inputField() {
   inputField = new JTextField();
   Border inputBorder = BorderFactory.createEtchedBorder();
   inputBorder = BorderFactory.createTitledBorder(inputBorder, "Please type your words here:");
   inputField.setBorder(inputBorder);
   inputField.addActionListener(new ActionListenerField());
   return inputField;
 }
Exemplo n.º 8
0
 public RowPanel(String name) {
   super();
   Border empty = BorderFactory.createEmptyBorder(10, 10, 10, 10);
   Border line = BorderFactory.createLineBorder(Color.GRAY);
   Border title = BorderFactory.createTitledBorder(line, name);
   Border compound = BorderFactory.createCompoundBorder(title, empty);
   setBorder(compound);
   setLayout(new RowLayout());
 }
  /**
   * Create plot info panel
   *
   * @return panel
   */
  private JPanel createMapPanel() {
    JPanel panel = new JPanel(new BorderLayout(), true);

    // create an raised, etched, titled border
    Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    TitledBorder titledBorder = BorderFactory.createTitledBorder(etchedBorder, "Map");
    titledBorder.setTitleJustification(TitledBorder.LEFT);
    panel.setBorder(titledBorder);

    // load image
    java.net.URL imgURL = getClass().getResource("/resources/map.png");
    map = new ScrollablePicture(new ImageIcon(imgURL), 10);
    // map = new ScrollablePicture(new ImageIcon("resources/map.png"), 10);
    mapScrollPane = new JScrollPane(map);
    mapScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    mapScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    map.addMouseListener(
        new MouseListener() {
          /**
           * Get the coordinates of a mouse click event
           *
           * @param e MouseEvent
           */
          @Override
          public void mouseClicked(MouseEvent e) {
            if (cemeteryPlotterFrame.cemeteryPlotterPlot.isEditable())
              cemeteryPlotterFrame.cemeteryPlotterPlot.setMapLocationField(e.getPoint());
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {
            if (cemeteryPlotterFrame.cemeteryPlotterPlot.isEditable())
              mapScrollPane.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
          }

          @Override
          public void mouseExited(MouseEvent e) {}
        });

    // add map scroll pane to main panel
    panel.add(mapScrollPane, BorderLayout.CENTER);

    return panel;
  }
Exemplo n.º 10
0
  public static void main(String[] args) {
    // create a JFrame to hold everything
    JFrame frame = new JFrame("Borders");

    // Create labels with borders.
    int center = SwingConstants.CENTER;
    JLabel labelOne = new JLabel("raised BevelBorder", center);
    labelOne.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    JLabel labelTwo = new JLabel("EtchedBorder", center);
    labelTwo.setBorder(BorderFactory.createEtchedBorder());
    JLabel labelThree = new JLabel("MatteBorder", center);
    labelThree.setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.pink));
    JLabel labelFour = new JLabel("TitledBorder", center);
    Border etch = BorderFactory.createEtchedBorder();
    labelFour.setBorder(BorderFactory.createTitledBorder(etch, "Title"));
    JLabel labelFive = new JLabel("TitledBorder", center);
    Border low = BorderFactory.createLoweredBevelBorder();
    labelFive.setBorder(
        BorderFactory.createTitledBorder(low, "Title", TitledBorder.RIGHT, TitledBorder.BOTTOM));
    JLabel labelSix = new JLabel("CompoundBorder", center);
    Border one = BorderFactory.createEtchedBorder();
    Border two = BorderFactory.createMatteBorder(4, 4, 4, 4, Color.blue);
    labelSix.setBorder(BorderFactory.createCompoundBorder(one, two));

    // add components to the content pane
    Container c = frame.getContentPane(); // unecessary in 1.5+
    c.setLayout(new GridLayout(3, 2));
    c.add(labelOne);
    c.add(labelTwo);
    c.add(labelThree);
    c.add(labelFour);
    c.add(labelFive);
    c.add(labelSix);

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
  }
Exemplo n.º 11
0
    protected void layoutUIComponents(String strPath, boolean bDefaultFile) {
      JLabel label = null;

      // i18n
      // label = new JLabel( "File names can be constructed from a template. The LABEL field is " );
      label =
          new JLabel(
              Util.getAdmLabel(
                  "_admin_File_names_can_be_constructed_from_a_template._The_LABEL_field_is_"));
      label.setForeground(Color.black);
      // m_gbc.weightx = 0.5;
      showInstruction(m_gbl, m_gbc, 0, 0, 7, label);

      // i18n
      // label = new JLabel( "presented as the choice to the user in the \"Data save\" pop-up." );
      label =
          new JLabel(
              Util.getAdmLabel(
                  "_admin_presented_as_the_choice_to_the_user_in_the_Data_save_pop-up."));
      showInstruction(m_gbl, m_gbc, 0, 1, 7, label);
      showInstruction(m_gbl, m_gbc, 0, 2, 1, new JLabel(""));

      label = new JLabel(Util.getAdmLabel("_adm_LABEL"));
      label.setForeground(Color.black);
      m_gbc.gridx = 1;
      m_gbc.gridy = 2;
      m_gbc.ipadx = 10;
      m_gbl.setConstraints(label, m_gbc);
      m_pnlDisplay.add(label);

      label = new JLabel("     ");
      m_gbc.gridx = 2;
      m_gbc.gridy = 2;
      m_gbc.ipadx = 0; // reset to default
      m_gbc.gridwidth = 5;
      m_gbl.setConstraints(label, m_gbc);
      // add( label );

      showInstruction(m_gbl, m_gbc, 2, 2, 1, new JLabel(Util.getAdmLabel("_admin_TEMPLATE")));

      m_nRow = 3;
      m_bDefaultFile = bDefaultFile;
      m_objTxfValue.clearArrays();
      displayNewTxf(strPath);

      m_pnlDisplay.setBorder(
          new CompoundBorder(
              BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
Exemplo n.º 12
0
  VerificationDlg(JFrame par, String pwd) {
    super(par, "Password Keeper - Enter Password", true); // Modal Dialog

    this.par = par;
    this.pwd = pwd;

    okButton = new JButton("OK");
    okButton.addActionListener(this);

    dlgPanel = new JPanel();
    dlgPanel.setLayout(new GridBagLayout());
    cns = new GridBagConstraints();

    cns.gridx = cns.gridy = 0;
    cns.insets = new Insets(2, 2, 2, 2);

    dlgPanel.add(new JLabel("Password"), cns);

    cns.gridx++;

    passField = new TextField(30);

    dlgPanel.add(passField, cns);

    cns.gridy++;
    // cns.gridx = 0;

    dlgPanel.add(okButton, cns);

    cancelButton = new JButton("Cancel");

    cns.gridx++;

    dlgPanel.add(cancelButton, cns);

    Container cp = this.getContentPane();

    Border rb = BorderFactory.createEtchedBorder();
    dlgPanel.setBorder(
        BorderFactory.createTitledBorder(
            rb, "Enter Password", TitledBorder.LEFT, TitledBorder.TOP));

    cp.add(dlgPanel);

    pack();
  }
Exemplo n.º 13
0
    protected void layoutUIComponents(String strPath, boolean bDefaultFile) {
      // gbc.weightx = 0.5;

      showInstructions(m_gbl, m_gbc, 0, 0, 7, infoLabel1);
      showInstructions(m_gbl, m_gbc, 0, 1, 7, infoLabel2);
      showInstructions(m_gbl, m_gbc, 0, 2, 7, infoLabel3);
      /*showInstructions( gbl, gbc, 0, 3, 7, infoLabel4 );
      showInstructions( gbl, gbc, 0, 4, 7, infoLabel5 );*/
      showInstructions(m_gbl, m_gbc, 0, 5, 1, new JLabel(""));

      // i18n
      // label = new JLabel( "LABEL" );
      label = new JLabel(Util.getAdmLabel("_adm_LABEL"));
      label.setForeground(Color.black);
      m_gbc.gridx = 1;
      m_gbc.gridy = 5;
      // gbc.ipadx = 10;
      m_gbl.setConstraints(label, m_gbc);
      m_pnlDisplay.add(label);

      label = new JLabel("     ");
      m_gbc.gridx = 2;
      m_gbc.gridy = 5;
      m_gbc.ipadx = 0;
      m_gbc.gridwidth = 5;
      m_gbc.weightx = 0;
      m_gbl.setConstraints(label, m_gbc);
      // add( label );

      // i18n
      // showInstructions( m_gbl, m_gbc, 2, 5, 1, new JLabel( "DIRECTORY" ));
      showInstructions(m_gbl, m_gbc, 2, 5, 1, new JLabel(Util.getAdmLabel("_adm_DIRECTORY")));

      m_nRow = 5;

      m_bDefaultFile = bDefaultFile;
      m_objTxfValue.clearArrays();
      displayNewTxf(strPath);

      m_pnlDisplay.setBorder(
          new CompoundBorder(
              // i18n
              // BorderFactory.createTitledBorder( "  Parent Directories  "),
              BorderFactory.createTitledBorder(Util.getAdmLabel("_adm_Parent_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
  public TreeSelectionInfoPanel() {
    super();

    // Setup default (non-selection) Characteristics (border, layout, etc)
    setLayout(new GridLayout(4, 1));
    setBorder(
        BorderFactory.createTitledBorder(
            this.getBorder(), "Selection Statistics", TitledBorder.TOP, TitledBorder.CENTER));

    // Create Initial State Information
    childSelectionInfoLabel = new JLabel();
    averageFitnessLabel = new JLabel();
    bestFitnessLabel = new JLabel();
    worstFitnessLabel = new JLabel();
    setEmptySelection();

    add(childSelectionInfoLabel);
    add(averageFitnessLabel);
    add(bestFitnessLabel);
    add(worstFitnessLabel);
  }
Exemplo n.º 15
0
  /**
   * Add a border of a particular style to a component
   *
   * @param c : JComponent to add border to
   * @param borderType : type of border, BD_x
   * @param label : if not null, string to display at top of border
   * @param labelAlignment : if label defined, this determines its horizontal alignment
   */
  public static void addBorder(JComponent c, int borderType, String label, int labelAlignment) {
    final Border[] b = {
      // #0: empty, spacing of 2
      BorderFactory.createEmptyBorder(2, 2, 2, 2),
      // #1: lowered etched, interior spacing of 2
      BorderFactory.createCompoundBorder(
          BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
          BorderFactory.createEmptyBorder(2, 2, 2, 2)),
      // BorderFactory.createLineBorder(Color.red,3),
    };

    Tools.ASSERT(!(label != null && borderType < 0));

    if (label != null) {
      TitledBorder t = BorderFactory.createTitledBorder(b[borderType], label);

      int tbAlign = 0;
      switch (labelAlignment) {
        default:
          tbAlign = TitledBorder.LEFT;
          break;
        case SwingConstants.CENTER:
          tbAlign = TitledBorder.CENTER;
          break;
        case SwingConstants.RIGHT:
          tbAlign = TitledBorder.RIGHT;
          break;
      }
      t.setTitleJustification(tbAlign);
      c.setBorder(t);
    } else {
      if (borderType >= 0) {
        c.setBorder(b[borderType]);
      }
    }
  }
  public ClassMemberSpecificationDialog(JDialog owner, boolean isField) {
    super(owner, true);
    setResizable(true);

    // Create some constraints that can be reused.
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(1, 2, 1, 2);

    GridBagConstraints constraintsStretch = new GridBagConstraints();
    constraintsStretch.fill = GridBagConstraints.HORIZONTAL;
    constraintsStretch.weightx = 1.0;
    constraintsStretch.anchor = GridBagConstraints.WEST;
    constraintsStretch.insets = constraints.insets;

    GridBagConstraints constraintsLast = new GridBagConstraints();
    constraintsLast.gridwidth = GridBagConstraints.REMAINDER;
    constraintsLast.anchor = GridBagConstraints.WEST;
    constraintsLast.insets = constraints.insets;

    GridBagConstraints constraintsLastStretch = new GridBagConstraints();
    constraintsLastStretch.gridwidth = GridBagConstraints.REMAINDER;
    constraintsLastStretch.fill = GridBagConstraints.HORIZONTAL;
    constraintsLastStretch.weightx = 1.0;
    constraintsLastStretch.anchor = GridBagConstraints.WEST;
    constraintsLastStretch.insets = constraints.insets;

    GridBagConstraints panelConstraints = new GridBagConstraints();
    panelConstraints.gridwidth = GridBagConstraints.REMAINDER;
    panelConstraints.fill = GridBagConstraints.HORIZONTAL;
    panelConstraints.weightx = 1.0;
    panelConstraints.weighty = 0.0;
    panelConstraints.anchor = GridBagConstraints.NORTHWEST;
    panelConstraints.insets = constraints.insets;

    GridBagConstraints stretchPanelConstraints = new GridBagConstraints();
    stretchPanelConstraints.gridwidth = GridBagConstraints.REMAINDER;
    stretchPanelConstraints.fill = GridBagConstraints.BOTH;
    stretchPanelConstraints.weightx = 1.0;
    stretchPanelConstraints.weighty = 1.0;
    stretchPanelConstraints.anchor = GridBagConstraints.NORTHWEST;
    stretchPanelConstraints.insets = constraints.insets;

    GridBagConstraints labelConstraints = new GridBagConstraints();
    labelConstraints.anchor = GridBagConstraints.CENTER;
    labelConstraints.insets = new Insets(2, 10, 2, 10);

    GridBagConstraints lastLabelConstraints = new GridBagConstraints();
    lastLabelConstraints.gridwidth = GridBagConstraints.REMAINDER;
    lastLabelConstraints.anchor = GridBagConstraints.CENTER;
    lastLabelConstraints.insets = labelConstraints.insets;

    GridBagConstraints okButtonConstraints = new GridBagConstraints();
    okButtonConstraints.weightx = 1.0;
    okButtonConstraints.weighty = 1.0;
    okButtonConstraints.anchor = GridBagConstraints.SOUTHEAST;
    okButtonConstraints.insets = new Insets(4, 4, 8, 4);

    GridBagConstraints cancelButtonConstraints = new GridBagConstraints();
    cancelButtonConstraints.gridwidth = GridBagConstraints.REMAINDER;
    cancelButtonConstraints.weighty = 1.0;
    cancelButtonConstraints.anchor = GridBagConstraints.SOUTHEAST;
    cancelButtonConstraints.insets = okButtonConstraints.insets;

    GridBagLayout layout = new GridBagLayout();

    Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);

    this.isField = isField;

    // Create the access panel.
    JPanel accessPanel = new JPanel(layout);
    accessPanel.setBorder(
        BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("access")));

    accessPanel.add(Box.createGlue(), labelConstraints);
    accessPanel.add(new JLabel(GUIResources.getMessage("required")), labelConstraints);
    accessPanel.add(new JLabel(GUIResources.getMessage("not")), labelConstraints);
    accessPanel.add(new JLabel(GUIResources.getMessage("dontCare")), labelConstraints);
    accessPanel.add(Box.createGlue(), constraintsLastStretch);

    publicRadioButtons = addRadioButtonTriplet("Public", accessPanel);
    privateRadioButtons = addRadioButtonTriplet("Private", accessPanel);
    protectedRadioButtons = addRadioButtonTriplet("Protected", accessPanel);
    staticRadioButtons = addRadioButtonTriplet("Static", accessPanel);
    finalRadioButtons = addRadioButtonTriplet("Final", accessPanel);

    if (isField) {
      volatileRadioButtons = addRadioButtonTriplet("Volatile", accessPanel);
      transientRadioButtons = addRadioButtonTriplet("Transient", accessPanel);
    } else {
      synchronizedRadioButtons = addRadioButtonTriplet("Synchronized", accessPanel);
      nativeRadioButtons = addRadioButtonTriplet("Native", accessPanel);
      abstractRadioButtons = addRadioButtonTriplet("Abstract", accessPanel);
      strictRadioButtons = addRadioButtonTriplet("Strict", accessPanel);
    }

    // Create the type panel.
    JPanel typePanel = new JPanel(layout);
    typePanel.setBorder(
        BorderFactory.createTitledBorder(
            etchedBorder, GUIResources.getMessage(isField ? "type" : "returnType")));

    typePanel.add(typeTextField, constraintsLastStretch);

    // Create the name panel.
    JPanel namePanel = new JPanel(layout);
    namePanel.setBorder(
        BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("name")));

    namePanel.add(nameTextField, constraintsLastStretch);

    // Create the arguments panel.
    JPanel argumentsPanel = new JPanel(layout);
    argumentsPanel.setBorder(
        BorderFactory.createTitledBorder(etchedBorder, GUIResources.getMessage("arguments")));

    argumentsPanel.add(argumentsTextField, constraintsLastStretch);

    // Create the Ok button.
    JButton okButton = new JButton(GUIResources.getMessage("ok"));
    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            returnValue = APPROVE_OPTION;
            hide();
          }
        });

    // Create the Cancel button.
    JButton cancelButton = new JButton(GUIResources.getMessage("cancel"));
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            hide();
          }
        });

    // Add all panels to the main panel.
    JPanel mainPanel = new JPanel(layout);
    mainPanel.add(accessPanel, panelConstraints);
    mainPanel.add(typePanel, panelConstraints);
    mainPanel.add(namePanel, panelConstraints);

    if (!isField) {
      mainPanel.add(argumentsPanel, panelConstraints);
    }

    mainPanel.add(okButton, okButtonConstraints);
    mainPanel.add(cancelButton, cancelButtonConstraints);

    getContentPane().add(mainPanel);
  }
Exemplo n.º 17
0
  private JPanel getContentPanel() {

    JPanel contentPanel1 = new JPanel();
    summaryPanel = new JPanel();
    resultPanel = new JPanel();

    jPanel1 = new javax.swing.JPanel();
    createFilesButton = new JButton();
    showFilesButton = new JButton();

    contentPanel1.setLayout(new java.awt.BorderLayout());
    jPanel1.setLayout(new MigLayout("wrap 1"));

    /* Summary */
    summaryPanel.setLayout(new MigLayout("wrap 1,w 400"));
    summaryPanel.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createEtchedBorder(),
            "Summary",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_POSITION,
            new Font("Courier", Font.BOLD, 14)));

    summaryField = new JTextArea("", 10, 30);
    summaryField.setLineWrap(true);
    summaryField.setWrapStyleWord(true);
    summaryField.setEditable(false);
    JScrollPane summaryScrollPane = new JScrollPane(summaryField);
    summaryScrollPane.setVerticalScrollBarPolicy(
        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS & JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    summaryPanel.add(summaryScrollPane);

    createFilesButton.setText("Create Data Loader CLI Files");
    createFilesButton.setActionCommand(CREATE_FILES_ACTION_COMMAND);
    summaryPanel.add(createFilesButton, "");
    jPanel1.add(summaryPanel);

    /* Results */
    resultPanel.setLayout(new MigLayout("wrap 1,w 400"));
    resultPanel.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createEtchedBorder(),
            "Results",
            TitledBorder.DEFAULT_JUSTIFICATION,
            TitledBorder.DEFAULT_POSITION,
            new Font("Courier", Font.BOLD, 14)));

    statusField = new JTextArea("", 6, 30);
    statusField.setLineWrap(true);
    statusField.setWrapStyleWord(true);
    statusField.setEditable(false);
    JScrollPane messageScrollPane = new JScrollPane(statusField);
    messageScrollPane.setVerticalScrollBarPolicy(
        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS & JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    resultPanel.add(messageScrollPane);

    /* Not supported by Java 1.5
    showFilesButton.setText("Show Files");
    showFilesButton.setActionCommand(SHOW_FILES_ACTION_COMMAND);
    showFilesButton.setEnabled(false);
    resultPanel.add(showFilesButton,"");
    */

    jPanel1.add(resultPanel);

    /* End */
    contentPanel1.add(jPanel1, java.awt.BorderLayout.CENTER);

    return contentPanel1;
  }
Exemplo n.º 18
0
  // CONSTRUCTOR
  public FACFrame() {

    // SET PROPERTIES OF THE MAIN FRAME
    setTitle("Fully Associative Cache");
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setIconImage(Toolkit.getDefaultToolkit().createImage(FACFrame.class.getResource("cam.gif")));

    // CREATE COMPONENTS AND SET THEIR PROPERTIES

    // NAVIGATION BUTTONS
    restart = new JButton("Restart");
    next = new JButton("Next");
    back = new JButton("Back");
    quit = new JButton("Quit");

    // CACHE HITS AND MISSES INFO.
    lCacheHits = new JLabel("Cache Hits");
    lCacheMisses = new JLabel("Cache Misses");
    tCacheHits = new JTextField(5);
    tCacheMisses = new JTextField(5);
    tCacheHits.setEditable(false);
    tCacheHits.setFont(new Font("Monospaced", Font.BOLD, 14));
    tCacheHits.setText("  0");
    tCacheMisses.setEditable(false);
    tCacheMisses.setFont(new Font("Monospaced", Font.BOLD, 14));
    tCacheMisses.setText("  0");

    // PROGRESS UPDATE AREA
    tProgress = new JTextArea(3, 45);
    tProgress.setEditable(false);
    tProgress.setLineWrap(true);
    tProgress.setWrapStyleWord(true);
    tProgress.setCaretPosition(0);
    tProgress.setFont(new Font("Serif", Font.BOLD + Font.ITALIC, 16));
    tProgress.setText(
        "Welcome to Fully Associative Cache!\nThe system specs are as follows -"
            + "\n  16 Blocks in Cache\n  32 Blocks in Main Memory\n  8 Words per Block"
            + "\n  The replacement algorithm shown is the Least-Recently-Used algorithm"
            + "\n  as it is the most commonly used one."
            + "\nPlease generate the Address Reference String."
            + "\nThen click on \"Next\" to continue.");
    progressScroll = new JScrollPane();
    progressScroll.getViewport().add(tProgress);
    progressScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    lProgress = new JLabel("PROGRESS UPDATE");

    // ADDRESS REFERENCE STRING
    addRefStrList = new JList();
    addRefStrList.setEnabled(false);
    addRefStrScroll = new JScrollPane();
    addRefStrScroll.getViewport().setView(addRefStrList);
    addRefStrScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    addRefStrScroll.setPreferredSize(new Dimension(140, 300));

    // BUTTONS USED TO ADDRESS GENERATION
    autoGen = new JButton("Auto Generate Add. Ref. Str.");
    selfGen = new JButton("Self Generate Add. Ref. Str.");

    // BITS IN MAIN MEMORY ADDRESS
    lBits = new JLabel("                   TAG                        WORD");

    tTag = new JTextField(9);
    tTag.setEditable(false);
    tWord = new JTextField(7);
    tWord.setEditable(false);

    // SET THE FONT STYLES FOR THE BITS IN MAIN MEMORY ADDRESS
    tTag.setFont(new Font("Monospaced", Font.BOLD, 14));
    tWord.setFont(new Font("Monospaced", Font.BOLD, 14));

    // REGISTER LISTENERS
    restart.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            reStart();
          }
        });

    next.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            nextClicked = true;
            step();
          }
        });

    back.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            nextClicked = false;
            step();
          }
        });

    quit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int confirmQuit =
                JOptionPane.showConfirmDialog(
                    null,
                    "Really Quit?",
                    "Quit Confirmation",
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.QUESTION_MESSAGE);
            switch (confirmQuit) {
              case JOptionPane.YES_OPTION:
                removeInstance();
              case JOptionPane.NO_OPTION:
                break;
            }
          }
        });

    autoGen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            autoGenerateString();
          }
        });

    selfGen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            selfGenerateString();
          }
        });

    // DISABLE NAVIGATION BUTTONS FOR NOW
    next.setEnabled(false);
    back.setEnabled(false);

    // CREATE PANELS
    cachePanel = new FACachePanel();
    memoryPanel = new MemoryPanel();
    bottomPanel = new JPanel();
    cache = new JPanel();
    cacheHitsMisses = new JPanel();
    pAutoSelfGen = new JPanel();
    pAddRefStr = new JPanel();
    pEastPanel = new JPanel();
    pBitsInMM = new JPanel();

    // ADD COMPONENTS TO THE PANELS

    // PANEL WITH PROGRESS UPDATE TEXT AREA AND NAVIGATION BUTTONS
    bottomPanel.add(lProgress);
    bottomPanel.add(progressScroll);
    bottomPanel.add(restart);
    bottomPanel.add(next);
    bottomPanel.add(back);
    bottomPanel.add(quit);

    // PANEL WITH CACHE BLOCKS, HITS AND MISSES INFO.
    cacheHitsMisses.add(lCacheHits);
    cacheHitsMisses.add(tCacheHits);
    cacheHitsMisses.add(lCacheMisses);
    cacheHitsMisses.add(tCacheMisses);
    cacheHMBorder = BorderFactory.createEtchedBorder();
    cacheHitsMisses.setBorder(BorderFactory.createTitledBorder(cacheHMBorder, ""));

    cache.setLayout(new BorderLayout());
    cache.add(cachePanel, "Center");
    cache.add(cacheHitsMisses, "South");

    // PANEL WITH ADDRESS REFERENCE STRING AND STRING GENERATION BUTTONS
    pAutoSelfGen.setLayout(new GridLayout(2, 1));
    pAutoSelfGen.add(autoGen);
    pAutoSelfGen.add(selfGen);

    pAddRefStr.setLayout(new BorderLayout());
    pAddRefStr.setPreferredSize(new Dimension(160, 400));

    pAddRefStr.add(addRefStrScroll, "Center");
    pAddRefStr.add(pAutoSelfGen, "South");
    addRefStrBorder = BorderFactory.createEtchedBorder();
    pAddRefStr.setBorder(
        BorderFactory.createTitledBorder(addRefStrBorder, " Address Reference String "));

    // PANEL WITH THE MAIN MEMORY ADDRESS BITS INFO.
    pBitsInMM.setLayout(new BorderLayout());
    bitsInMMBorder = BorderFactory.createEtchedBorder();
    pBitsInMM.setBorder(BorderFactory.createTitledBorder(bitsInMMBorder, " Main Memory Address "));
    pBitsInMM.add(tTag, "Center");
    pBitsInMM.add(tWord, "East");
    pBitsInMM.add(lBits, "South");

    // PANEL CONTAINING THE ADDRESS REF. STRING PANEL AND BITS IN MM PANEL
    pEastPanel.setLayout(new BorderLayout());
    pEastPanel.setPreferredSize(new Dimension(310, 650));
    pEastPanel.add(pAddRefStr, "Center");
    pEastPanel.add(pBitsInMM, "South");

    // ADD COMPONENTS TO THE FRAME CONTAINER
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    c.add(cache, "West");
    c.add(memoryPanel, "Center");
    c.add(pEastPanel, "East");
    c.add(bottomPanel, "South");

    // INITIALIZE ARRAYS THAT HOLDS STATUS OF EMPTY AND LRU CACHE BLOCKS
    for (int i = 0; i < 16; i++) {
      statusCacheEmpty[i] = true;
      statusCacheLRU[i] = 0;
    }

    /*
     * CALL THE FUNCTION TO GENERATE THE ARRAY addresses, WHICH CONTAINS ALL THE POSSIBLE MEMORY ADDRESSES
     * THIS ARRAY WILL BE USEFUL IN THE AUTO GENERATION OF ADDRESSES AS WELL AS FOR VALIDATION OF
     * ADDRESS STRINGS INPUT BY THE USER IF HE/SHE CHOOSES SELF GENERATION.
     */
    createAddresses();

    pack();
  } // END CONSTRUCTOR
Exemplo n.º 19
0
  public ImageLabFrame() {

    // Set up menus
    JMenuBar menuBar = new JMenuBar();

    JMenu imageLabMenu = new JMenu("imageLab");
    menuBar.add(imageLabMenu);

    aboutItem = new JMenuItem("About imageLab");
    imageLabMenu.add(aboutItem);
    quitItem = new JMenuItem("Quit");
    imageLabMenu.add(quitItem);

    JMenu fileMenu = new JMenu("File");
    menuBar.add(fileMenu);
    openItem = new JMenuItem("Open File...");
    fileMenu.add(openItem);
    saveItem = new JMenuItem("Save As...");
    fileMenu.add(saveItem);

    JMenu imageMenu = new JMenu("Images");
    menuBar.add(imageMenu);
    addPictureGenerator(imageMenu, new Stripe());

    JMenu filterMenu = new JMenu("Filters");
    menuBar.add(filterMenu);
    addFilter(filterMenu, new BWFilter());
    filterMenu.addSeparator();
    addScalableFilter(filterMenu, new SwirlFilter());

    // Listeners for filters are added in addScalableFilter
    aboutItem.addActionListener(this);
    quitItem.addActionListener(this);
    openItem.addActionListener(this);
    saveItem.addActionListener(this);

    // Set up rest of GUI

    lab = initialImage().getJLabel();

    slider = new JSlider(0, 100);
    sliderPanel = new JPanel();
    sliderPanel.add(slider);
    sliderPanel.setVisible(false);
    Border b1 = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    border = BorderFactory.createTitledBorder(b1, "");
    sliderPanel.setBorder(border);
    slider.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            double scale = (slider.getValue() - 50) / 50.0;
            currentFilter.apply(pic1, pic2, scale);
            lab.setIcon(pic2.getJLabel().getIcon());
            repaint();
          }
        });

    JPanel panel = new JPanel(new BorderLayout());
    getContentPane().add(panel);
    panel.add(lab, BorderLayout.NORTH);
    panel.add(sliderPanel, BorderLayout.SOUTH);
    setJMenuBar(menuBar);
    pack();
    setTitle("imageLab");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Prepare file chooser
    chooser = new JFileChooser(new File("."));
    FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG Images", "jpg");
    chooser.setFileFilter(filter);
  }
Exemplo n.º 20
0
    public PlayerView(String player) {
      playerName = new String(player);

      // Set-Up Top of Score Area
      namePanel = new JPanel();
      nameText = new JLabel(player);
      nameText.setFont(ScoreFont);
      namePanel.setLayout(new BorderLayout());
      namePanel.add(nameText, BorderLayout.CENTER);

      scorePanel = new JPanel();
      scoreText = new JLabel("  0");
      scoreText.setFont(ScoreFont);
      scorePanel.setLayout(new BorderLayout());
      scorePanel.add(scoreText, BorderLayout.CENTER);

      topPanel = new JPanel();
      BoxLayout layout = new BoxLayout(topPanel, BoxLayout.LINE_AXIS);

      topPanel.setLayout(layout);
      topPanel.add(namePanel);
      topPanel.add(Box.createRigidArea(new Dimension(10, 0)));
      topPanel.add(scorePanel);
      topPanel.add(Box.createRigidArea(new Dimension(10, 0)));

      //
      // topPanel.setLayout( new BorderLayout());
      // topPanel.add(namePanel, BorderLayout.WEST);
      // topPanel.add(scorePanel, BorderLayout.EAST);
      //
      // Create bordering for top panel
      Border raisedBevel, loweredBevel, compound;

      raisedBevel = BorderFactory.createRaisedBevelBorder();
      loweredBevel = BorderFactory.createLoweredBevelBorder();
      compound = BorderFactory.createCompoundBorder(raisedBevel, loweredBevel);
      topPanel.setBorder(compound);

      // Set-Up area to display word list
      wordPanel = new JPanel();
      Border etched = BorderFactory.createEtchedBorder();
      TitledBorder etchedTitle = BorderFactory.createTitledBorder(etched, "Word List");
      etchedTitle.setTitleJustification(TitledBorder.RIGHT);
      wordPanel.setBorder(etchedTitle);
      myWordList = new ExpandableList();
      myWordList.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              String word = e.getActionCommand();
              java.util.List<BoardCell> list = myFinder.cellsForWord(myBoard, word);
              myBoardPanel.highlightDice(list);
            }
          });
      wordPanel.add(
          new JScrollPane(
              myWordList,
              JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
              JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));

      setLayout(new BorderLayout(30, 30));
      add(topPanel, BorderLayout.NORTH);
      add(wordPanel, BorderLayout.CENTER);
    }
Exemplo n.º 21
0
  /** Building up the core GUI. */
  private void buildUpGUI() {
    table = new JTable(new ConstantPoolTableModel());

    setLayout(new BorderLayout());
    add(mainPanel);

    mainPanel.add(tablePanel, BorderLayout.CENTER);
    mainPanel.add(searchPanel, BorderLayout.NORTH);

    tablePanel.add(table.getTableHeader(), BorderLayout.NORTH);
    tablePanel.add(new JScrollPane(table), BorderLayout.CENTER);

    searchPanel.setLayout(new GridLayout(0, 3));
    searchPanel.add(findPanel);
    searchPanel.add(gotoPanel);
    searchPanel.add(filterPanel);

    findPanel.setBorder(BorderFactory.createTitledBorder("Search String:"));
    gotoPanel.setBorder(BorderFactory.createTitledBorder("Jump to index:"));
    filterPanel.setBorder(BorderFactory.createTitledBorder("Filtering:"));

    findPanel.setLayout(new BoxLayout(findPanel, BoxLayout.Y_AXIS));
    findTextField.setAlignmentX(Component.CENTER_ALIGNMENT);
    findPanel.add(findTextField);
    findButtonPanel.add(findNextButton);
    findButtonPanel.add(findPrevButton);

    findButtonPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    findPanel.add(findButtonPanel);

    gotoPanel.setLayout(new BorderLayout());
    JPanel tmp = new JPanel();
    gotoPanel.add(tmp, BorderLayout.CENTER);
    tmp.add(gotoTextField);
    tmp = new JPanel();
    gotoPanel.add(tmp, BorderLayout.EAST);
    tmp.add(gotoButton);

    filterPanel.setLayout(new BorderLayout());
    tmp = new JPanel();
    filterPanel.add(tmp, BorderLayout.CENTER);
    tmp.add(filterComboBox);

    tmp = new JPanel();
    filterPanel.add(tmp, BorderLayout.EAST);
    tmp.add(filterButton);

    // adding listeners
    findTextField.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent ke) {
            if (KeyEvent.VK_ENTER == ke.getKeyChar()) {
              findNext();
            }
          }
        });

    findNextButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            findNext();
          }
        });

    findPrevButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            findPrev();
          }
        });

    gotoTextField.addKeyListener(
        new KeyAdapter() {
          public void keyTyped(KeyEvent ke) {
            if (KeyEvent.VK_ENTER == ke.getKeyChar()) {
              gotoLine();
            }
          }
        });

    gotoButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            gotoLine();
          }
        });

    filterButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            filterData();
          }
        });
  } // buildUpGUI
Exemplo n.º 22
0
 private Border createTitleBorder(String title) {
   TitledBorder b = BorderFactory.createTitledBorder(title);
   //            b.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
   return new CompoundBorder(b, BorderFactory.createEmptyBorder(10, 10, 10, 10));
 }
Exemplo n.º 23
0
  public LibGui() {
    // menu bar and menu item initialization
    menu = new JMenuBar();
    m1 = new JMenu("Options");
    m2 = new JMenu("Programs");
    m3 = new JMenu("Help");

    AddNew = new JMenuItem("AddNew");

    Search = new JMenuItem("Search");

    Display = new JMenuItem("Display");
    Delete = new JMenuItem("Delete");
    Modify = new JMenuItem("Modify");
    Exit = new JMenuItem("Exit");
    Help = new JMenuItem("Help");

    // text area initialization
    tac = new JTextArea(2, 3);

    tac.setText("For: Birgang Institute of Technology" + " " + "Birganj,Parsa ");

    tac.setForeground(Color.red);
    tac.setEditable(false);

    // button intialization
    btnAddNew = new JButton("ADDNEW");

    btnAddNew.setToolTipText("Add new Details");

    btnSearch = new JButton("SEARCH");
    btnSearch.setToolTipText("Search particular student");

    btnDelete = new JButton("DELETE");
    btnDelete.setToolTipText("Delete particular student");

    btnDisplay = new JButton("DISPLAY");
    btnDisplay.setToolTipText("Display particular student");

    btnModify = new JButton("MODIFY");
    btnModify.setToolTipText("Modifies particular student");

    btnExit = new JButton("EXIT");
    btnExit.setToolTipText("Out of Program");

    // initialization panel
    pMain = new JPanel();
    pNorth = new JPanel();
    pSouth = new JPanel();
    pCenter = new JPanel();

    lbllogo = new JLabel(new ImageIcon("//G:/MFCfinish.gif"), JLabel.CENTER);

    // add menuitem to menu
    m1.add(AddNew);
    m1.add(Search);
    m1.add(Display);
    m1.add(Delete);
    m1.add(Modify);

    m2.add(Exit);
    m3.add(Help);

    menu.add(m1);
    menu.add(m2);
    menu.add(m3);

    pMain.add(btnAddNew);
    pMain.add(btnSearch);
    pMain.add(btnDelete);
    pMain.add(btnDisplay);
    pMain.add(btnModify);
    pMain.add(btnExit);

    pMain.setLayout(new BoxLayout(pMain, BoxLayout.Y_AXIS));
    pMain.setBorder(BorderFactory.createTitledBorder("OPTIONS"));
    pMain.setLayout(new GridLayout(6, 1));
    pMain.setBackground(Color.white);

    pCenter.setBackground(Color.red);
    pCenter.setLayout(new BoxLayout(pMain, BoxLayout.Y_AXIS));
    pCenter.setLayout(new GridLayout(2, 1));
    pCenter.add(lbllogo);
    pCenter.add(tac);

    pNorth.setBackground(Color.white);

    pNorth.add(menu);

    this.getContentPane().add(pMain, "West");
    this.getContentPane().add(pCenter, "Center");
    this.getContentPane().add(pNorth, "North");

    this.setSize(400, 300);
    this.setResizable(false);
    this.setLocation(150, 150);
    this.setTitle("MENU");
    this.show();
  }
Exemplo n.º 24
0
  public SceneLayoutApp() {
    super();
    new Pair();
    final JFrame frame = new JFrame("Scene Layout");

    final JPanel panel = new JPanel(new BorderLayout());
    frame.setContentPane(panel);
    final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setMaximumSize(screenSize);
    frame.setSize(screenSize);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JMenuBar mb = new JMenuBar();
    frame.setJMenuBar(mb);

    final JMenu jMenu = new JMenu("File");
    mb.add(jMenu);
    mb.add(new JMenu("Edit"));
    mb.add(new JMenu("Help"));
    JMenu menu = new JMenu("Look and Feel");

    //
    // Get all the available look and feel that we are going to use for
    // creating the JMenuItem and assign the action listener to handle
    // the selection of menu item to change the look and feel.
    //
    UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < lookAndFeelInfos.length; i++) {
      final UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i];
      JMenuItem item = new JMenuItem(lookAndFeelInfo.getName());
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              try {
                //
                // Set the look and feel for the frame and update the UI
                // to use a new selected look and feel.
                //
                UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
                SwingUtilities.updateComponentTreeUI(frame);
              } catch (ClassNotFoundException e1) {
                e1.printStackTrace();
              } catch (InstantiationException e1) {
                e1.printStackTrace();
              } catch (IllegalAccessException e1) {
                e1.printStackTrace();
              } catch (UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
              }
            }
          });
      menu.add(item);
    }

    mb.add(menu);
    jMenu.add(new JMenuItem(new scene.action.QuitAction()));

    panel.add(new JScrollPane(desktopPane), BorderLayout.CENTER);
    final JToolBar bar = new JToolBar();

    panel.add(bar, BorderLayout.NORTH);

    final JComboBox comboNewWindow =
        new JComboBox(
            new String[] {"320:180", "320:240", "640:360", "640:480", "1280:720", "1920:1080"});

    comboNewWindow.addActionListener(new CreateSceneWindowAction());

    comboNewWindow.setBorder(BorderFactory.createTitledBorder("Create New Window"));
    bar.add(comboNewWindow);
    bar.add(
        new AbstractAction("Progress Bars") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new ProgressBarAnimator();
          }
        });
    bar.add(
        new AbstractAction("Sliders") {

          /** Invoked when an action occurs. */
          @Override
          public void actionPerformed(ActionEvent e) {
            new SliderBarAnimator();
          }
        });

    final JCheckBox permaViz = new JCheckBox();
    permaViz.setText("Show the dump window");
    permaViz.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    dumpWindow = new JInternalFrame("perma dump window");
    dumpWindow.setContentPane(new JScrollPane(permText));

    permaViz.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dumpWindow.setVisible(permaViz.isSelected());
          }
        });

    comboNewWindow.setMaximumSize(comboNewWindow.getPreferredSize());

    permaViz.setSelected(false);
    bar.add(new CreateWebViewV1Action());
    bar.add(new CreateWebViewV2Action());
    bar.add(permaViz);
    desktopPane.add(dumpWindow);
    dumpWindow.setSize(400, 400);
    dumpWindow.setResizable(true);
    dumpWindow.setClosable(false);
    dumpWindow.setIconifiable(false);
    final JMenuBar m = new JMenuBar();
    final JMenu cmenu = new JMenu("Create");
    m.add(cmenu);
    final JMenuItem menuItem =
        new JMenuItem(
            new AbstractAction("new") {
              @Override
              public void actionPerformed(ActionEvent e) {
                Runnable runnable =
                    new Runnable() {
                      public void run() {
                        Object[] in = (Object[]) XSTREAM.fromXML(permText.getText());

                        final JInternalFrame ff = new JInternalFrame();

                        final ScenePanel c = new ScenePanel();
                        ff.setContentPane(c);
                        desktopPane.add(ff);
                        final Dimension d = (Dimension) in[0];
                        c.setMaximumSize(d);
                        c.setPreferredSize(d);

                        ff.setSize(d.width + 50, d.height + 50);
                        ScenePanel.panes.put(c, (List<Pair<Point, ArrayList<URL>>>) in[1]);

                        c.invalidate();
                        c.repaint();

                        ff.pack();
                        ff.setClosable(true);

                        ff.setMaximizable(false);
                        ff.setIconifiable(false);
                        ff.setResizable(false);
                        ff.show();
                      }
                    };

                SwingUtilities.invokeLater(runnable);
              }
            });
    cmenu.add(menuItem);
    //        JMenuBar menuBar = new JMenuBar();

    //        getContentPane().add(menuBar);

    dumpWindow.setJMenuBar(m);
    frame.setVisible(true);
  }
Exemplo n.º 25
0
  public void init() {
    symbolData =
        new Icon[] {
          new ImageIcon(getClass().getResource("images/sym_square.gif")),
          new ImageIcon(getClass().getResource("images/sym_squarefilled.gif")),
          new ImageIcon(getClass().getResource("images/sym_circle.gif")),
          new ImageIcon(getClass().getResource("images/sym_circlefilled.gif")),
          new ImageIcon(getClass().getResource("images/sym_diamond.gif")),
          new ImageIcon(getClass().getResource("images/sym_diamondfilled.gif")),
          new ImageIcon(getClass().getResource("images/sym_triangle.gif")),
          new ImageIcon(getClass().getResource("images/sym_trianglefilled.gif")),
          new ImageIcon(getClass().getResource("images/sym_cross1.gif")),
          new ImageIcon(getClass().getResource("images/sym_cross2.gif"))
        };

    mSymbolPopup = new JOAJComboBox();
    for (int i = 0; i < symbolData.length; i++) {
      mSymbolPopup.addItem(symbolData[i]);
    }
    mSymbolPopup.setSelectedIndex(mCurrSymbol - 1);

    JPanel everyThingPanel = new JPanel(new BorderLayout(5, 5));

    // create the two parameter chooser lists
    Container contents = this.getContentPane();
    this.getContentPane().setLayout(new BorderLayout(5, 5));
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout(5, 5));
    JPanel paramPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    JPanel upperPanel = new JPanel(new BorderLayout(5, 5));
    mYParamList =
        new StnParameterChooser(mFileViewer, new String("Stations Parameters:"), this, 5, "SALT");
    OffsetPanel ofp = new OffsetPanel(this);
    mYParamList.init();
    paramPanel.add(mYParamList);
    paramPanel.add(ofp);
    upperPanel.add("Center", paramPanel);
    everyThingPanel.add(BorderLayout.NORTH, upperPanel);

    // Options
    JPanel middlePanel = new JPanel();
    middlePanel.setLayout(new ColumnLayout(Orientation.CENTER, Orientation.TOP, 3));
    TitledBorder tb = BorderFactory.createTitledBorder(b.getString("kOptions"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    middlePanel.setBorder(tb);

    // containers for the non-advanced options
    JPanel nonAdvOptions = new JPanel();
    nonAdvOptions.setLayout(new BorderLayout(5, 0));

    JPanel ctrNonAdvOptions = new JPanel();
    ctrNonAdvOptions.setLayout(new GridLayout(1, 2, 2, 2));

    // plot axes goes in ctrNonAdvOptions
    JPanel axesOptions = new JPanel();
    axesOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0));
    tb = BorderFactory.createTitledBorder(b.getString("kAxes"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    axesOptions.setBorder(tb);
    JPanel line0 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    JPanel line1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    JPanel line3 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    JPanel line33 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    mConnectObs = new JOAJCheckBox(b.getString("kConnectObservations"), true);
    mReverseY = new JOAJCheckBox(b.getString("kReverseYAxis"), false);
    mReverseY.addItemListener(this);
    mPlotYGrid = new JOAJCheckBox(b.getString("kYGrid"));
    mPlotXGrid = new JOAJCheckBox(b.getString("kXGrid"));
    line0.add(mConnectObs);
    line1.add(mReverseY);
    line3.add(mPlotYGrid);
    line33.add(mPlotXGrid);
    axesOptions.add(line1);
    axesOptions.add(line3);
    axesOptions.add(line33);

    // other options
    JPanel otherOptions = new JPanel();
    otherOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0));
    tb = BorderFactory.createTitledBorder(b.getString("kOther"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    otherOptions.setBorder(tb);

    // plot symbols
    JPanel line4 = new JPanel();
    line4.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    mEnableSymbols = new JOAJLabel(b.getString("kSymbol"));
    line4.add(mEnableSymbols);
    line4.add(mSymbolPopup);
    mSymbolPopup.addItemListener(this);
    mSizeLabel = new JOAJLabel(b.getString("kSize"));
    line4.add(mSizeLabel);

    SpinnerNumberModel model = new SpinnerNumberModel(4, 1, 100, 1);
    mSizeField = new JSpinner(model);

    line4.add(mSizeField);
    otherOptions.add(line0);
    otherOptions.add(line4);

    // add the axes and other panels to the gridlayout
    ctrNonAdvOptions.add(axesOptions);
    ctrNonAdvOptions.add(otherOptions);

    // add this panel to the north of the borderlayout
    nonAdvOptions.add("Center", ctrNonAdvOptions);

    JPanel colorNameContPanel = new JPanel();
    colorNameContPanel.setLayout(new BorderLayout(0, 0));

    JPanel colorNamePanel = new JPanel();
    colorNamePanel.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0));

    // swatches
    JPanel lineLCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    lineLCS.add(new JOAJLabel(b.getString("kLineColor")));
    mLineColorSwatch = new Swatch(Color.black, 12, 12);
    lineLCS.add(new JOAJLabel(" "));
    lineLCS.add(mLineColorSwatch);

    JPanel lineSCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    lineSCS.add(new JOAJLabel(b.getString("kSymbolColor")));
    mSymbolColorSwatch = new Swatch(Color.black, 12, 12);
    lineSCS.add(new JOAJLabel(" "));
    lineSCS.add(mSymbolColorSwatch);

    JPanel line7 = new JPanel();
    line7.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    line7.add(new JOAJLabel(b.getString("kBackgroundColor")));
    plotBg = new Swatch(JOAConstants.DEFAULT_CONTENTS_COLOR, 12, 12);
    line7.add(new JOAJLabel(" "));
    line7.add(plotBg);
    JPanel line8 = new JPanel();
    line8.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    line8.add(new JOAJLabel(b.getString("kGridColor")));
    axesColor = new Swatch(Color.black, 12, 12);
    line8.add(new JOAJLabel(" "));
    line8.add(axesColor);
    JPanel line9 = new JPanel();
    line9.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    line9.add(new JOAJLabel(b.getString("kColorSchemes")));
    Vector<String> presetSchemes = new Vector<String>();
    presetSchemes.addElement(b.getString("kDefault"));
    presetSchemes.addElement(b.getString("kWhiteBackground"));
    presetSchemes.addElement(b.getString("kBlackBackground"));
    presetColorSchemes = new JOAJComboBox(presetSchemes);
    presetColorSchemes.setSelectedItem(b.getString("kDefault"));
    presetColorSchemes.addItemListener(this);
    line9.add(presetColorSchemes);

    JPanel swatchCont = new JPanel();
    swatchCont.setLayout(new GridLayout(4, 1, 0, 5));
    swatchCont.add(lineLCS);
    swatchCont.add(lineSCS);
    swatchCont.add(line7);
    swatchCont.add(line8);
    JPanel swatchContCont = new JPanel();
    swatchContCont.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    swatchContCont.add(swatchCont);
    swatchContCont.add(line9);
    tb = BorderFactory.createTitledBorder(b.getString("kColors"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    swatchContCont.setBorder(tb);

    // window name
    JPanel namePanel = new JPanel();
    namePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 5));
    namePanel.add(new JOAJLabel(b.getString("kWindowName")));
    mNameField = new JOAJTextField(30);
    mNameField.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    namePanel.add(mNameField);

    // add the color panel
    colorNameContPanel.add("North", swatchContCont);
    colorNamePanel.add(colorNameContPanel);

    // add the name panel
    colorNamePanel.add(namePanel);

    // add these to the south of the borderlayout
    nonAdvOptions.add("South", colorNamePanel);

    // add all of this to the middle panel
    middlePanel.add(nonAdvOptions);

    // advanced options panel
    // axis container
    // y axis detail
    // container for the axes stuff
    plotScaleCont = new JPanel(new GridLayout(1, 2, 5, 5));

    // y axis container
    JPanel yAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2));
    tb = BorderFactory.createTitledBorder(b.getString("kYAxis"));
    yAxis.setBorder(tb);
    StnPlotSpecification mPlotSpec = new StnPlotSpecification();

    JPanel line5y = new JPanel();
    line5y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line5y.add(new JOAJLabel(b.getString("kMinimum")));
    yMin = new JOAJTextField(6);
    yMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMin()), 3, false));
    yMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line5y.add(yMin);

    JPanel line6y = new JPanel();
    line6y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line6y.add(new JOAJLabel(b.getString("kMaximum")));
    yMax = new JOAJTextField(6);
    yMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMax()), 3, false));
    yMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line6y.add(yMax);

    JPanel line7y = new JPanel();
    line7y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line7y.add(new JOAJLabel(b.getString("kIncrement")));
    yInc = new JOAJTextField(6);
    yInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getYInc()), 3, false));
    yInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line7y.add(yInc);

    JPanel line8y = new JPanel();
    line8y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line8y.add(new JOAJLabel(b.getString("kNoMinorTicks")));

    SpinnerNumberModel model3 = new SpinnerNumberModel(mPlotSpec.getYTics(), 0, 100, 1);
    yTics = new JSpinner(model3);
    line8y.add(yTics);

    yAxis.add(line5y);
    yAxis.add(line6y);
    yAxis.add(line7y);
    yAxis.add(line8y);
    yAxis.add(new JLabel("   "));
    yAxis.add(new JLabel("    "));
    yAxis.add(new JLabel("    "));
    plotScaleCont.add(yAxis);

    // x axis container
    JPanel xAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2));
    tb = BorderFactory.createTitledBorder(b.getString("kXAxis"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    xAxis.setBorder(tb);

    JPanel line5x = new JPanel();
    line5x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line5x.add(mMinXLabel);
    xMin = new JOAJTextField(6);
    xMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMin()), 3, false));
    xMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line5x.add(xMin);

    JPanel minTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1));
    minTime.add(mMinXTLabel);
    JPanel maxTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1));
    maxTime.add(mMaxXTLabel);

    GeoDate minDate = new GeoDate(mFileViewer.getMinDate());
    minDate.decrement(1.0, GeoDate.YEARS);
    GeoDate maxDate = new GeoDate(mFileViewer.getMaxDate());
    maxDate.increment(1.0, GeoDate.YEARS);
    // value, start,end
    SpinnerDateModel mStartDateModel =
        new SpinnerDateModel(
            new GeoDate(mFileViewer.getMinDate()), minDate, maxDate, Calendar.HOUR);
    mStartSpinner = new JSpinner(mStartDateModel);
    JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(mStartSpinner, "yyyy-MM-dd HH:mm");
    mStartSpinner.setEditor(dateEditor);

    SpinnerDateModel mEndDateModel =
        new SpinnerDateModel(
            new GeoDate(mFileViewer.getMaxDate()), minDate, maxDate, Calendar.HOUR);
    mEndSpinner = new JSpinner(mEndDateModel);
    JSpinner.DateEditor dateEditor2 = new JSpinner.DateEditor(mEndSpinner, "yyyy-MM-dd HH:mm");
    minTime.add(mStartSpinner);
    maxTime.add(mEndSpinner);
    mEndSpinner.setEditor(dateEditor2);

    JPanel line6x = new JPanel();
    line6x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line6x.add(mMaxXLabel);
    xMax = new JOAJTextField(6);
    xMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMax()), 3, false));
    xMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line6x.add(xMax);

    JPanel line7x = new JPanel();
    line7x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line7x.add(mIncLabel);
    xInc = new JOAJTextField(6);
    xInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getXInc()), 3, false));
    xInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line7x.add(xInc);

    JPanel line8x = new JPanel();
    line8x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line8x.add(mXIncLabel);

    SpinnerNumberModel model2 = new SpinnerNumberModel(mPlotSpec.getXTics(), 0, 100, 1);
    xTics = new JSpinner(model2);
    line8x.add(xTics);

    xAxis.add(minTime);
    xAxis.add(maxTime);
    xAxis.add(line5x);
    xAxis.add(line6x);
    xAxis.add(line7x);
    xAxis.add(line8x);
    plotScaleCont.add(xAxis);

    everyThingPanel.add(BorderLayout.CENTER, plotScaleCont);
    everyThingPanel.add(BorderLayout.SOUTH, middlePanel);

    mainPanel.add(BorderLayout.CENTER, new TenPixelBorder(everyThingPanel, 10, 10, 10, 10));

    // lower panel
    mOKBtn = new JOAJButton(b.getString("kPlot"));
    mOKBtn.setActionCommand("ok");
    this.getRootPane().setDefaultButton(mOKBtn);
    mCancelButton = new JOAJButton(b.getString("kCancel"));
    mCancelButton.setActionCommand("cancel");
    JPanel dlgBtnsInset = new JPanel();
    JPanel dlgBtnsPanel = new JPanel();
    dlgBtnsInset.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 1));
    dlgBtnsPanel.setLayout(new GridLayout(1, 4, 15, 1));
    if (JOAConstants.ISMAC) {
      dlgBtnsPanel.add(mCancelButton);
      dlgBtnsPanel.add(mOKBtn);
    } else {
      dlgBtnsPanel.add(mOKBtn);
      dlgBtnsPanel.add(mCancelButton);
    }
    dlgBtnsInset.add(dlgBtnsPanel);

    mOKBtn.addActionListener(this);
    mCancelButton.addActionListener(this);

    mainPanel.add(new TenPixelBorder(dlgBtnsInset, 5, 5, 5, 5), "South");
    contents.add("Center", mainPanel);
    this.pack();

    runTimer();
    setXRangeToDistance();

    // show dialog at center of screen
    Rectangle dBounds = this.getBounds();
    Dimension sd = Toolkit.getDefaultToolkit().getScreenSize();
    int x = sd.width / 2 - dBounds.width / 2;
    int y = sd.height / 2 - dBounds.height / 2;
    this.setLocation(x, y);
  }
  /** Initializes all GUI components */
  private void initComponents() {

    mainPanel = new JPanel();
    editPanel = new JPanel();
    editPanelLeft = new JPanel();
    editPanelCenter = new JPanel();
    editPanelRight = new JPanel();
    tablePanel = new JPanel();

    companyIdTextField = new JTextField();
    companyIdTextField.setEditable(false);
    companyNameTextField = new JTextField();
    urlTextField = new JTextField();
    insuranceTypesTextField = new JTextField();
    telephoneTextField = new JTextField();
    percentageTextField = new JTextField();
    percentageTextField.setToolTipText("<html>Only <b>numerical</b> values allowed</html>");
    searchTextField = new JTextField();
    searchTextField.setToolTipText(
        "<html>Use either <b>AND</b> or <b>OR</b> for combined search queries<br>You can also use <b>spaces</b> instead of <b>OR</b></html>");
    generalDescriptionTextField = new JTextField();

    companyIdLabel = new InsuranceCompanyLabel("ID");
    companyNameLabel = new InsuranceCompanyLabel("Company");
    urlLabel = new InsuranceCompanyLabel("Website");
    insuranceTypesLabel = new InsuranceCompanyLabel("Insurance Types");
    telephoneLabel = new InsuranceCompanyLabel("Telephone");
    percentageLabel = new InsuranceCompanyLabel("Broker Percentage");
    searchLabel = new InsuranceCompanyLabel("Search Insurance Types");
    generalDescriptionLabel = new InsuranceCompanyLabel("General Description");
    sortLabel = new InsuranceCompanyLabel("Sorting");

    addInsuranceCompanyButton = new InsuranceCompanyButton("New Insurance Company", 190, 45);
    addInsuranceCompanyButton.setToolTipText(
        "<html>Create a new <b>empty</b> Insurance Company</html>");
    saveInsuranceCompanyButton = new InsuranceCompanyButton("Save Insurance Company", 190, 45);
    saveInsuranceCompanyButton.setToolTipText(
        "<html>Save the <b>selected</b> Insurance Company<br>Hint: Press <b>Enter</b> to quickly save an entry</html>");
    saveInsuranceCompanyButton.setDefaultCapable(true);
    getRootPane()
        .setDefaultButton(
            saveInsuranceCompanyButton); // Set the save button as default button, so quicker
                                         // editing by pressing Enter is possible
    deleteInsuranceCompanyButton = new InsuranceCompanyButton("Delete Insurance Company", 190, 45);
    deleteInsuranceCompanyButton.setToolTipText(
        "<html>Delete the <b>selected</b> Insurance Company</html>");
    clearSearchButton = new InsuranceCompanyButton("x", 40, 35);
    clearSearchButton.setToolTipText("<html>Click to <b>clear</b> the search field</html>");

    String[] sortStrategies = {"ID", "Company Name", "Percentage"};
    sortComboBox = new JComboBox(sortStrategies);

    tableData = new InsuranceCompanyTableModel(model.getInsuranceCompanies());
    insuranceCompaniesTable = new JTable();

    insuranceCompanyScrollPane = new JScrollPane(insuranceCompaniesTable);

    // Set layout and add components to panels
    setLayout(new BorderLayout());
    add(mainPanel, BorderLayout.CENTER);
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(editPanel, BorderLayout.NORTH);
    editPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    editPanel.setLayout(new BorderLayout());
    editPanel.add(editPanelLeft, BorderLayout.CENTER);
    editPanelLeft.setBorder(new EmptyBorder(0, 0, 5, 15));
    editPanelLeft.setLayout(new GridLayout(4, 4, 5, 0));
    editPanelLeft.add(companyIdLabel);
    editPanelLeft.add(companyNameLabel);
    editPanelLeft.add(urlLabel);
    editPanelLeft.add(telephoneLabel);
    editPanelLeft.add(companyIdTextField);
    editPanelLeft.add(companyNameTextField);
    editPanelLeft.add(urlTextField);
    editPanelLeft.add(telephoneTextField);
    editPanelLeft.add(percentageLabel);
    editPanelLeft.add(searchLabel);
    editPanelLeft.add(new JLabel());
    editPanelLeft.add(sortLabel);
    editPanelLeft.add(percentageTextField);
    editPanelLeft.add(searchTextField);
    Container searchBox = Box.createVerticalBox();
    searchBox.add(clearSearchButton);
    editPanelLeft.add(searchBox);
    editPanelLeft.add(sortComboBox);
    editPanel.add(editPanelRight, BorderLayout.EAST);
    Container box = Box.createVerticalBox();
    box.add(saveInsuranceCompanyButton);
    box.add(Box.createVerticalStrut(5));
    box.add(addInsuranceCompanyButton);
    box.add(Box.createVerticalStrut(5));
    box.add(deleteInsuranceCompanyButton);
    editPanelRight.add(box);
    editPanel.add(editPanelCenter, BorderLayout.SOUTH);
    editPanelCenter.setLayout(new GridLayout(4, 1));
    editPanelCenter.add(insuranceTypesLabel);
    editPanelCenter.add(insuranceTypesTextField);
    editPanelCenter.add(generalDescriptionLabel);
    editPanelCenter.add(generalDescriptionTextField);
    mainPanel.add(tablePanel, BorderLayout.CENTER);
    tablePanel.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createEmptyBorder(10, 10, 10, 10), "Insurance Companies Overview"));
    tablePanel.setLayout(new BorderLayout());
    tablePanel.add(insuranceCompanyScrollPane, BorderLayout.CENTER);

    setMinimumSize(new Dimension(800, 600));
    setPreferredSize(new Dimension(900, 600));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
  }
Exemplo n.º 27
0
 @SuppressWarnings("serial")
 private void initGUI() {
   try {
     setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
     getContentPane().setLayout(null);
     this.setTitle("Overzicht");
     this.setVisible(true);
     {
       lStart = new JLabel();
       getContentPane().add(lStart);
       lStart.setText("Overzicht");
       lStart.setHorizontalAlignment(SwingConstants.CENTER);
       lStart.setBackground(new java.awt.Color(54, 190, 54));
       lStart.setFont(new java.awt.Font("Arial", 1, 36));
       lStart.setForeground(new java.awt.Color(0, 128, 64));
       lStart.setOpaque(true);
       lStart.setBounds(0, 0, 336, 49);
     }
     {
       pInzet = new JPanel();
       getContentPane().add(pInzet);
       pInzet.setBorder(
           BorderFactory.createTitledBorder(
               null,
               "Selectie",
               TitledBorder.LEADING,
               TitledBorder.DEFAULT_POSITION,
               new java.awt.Font("Tahoma", 1, 11)));
       pInzet.setLayout(null);
       pInzet.setBounds(14, 63, 308, 105);
       pInzet.setFont(new java.awt.Font("Tahoma", 1, 12));
       {
         lMin = new JLabel();
         pInzet.add(lMin);
         lMin.setText("Speler");
         lMin.setFont(new java.awt.Font("Arial", 0, 12));
         lMin.setBounds(17, 59, 62, 27);
       }
       {
         lMax = new JLabel();
         pInzet.add(lMax);
         lMax.setText("Spelronde");
         lMax.setFont(new java.awt.Font("Arial", 0, 12));
         lMax.setBounds(17, 26, 62, 25);
       }
       // Combo voor Spelrondes. Deze wordt eerst geladen. Na selectie
       // wordt de speler gevuld.
       {
         oc = new OverzichtController(this);
         String[] rondes = oc.GeefSpelrondes();
         ComboBoxModel cbSpelRondeModel = new DefaultComboBoxModel(rondes);
         cbSpelRonde = new JComboBox();
         pInzet.add(cbSpelRonde);
         cbSpelRonde.setModel(cbSpelRondeModel);
         cbSpelRonde.setBounds(91, 29, 156, 21);
         cbSpelRonde.setToolTipText("Maak een keuze uit de gespeelde speelronden.");
       }
       {
         bStart = new JButton();
         getContentPane().add(bStart);
         bStart.setText("Sluiten");
         bStart.setFont(new java.awt.Font("Arial", 0, 12));
         bStart.setBounds(196, 303, 75, 23);
         bStart.addActionListener(
             new ActionListener() {
               public void actionPerformed(ActionEvent evt) {
                 bStartActionPerformed(evt);
               }
             });
       }
     }
     pack();
     this.setSize(352, 364);
   } catch (Exception e) {
     e.printStackTrace();
   }
 } // private void initGUI()
Exemplo n.º 28
0
  /** Constructor allows for set up of the panel */
  public MapCreation() {
    // panel set up
    this.setLayout(new GridLayout(0, 1));

    // set up labels
    smallIcon = new ImageIcon("images/MapCreation/smallWorld.png");
    smallLabel = new JLabel(smallIcon);

    mediumIcon = new ImageIcon("images/MapCreation/mediumWorld.png");
    mediumLabel = new JLabel(mediumIcon);

    largeIcon = new ImageIcon("images/MapCreation/largeWorld.png");
    largeLabel = new JLabel(largeIcon);

    continentIcon = new ImageIcon("images/MapCreation/Continent.png");
    continentLabel = new JLabel(continentIcon);

    variedIcon = new ImageIcon("images/MapCreation/ContinentAndIsland.png");
    variedLabel = new JLabel(variedIcon);

    islandIcon = new ImageIcon("images/MapCreation/Islands.png");
    islandLabel = new JLabel(islandIcon);

    mainLabel = new JLabel("New Map Creation");
    mainLabel.setForeground(new Color(51, 0, 51));
    mainLabel.setFont(new Font("Dialog", 1, 32));
    mainLabel.setHorizontalAlignment(SwingConstants.CENTER);

    // set up the radioButtons
    smallButton = new JRadioButton("Small 50x50");
    mediumButton = new JRadioButton("Medium 75x75");
    largeButton = new JRadioButton("Large 100x100");
    largeButton.setSelected(true);

    sizeGroup = new ButtonGroup();
    sizeGroup.add(smallButton);
    sizeGroup.add(mediumButton);
    sizeGroup.add(largeButton);

    continentButton = new JRadioButton("Continents");
    variedButton = new JRadioButton("Varied");
    variedButton.setSelected(true);
    islandButton = new JRadioButton("Islands");

    styleGroup = new ButtonGroup();
    styleGroup.add(continentButton);
    styleGroup.add(variedButton);
    styleGroup.add(islandButton);

    // set up the panels
    sizePanel = new JPanel(new GridLayout(2, 3));
    sizePanel.setBorder(BorderFactory.createTitledBorder("Please select map size"));
    sizePanel.add(smallLabel);
    sizePanel.add(mediumLabel);
    sizePanel.add(largeLabel);
    sizePanel.add(smallButton);
    sizePanel.add(mediumButton);
    sizePanel.add(largeButton);

    stylePanel = new JPanel(new GridLayout(2, 3));
    stylePanel.setBorder(BorderFactory.createTitledBorder("Please select land style"));
    stylePanel.add(continentLabel);
    stylePanel.add(variedLabel);
    stylePanel.add(islandLabel);
    stylePanel.add(continentButton);
    stylePanel.add(variedButton);
    stylePanel.add(islandButton);

    // add to panel
    this.add(mainLabel);
    this.add(sizePanel);
    this.add(stylePanel);
    // this.add(buttonPanel);
  } // end constructor
  public InfoPanelForDrawable(
      final Map map_line2treenodes, final String[] y_colnames, final Drawable dobj) {
    super();
    super.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    /* Define DecialFormat for the displayed time */
    if (fmt == null) {
      fmt = (DecimalFormat) NumberFormat.getInstance();
      fmt.applyPattern(FORMAT);
    }
    if (tfmt == null) tfmt = new TimeFormat();
    if (Normal_Border == null) {
      /*
      Normal_Border = BorderFactory.createCompoundBorder(
                      BorderFactory.createRaisedBevelBorder(),
                      BorderFactory.createLoweredBevelBorder() );
      */
      Normal_Border = BorderFactory.createEtchedBorder();
    }
    if (Shadow_Border == null) {
      Shadow_Border =
          BorderFactory.createTitledBorder(
              Normal_Border,
              " Preview State ",
              TitledBorder.LEFT,
              TitledBorder.TOP,
              Const.FONT,
              Color.magenta);
    }

    drawable = dobj;

    // Set the CategoryLabel Icon
    Dimension panel_max_size;
    Category type = null;
    CategoryLabel label_type = null;
    JPanel top_panel = new JPanel();
    top_panel.setLayout(new BoxLayout(top_panel, BoxLayout.X_AXIS));
    if (drawable instanceof Shadow && ((Shadow) drawable).getSelectedSubCategory() != null) {
      type = ((Shadow) drawable).getSelectedSubCategory();
      label_type = new CategoryLabel(type);
      ((Shadow) drawable).clearSelectedSubCategory();
      top_panel.setBorder(Shadow_Border);
    } else {
      type = drawable.getCategory();
      label_type = new CategoryLabel(type);
      top_panel.setBorder(Normal_Border);
    }
    top_panel.add(STRUT);
    top_panel.add(label_type);
    top_panel.add(GLUE);
    top_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel_max_size = top_panel.getPreferredSize();
    panel_max_size.width = Short.MAX_VALUE;
    top_panel.setMaximumSize(panel_max_size);
    super.add(top_panel);

    // Determine the text of the drawable
    TextAreaBuffer textbuf;
    int num_cols, num_rows;
    textbuf = new TextAreaBuffer(map_line2treenodes, y_colnames);
    if (drawable instanceof Shadow) textbuf.setShadowText((Shadow) drawable, type);
    else if (drawable instanceof Composite) textbuf.setCompositeText((Composite) drawable);
    else textbuf.setPrimitiveText((Primitive) drawable);
    textbuf.finalized();
    num_cols = textbuf.getColumnCount();
    num_rows = textbuf.getRowCount();

    // Set the TextArea
    JTextArea text_area;
    int adj_num_cols;
    text_area = new JTextArea(textbuf.toString());
    adj_num_cols = Routines.getAdjNumOfTextColumns(text_area, num_cols);
    num_cols = (int) Math.ceil(adj_num_cols * 85.0d / 100.0d);
    text_area.setColumns(num_cols);
    text_area.setRows(num_rows);
    text_area.setEditable(false);
    text_area.setLineWrap(true);
    JScrollPane scroller = new JScrollPane(text_area);
    scroller.setAlignmentX(Component.LEFT_ALIGNMENT);
    super.add(scroller);
  }