示例#1
0
 private JRadioButton getRegionButton(
     JRadioButton button, int x, int y, int w, int h, String tip) {
   button.setBounds(new Rectangle(x, y, w, h));
   button.setBorder(BorderFactory.createLoweredBevelBorder());
   button.setToolTipText(Messages.getString(tip));
   button.addActionListener(alRegion);
   regionButtons.add(button);
   return button;
 }
示例#2
0
 private JRadioButton getShapeButton(
     JRadioButton button, int x, int y, int w, int h, String tip, Shp shp, Obj obj) {
   button.setBounds(new Rectangle(x, y, w, h));
   button.setBorder(BorderFactory.createLoweredBevelBorder());
   button.setToolTipText(Messages.getString(tip));
   button.addActionListener(alShape);
   shapeButtons.add(button);
   shapes.put(shp, button);
   objects.put(shp, obj);
   return button;
 }
  /**
   * Initializes the GUI by creating the components, placing them in the dialog, and displaying
   * them.
   */
  private void init() {
    setForeground(Color.black);

    setTitle("Nonlocal Means Filter");

    JPanel mainPanel;
    mainPanel = new JPanel();
    mainPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    mainPanel.setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 1;
    gbc.insets = new Insets(3, 3, 3, 3);
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;

    paramPanel = new JPanel(new GridBagLayout());
    paramPanel.setForeground(Color.black);
    paramPanel.setBorder(buildTitledBorder("Parameters"));
    mainPanel.add(paramPanel, gbc);

    GridBagConstraints gbc2 = new GridBagConstraints();
    gbc2.gridwidth = 1;
    gbc2.gridheight = 1;
    gbc2.anchor = GridBagConstraints.WEST;
    gbc2.weightx = 1;
    gbc2.insets = new Insets(3, 3, 3, 3);
    gbc2.gridx = 0;
    gbc2.gridy = 0;
    gbc2.fill = GridBagConstraints.HORIZONTAL;

    labelSearchWindowSide = createLabel("Search window side (odd)");

    paramPanel.add(labelSearchWindowSide, gbc2);

    gbc2.gridx = 1;
    textSearchWindowSide = createTextField("15");
    paramPanel.add(textSearchWindowSide, gbc2);

    gbc2.gridx = 0;
    gbc2.gridy = 1;
    labelSimilarityWindowSide = createLabel("Similarity window side (odd) ");
    paramPanel.add(labelSimilarityWindowSide, gbc2);

    gbc2.gridx = 1;
    textSimilarityWindowSide = createTextField("7");
    paramPanel.add(textSimilarityWindowSide, gbc2);

    gbc2.gridx = 0;
    gbc2.gridy = 2;
    labelNoiseStandardDeviation = createLabel("Noise standard deviation ");
    paramPanel.add(labelNoiseStandardDeviation, gbc2);

    gbc2.gridx = 1;
    textNoiseStandardDeviation = createTextField("10.0");
    paramPanel.add(textNoiseStandardDeviation, gbc2);

    gbc2.gridx = 0;
    gbc2.gridy = 3;
    labelDegree = createLabel("Degree of filtering ");
    labelDegree.setEnabled(doRician);
    paramPanel.add(labelDegree, gbc2);

    gbc2.gridx = 1;
    textDegree = createTextField("1.414");
    textDegree.setEnabled(doRician);
    paramPanel.add(textDegree, gbc2);

    gbc2.gridx = 0;
    gbc2.gridy = 4;
    doRicianCheckBox = new JCheckBox("Deal with Rician noise in MRI");
    doRicianCheckBox.setFont(serif12);
    doRicianCheckBox.setSelected(false);
    doRicianCheckBox.addActionListener(this);
    paramPanel.add(doRicianCheckBox, gbc2);

    if (image.getNDims() > 2) {
      gbc2.gridx = 0;
      gbc2.gridy = 5;
      gbc2.gridwidth = 2;

      image25DCheckBox = new JCheckBox("Process each slice independently (2.5D)");
      image25DCheckBox.setFont(serif12);
      paramPanel.add(image25DCheckBox, gbc2);
      image25DCheckBox.setSelected(false);
    } // if (image.getNDims > 2)

    JPanel outputOptPanel = new JPanel(new GridLayout(1, 2));
    destinationPanel = new JPanel(new BorderLayout());
    destinationPanel.setForeground(Color.black);
    destinationPanel.setBorder(buildTitledBorder("Destination"));
    outputOptPanel.add(destinationPanel);

    destinationGroup = new ButtonGroup();
    newImage = new JRadioButton("New image", true);
    newImage.setBounds(10, 16, 120, 25);
    newImage.setFont(serif12);
    destinationGroup.add(newImage);
    destinationPanel.add(newImage, BorderLayout.NORTH);

    replaceImage = new JRadioButton("Replace image", false);
    replaceImage.setFont(serif12);
    destinationGroup.add(replaceImage);
    destinationPanel.add(replaceImage, BorderLayout.CENTER);

    // Only if the image is unlocked can it be replaced.
    if (image.getLockStatus() == ModelStorageBase.UNLOCKED) {
      replaceImage.setEnabled(true);
    } else {
      replaceImage.setEnabled(false);
    }

    gbc.gridx = 0;
    gbc.gridy = 1;
    mainPanel.add(outputOptPanel, gbc);

    mainDialogPanel.add(mainPanel, BorderLayout.CENTER);
    mainDialogPanel.add(buildButtons(), BorderLayout.SOUTH);

    getContentPane().add(mainDialogPanel);

    pack();
    setResizable(true);
    // setVisible(true);

    System.gc();
  }
示例#4
0
  public static void main(String[] args) {
    ArrayList<Student> studentList = new ArrayList<Student>();

    studentList.add(new Student(56070106, "มารุต", "นนท์ขุนทด"));
    studentList.add(new Student(57070035, "ณัฐนันท์", "กุลโชควณิช"));
    studentList.add(new Student(56070013, "จันทนีย์", "แซ่เลี่ยว"));
    studentList.add(new Student(57070134, "สุทธินัย", "บุญยิ่งยงชัย"));
    studentList.add(new Student(57070067, "ปรีชาชาญ", "ชอบชน"));
    studentList.add(new Student(57070002, "กฤษฎา", "อิงอาน"));
    studentList.add(new Student(57070052, "ธรรศ", "แสงสมเรือง"));
    studentList.add(new Student(57070082, "พิสิฐ", "ไตรอังกูร"));
    studentList.add(new Student(57070044, "ธนกฤต", "ตั้งดำรงทรัพย์"));
    studentList.add(new Student(57070120, "สถาพร", "แดงน้อย"));
    studentList.add(new Student(56070085, "ปองพล", "จันทโพธิ์"));
    studentList.add(new Student(57070026, "ชยุต", "รักสมยา"));
    studentList.add(new Student(57070078, "พัชรพล", "โสภณ"));
    studentList.add(new Student(57070021, "จิระพัฒน์", "กึ่งวงษ์"));
    studentList.add(new Student(57070075, "พชร", "ไชยเจริญ"));
    studentList.add(new Student(57070039, "ต้นสาย", "สิงห์กังวาน"));
    studentList.add(new Student(57070030, "ชุติภา", "บุญประเสริฐ"));
    studentList.add(new Student(57070150, "เอื้อมพร", "รักกำเหนิด"));
    studentList.add(new Student(57070065, "ปทิตตา", "สุวรรณฤกษ์"));
    studentList.add(new Student(57070012, "เขมทัต", "บุตรฉิม"));
    studentList.add(new Student(57070125, "สัฟวัน", "แปเราะ"));
    studentList.add(new Student(57070010, "กุลธิดา", "ขันแก้ว"));
    studentList.add(new Student(56070067, "ธีรฉัตร", "ต้นแก้ว"));
    studentList.add(new Student(57070020, "จิรสิน", "ปัญญาวิสุทธิชัย"));
    studentList.add(new Student(57070046, "ธนพรรธน์", "ธนวัฒน์ปัญญา"));
    studentList.add(new Student(56070019, "จุฑาทิพย์", "บุญเฉื่อย"));
    studentList.add(new Student(57070080, "พิพัฒน์", "เสวย"));
    studentList.add(new Student(57070027, "ชัญญานุช", "กิ่มเปี่ยม"));
    studentList.add(new Student(57070057, "ธีระวัฒน์", "ธีระธำรงรักษ์"));
    studentList.add(new Student(57070114, "ศุภกิตติ์", "เจิ้ง"));
    studentList.add(new Student(57070123, "สรัล", "แขดวง"));
    studentList.add(new Student(57070086, "ภัทรพล", "แก้วกุศลวิวัฒน์"));
    studentList.add(new Student(57070117, "ศุภวิชญ์", "เกตุมาก"));
    studentList.add(new Student(57070113, "ศุทธินี", "จันทรศิริ"));
    studentList.add(new Student(57070124, "สรัลดา", "ฝูงใหญ่"));
    studentList.add(new Student(57070105, "วรุตม์", "วัฒนกิจรุ่งโรจน์"));
    studentList.add(new Student(57070066, "ปรัชญาวิช", "เรามานะ"));
    studentList.add(new Student(57070040, "ไตรปฎก", "อินทสุวรรณ"));
    studentList.add(new Student(57070029, "ชานิวัฒน์", "แสงไชย"));
    studentList.add(new Student(57070126, "สาธิกา", "ลิมะวิรัชพงษ์"));
    studentList.add(new Student(57070063, "เบญจรัตน์", "รอดกร"));
    studentList.add(new Student(56070116, "วรพล", "บุญทรัพย์"));
    studentList.add(new Student(57070017, "จิธารา", "วิจิตรบุญชูวงศ์"));
    studentList.add(new Student(57070085, "ภฤศ", "วิบูลฤทธิ์"));
    studentList.add(new Student(56070031, "ฐิติพงศ์", "นนทะโคตร"));
    studentList.add(new Student(56070084, "ประดับดาว", "เพชรพลายงาม"));
    studentList.add(new Student(57070135, "สุภัสกรณ์", "จิรโชคนุเคราะห์"));
    studentList.add(new Student(57070076, "พชร", "ลีละวงศ์พานิช"));
    studentList.add(new Student(57070133, "สุชานันท์", "ฉันท์เรืองวณิชย์"));
    studentList.add(new Student(56070081, "ปกรณ์", "เมฆศิรินภาพงศ์"));
    studentList.add(new Student(57070101, "วรดี", "สันติวโรทัย"));
    studentList.add(new Student(57070004, "กานต์", "เนียมจันทร์"));
    studentList.add(new Student(57070015, "จักรภัทร", "แก้วทอง"));
    studentList.add(new Student(57070022, "จิรัฏฐ์", "อัครสุวรรณชัย"));
    studentList.add(new Student(57070129, "สาลินี", "ทีอำไพ"));
    studentList.add(new Student(57070028, "ชาตรี", "ฐิตานุวงศ์"));
    studentList.add(new Student(57070148, "อิทธิพัทธ์", "ฉิมหิรัญ"));
    studentList.add(new Student(56070074, "นราวิทย์", "ศรพลทัน"));
    studentList.add(new Student(57070143, "อภิชา", "อินทรพรห์ม"));
    studentList.add(new Student(57070073, "พงศ์ณเรศ", "ชูทอง"));
    studentList.add(new Student(57070009, "กิตติศักดิ์", "เตชะเรืองสุวรรณ"));
    studentList.add(new Student(57070037, "ณัฐวุฒิ", "กรวิศิษฎ์วาทิน"));
    studentList.add(new Student(57070111, "ศาสตรา", "ตัณฑ์ศุภศิริ"));
    studentList.add(new Student(57070094, "มธุริน", "สังขวิจิตร"));
    studentList.add(new Student(57070008, "กิตติศักดิ์", "แก้วน่าน"));
    studentList.add(new Student(57070050, "ธนาวัฒน์", "รักสมบัติ"));
    studentList.add(new Student(57070061, "บุณฑริกา", "โพชฌงค์เดช"));
    studentList.add(new Student(57070054, "ธาราทิพย์", "มาลัยมาลย์"));
    studentList.add(new Student(57070056, "ธีรโชติ", "จิวะรังสินี"));
    studentList.add(new Student(57070001, "กนกพล", "นิลเพชร"));
    studentList.add(new Student(57070059, "นวพร", "พ่วงสายกิ่ม"));
    studentList.add(new Student(57070139, "อชิรญา", "ทรงพุฒิ"));
    studentList.add(new Student(57070115, "ศุภณัฐ", "สวนทวี"));
    studentList.add(new Student(57070055, "ธิปก", "ลายรัศมี"));
    studentList.add(new Student(56070046, "ณิธยาน์", "สกลพิสิษฐ์"));
    studentList.add(new Student(57070099, "รังสิมันต์", "แสนประเสริฐ"));
    studentList.add(new Student(56070115, "วณัฐพงศ์", "เชาวน์รัตนะ"));
    studentList.add(new Student(57070006, "กิจธนา", "ชยางศุ"));
    studentList.add(new Student(57070110, "ศกานต์", "พรหมลายนาค"));
    studentList.add(new Student(57070045, "ธนกฤต", "ปิ่นทะนา"));
    studentList.add(new Student(57070048, "ธนัญญา", "ธำรงธัญวงศ์"));
    studentList.add(new Student(57070091, "ภานุวัต", "หัวใจ"));
    studentList.add(new Student(57070031, "ฐิติ", "จันทมงคลเลิศ"));
    studentList.add(new Student(57070145, "อมิตา", "มงคลปรีดาไชย"));
    studentList.add(new Student(57070047, "ธนรัช", "ตะสาริกา"));
    studentList.add(new Student(57070074, "พงศธร", "สังข์ยิ้ม"));
    studentList.add(new Student(57070132, "สุชัจจ์", "จงประสิทธิ์"));
    studentList.add(new Student(57070088, "ภาคภูมิ", "จรัสพันธุ์"));
    studentList.add(new Student(57070060, "นัชชา", "โรจนประเสริฐ"));
    studentList.add(new Student(57070130, "สิทธิชัย", "มะศิริ"));
    studentList.add(new Student(57070121, "สยามรัฐ", "สุภาวะกุล"));
    studentList.add(new Student(57070127, "สาธิต", "ศิริหงษ์ทอง"));
    studentList.add(new Student(57070018, "จิรทีปต์", "ทาทิพย์"));
    studentList.add(new Student(57070068, "ปวริศา", "ทองเงิน"));
    studentList.add(new Student(57070096, "เมธิชัย", "อรัญชราธร"));
    studentList.add(new Student(57070007, "กิตติทัต", "ภวรัญชนกุล"));
    studentList.add(new Student(57070142, "อภิชัย", "ตันตสิรินทร์"));
    studentList.add(new Student(57070033, "ณัฐกิตติ์", "วัยวัฒน์ภัทรกุล"));
    studentList.add(new Student(57070025, "ธนวัฒน์", "กุสูงเนิน"));
    studentList.add(new Student(57070042, "ทศพล", "อยู่สุข"));
    studentList.add(new Student(57070049, "ธนาภา", "ธำรงธัญวงศ์"));
    studentList.add(new Student(57070053, "ธัชกร", "จอมอุตม์"));
    studentList.add(new Student(57070149, "อินทุภรณ์", "อินทรสุวรรณ"));
    studentList.add(new Student(57070038, "ณัฐวุฒิ", "วรกิจลาวัลย์"));
    studentList.add(new Student(57070136, "สุมณฑา", "สุขพลำ"));
    studentList.add(new Student(57070093, "มงคล", "อุ่มออง"));
    studentList.add(new Student(57070041, "ไตรศักดิ์", "ไตรเสนีย์"));
    studentList.add(new Student(57070071, "ปยณัฐ", "เพ็งชัย"));
    studentList.add(new Student(57070077, "พศวัต", "พฤกษ์พนาสันต์"));
    studentList.add(new Student(57070146, "อรรคพล", "ไชยณรงค์"));
    studentList.add(new Student(57070103, "วรพงษ์", "มาลัยวงษ์"));
    studentList.add(new Student(57070098, "รเมศ", "ยังดำ"));
    studentList.add(new Student(57070087, "ภัทรภูมิ", "ศิริคำ"));
    studentList.add(new Student(57070107, "วิรุฬห์", "ลีลาชัย"));
    studentList.add(new Student(57070137, "เสกสรรค์", "เนรมิตธนสมบัติ"));
    studentList.add(new Student(57070083, "พีรณัฐ", "ฤกษ์ศุภสมพล"));
    studentList.add(new Student(57070062, "บุษกร", "ยวงเงิน"));
    studentList.add(new Student(57070011, "ขนิษฐา", "วิเศษถวัลย์"));
    studentList.add(new Student(57070079, "พิชัย", "สิวะวัฒน์"));
    studentList.add(new Student(57070128, "สาริศ", "สิทธิชอบธรรม"));
    studentList.add(new Student(57070019, "จิรวัฒน์", "บุญกำเหนิด"));
    studentList.add(new Student(57070051, "ธนู", "ชมญาติ"));
    studentList.add(new Student(56070154, "อุกกฤษฏ์", "ธีรคุณากร"));
    studentList.add(new Student(57070064, "ปฏิภาณ", "ขุนแขวง"));
    studentList.add(new Student(57070013, "คณาธิป", "แซ่แพ"));
    studentList.add(new Student(57070084, "พีระพล", "กุลธรรมโยธิน"));
    studentList.add(new Student(57070140, "อดิศร", "ศรีภัคไพสิฐ"));
    studentList.add(new Student(57070109, "วิสรรทูร", "แจ้งวงษ์วรัศ"));
    studentList.add(new Student(57070141, "อธิวัฒน์", "วรศักดิ์สิริกุล"));
    studentList.add(new Student(57070119, "ศุภาวรรณ", "คีรินทร์นนท์"));
    studentList.add(new Student(57070144, "อภิสิทธิ์", "บุญรัตน์"));
    studentList.add(new Student(57070036, "ณัฐวีร์", "ชุติอนุสรณ์ชัย"));
    studentList.add(new Student(57070104, "วรเวทน์", "ศิรพัฒน์พงค์"));
    studentList.add(new Student(57070014, "คุณัญญา", "ศรีวงษ์"));
    studentList.add(new Student(57070138, "หฤษฏ์", "ลีละบรรยงค์"));
    studentList.add(new Student(57070106, "วัฒกร", "มะลิขาว"));
    studentList.add(new Student(57070058, "นภัส", "ตั้งหลักมงคล"));
    studentList.add(new Student(57070112, "ศิริราช", "จันตา"));
    studentList.add(new Student(57070005, "กิ่งกาญจน์", "แพรอด"));
    studentList.add(new Student(57070102, "วรพงษ์", "บูรณ์พงษ์ทอง"));

    // Create frame
    JFrame frame = new JFrame();
    frame.setTitle("Lab10: Problem3");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setBounds(150, 150, 350, 250);
    frame.setLayout(null);

    // Crate component
    JLabel label1 = new JLabel("Input :");
    frame.add(label1);
    label1.setBounds(20, 20, 60, 20);

    JTextField inputBox = new JTextField();
    frame.add(inputBox);
    inputBox.setBounds(80, 22, 120, 20);

    JButton submitButton = new JButton("Submit");
    frame.add(submitButton);
    submitButton.setBounds(220, 20, 100, 54);

    JLabel label2 = new JLabel("Search by:");
    frame.add(label2);
    label2.setBounds(20, 50, 120, 20);

    JRadioButton oneIncrement = new JRadioButton("First Name");
    frame.add(oneIncrement);
    oneIncrement.setBounds(100, 50, 100, 50);

    JRadioButton twoIncrement = new JRadioButton("Last Name");
    frame.add(twoIncrement);
    twoIncrement.setBounds(100, 90, 100, 50);

    ButtonGroup incrementGroup = new ButtonGroup();
    incrementGroup.add(oneIncrement);
    incrementGroup.add(twoIncrement);
    oneIncrement.setSelected(true);

    // Action
    submitButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int choose = 1;
            int found = 0;
            if (twoIncrement.isSelected()) choose = 2;
            String message = inputBox.getText();
            if (choose == 1) {
              for (int i = 0; i < studentList.size(); i++) {
                if (message.equals(studentList.get(i).getFirstname())) {
                  JOptionPane.showMessageDialog(
                      frame,
                      String.format(
                          "%d: %s %s",
                          studentList.get(i).getId(),
                          studentList.get(i).getFirstname(),
                          studentList.get(i).getLastname()),
                      "Foundasd",
                      JOptionPane.INFORMATION_MESSAGE);
                  found = 1;
                  break;
                }
              }
            } else if (choose == 2) {
              for (int i = 0; i < studentList.size(); i++) {
                if (message.equals(studentList.get(i).getLastname())) {
                  JOptionPane.showMessageDialog(
                      frame,
                      String.format(
                          "%d: %s %s",
                          studentList.get(i).getId(),
                          studentList.get(i).getFirstname(),
                          studentList.get(i).getLastname()),
                      "Found",
                      JOptionPane.INFORMATION_MESSAGE);
                  found = 1;
                  break;
                }
              }
            }

            if (found != 1) {
              JOptionPane.showMessageDialog(
                  frame, "ค้นหาไม่พบ", "Not Found", JOptionPane.ERROR_MESSAGE);
            }
          }
        });

    // Show
    frame.setVisible(true);
  }
示例#5
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);
  }
示例#6
0
  private void jbInit() throws Exception {
    confirm = new JButton(ls.getString(16));
    cancel = new JButton(ls.getString(18));
    pauseRB = new JRadioButton(ls.getString(22));
    leftRB = new JRadioButton(ls.getString(13));
    rightRB = new JRadioButton(ls.getString(14));

    Container container = this.getContentPane();
    titledBorder1 = new TitledBorder(ls.getString(11));
    container.setLayout(null);
    leftL.setEditable(false);
    leftL.setBounds(new Rectangle(116, 24, 84, 20));
    leftL.setText(
        gameconfigure.getLeftKeyCode() + " " + KeyEvent.getKeyText(gameconfigure.getLeftKeyCode()));
    leftRB.setBounds(new Rectangle(5, 23, 97, 20));
    leftRB.addActionListener(new KeyOptionDialog_leftRB_actionAdapter(this));

    rightRB.setBounds(new Rectangle(5, 48, 97, 20));
    rightRB.addActionListener(new KeyOptionDialog_rightRB_actionAdapter(this));

    rightL.setText(
        gameconfigure.getRightKeyCode()
            + " "
            + KeyEvent.getKeyText(gameconfigure.getRightKeyCode()));
    rightL.setEditable(false);
    rightL.setBounds(new Rectangle(116, 49, 84, 20));

    confirm.setBounds(new Rectangle(110, 114, 85, 20));

    confirm.addActionListener(new KeyOptionDialog_confirm_actionAdapter(this));
    cancel.setBounds(new Rectangle(18, 114, 85, 20));
    cancel.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cancel_actionPerformed(e);
          }
        });

    pauseRB.setBounds(new Rectangle(6, 74, 97, 20));
    pauseRB.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            pauseRB_actionPerformed(e);
          }
        });
    pauseL.setText(
        gameconfigure.getPausekeyCode()
            + " "
            + KeyEvent.getKeyText(gameconfigure.getPausekeyCode()));
    pauseL.setBounds(new Rectangle(117, 75, 84, 20));
    pauseL.setEditable(false);
    container.add(leftL, null);
    container.add(rightL, null);
    container.add(rightRB, null);
    container.add(leftRB, null);
    container.add(pauseL, null);
    container.add(confirm, null);
    container.add(cancel, null);
    container.add(pauseRB, null);
    keylistener =
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {

            switch (KeyOptionDialog.this.selecti) {
              case 1:
                leftL.setText(e.getKeyCode() + " " + e.getKeyText(e.getKeyCode()));
                gameconfigure.setLeftKeyCode(e.getKeyCode());
                break;
              case 2:
                rightL.setText(e.getKeyCode() + " " + e.getKeyText(e.getKeyCode()));
                gameconfigure.setRightKeyCode(e.getKeyCode());
                break;

              case 6:
                pauseL.setText(e.getKeyCode() + " " + e.getKeyText(e.getKeyCode()));
                gameconfigure.setPausekeyCode(e.getKeyCode());
                break;
            }
          }
        };

    Component[] com = container.getComponents();
    for (int i = 0; i < com.length; i++) {
      com[i].addKeyListener(keylistener);
    }
    buttonGroup.add(leftRB);
    buttonGroup.add(rightRB);
    buttonGroup.add(pauseRB);
  }
示例#7
0
  InputFrame() {
    JPanel pane = new JPanel();
    pane.setLayout(null);
    pane.setBackground(Color.LIGHT_GRAY);
    add(pane);
    // JTextField文字欄位元件
    lblName = new JLabel("姓名:");
    lblName.setBounds(10, 10, 40, 20);
    pane.add(lblName);
    text0.setBounds(50, 10, 80, 20);
    text0.addActionListener(textfield);
    pane.add(text0);
    // JSpinner數位序列元件
    lblAge = new JLabel("年齡:");
    lblAge.setBounds(170, 10, 40, 20);
    pane.add(lblAge);
    JSpinner spin = new JSpinner(new SpinnerNumberModel(20, 1, 100, 1));
    spin.setBounds(210, 10, 80, 20);
    spin.addChangeListener(spinner);
    pane.add(spin);
    // JRadioButton選項圓鈕元件
    lblSex = new JLabel("性別:");
    lblSex.setBounds(10, 40, 40, 20);
    pane.add(lblSex);
    ButtonGroup group = new ButtonGroup();
    JRadioButton rb1 = new JRadioButton("帥哥", false);
    rb1.setBounds(50, 40, 60, 20);
    JRadioButton rb2 = new JRadioButton("美女", false);
    rb2.setBounds(110, 40, 60, 20);
    rb1.setOpaque(false);
    rb2.setOpaque(false); // 秀出底色
    rb1.addActionListener(radio);
    rb2.addActionListener(radio);
    group.add(rb1);
    group.add(rb2);
    pane.add(rb1);
    pane.add(rb2);
    // JCheckBox核對方塊元件
    lblInter = new JLabel("興趣:");
    lblInter.setBounds(10, 70, 50, 20);
    pane.add(lblInter);
    for (int i = 0; i < check.length; i++) {
      check[i] = new JCheckBox(checkItem[i]);
      check[i].setBounds(50 + 60 * i, 70, 60, 20);
      check[i].setOpaque(false);
      check[i].addActionListener(checkbox);
      pane.add(check[i]);
    }
    // JComboBox下拉式清單元件
    lblAcad = new JLabel("學歷:");
    lblAcad.setBounds(10, 100, 50, 20);
    pane.add(lblAcad);
    String[] items_c = {"博士", "碩士", "大學", "高中", "國中", "國小"};
    JComboBox c_box = new JComboBox(items_c);
    c_box.setBounds(50, 100, 100, 20);
    c_box.addItemListener(cbo);
    pane.add(c_box);
    // JList清單元件
    lblPlace = new JLabel("居住地區:");
    lblPlace.setBounds(170, 100, 70, 20);
    pane.add(lblPlace);
    String[] items_p = {
      "台北", "桃園", "新竹", "苗栗", "台中", "彰化", "雲林", "嘉義", "台南", "高雄", "屏東", "花蓮", "台東", "澎湖"
    };
    JList list = new JList(items_p);
    list.setVisibleRowCount(4);
    list.addListSelectionListener(list_p);
    JScrollPane scroll = new JScrollPane(list);
    scroll.setBounds(240, 100, 80, 80);
    pane.add(scroll);
    // JTextArea文字區域元件
    texta.setBounds(10, 190, 330, 40);
    texta.setEditable(false);
    pane.add(texta);

    setTitle("輸入元件綜合應用");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(50, 50, 360, 280);
    setVisible(true);
  }