Beispiel #1
0
  private void listPeople() {

    try {

      jScrollPane1.getViewport().setView(null);

      JFlowPanel jPeople = new JFlowPanel();
      jPeople.applyComponentOrientation(getComponentOrientation());

      java.util.List people = m_dlSystem.listPeopleVisible();

      for (int i = 0; i < people.size(); i++) {

        AppUser user = (AppUser) people.get(i);

        JButton btn = new JButton(new AppUserAction(user));
        btn.applyComponentOrientation(getComponentOrientation());
        btn.setFocusPainted(false);
        btn.setFocusable(false);
        btn.setRequestFocusEnabled(false);
        btn.setHorizontalAlignment(SwingConstants.LEADING);
        btn.setMaximumSize(new Dimension(150, 50));
        btn.setPreferredSize(new Dimension(150, 50));
        btn.setMinimumSize(new Dimension(150, 50));

        jPeople.add(btn);
      }
      jScrollPane1.getViewport().setView(jPeople);

    } catch (BasicException ee) {
      ee.printStackTrace();
    }
  }
 private void initButton(JButton button) {
   button.setText("");
   button.setBorder(RAISED_BORDER);
   button.setBorderPainted(false);
   button.setFocusPainted(false);
   button.setHorizontalAlignment(SwingConstants.CENTER);
   button.setVerticalAlignment(SwingConstants.CENTER);
 }
  public void initComponents() {
    /** ******************** The main container *************************** */
    Container container = this.getContentPane();
    container.setLayout(new BorderLayout());
    container.setBackground(Color.black);
    this.setSize(650, 600);
    this.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {}
        });

    /** ************************* MAIN PANEL ******************************* */
    mainPanel = new JPanel();
    // If put to False: we see the container's background
    mainPanel.setOpaque(false);
    mainPanel.setLayout(new BorderLayout());
    container.add(mainPanel, BorderLayout.CENTER);

    allmessagesTextArea = new TextArea();
    allmessagesTextArea.setEditable(false);
    allmessagesTextArea.setFont(new Font("Dialog", 1, 12));
    allmessagesTextArea.setForeground(Color.black);
    allmessagesTextArea.append("Select a session in the list to view its messages");
    mainPanel.add(allmessagesTextArea, BorderLayout.CENTER);

    sessionsList = new List();
    sessionsList.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            showMessages(e);
          }
        });
    sessionsList.setForeground(Color.black);
    sessionsList.setFont(new Font("Dialog", 1, 14));
    mainPanel.add(sessionsList, BorderLayout.WEST);

    okButton = new JButton("  OK  ");
    okButton.setToolTipText("Returns to the main frame");
    okButton.setFont(new Font("Dialog", 1, 16));
    okButton.setFocusPainted(false);
    okButton.setBackground(Color.lightGray);
    okButton.setBorder(new BevelBorder(BevelBorder.RAISED));
    okButton.setVerticalAlignment(SwingConstants.CENTER);
    okButton.setHorizontalAlignment(SwingConstants.CENTER);
    container.add(okButton, BorderLayout.SOUTH);
    okButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent evt) {
            setVisible(false);
          }
        });
  }
Beispiel #4
0
    private void initButton() {
      int actionCommandId = 1;
      for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 7; j++) {
          JButton numberButton = new JButton();
          numberButton.setBorder(BorderFactory.createEmptyBorder());
          numberButton.setHorizontalAlignment(SwingConstants.CENTER);
          numberButton.setActionCommand(String.valueOf(actionCommandId));

          numberButton.addMouseListener(this);

          numberButton.setBackground(palletTableColor);
          numberButton.setForeground(dateFontColor);
          numberButton.setText(String.valueOf(actionCommandId));
          numberButton.setPreferredSize(new Dimension(25, 25));
          daysButton[i][j] = numberButton;
          actionCommandId++;
        }
      }
    }
 private void setLookLowered(JButton button) {
   button.setBorder(LOWERED_BORDER);
   button.setHorizontalAlignment(SwingConstants.RIGHT);
   button.setVerticalAlignment(SwingConstants.BOTTOM);
   button.setBorderPainted(true);
 }
 private void setLookRaised(JButton button) {
   button.setBorder(RAISED_BORDER);
   button.setHorizontalAlignment(SwingConstants.CENTER);
   button.setVerticalAlignment(SwingConstants.CENTER);
   button.setBorderPainted(true);
 }
Beispiel #7
0
  Primary() {
    // Initial declarations, adding of listeners, and database linking.
    // Database link
    DBHookUp db = new DBHookUp();

    // Frame stuff
    frame = new JFrame("4 Byte Warrior");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBackground(Color.RED);
    frame.setResizable(false);
    // Panels
    main = new JPanel();
    scores = new JPanel();
    credits = new JPanel();
    story = new JPanel();
    tutorial = new JPanel();
    main.setLayout(new BoxLayout(main, BoxLayout.Y_AXIS));
    main.setBackground(Color.RED);
    main.setOpaque(true);
    scores.setLayout(new BorderLayout());
    scores.setBackground(Color.RED);
    scores.setOpaque(true);
    credits.setLayout(new BorderLayout());
    credits.setBackground(Color.RED);
    credits.setOpaque(true);
    // story.setLayout(new BoxLayout(story, BoxLayout.PAGE_AXIS));
    story.setLayout(new BorderLayout());
    story.setBackground(Color.RED);
    story.setOpaque(true);
    // tutorial.setLayout(new BoxLayout(tutorial, BoxLayout.PAGE_AXIS));
    tutorial.setLayout(new BorderLayout());
    tutorial.setBackground(Color.RED);
    tutorial.setOpaque(true);

    // Buttons
    start = new JButton("Go");
    start.addActionListener(this);
    start.setPreferredSize(new Dimension(125, 35));
    start.setAlignmentX(start.CENTER_ALIGNMENT);
    start.setBackground(Color.BLACK);
    start.setForeground(Color.WHITE);
    start.setHorizontalAlignment(SwingConstants.CENTER);
    cred = new JButton("Credits");
    cred.setPreferredSize(new Dimension(125, 35));
    cred.addActionListener(this);
    cred.setAlignmentX(cred.CENTER_ALIGNMENT);
    cred.setBackground(Color.BLACK);
    cred.setForeground(Color.WHITE);
    cred.setHorizontalAlignment(SwingConstants.CENTER);
    high = new JButton("High Scores");
    high.addActionListener(this);
    high.setPreferredSize(new Dimension(125, 35));
    high.setAlignmentX(high.CENTER_ALIGNMENT);
    high.setBackground(Color.BLACK);
    high.setForeground(Color.WHITE);
    high.setHorizontalAlignment(SwingConstants.CENTER);
    stor = new JButton("Next");
    stor.addActionListener(this);
    stor.setPreferredSize(new Dimension(100, 35));
    stor.setAlignmentX(stor.CENTER_ALIGNMENT);
    stor.setBackground(Color.BLACK);
    stor.setForeground(Color.WHITE);
    stor.setHorizontalAlignment(SwingConstants.CENTER);
    tutor = new JButton("Play");
    tutor.addActionListener(this);
    tutor.setPreferredSize(new Dimension(100, 35));
    tutor.setAlignmentX(tutor.CENTER_ALIGNMENT);
    tutor.setBackground(Color.BLACK);
    tutor.setForeground(Color.WHITE);
    returns1 = new JButton("Return");
    returns1.addActionListener(this);
    returns1.setPreferredSize(new Dimension(100, 35));
    returns1.setAlignmentX(returns1.CENTER_ALIGNMENT);
    returns1.setBackground(Color.BLACK);
    returns1.setForeground(Color.WHITE);
    returns1.setHorizontalAlignment(SwingConstants.CENTER);
    returns2 = new JButton("Return");
    returns2.addActionListener(this);
    returns2.setPreferredSize(new Dimension(100, 35));
    returns2.setAlignmentX(returns2.CENTER_ALIGNMENT);
    returns2.setBackground(Color.BLACK);
    returns2.setForeground(Color.WHITE);
    returns2.setHorizontalAlignment(SwingConstants.CENTER);
    returns3 = new JButton("Return");
    returns3.addActionListener(this);
    returns3.setPreferredSize(new Dimension(100, 35));
    returns3.setAlignmentX(returns3.CENTER_ALIGNMENT);
    returns3.setBackground(Color.BLACK);
    returns3.setForeground(Color.WHITE);
    returns3.setHorizontalAlignment(SwingConstants.CENTER);
    returns4 = new JButton("Return");
    returns4.addActionListener(this);
    returns4.setPreferredSize(new Dimension(100, 35));
    returns4.setAlignmentX(returns4.CENTER_ALIGNMENT);
    returns4.setBackground(Color.BLACK);
    returns4.setForeground(Color.WHITE);
    returns4.setHorizontalAlignment(SwingConstants.CENTER);

    // Text display
    theme = new JLabel();
    String text =
        String.format(
            "<html><div style=\"width:%dpx;\"><center><font size = \"4\">%s</font></center></div><html>",
            300,
            "Binary was a land of peace, ruled by the good king Groshi. "
                + "One day, the Dark Knight and his armies descended upon "
                + "the kingdom, throwing it into chaos. The Dark Knight "
                + "killed Groshi and kidnapped his daughter Elsie. "
                + "Only one memember of the kingdom could hope to "
                + "save the kingdom...<br/><br/>"
                + "<font size = \"7\"> THE 4 BYTE WARRIOR </font>");
    theme.setText(text);
    theme.setHorizontalAlignment(JLabel.CENTER);
    theme.setVerticalAlignment(JLabel.CENTER);
    theme.setForeground(Color.WHITE);
    instruct = new JLabel();
    String instruction =
        String.format(
            "<html><div style=\"width:%dpx;\"><center>%s</center></div><html>",
            200,
            "Z Key: Attack<br/>X Key: Cycle through inventory<br/>D-Pad: Movement<br/>A: Pause<br/><br/><br/>Defeat the enemeies to advance. Fight the bosses, get through the 8 worlds of Binary, and save Princess Elsie.");
    instruct.setText(instruction);
    instruct.setHorizontalAlignment(JLabel.CENTER);
    instruct.setVerticalAlignment(JLabel.CENTER);
    instruct.setForeground(Color.WHITE);
    String names =
        String.format(
            "<html><div style=\"width:%dpx;\"><center>%s</center></div><html>",
            150, "Alexander Friebe<br/>Charles Heckel<br/>Nicholas Lindsley<br/>Ben McWerthy<br/>");
    people = new JLabel(names);
    people.setHorizontalAlignment(JLabel.CENTER);
    people.setVerticalAlignment(JLabel.CENTER);
    people.setForeground(Color.WHITE);
    String major =
        String.format(
            "<html><div style=\"width:%dpx;\"><center>%s</center></div><html>",
            150,
            "Computer Science<br/>Computer Engineering<br/>Computer Engineering<br/>Computer Science<br/>");
    majors = new JLabel(major);
    majors.setHorizontalAlignment(JLabel.CENTER);
    majors.setVerticalAlignment(JLabel.CENTER);
    majors.setForeground(Color.WHITE);
    String credi =
        String.format(
            "<html><div style=\"width:%dpx;\"><center><font size = \"4\">%s</font></center></div><html>",
            150, "Credits");
    top = new JLabel(credi);
    top.setHorizontalAlignment(JLabel.CENTER);
    top.setVerticalAlignment(JLabel.CENTER);
    top.setForeground(Color.WHITE);
    scoresTop = new JLabel();
    String scTop =
        String.format(
            "<html><div style=\"width:%dpx;\"><center><font size = \"4\">%s</font></center></div><html>",
            200, "High Scores for Enemies Killed");
    scoresTop.setText(scTop);
    scoresTop.setForeground(Color.WHITE);
    scoresTop.setHorizontalAlignment(JLabel.CENTER);
    scoresTop.setVerticalAlignment(JLabel.CENTER);
    JLabel dbScores = new JLabel();
    ArrayList<Integer> sc = db.getScores();
    System.out.println(sc.size());
    // System.out.println(sc.get(0));
    String actual =
        String.format(
            "<html><div style=\"width:%dpx;\"><center><font size = \"4\">%s</font></center></div><html>",
            100, sc.get(0) + "<br/>" + sc.get(1) + "<br/>" + sc.get(2) + "<br/>");
    dbScores.setText(actual);
    dbScores.setHorizontalAlignment(JLabel.CENTER);
    dbScores.setVerticalAlignment(JLabel.CENTER);
    dbScores.setForeground(Color.WHITE);

    // Additions to main
    mainButtons = new JPanel(new GridLayout(3, 1));
    mainButtons.add(start);
    mainButtons.add(high);
    mainButtons.add(cred);
    main.add(mainButtons);

    // Additions to credits
    credits.add(top, BorderLayout.PAGE_START);
    // credits.add(people, BorderLayout.LINE_START);
    // credits.add(majors, BorderLayout.LINE_END);
    JPanel middle = new JPanel(new GridLayout(1, 2));
    middle.add(people);
    middle.add(majors);
    middle.setBackground(Color.RED);
    JPanel bottom = new JPanel(new GridLayout(1, 1));
    bottom.add(returns2);
    bottom.setBackground(Color.RED);
    credits.add(middle, BorderLayout.CENTER);
    credits.add(bottom, BorderLayout.PAGE_END);

    // Additions to high scores
    scores.add(scoresTop, BorderLayout.PAGE_START);
    scores.add(dbScores, BorderLayout.CENTER);
    JPanel bot = new JPanel(new GridLayout(1, 1));
    bot.add(returns1);
    bot.setBackground(Color.RED);
    scores.add(bot, BorderLayout.PAGE_END);

    // Additions to story
    story.add(theme, BorderLayout.CENTER);
    buttons = new JPanel(new GridLayout(2, 1));
    buttons.setBackground(Color.RED);
    // buttons.setOpaque(true);
    buttons.add(stor);
    buttons.add(returns3);
    story.add(buttons, BorderLayout.PAGE_END);

    // Additions to tutorial
    JPanel tutButtons = new JPanel(new GridLayout(2, 1));
    tutorial.add(instruct, BorderLayout.CENTER);
    tutButtons.add(tutor);
    tutButtons.add(returns4);
    tutButtons.setBackground(Color.RED);
    tutorial.add(tutButtons, BorderLayout.PAGE_END);

    main.setBorder(new EmptyBorder(100, 150, 100, 150));
    bot.setBorder(new EmptyBorder(0, 150, 0, 150));
    // middle.setBorder(new EmptyBorder(0,150,0,150));
    bottom.setBorder(new EmptyBorder(0, 150, 0, 150));
    buttons.setBorder(new EmptyBorder(0, 150, 0, 150));
    tutButtons.setBorder(new EmptyBorder(0, 150, 0, 150));
    frame.add(main);

    frame
        .pack(); // critical to call before you make the window visible in order to make everything
                 // look right 100% of the time
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }