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)));
    }
    public MyJObject(int i) {
      CourseCheckBox = new JCheckBox(DataTransfer.Courses.elementAt(i));
      CourseCheckBox.setForeground(Color.WHITE);
      CourseCheckBox.setFont(new Font("SERRIF", Font.BOLD + Font.ITALIC, 13));
      CourseCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
      CourseCheckBox.setOpaque(false);
      CourseCheckBox.setSelected(true);

      TotalMarks =
          new JLabel(
              Float.toString(
                  Float.valueOf(
                      TwoDecimal.format(Float.parseFloat(DataTransfer.Total.elementAt(i))))),
              SwingConstants.CENTER);
      TotalMarks.setForeground(Color.WHITE);
      TotalMarks.setFont(new Font("SERRIF", Font.BOLD + Font.ITALIC, 13));

      GradePoint = new JLabel(DataTransfer.GradePoint.elementAt(i), SwingConstants.LEFT);
      GradePoint.setForeground(Color.WHITE);
      GradePoint.setFont(new Font("SERRIF", Font.ITALIC, 13));

      LetterGrade = new JLabel(DataTransfer.LetterGrade.elementAt(i), SwingConstants.LEFT);
      LetterGrade.setForeground(Color.WHITE);
      LetterGrade.setFont(new Font("SERRIF", Font.PLAIN, 13));

      CreditLabel = new JLabel(Credit.elementAt(i), SwingConstants.LEFT);
      CreditLabel.setForeground(Color.WHITE);
      CreditLabel.setFont(new Font("SERRIF", Font.PLAIN, 13));

      ExamTypeLabel = new JLabel(DataTransfer.ExamType.elementAt(i), SwingConstants.LEFT);
      ExamTypeLabel.setForeground(Color.WHITE);
      ExamTypeLabel.setFont(new Font("SERRIF", Font.PLAIN, 12));
    }
Example #3
0
  @Override
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    textLabel.setFont(table.getFont());
    textLabel.setText(Objects.toString(value, ""));
    textLabel.setBorder(hasFocus ? focusCellHighlightBorder : noFocusBorder);

    FontMetrics fm = table.getFontMetrics(table.getFont());
    Insets i = textLabel.getInsets();
    int swidth =
        iconLabel.getPreferredSize().width + fm.stringWidth(textLabel.getText()) + i.left + i.right;
    int cwidth = table.getColumnModel().getColumn(column).getWidth();
    dim.width = swidth > cwidth ? cwidth : swidth;

    if (isSelected) {
      textLabel.setOpaque(true);
      textLabel.setForeground(table.getSelectionForeground());
      textLabel.setBackground(table.getSelectionBackground());
      iconLabel.setIcon(sicon);
    } else {
      textLabel.setOpaque(false);
      textLabel.setForeground(table.getForeground());
      textLabel.setBackground(table.getBackground());
      iconLabel.setIcon(nicon);
    }
    return panel;
  }
 @Override
 public void paintComponent(Graphics g) {
   if (selected) {
     g.setColor(selColor);
     g.fillRoundRect(0, 0, getWidth(), getHeight(), getWidth() / 10, getHeight() / 10);
     label.setForeground(Color.YELLOW);
   } else label.setForeground(Color.WHITE);
   super.paintComponent(g);
 }
Example #5
0
 /** Formats and displays today's date. */
 public void reformat() {
   Date today = new Date();
   SimpleDateFormat formatter = new SimpleDateFormat(currentPattern);
   try {
     String dateString = formatter.format(today);
     result.setForeground(Color.black);
     result.setText(dateString);
   } catch (IllegalArgumentException iae) {
     result.setForeground(Color.red);
     result.setText("Error: " + iae.getMessage());
   }
 }
    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)));
    }
  /*
   * Gets the user choice for font, style and size and redraws the text
   *     accordingly.
   */
  public void setSampleFont() {
    // Get the font name from the JComboBox
    fontName = (String) facenameCombo.getSelectedItem();

    sampleField.setText(textField.getText());

    // Get the font style from the JCheckBoxes
    fontStyle = 0;
    if (italicCheckBox.isSelected()) fontStyle += Font.ITALIC;
    if (boldCheckBox.isSelected()) fontStyle += Font.BOLD;

    // Get the font size
    fontSize = 0;

    fontSize = Integer.parseInt((String) sizeCombo.getSelectedItem());

    // THE FOLLOWING IS NO LONGER NEEDED
    //            if(smallButton.isSelected())
    //                  fontSize=SMALL;
    //            else if(mediumButton.isSelected())
    //                  fontSize=MEDIUM;
    //            else if(largeButton.isSelected())
    //                  fontSize=LARGE;

    // Set the font of the text field
    sampleField.setFont(new Font(fontName, fontStyle, fontSize));
    sampleField.setForeground(fontColor);
    sampleField.repaint();

    pack();
  } // end setSampleFont method
    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)));
    }
Example #9
0
 private void setStatus() {
   // Update the status display
   status.setText(running ? "Running" : "Stopped");
   status.setForeground(running ? Color.BLACK : Color.RED);
   start.setEnabled(!running);
   stop.setEnabled(running);
   launchBrowser.setEnabled(running);
 }
Example #10
0
  public ComboBoxDemo2() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    String[] patternExamples = {
      "dd MMMMM yyyy",
      "dd.MM.yy",
      "MM/dd/yy",
      "yyyy.MM.dd G 'at' hh:mm:ss z",
      "EEE, MMM d, ''yy",
      "h:mm a",
      "H:mm:ss:SSS",
      "K:mm a,z",
      "yyyy.MMMMM.dd GGG hh:mm aaa"
    };

    currentPattern = patternExamples[0];

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setEditable(true);
    patternList.addActionListener(this);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // == LEFT
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything.
    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternPanel.add(patternList);

    JPanel resultPanel = new JPanel(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(patternPanel);
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
  } // constructor
    public SidebarOption(String labelTxt, String rsc) {
      label = new JLabel(labelTxt);
      label.setForeground(Color.WHITE);
      label.setFont(font);
      add(label);
      setOpaque(false);
      setMaximumSize(new Dimension(1000, label.getPreferredSize().height + 5));

      this.rsc = ClassLoader.getSystemClassLoader().getResource(rsc);
    }
Example #12
0
  /** Implement this method in ListCellRenderer */
  public Component getListCellRendererComponent(
      JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    Object[] pair = (Object[]) value; // Cast value into an array
    jlblCell.setOpaque(true);
    jlblCell.setIcon((ImageIcon) pair[0]);
    jlblCell.setText(pair[1].toString());

    if (isSelected) {
      jlblCell.setForeground(list.getSelectionForeground());
      jlblCell.setBackground(list.getSelectionBackground());
    } else {
      jlblCell.setForeground(list.getForeground());
      jlblCell.setBackground(list.getBackground());
    }

    jlblCell.setBorder(cellHasFocus ? lineBorder : emptyBorder);

    return jlblCell;
  }
Example #13
0
    private void createYearAndMonthPanal() {
      Calendar c = getNowCalendar();
      int currentYear = c.get(Calendar.YEAR);
      int currentMonth = c.get(Calendar.MONTH) + 1;
      int currentHour = c.get(Calendar.HOUR_OF_DAY);
      yearSpin =
          new JSpinner(new javax.swing.SpinnerNumberModel(currentYear, startYear, lastYear, 1));
      monthSpin = new JSpinner(new javax.swing.SpinnerNumberModel(currentMonth, 1, 12, 1));
      hourSpin = new JSpinner(new javax.swing.SpinnerNumberModel(currentHour, 0, 23, 1));

      yearPanel.setLayout(new java.awt.FlowLayout());
      yearPanel.setBackground(controlLineColor);

      yearSpin.setPreferredSize(new Dimension(48, 20));
      yearSpin.setName("Year");
      yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, "####"));
      yearSpin.addChangeListener(this);
      yearPanel.add(yearSpin);

      JLabel yearLabel = new JLabel("年");
      yearLabel.setForeground(controlTextColor);
      yearPanel.add(yearLabel);

      monthSpin.setPreferredSize(new Dimension(35, 20));
      monthSpin.setName("Month");
      monthSpin.addChangeListener(this);
      yearPanel.add(monthSpin);

      JLabel monthLabel = new JLabel("月");
      monthLabel.setForeground(controlTextColor);
      yearPanel.add(monthLabel);

      hourSpin.setPreferredSize(new Dimension(35, 20));
      hourSpin.setName("Hour");
      hourSpin.addChangeListener(this);
      yearPanel.add(hourSpin);

      JLabel hourLabel = new JLabel("日");
      hourLabel.setForeground(controlTextColor);
      yearPanel.add(hourLabel);
    }
  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);
    }
  }
 private void showInstruction(
     GridBagLayout gbl,
     GridBagConstraints gbc,
     int gridx,
     int gridy,
     int gridwidth,
     JLabel instruction) {
   gbc.gridwidth = gridwidth;
   gbc.gridx = gridx;
   gbc.gridy = gridy;
   gbl.setConstraints(instruction, gbc);
   instruction.setForeground(Color.black);
   m_pnlDisplay.add(instruction);
 }
    /**
     * Return a component that has been configured to display the specified value.
     *
     * @param list The JList we're painting.
     * @param value The value returned by list.getModel().getElementAt(index).
     * @param index The cells index.
     * @param isSelected True if the specified cell was selected.
     * @param cellHasFocus True if the specified cell has the focus.
     * @return A component whose paint() method will render the specified value.
     * @todo Implement this javax.swing.ListCellRenderer method
     */
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
      HostItem hi = (HostItem) value;
      JLabel c = new JLabel(hi.name);
      if (isSelected && hi.eavesDroppingEnabled) {
        c.setBackground(Color.magenta);
        c.setForeground(list.getSelectionForeground());
      } else if (!isSelected && hi.eavesDroppingEnabled) {
        c.setBackground(Color.red);
        c.setForeground(list.getForeground());
      } else if (isSelected) {
        c.setBackground(list.getSelectionBackground());
        c.setForeground(list.getSelectionForeground());
      } else {
        c.setBackground(list.getBackground());
        c.setForeground(list.getForeground());
      }

      c.setEnabled(list.isEnabled());
      c.setFont(list.getFont());
      c.setOpaque(true);

      return c;
    }
    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)));
    }
Example #18
0
  private void insertParameter(ConfigParamDescr descr, String format, int pos) {
    try {
      StyledDocument doc = (StyledDocument) editorPane.getDocument();

      // The component must first be wrapped in a style
      Style style = doc.addStyle("Parameter-" + numParameters, null);
      JLabel label = new JLabel(descr.getDisplayName());
      label.setAlignmentY(0.8f); // make sure we line up
      label.setFont(new Font("Helvetica", Font.PLAIN, 14));
      label.setForeground(Color.BLUE);
      label.setName(descr.getKey());
      label.setToolTipText("key: " + descr.getKey() + "    format: " + format);
      StyleConstants.setComponent(style, label);
      doc.insertString(pos, format, style);
      numParameters++;
    } catch (BadLocationException e) {
    }
  }
Example #19
0
      /**
       * Draw one die including the letter centered in the middle of the die. If highlight is true,
       * we reverse the background and letter colors to highlight the die.
       */
      public void paintComponent(Graphics g) {
        super.paintComponent(g);

        int centeredXOffset, centeredYOffset;
        // Draw the blank die
        g.setColor((isHighlighted) ? FACECOLOR : DIECOLOR);
        g.fillRoundRect(0, 0, DIESIZE, DIESIZE, DIESIZE / 2, DIESIZE / 2);

        // Outline the die with black
        g.setColor(Color.black);
        g.drawRoundRect(0, 0, DIESIZE, DIESIZE, DIESIZE / 2, DIESIZE / 2);
        Graphics faceGraphics = faceLabel.getGraphics();
        faceGraphics.setColor(isHighlighted ? DIECOLOR : FACECOLOR);
        Color myColor = isHighlighted ? DIECOLOR : FACECOLOR;
        faceLabel.setForeground(myColor);
        faceLabel.setFont(FACEFONT);
        faceLabel.setText(face);
      }
Example #20
0
  // event handling
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnok) {
      PreparedStatement pstm;
      ResultSet rs;
      String sql;
      // if no entries has been made and hit ok button throw an error
      // you can do this step using try clause as well
      if ((tf1.getText().equals("") && (tf2.getText().equals("")))) {
        lblmsg.setText("Enter your details ");
        lblmsg.setForeground(Color.magenta);
      } else {

        try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          Connection connect = DriverManager.getConnection("jdbc:odbc:student_base");
          System.out.println("Connected to the database");
          pstm = connect.prepareStatement("insert into student_base values(?,?)");
          pstm.setString(1, tf1.getText());
          pstm.setString(2, tf2.getText());
          // execute method to execute the query
          pstm.executeUpdate();
          lblmsg.setText("Details have been added to database");

          // closing the prepared statement  and connection object
          pstm.close();
          connect.close();
        } catch (SQLException sqe) {
          System.out.println("SQl error");
        } catch (ClassNotFoundException cnf) {
          System.out.println("Class not found error");
        }
      }
    }
    // upon clickin button addnew , your textfield will be empty to enternext record
    if (e.getSource() == btnaddnew) {
      tf1.setText("");
      tf2.setText("");
    }

    if (e.getSource() == btnexit) {
      System.exit(1);
    }
  }
Example #21
0
  @Override
  public Component getTreeCellRendererComponent(
      JTree tree,
      Object value,
      boolean selected,
      boolean expanded,
      boolean leaf,
      int row,
      boolean hasFocus) {
    JLabel l =
        (JLabel)
            super.getTreeCellRendererComponent(
                tree, value, selected, expanded, leaf, row, hasFocus);
    Color bColor;
    Color fColor;
    if (selected) {
      bColor = getBackgroundSelectionColor();
      fColor = getTextSelectionColor();
    } else {
      bColor = getBackgroundNonSelectionColor();
      fColor = getTextNonSelectionColor();
      if (bColor == null) {
        bColor = getBackground();
      }
      if (fColor == null) {
        fColor = getForeground();
      }
    }
    text.setForeground(fColor);
    text.setBackground(bColor);
    text.setBorder(hasFocus ? hasFocusBorder : emptyBorder);
    text.setText(l.getText());
    icon.setIcon(l.getIcon());

    return p;
  }
  /** 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
  /** This method is called from within the constructor to initialize the form. */
  public void initComponents() {

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

    proxyStackNameLabel = new JLabel("Proxy stack name:");
    proxyStackNameLabel.setToolTipText("The name of the stack to set");
    // Alignment of the text
    proxyStackNameLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    proxyStackNameLabel.setForeground(Color.black);
    // Size of the text
    proxyStackNameLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    proxyStackNameLabel.setOpaque(true);
    proxyStackNameLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    proxyStackNameLabel.setBorder(ProxyLauncher.labelBorder);
    proxyStackNameTextField = new JTextField(20);
    proxyStackNameTextField.setHorizontalAlignment(AbstractButton.CENTER);
    proxyStackNameTextField.setFont(new Font("Dialog", 0, 14));
    proxyStackNameTextField.setBackground(ProxyLauncher.textBackGroundColor);
    proxyStackNameTextField.setForeground(Color.black);
    proxyStackNameTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(proxyStackNameLabel);
    firstPanel.add(proxyStackNameTextField);

    proxyIPAddressLabel = new JLabel("Proxy IP address:");
    proxyIPAddressLabel.setToolTipText("The address of the proxy to set");
    // Alignment of the text
    proxyIPAddressLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    proxyIPAddressLabel.setForeground(Color.black);
    // Size of the text
    proxyIPAddressLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    proxyIPAddressLabel.setOpaque(true);
    proxyIPAddressLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    proxyIPAddressLabel.setBorder(ProxyLauncher.labelBorder);
    proxyIPAddressTextField = new JTextField(20);
    proxyIPAddressTextField.setHorizontalAlignment(AbstractButton.CENTER);
    proxyIPAddressTextField.setFont(new Font("Dialog", 0, 14));
    proxyIPAddressTextField.setBackground(ProxyLauncher.textBackGroundColor);
    proxyIPAddressTextField.setForeground(Color.black);
    proxyIPAddressTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(proxyIPAddressLabel);
    firstPanel.add(proxyIPAddressTextField);

    outboundProxyLabel = new JLabel("Next hop (IP:port/protocol):");
    outboundProxyLabel.setToolTipText(
        "Location where the message will be sent "
            + "if all the resolutions (DNS, router,...) fail. If not set: 404 will be replied");
    // Alignment of the text
    outboundProxyLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    outboundProxyLabel.setForeground(Color.black);
    // Size of the text
    outboundProxyLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    outboundProxyLabel.setOpaque(true);
    outboundProxyLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    outboundProxyLabel.setBorder(ProxyLauncher.labelBorder);
    outboundProxyTextField = new JTextField(20);
    outboundProxyTextField.setHorizontalAlignment(AbstractButton.CENTER);
    outboundProxyTextField.setFont(new Font("Dialog", 0, 14));
    outboundProxyTextField.setBackground(ProxyLauncher.textBackGroundColor);
    outboundProxyTextField.setForeground(Color.black);
    outboundProxyTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(outboundProxyLabel);
    firstPanel.add(outboundProxyTextField);

    routerClassLabel = new JLabel("The Router class name:");
    routerClassLabel.setToolTipText(
        "The class name (full java package name) of the router" + " used to forward the messages");
    // Alignment of the text
    routerClassLabel.setHorizontalAlignment(AbstractButton.CENTER);
    // Color of the text
    routerClassLabel.setForeground(Color.black);
    // Size of the text
    routerClassLabel.setFont(new Font("Dialog", 1, 12));
    // If put to true: we see the label's background
    routerClassLabel.setOpaque(true);
    routerClassLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    routerClassLabel.setBorder(ProxyLauncher.labelBorder);
    routerClassTextField = new JTextField(20);
    routerClassTextField.setHorizontalAlignment(AbstractButton.CENTER);
    routerClassTextField.setFont(new Font("Dialog", 0, 12));
    routerClassTextField.setBackground(ProxyLauncher.textBackGroundColor);
    routerClassTextField.setForeground(Color.black);
    routerClassTextField.setBorder(BorderFactory.createLoweredBevelBorder());
    firstPanel.add(routerClassLabel);
    firstPanel.add(routerClassTextField);

    JPanel panel = new JPanel();
    // top, left, bottom, right
    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 2));
    // If put to False: we see the container's background
    panel.setOpaque(false);
    // rows, columns, horizontalGap, verticalGap
    panel.setLayout(new BorderLayout());
    this.add(panel);

    JLabel lpLabel = new JLabel("Listening points list:");
    lpLabel.setVisible(true);
    lpLabel.setToolTipText("The listening points of the proxy");
    lpLabel.setHorizontalAlignment(AbstractButton.CENTER);
    lpLabel.setForeground(Color.black);
    lpLabel.setFont(new Font("Dialog", 1, 12));
    lpLabel.setOpaque(true);
    lpLabel.setBackground(ProxyLauncher.labelBackGroundColor);
    lpLabel.setBorder(ProxyLauncher.labelBorder);
    panel.add(lpLabel, BorderLayout.NORTH);

    // this.add(listeningPointsList);
    JScrollPane scrollPane =
        new JScrollPane(
            listeningPointsList,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    panel.add(scrollPane, BorderLayout.CENTER);

    thirdPanel = new JPanel();
    thirdPanel.setOpaque(false);
    // top, left, bottom, right
    thirdPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 5, 0));
    thirdPanel.setLayout(new GridLayout(1, 2, 3, 3));

    JButton addLPButton = new JButton(" Add ");
    addLPButton.setToolTipText("Add a listening point");
    addLPButton.setFocusPainted(false);
    addLPButton.setFont(new Font("Dialog", 1, 16));
    addLPButton.setBackground(ProxyLauncher.buttonBackGroundColor);
    addLPButton.setBorder(ProxyLauncher.buttonBorder);
    addLPButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            addLPButtonActionPerformed(evt);
          }
        });
    thirdPanel.add(addLPButton);

    JButton removeLPButton = new JButton(" Remove ");
    removeLPButton.setToolTipText("Remove a listening point");
    removeLPButton.setFocusPainted(false);
    removeLPButton.setFont(new Font("Dialog", 1, 16));
    removeLPButton.setBackground(ProxyLauncher.buttonBackGroundColor);
    removeLPButton.setBorder(ProxyLauncher.buttonBorder);
    removeLPButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            removeLPButtonActionPerformed(evt);
          }
        });
    thirdPanel.add(removeLPButton);

    panel.add(thirdPanel, BorderLayout.SOUTH);
  }
 /** Set the status text to an error */
 public void setErrorStatus(String txt) {
   status_text.setForeground(Color.red);
   status_text.setText("  " + txt);
 }
  /** This method is called from within the constructor to initialize the form. */
  public void initComponents() {
    /** *************** The main frame ************************************** */
    // width, height
    this.setSize(560, 370);
    Container container = this.getContentPane();
    container.setLayout(new BoxLayout(getContentPane(), 1));
    container.setBackground(containerBackGroundColor);
    this.setLocation(0, 0);
    this.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            new AlertInstantMessaging(
                "Your changes will not be checked: use the Submit button!!!",
                JOptionPane.WARNING_MESSAGE);
            hideFrame();
          }
        });

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

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

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

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

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

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

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

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

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

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

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

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

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

    submitButton = new JButton(" Submit ");
    submitButton.setToolTipText("Submit your changes!");
    submitButton.setFocusPainted(false);
    submitButton.setFont(new Font("Dialog", 1, 16));
    submitButton.setBackground(buttonBackGroundColor);
    submitButton.setBorder(buttonBorder);
    submitButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            submitButtonActionPerformed(evt);
          }
        });
    thirdPanel.add(submitButton);
    container.add(thirdPanel);
  }
Example #26
0
    private void flushWeekAndDayPanal(Calendar c) {
      //            c.set
      c.set(Calendar.DAY_OF_MONTH, 1);
      c.setFirstDayOfWeek(0);
      int firstdayofWeek = c.get(Calendar.DAY_OF_WEEK);
      int lastdayofWeek = c.getActualMaximum(Calendar.DAY_OF_MONTH);
      String colname[] = {"日", "一", "二", "三", "四", "五", "六"};
      int today = getNowCalendar().get(Calendar.DAY_OF_MONTH);
      // 璁剧疆鍥哄畾瀛椾綋锛屼互鍏嶈皟鐢ㄧ幆澧冩敼鍙樺奖鍝嶇晫闈㈢編瑙�
      dayPanel.setFont(new java.awt.Font("寰蒋闆呴粦", java.awt.Font.PLAIN, 12));
      dayPanel.setLayout(new GridBagLayout());
      dayPanel.setBackground(palletTableColor);

      JLabel cell;

      for (int i = 0; i < 7; i++) {
        cell = new JLabel(colname[i]);
        cell.setHorizontalAlignment(JLabel.CENTER);
        cell.setPreferredSize(new Dimension(25, 25));
        if (i == 0 || i == 6) {
          cell.setForeground(weekendFontColor);
        } else {
          cell.setForeground(weekFontColor);
        }
        dayPanel.add(
            cell,
            new GridBagConstraints(
                i,
                0,
                1,
                1,
                0.0,
                0.0,
                GridBagConstraints.CENTER,
                GridBagConstraints.NONE,
                new Insets(0, 0, 0, 0),
                0,
                0));
      }

      int actionCommandId = 1;
      for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 7; j++) {

          JButton numberButton = daysButton[i][j];
          actionCommandId = Integer.parseInt(numberButton.getActionCommand());
          if (actionCommandId == today) {
            numberButton.setBackground(todayBtnColor);
          }
          if ((actionCommandId + firstdayofWeek - 2) % 7 == 6
              || (actionCommandId + firstdayofWeek - 2) % 7 == 0) {
            numberButton.setForeground(weekendFontColor);
          } else {
            numberButton.setForeground(dateFontColor);
          }
          if (actionCommandId <= lastdayofWeek) {
            int y = 0;
            if ((firstdayofWeek - 1) <= (j + firstdayofWeek - 1) % 7) {
              y = i + 1;
            } else {
              y = i + 2;
            }
            dayPanel.add(
                numberButton,
                new GridBagConstraints(
                    (j + firstdayofWeek - 1) % 7,
                    y,
                    1,
                    1,
                    0.0,
                    0.0,
                    GridBagConstraints.CENTER,
                    GridBagConstraints.NONE,
                    new Insets(0, 0, 0, 0),
                    0,
                    0));
          }
        }
      }
    }
Example #27
0
  private void makeFrame(String[] audioFiles) {
    // the following makes sure that our application exits when
    // the user closes its window
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JPanel contentPane = (JPanel) getContentPane();
    contentPane.setBorder(new EmptyBorder(6, 10, 10, 10));

    // Specify the layout manager with nice spacing
    contentPane.setLayout(new BorderLayout(8, 8));

    // Create the left side with combobox and scroll list
    JPanel leftPane = new JPanel();
    {
      leftPane.setLayout(new BorderLayout(8, 8));

      fileList = new JList(audioFiles);
      fileList.setForeground(new Color(140, 171, 226));
      fileList.setBackground(new Color(0, 0, 0));
      fileList.setSelectionBackground(new Color(87, 49, 134));
      fileList.setSelectionForeground(new Color(140, 171, 226));
      JScrollPane scrollPane = new JScrollPane(fileList);
      scrollPane.setColumnHeaderView(new JLabel("Audio files"));
      leftPane.add(scrollPane, BorderLayout.CENTER);
    }
    contentPane.add(leftPane, BorderLayout.CENTER);

    // Create the center with image, text label, and slider
    JPanel centerPane = new JPanel();
    {
      centerPane.setLayout(new BorderLayout(8, 8));

      infoLabel = new JLabel("  ");
      infoLabel.setHorizontalAlignment(SwingConstants.CENTER);
      infoLabel.setForeground(new Color(140, 171, 226));
      centerPane.add(infoLabel, BorderLayout.CENTER);
    }
    contentPane.add(centerPane, BorderLayout.EAST);

    // Create the toolbar with the buttons
    JPanel toolbar = new JPanel();
    {
      toolbar.setLayout(new GridLayout(1, 0));

      JButton button = new JButton("Play");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              play();
            }
          });
      toolbar.add(button);

      button = new JButton("Stop");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              stop();
            }
          });
      toolbar.add(button);

      button = new JButton("Pause");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              pause();
            }
          });
      toolbar.add(button);

      button = new JButton("Resume");
      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              resume();
            }
          });
      toolbar.add(button);
    }

    contentPane.add(toolbar, BorderLayout.NORTH);

    // building is done - arrange the components
    pack();

    // place this frame at the center of the screen and show
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    setLocation(d.width / 2 - getWidth() / 2, d.height / 2 - getHeight() / 2);
    setVisible(true);
  }
Example #28
0
  public JavaPanel() {
    super();
    setLayout(new BorderLayout());
    config = Configuration.getInstance();
    Properties props = config.props;
    running = false;
    Util.isRunning();

    JPanel main = new JPanel();
    main.setLayout(new BorderLayout());
    main.setBackground(bgColor);

    // North Panel
    JPanel np = new JPanel();
    np.setBackground(bgColor);
    JLabel title = new JLabel(config.programName);
    title.setFont(new Font("SansSerif", Font.BOLD, 24));
    title.setForeground(Color.BLUE);
    np.add(title);
    np.setBorder(BorderFactory.createEmptyBorder(10, 0, 20, 0));
    main.add(np, BorderLayout.NORTH);

    // Center Panel
    RowPanel javaPanel = new RowPanel("Java Parameters");
    javaPanel.setBackground(bgColor);
    javaPanel.addRow(initMemory = new Row("Initial memory pool:", props.getProperty("ms", "")));
    javaPanel.addRow(maxMemory = new Row("Maximum memory pool:", props.getProperty("mx", "")));
    javaPanel.addRow(stackSize = new Row("Thread stack size:", props.getProperty("ss", "")));
    javaPanel.addRow(extDirs = new Row("Extensions directory:", props.getProperty("ext", "")));
    javaPanel.addRow(
        debugSSL = new CBRow("Enable SSL debugging:", props.getProperty("ssl", "").equals("yes")));
    javaPanel.addRow(
        javaMonitor =
            new CBRow("Enable Java monitoring:", props.getProperty("mon", "").equals("yes")));

    RowPanel serverPanel = new RowPanel("Server Parameters");
    serverPanel.setBackground(bgColor);
    serverPanel.addRow(serverPort = new Row("Server port:", Integer.toString(config.port)));
    serverPanel.addRow(
        clearLogs = new CBRow("Clear logs on start:", props.getProperty("clr", "").equals("yes")));

    JPanel cp = new JPanel();
    cp.setLayout(new RowLayout());
    cp.setBackground(bgColor);

    cp.add(serverPanel);
    cp.add(RowLayout.crlf());
    cp.add(Box.createVerticalStrut(20));
    cp.add(RowLayout.crlf());
    cp.add(javaPanel);
    cp.add(RowLayout.crlf());

    JPanel ccp = new JPanel(new FlowLayout());
    ccp.setBackground(bgColor);
    ccp.add(cp);
    main.add(ccp, BorderLayout.CENTER);

    // South Panel
    JPanel sp = new JPanel();
    sp.setBorder(BorderFactory.createEmptyBorder(10, 0, 20, 0));
    sp.setBackground(bgColor);

    start = new JButton("Start");
    sp.add(start);
    start.addActionListener(this);
    sp.add(Box.createHorizontalStrut(15));

    stop = new JButton("Stop");
    sp.add(stop);
    stop.addActionListener(this);
    sp.add(Box.createHorizontalStrut(70));

    launchBrowser = new JButton(config.browserButtonName + " Home Page");
    sp.add(launchBrowser);
    launchBrowser.addActionListener(this);

    main.add(sp, BorderLayout.SOUTH);

    this.add(main, BorderLayout.CENTER);
    this.add(new StatusPanel(status), BorderLayout.SOUTH);

    running = Util.isRunning();
    setStatus();
  }
Example #29
0
  /** Instantiates a new game panel. */
  public GamePanel() {
    super();
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    CARD_BACK.add(new CardPanel("img/cards/BACK.png"));

    // The code below is just for reference
    //        dealerCards = new ArrayList<>();
    //        for (int i = 0; i < dealerInHand.size(); i++)
    //        {
    //            dealerCards.add(new CardPanel("img/cards/" + dealerInHand.get(i) + ".png"));
    //        }
    //
    //        playerCardsOne = new ArrayList<>();
    //        for (int i = 0; i < playerInHandOne.size(); i++)
    //        {
    //            playerCardsOne.add(new CardPanel("img/cards/" + playerInHandOne.get(i) + ".png"));
    //        }
    //
    //        playerCardsTwo = new ArrayList<>();
    //        for (int i = 0; i < playerInHandTwo.size(); i++)
    //        {
    //            playerCardsTwo.add(new CardPanel("img/cards/" + playerInHandTwo.get(i) + ".png"));
    //        }
    // The code above is just for reference

    dealerDeckContainer = new CardDeckContainer();
    dealerStatContainer = new JPanel(new BorderLayout());
    dealerStatContainer.setOpaque(false);
    JLabel dealerStatTitle = new JLabel("Dealer in Hand");
    dealerStatTitle.setForeground(Color.WHITE);
    dealerStatTitle.setHorizontalAlignment(JLabel.CENTER);
    dealerStatTitle.setFont(new Font("", Font.PLAIN, 12));
    dealerStatPoint.setForeground(Color.WHITE);
    dealerStatPoint.setHorizontalAlignment(JLabel.CENTER);
    dealerStatPoint.setFont(new Font("", Font.PLAIN, 12));
    dealerStatContainer.add(dealerStatTitle, BorderLayout.NORTH);
    dealerStatContainer.add(dealerStatPoint, BorderLayout.CENTER);

    playerDeckOneContainer = new CardDeckContainer();
    playerStatOneContainer = new JPanel(new BorderLayout());
    playerStatOneContainer.setOpaque(false);
    JLabel playerStatOneTitle = new JLabel("Player in Hand");
    playerStatOneTitle.setForeground(Color.WHITE);
    playerStatOneTitle.setHorizontalAlignment(JLabel.CENTER);
    playerStatOneTitle.setFont(new Font("", Font.PLAIN, 12));
    playerStatOnePoint.setForeground(Color.WHITE);
    playerStatOnePoint.setHorizontalAlignment(JLabel.CENTER);
    playerStatOnePoint.setFont(new Font("", Font.PLAIN, 12));
    playerStatOneDescription.setForeground(Color.WHITE);
    playerStatOneDescription.setHorizontalAlignment(JLabel.CENTER);
    playerStatOneDescription.setFont(new Font("", Font.BOLD, 12));
    playerStatOneContainer.add(playerStatOneTitle, BorderLayout.NORTH);
    playerStatOneContainer.add(playerStatOnePoint, BorderLayout.CENTER);
    playerStatOneContainer.add(playerStatOneDescription, BorderLayout.SOUTH);

    playerDeckTwoContainer = new CardDeckContainer(new CardDeckPanel(CARD_BACK));
    playerStatTwoContainer = new JPanel(new BorderLayout());
    playerStatTwoContainer.setOpaque(false);
    JLabel playerStatTwoTitle = new JLabel("Player Hand 2");
    playerStatTwoTitle.setForeground(Color.WHITE);
    playerStatTwoTitle.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoTitle.setFont(new Font("", Font.PLAIN, 12));
    playerStatTwoPoint.setForeground(Color.WHITE);
    playerStatTwoPoint.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoPoint.setFont(new Font("", Font.PLAIN, 12));
    playerStatTwoDescription.setForeground(Color.WHITE);
    playerStatTwoDescription.setHorizontalAlignment(JLabel.CENTER);
    playerStatTwoDescription.setFont(new Font("", Font.BOLD, 12));
    playerStatTwoContainer.add(playerStatTwoTitle, BorderLayout.NORTH);
    playerStatTwoContainer.add(playerStatTwoPoint, BorderLayout.CENTER);
    playerStatTwoContainer.add(playerStatTwoDescription, BorderLayout.SOUTH);

    gameStatPanel = new JPanel();
    gameStatPanelPlayerName = new JLabel();
    gameStatPanelCurrentChips = new JLabel();
    gameStatPanelCurrentBet = new JLabel();
    gameStatPanelPlayerName.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelPlayerName.setForeground(Color.WHITE);
    gameStatPanelPlayerName.setBorder(new EmptyBorder(0, 0, 0, 5));
    gameStatPanelCurrentChips.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelCurrentChips.setForeground(Color.WHITE);
    gameStatPanelCurrentChips.setBorder(new EmptyBorder(0, 5, 0, 5));
    gameStatPanelCurrentBet.setFont(new Font("", Font.PLAIN, 14));
    gameStatPanelCurrentBet.setForeground(Color.WHITE);
    gameStatPanelCurrentBet.setBorder(new EmptyBorder(0, 5, 0, 0));
    gameStatPanel.add(gameStatPanelPlayerName);
    gameStatPanel.add(gameStatPanelCurrentChips);
    gameStatPanel.add(gameStatPanelCurrentBet);
    gameStatPanel.setOpaque(false);

    gameButtonPanel = new JPanel(cardLayout);
    betButtonPanel = new JPanel();
    playButtonPanel = new JPanel();
    JLabel pleaseBet = new JLabel("Please bet: ");
    pleaseBet.setFont(new Font("", Font.PLAIN, 14));
    pleaseBet.setForeground(Color.WHITE);
    betButtonPanel.add(pleaseBet);
    betField = new JTextField();
    betField.setFont(new Font("", Font.PLAIN, 14));
    betField.setPreferredSize(new Dimension(80, 28));
    betButtonPanel.add(betField);
    JButton betButton = new JButton("Bet");
    JButton backButton = new JButton("Back");
    betButtonPanel.add(betButton);
    betButtonPanel.add(backButton);
    betButtonPanel.setOpaque(false);

    hitButton = new JButton("Hit");
    standButton = new JButton("Stand");
    doubleButton = new JButton("Double");
    // JButton splitButton = new JButton("Split");
    // splitButton.setEnabled(false);
    playButtonPanel.add(hitButton);
    playButtonPanel.add(standButton);
    playButtonPanel.add(doubleButton);
    // playButtonPanel.add(splitButton);
    playButtonPanel.setOpaque(false);
    gameButtonPanel.add("betbutton", betButtonPanel);
    gameButtonPanel.add("playbutton", playButtonPanel);
    gameButtonPanel.setOpaque(false);

    add(gameStatPanel);
    add(dealerDeckContainer);
    add(playerDeckTwoContainer);
    add(playerDeckOneContainer);
    add(gameButtonPanel);

    this.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentShown(ComponentEvent e) {
            Game.initGame();
          }
        });

    betButtonPanel.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentShown(ComponentEvent e) {
            betField.setText("");
            if (BlackJack.player.getChip() <= 0) {
              JOptionPane.showMessageDialog(
                  null, "You are penniless!", "Information", JOptionPane.INFORMATION_MESSAGE);
              User.deleteUserByName(BlackJack.player.getName());
              BlackJack.player = new Player(true);
              BlackJack.dealer = new Player(false);
              BlackjackFrame.cardLayout.show(getParent(), "welcome");
            }
            hitButton.setEnabled(true);
            standButton.setEnabled(true);
            doubleButton.setEnabled(true);
            BlackJack.player.setBet(0);
            BlackJack.player.getHandOne().clear();
            BlackJack.player.getHandTwo().clear();
            BlackJack.dealer.getHandOne().clear();
            GamePanel.gameStatPanelPlayerName.setText("Player: " + BlackJack.player.getName());
            GamePanel.gameStatPanelCurrentChips.setText("Chips: " + BlackJack.player.getChip());
            GamePanel.gameStatPanelCurrentBet.setText("Bet: 0");
            GamePanel.gameStatPanel.repaint();
          }
        });

    betField.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyTyped(KeyEvent e) {
            int keyChar = e.getKeyChar();
            if (keyChar < KeyEvent.VK_0 || keyChar > KeyEvent.VK_9) {
              e.consume();
            }
          }
        });

    betButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Game.bet(Integer.parseInt(betField.getText()));
          }
        });

    backButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int choice =
                JOptionPane.showConfirmDialog(
                    null,
                    "Do you want to go back to main menu?\nYour record will be saved.",
                    "Go Back",
                    JOptionPane.YES_NO_OPTION);
            if (choice == JOptionPane.YES_OPTION) {
              User.updateUser();
              BlackJack.player = new Player(true);
              BlackJack.dealer = new Player(false);
              BlackjackFrame.cardLayout.show(getParent(), "welcome");
            }
          }
        });

    hitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            doubleButton.setEnabled(false);
            Game.hit();
          }
        });

    standButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            hitButton.setEnabled(false);
            standButton.setEnabled(false);
            doubleButton.setEnabled(false);
            playerStatOneDescription.setText("Stand");
            playerStatOneDescription.repaint();
            Game.dealerGame();
          }
        });

    doubleButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            hitButton.setEnabled(false);
            standButton.setEnabled(false);
            doubleButton.setEnabled(false);
            if (!Game.doubleDown()) {
              hitButton.setEnabled(true);
              standButton.setEnabled(true);
              doubleButton.setEnabled(false);
            }
          }
        });
  }
  public void createDialogBox(String Roll, String ExamYear) {
    RPS = new JDialog();

    this.NumberOfCourses = DataTransfer.Courses.size();
    this.Roll = Roll;
    this.ExamYear = ExamYear;
    this.Session = setSession();
    final int Final = NumberOfCourses;
    final int Height = (Final * 40 + 270 > 600) ? Final * 40 + 270 : 600;

    Panel =
        new JPanel() {
          protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(
                new ImageIcon(getClass().getResource("/Icons/8.jpg")).getImage(),
                0,
                0,
                950,
                Height,
                null);
            ButtonBorder.paintBorder(this, g, 284, 84 + Final * 40 + 60 + 60, 252, 32);
          }
        };

    Panel.setPreferredSize(
        new Dimension(
            600,
            NumberOfCourses * 40
                + 150
                + 60
                + 60)); // 50+(100*5+3*5)+50, 120+NumberOfCourses*30+(NumberOfCourses-1)*10+50+60
    Panel.setLayout(null);

    RollLabel = new JLabel("Roll  :  " + this.Roll, SwingConstants.CENTER);
    RollLabel.setForeground(Color.WHITE);
    RollLabel.setFont(new Font("SERRIF", Font.BOLD, 15));
    RollLabel.setBounds(112, 20, 615, 20);
    Panel.add(RollLabel);

    SessionLabel = new JLabel("Session  :  " + this.Session, SwingConstants.CENTER);
    SessionLabel.setForeground(Color.WHITE);
    SessionLabel.setFont(new Font("SERRIF", Font.BOLD, 15));
    SessionLabel.setBounds(112, 40, 615, 20);
    Panel.add(SessionLabel);

    ColumnName = new JLabel("", SwingConstants.LEFT);
    ColumnName.setText(
        "     COURSE NO.        TOTAL MARKS      GRADE POINT      LETTER GRADE        COURSE CREDIT                 EXAM-TYPE");
    ColumnName.setForeground(Color.WHITE);
    ColumnName.setFont(new Font("SERRIF", Font.BOLD, 10));
    ColumnName.setBounds(112, 80, 635, 30);
    Panel.add(ColumnName);

    TakenLabel1 = new JLabel("Credit Hour Taken  :  ", SwingConstants.RIGHT);
    TakenLabel1.setForeground(Color.WHITE);
    TakenLabel1.setFont(new Font("SERRIF", Font.ITALIC, 12));
    TakenLabel1.setBounds(112, 85 + NumberOfCourses * 40 + 60, 130, 20);
    Panel.add(TakenLabel1);

    TakenLabel2 = new JLabel("", SwingConstants.LEFT);
    TakenLabel2.setForeground(Color.WHITE);
    TakenLabel2.setFont(new Font("SERRIF", Font.ITALIC, 12));
    TakenLabel2.setBounds(242, 85 + NumberOfCourses * 40 + 60, 50, 20);
    Panel.add(TakenLabel2);

    CompletedLabel1 = new JLabel("Credit Hour Completed  :  ", SwingConstants.RIGHT);
    CompletedLabel1.setForeground(Color.WHITE);
    CompletedLabel1.setFont(
        new Font("SERRIF", Font.ITALIC, 12)); // 50,85+NumberOfCourses*40+60+20,150,20
    CompletedLabel1.setBounds(342, 85 + NumberOfCourses * 40 + 60, 150, 20);
    Panel.add(CompletedLabel1);

    CompletedLabel2 = new JLabel("opps", SwingConstants.LEFT);
    CompletedLabel2.setForeground(Color.WHITE);
    CompletedLabel2.setFont(new Font("SERRIF", Font.ITALIC, 12));
    CompletedLabel2.setBounds(492, 85 + NumberOfCourses * 40 + 60, 50, 20);
    Panel.add(CompletedLabel2);

    GPALabel1 = new JLabel("GPA  :  ", SwingConstants.RIGHT);
    GPALabel1.setForeground(Color.WHITE);
    GPALabel1.setFont(new Font("SERRIF", Font.ITALIC, 12));
    GPALabel1.setBounds(552, 85 + NumberOfCourses * 40 + 60, 80, 20);
    Panel.add(GPALabel1);

    GPALabel2 = new JLabel("36.25", SwingConstants.LEFT);
    GPALabel2.setForeground(Color.WHITE);
    GPALabel2.setFont(new Font("SERRIF", Font.ITALIC, 12));
    GPALabel2.setBounds(632, 85 + NumberOfCourses * 40 + 60, 50, 20);
    Panel.add(GPALabel2);

    DocButton = new JButton("Create Document");
    DocButton.setFont(new Font("SERRIF", Font.BOLD, 15));
    DocButton.setBounds(
        285,
        85 + NumberOfCourses * 40 + 60 + 60,
        250,
        30); // 50+NumberOfCourses*30+(NumberOfCourses-1)*10+35
    DocButton.addActionListener(this);
    Panel.add(DocButton);

    CheckAll = new JCheckBox("Uncheck all");
    CheckAll.setForeground(Color.WHITE);
    CheckAll.setFont(new Font("SERRIF", Font.BOLD + Font.ITALIC, 12));
    CheckAll.setOpaque(false);
    CheckAll.setSelected(true);
    CheckAll.addActionListener(this);

    setComponentsOnTheGrid();

    Scroll =
        new JScrollPane(
            Panel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    RPS.add(Scroll);

    RPS.setModal(true);
    RPS.setTitle(" Result : Particular Student ");
    RPS.setResizable(false);
    RPS.setSize(840, 565);
    RPS.setLocation(
        250, 100 + (565 - RPS.getHeight()) / 2); // setiing RPS dialogbox in the middle of MenuFrame
    RPS.setVisible(true);
  }