// -----------------------------------------------------------------
  //  Sets up a panel with a label and a set of radio buttons
  //  that control its text.
  // -----------------------------------------------------------------
  public QuoteOptionsPanel() {
    comedyQuote = "Take my wife, please.";
    philosophyQuote = "I think, therefore I am.";
    carpentryQuote = "Measure twice. Cut once.";

    quote = new JLabel(comedyQuote);
    quote.setFont(new Font("Helvetica", Font.BOLD, 24));
    comedy = new JRadioButton("Comedy", true);
    comedy.setBackground(Color.green);
    philosophy = new JRadioButton("Philosophy");
    philosophy.setBackground(Color.green);
    carpentry = new JRadioButton("Carpentry");
    carpentry.setBackground(Color.green);

    ButtonGroup group = new ButtonGroup();
    group.add(comedy);
    group.add(philosophy);
    group.add(carpentry);

    QuoteListener listener = new QuoteListener();
    comedy.addActionListener(listener);
    philosophy.addActionListener(listener);
    carpentry.addActionListener(listener);

    add(quote);
    add(comedy);
    add(philosophy);
    add(carpentry);

    setBackground(Color.green);
    setPreferredSize(new Dimension(300, 100));
  }
示例#2
0
  private void makeMenuScreen() {
    menu = new JPanel();
    menu.setBackground(Color.BLACK);
    menu.setLayout(null);
    menu.setBounds(0, 0, width, height);

    try {
      BufferedImage menuIMG =
          ImageIO.read(this.getClass().getResource("/Resources/MenuBackground.png"));
      // BufferedImage menuIMG = ImageIO.read(new
      // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/MenuBackground.png"));
      menuIMGL =
          new JLabel(
              new ImageIcon(
                  menuIMG.getScaledInstance(
                      (int) (width * 0.8), (int) (height * 0.8), Image.SCALE_SMOOTH)));
      menuIMGL.setBounds(0, 0, width, height);
    } catch (Exception e) {
    }

    highscoreL = new JLabel(String.valueOf(highscore));
    highscoreL.setBackground(Color.darkGray);
    highscoreL.setBounds((width / 2) + 100, (height / 2) + 70, 500, 100);
    highscoreL.setForeground(Color.white);

    easy = new JButton("Easy");
    hard = new JButton("Hard");

    easy.addActionListener(this);
    hard.addActionListener(this);

    easy.setBounds((width / 2) - 60, (height / 2) - 50, 120, 20);
    hard.setBounds((width / 2) - 60, height / 2 - 10, 120, 20);

    onePlayerRB = new JRadioButton("One Player");
    twoPlayerRB = new JRadioButton("Two Player");
    mouseRB = new JRadioButton("Mouse (Player 1)");
    keyboardRB = new JRadioButton("Keyboard (Player 1)");
    keyboardSpeedS1 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50);
    keyboardSpeedS2 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50);
    musicCB = new JCheckBox("Music");

    onePlayerRB.setBackground(null);
    twoPlayerRB.setBackground(null);
    mouseRB.setBackground(null);
    keyboardRB.setBackground(null);
    keyboardSpeedS1.setBackground(null);
    keyboardSpeedS2.setBackground(null);
    musicCB.setBackground(null);

    onePlayerRB.setForeground(Color.WHITE);
    twoPlayerRB.setForeground(Color.WHITE);
    mouseRB.setForeground(Color.WHITE);
    keyboardRB.setForeground(Color.WHITE);
    keyboardSpeedS1.setForeground(Color.WHITE);
    keyboardSpeedS2.setForeground(Color.WHITE);
    musicCB.setForeground(Color.WHITE);

    ButtonGroup playerChoice = new ButtonGroup();
    playerChoice.add(onePlayerRB);
    playerChoice.add(twoPlayerRB);
    onePlayerRB.setSelected(true);

    ButtonGroup peripheralChoice = new ButtonGroup();
    peripheralChoice.add(mouseRB);
    peripheralChoice.add(keyboardRB);
    mouseRB.setSelected(true);

    musicCB.setSelected(true);

    onePlayerRB.setBounds((width / 2) + 100, (height / 2) - 50, 100, 20);
    twoPlayerRB.setBounds((width / 2) + 100, (height / 2) - 30, 100, 20);
    mouseRB.setBounds((width / 2) + 100, (height / 2), 200, 20);
    keyboardRB.setBounds((width / 2) + 100, (height / 2) + 20, 200, 20);
    keyboardSpeedS1.setBounds(width / 2 - 120, height / 2 + 100, 200, 50);
    keyboardSpeedS2.setBounds(width / 2 - 120, height / 2 + 183, 200, 50);
    musicCB.setBounds((width / 2) + 100, (height / 2) + 50, 100, 20);

    keyboardSpeedL1 = new JLabel("Keyboard Speed (Player One)");
    keyboardSpeedL1.setForeground(Color.WHITE);
    keyboardSpeedL1.setBounds(width / 2 - 113, height / 2 + 67, 200, 50);

    keyboardSpeedL2 = new JLabel("Keyboard Speed (Player Two)");
    keyboardSpeedL2.setForeground(Color.WHITE);
    keyboardSpeedL2.setBounds(width / 2 - 113, height / 2 + 150, 200, 50);

    howTo = new JButton("How To Play");
    howTo.addActionListener(this);
    howTo.setBounds((width / 2) - 60, height / 2 + 30, 120, 20);

    try {
      BufferedImage howToIMG = ImageIO.read(this.getClass().getResource("/Resources/HowTo.png"));
      // BufferedImage howToIMG = ImageIO.read(new
      // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/HowTo.png"));
      howToIMGL = new JLabel(new ImageIcon(howToIMG));
      howToIMGL.setBounds(
          width / 2 - howToIMG.getWidth() / 2,
          height / 2 - howToIMG.getHeight() / 2,
          howToIMG.getWidth(),
          howToIMG.getHeight());
    } catch (Exception e) {
    }

    howToBack = new JButton("X");
    howToBack.setBounds(
        (int) (width / 2 + width * 0.25) - 50, (int) (height / 2 - height * 0.25), 50, 50);
    howToBack.setBackground(Color.BLACK);
    howToBack.setForeground(Color.WHITE);
    howToBack.addActionListener(this);

    menu.add(easy);
    menu.add(hard);
    menu.add(howTo);
    menu.add(highscoreL);
    menu.add(onePlayerRB);
    menu.add(twoPlayerRB);
    menu.add(mouseRB);
    menu.add(keyboardRB);
    menu.add(keyboardSpeedL1);
    menu.add(keyboardSpeedL2);
    menu.add(keyboardSpeedS1);
    menu.add(keyboardSpeedS2);
    menu.add(musicCB);
    menu.add(menuIMGL);

    back = new JButton("Back");
    back.setBounds(width / 2 - 40, height / 2, 100, 20);
    back.addActionListener(this);
    back.setVisible(false);
    this.add(back);
  }
  public emp() {
    setTitle("AMRITA HUMAN RESOURCE MANAGEMENT SYSTEM    (EMPLOYEE DETAIL)");

    getContentPane().add(p, BorderLayout.CENTER);
    getContentPane().add(q, BorderLayout.SOUTH);

    setTitle("Placement Office");

    lname = new JLabel("Name: ");
    lextra = new JLabel("Vacancy(s): ");
    lfield = new JLabel("Field: ");
    lsal = new JLabel("Minimum Expected Salary: ");
    lusr = new JLabel("Login name: ");
    lpwd = new JLabel("Password: "******"5,000");
    cbsal.addItem("10,000");
    cbsal.addItem("15,000");
    cbsal.addItem("20,000");
    cbsal.setBackground(Color.ORANGE);

    it = new JRadioButton("Software Engg.");
    civil = new JRadioButton("Civil Engg.");
    mech = new JRadioButton("Mechanical Engg.");
    ButtonGroup bg2 = new ButtonGroup();
    bg2.add(it);
    bg2.add(civil);
    bg2.add(mech);
    civil.setBackground(Color.ORANGE);

    bSub = new JButton("Submit");
    bRes = new JButton("Reset");

    p.setLayout(new GridLayout(11, 2));
    Blank = new JLabel("");
    Blank1 = new JLabel("");
    Blank2 = new JLabel("");
    Blank3 = new JLabel("");
    Blank4 = new JLabel("");

    p.add(lusr);
    p.add(tusr);

    p.add(lpwd);
    p.add(tpwd);

    p.add(lname);
    p.add(tname);

    p.add(lextra);
    p.add(textra);

    p.add(lfield);
    p.add(it);

    p.add(Blank4);
    p.add(civil);

    p.add(Blank1);
    p.add(mech);

    p.add(lsal);
    p.add(cbsal);

    q.add(bSub);
    q.add(bRes);

    bSub.addActionListener(this);
    bRes.addActionListener(this);
    setVisible(true);
    setBounds(200, 200, 300, 300);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }