public void SpelersCombo(int ronde) {
    String[] spelers = null;
    if (ronde == 0) {
      spelers = new String[1];
      spelers[0] = "Geen Spelers";
    } else {
      spelers = oc.GeefSpelers(ronde);
    }

    ComboBoxModel cbSpelerModel = new DefaultComboBoxModel(spelers);
    cbSpeler = new JComboBox();
    pInzet.add(cbSpeler);
    cbSpeler.setModel(cbSpelerModel);
    cbSpeler.setBounds(91, 63, 156, 21);
    cbSpeler.setToolTipText("Maak een keuze uit een van de (meespelende) spelers.");
    cbSpeler.addItemListener(
        new ItemListener() {

          public void itemStateChanged(ItemEvent evt) {
            cbSpelerItemStateChanged(evt);
          }
        });
  } // public void SpelersCombo(int ronde)
 @SuppressWarnings("serial")
 private void initGUI() {
   try {
     setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
     getContentPane().setLayout(null);
     this.setTitle("Overzicht");
     this.setVisible(true);
     {
       lStart = new JLabel();
       getContentPane().add(lStart);
       lStart.setText("Overzicht");
       lStart.setHorizontalAlignment(SwingConstants.CENTER);
       lStart.setBackground(new java.awt.Color(54, 190, 54));
       lStart.setFont(new java.awt.Font("Arial", 1, 36));
       lStart.setForeground(new java.awt.Color(0, 128, 64));
       lStart.setOpaque(true);
       lStart.setBounds(0, 0, 336, 49);
     }
     {
       pInzet = new JPanel();
       getContentPane().add(pInzet);
       pInzet.setBorder(
           BorderFactory.createTitledBorder(
               null,
               "Selectie",
               TitledBorder.LEADING,
               TitledBorder.DEFAULT_POSITION,
               new java.awt.Font("Tahoma", 1, 11)));
       pInzet.setLayout(null);
       pInzet.setBounds(14, 63, 308, 105);
       pInzet.setFont(new java.awt.Font("Tahoma", 1, 12));
       {
         lMin = new JLabel();
         pInzet.add(lMin);
         lMin.setText("Speler");
         lMin.setFont(new java.awt.Font("Arial", 0, 12));
         lMin.setBounds(17, 59, 62, 27);
       }
       {
         lMax = new JLabel();
         pInzet.add(lMax);
         lMax.setText("Spelronde");
         lMax.setFont(new java.awt.Font("Arial", 0, 12));
         lMax.setBounds(17, 26, 62, 25);
       }
       // Combo voor Spelrondes. Deze wordt eerst geladen. Na selectie
       // wordt de speler gevuld.
       {
         oc = new OverzichtController(this);
         String[] rondes = oc.GeefSpelrondes();
         ComboBoxModel cbSpelRondeModel = new DefaultComboBoxModel(rondes);
         cbSpelRonde = new JComboBox();
         pInzet.add(cbSpelRonde);
         cbSpelRonde.setModel(cbSpelRondeModel);
         cbSpelRonde.setBounds(91, 29, 156, 21);
         cbSpelRonde.setToolTipText("Maak een keuze uit de gespeelde speelronden.");
       }
       {
         bStart = new JButton();
         getContentPane().add(bStart);
         bStart.setText("Sluiten");
         bStart.setFont(new java.awt.Font("Arial", 0, 12));
         bStart.setBounds(196, 303, 75, 23);
         bStart.addActionListener(
             new ActionListener() {
               public void actionPerformed(ActionEvent evt) {
                 bStartActionPerformed(evt);
               }
             });
       }
     }
     pack();
     this.setSize(352, 364);
   } catch (Exception e) {
     e.printStackTrace();
   }
 } // private void initGUI()
Esempio n. 3
0
  public static void main(String args[]) {
    // style that is necessary
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException e) {
    } catch (InstantiationException e) {
    } catch (IllegalAccessException e) {
    } catch (UnsupportedLookAndFeelException e) {
    }

    // Standard preparation for a frame
    fmain = new JFrame("Schedule Appointments"); // Create and name frame
    fmain.setSize(330, 375); // Set size to 400x400 pixels
    pane = fmain.getContentPane();
    pane.setLayout(null); // Apply null layout
    fmain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Close when X is clicked

    // controls and portions of Calendar
    lmonth = new JLabel("January");
    lyear = new JLabel("Change year:");
    cyear = new JComboBox();
    prev = new JButton("<<");
    next = new JButton(">>");
    canc = new JButton("Cancel");
    mcal =
        new DefaultTableModel() {
          public boolean isCellEditable(int rowIndex, int mColIndex) {
            return false;
          }
        };
    Cal = new JTable(mcal);
    scal = new JScrollPane(Cal);
    pcal = new JPanel(null);

    canc.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        });

    // action listeners for buttons and the like
    prev.addActionListener(new btnPrev_Action());
    next.addActionListener(new btnNext_Action());
    cyear.addActionListener(new cmbYear_Action());
    Cal.addMouseListener(new mouseCont());

    // Adding the elements to the pane
    pane.add(pcal);
    pcal.add(lmonth);
    pcal.add(cyear);
    pcal.add(prev);
    pcal.add(next);
    pcal.add(canc);
    pcal.add(scal);

    // Setting where the elements are on the pane
    pcal.setBounds(0, 0, 320, 335);
    lmonth.setBounds(160 - lmonth.getPreferredSize().width / 2, 25, 100, 25);
    canc.setBounds(10, 305, 80, 20);
    cyear.setBounds(215, 305, 100, 20);
    prev.setBounds(10, 25, 50, 25);
    next.setBounds(260, 25, 50, 25);
    scal.setBounds(10, 50, 300, 250);

    // Make frame visible
    fmain.setResizable(false);
    fmain.setVisible(true);

    // Inner workings for the day mechanism
    GregorianCalendar cal = new GregorianCalendar(); // Create calendar
    rday = cal.get(GregorianCalendar.DAY_OF_MONTH); // Get day
    rmonth = cal.get(GregorianCalendar.MONTH); // Get month
    ryear = cal.get(GregorianCalendar.YEAR); // Get year
    currentMonth = rmonth; // Match month and year
    currentYear = ryear;

    // Add days
    String[] days = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; // All of the days
    for (int i = 0; i < 7; i++) {
      mcal.addColumn(days[i]);
    }

    Cal.getParent().setBackground(Cal.getBackground()); // Set background

    // No resize/reorder
    Cal.getTableHeader().setResizingAllowed(false);
    Cal.getTableHeader().setReorderingAllowed(false);

    // Single cell selection
    Cal.setColumnSelectionAllowed(true);
    Cal.setRowSelectionAllowed(true);
    Cal.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // Set row/column count
    Cal.setRowHeight(38);
    mcal.setColumnCount(7);
    mcal.setRowCount(6);

    // Placing the dates in the cells
    for (int i = ryear - 100; i <= ryear + 100; i++) {
      cyear.addItem(String.valueOf(i));
    }

    // Refresh calendar
    refreshCalendar(rmonth, ryear); // Refresh calendar
  }