Example #1
0
  public OpenProjectListDialog(String name) {
    conn = SQLiteDBConnection.ConnecrDb();
    this.userName = name;

    setModalityType(ModalityType.APPLICATION_MODAL);
    setTitle("Open Project List");
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setLocationRelativeTo(null);
    setBounds(100, 100, 450, 250);

    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(null);

    projectList.setBounds(44, 46, 329, 108);
    contentPanel.add(projectList);
    String sql = "select * from Project where ProjectManager = ?;";
    try {
      pst = conn.prepareStatement(sql);
      pst.setString(1, userName);
      rs = pst.executeQuery();
      while (rs.next()) {
        projectList.add(rs.getString("ProjectName"));
      }
      rs.close();
      pst.close();

    } catch (Exception ex) {
      JOptionPane.showMessageDialog(null, ex);
    }

    JLabel lblNowYouHave = new JLabel("Now, you have the following projects: ");
    lblNowYouHave.setBounds(23, 11, 321, 14);
    contentPanel.add(lblNowYouHave);

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
    getContentPane().add(buttonPane, BorderLayout.SOUTH);

    JButton okButton = new JButton("OK");
    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String projectNam = projectList.getSelectedItem().toString();
            setProjectName(projectNam);
            // JOptionPane.showMessageDialog(null, "Project "+projectName+" Opened");
            dispose();
          }
        });
    okButton.setActionCommand("OK");
    buttonPane.add(okButton);
    getRootPane().setDefaultButton(okButton);
  }
Example #2
0
  /** @author Jesper Create the frame. */
  public LoadBookingW() {

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 451, 236);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JPanel panel = new JPanel();
    contentPane.add(panel, BorderLayout.CENTER);
    panel.setLayout(null);

    JButton btnCancel = new JButton("Cancel");
    btnCancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            selected = -1;
            latch.countDown();
          }
        });
    btnCancel.setBounds(12, 152, 71, 25);
    panel.add(btnCancel);

    listBookings = new List();
    listBookings.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            selected = listBookings.getSelectedIndex();
            latch.countDown();
          }
        });
    listBookings.setBounds(12, 41, 389, 99);
    panel.add(listBookings);

    JLabel lblReserveretSder = new JLabel("Bookings");
    lblReserveretSder.setFont(new Font("Tahoma", Font.PLAIN, 18));
    lblReserveretSder.setBounds(12, 13, 158, 22);
    panel.add(lblReserveretSder);
  }
Example #3
0
  private void setup() {
    setLayout(null);
    this.setSize(1200, 800);
    setBackground(Color.DARK_GRAY);
    list.setFont(new Font("Arial", Font.PLAIN, 24));
    list.setBounds(52, 118, 429, 501);

    selecionado1 = new Label("");
    selecionado1.setForeground(Color.WHITE);
    selecionado1.setFont(new Font("Dialog", Font.PLAIN, 18));
    selecionado1.setBounds(560, 128, 611, 43);
    add(selecionado1);

    PreencheGenero();
    add(list);

    logout = new JButton("Logout");
    logout.setBounds(1074, 673, 97, 25);
    logout.addActionListener(this);
    logout.setVisible(true);
    add(logout);

    autor = new JRadioButton("Autor");
    autor.setForeground(Color.WHITE);
    autor.setFont(new Font("Tahoma", Font.PLAIN, 18));
    autor.setSelected(false);
    autor.setBackground(Color.DARK_GRAY);
    autor.setBounds(52, 56, 127, 25);
    autor.addActionListener(this);
    add(autor);

    titulo = new JRadioButton("Trabalho artístico");
    titulo.setForeground(Color.WHITE);
    titulo.setFont(new Font("Tahoma", Font.PLAIN, 18));
    titulo.setBackground(Color.DARK_GRAY);
    titulo.setSelected(false);
    titulo.setBounds(275, 56, 181, 25);
    titulo.addActionListener(this);
    add(titulo);

    genero = new JRadioButton("Gênero");
    genero.setForeground(Color.WHITE);
    genero.setFont(new Font("Tahoma", Font.PLAIN, 18));
    genero.setBackground(Color.DARK_GRAY);
    genero.setSelected(true);
    genero.setBounds(499, 58, 127, 25);
    genero.addActionListener(this);
    add(genero);

    selecionado2 = new Label("");
    selecionado2.setForeground(Color.WHITE);
    selecionado2.setFont(new Font("Dialog", Font.PLAIN, 18));
    selecionado2.setBounds(560, 197, 611, 43);
    add(selecionado2);

    selecionado3 = new Label("");
    selecionado3.setForeground(Color.WHITE);
    selecionado3.setFont(new Font("Dialog", Font.PLAIN, 18));
    selecionado3.setBounds(560, 268, 611, 55);
    add(selecionado3);

    label = new Label("Selecione um Filtro");
    label.setForeground(Color.WHITE);
    label.setFont(new Font("Dialog", Font.PLAIN, 18));
    label.setBounds(52, 10, 611, 43);
    add(label);

    adicionar = new JButton("Adicionar");
    adicionar.setBounds(956, 673, 97, 25);
    adicionar.addActionListener(this);
    add(adicionar);

    Label logado = new Label("Selecione um Filtro");
    logado.setAlignment(Label.RIGHT);
    logado.setForeground(Color.WHITE);
    logado.setFont(new Font("Dialog", Font.PLAIN, 18));
    logado.setBounds(722, 10, 449, 43);
    logado.setText("Olá, " + Main.user.getNome());
    add(logado);
  }
Example #4
0
 /**
  * 新增視窗物件 設定物件屬性 內容
  *
  * @param o 物件instances
  * @param reg 物件位置
  * @param name 物件名稱
  * @param value 物件標籤 或 內容
  */
 protected void addObject(Object o, Rectangle reg, String name, String value) {
   if (o instanceof Label) {
     ((Label) o).setText(value);
     ((Label) o).setName(name);
     ((Label) o).setBounds(reg);
     ((Label) o).addMouseListener(this);
     this.add((Label) o);
   } else if (o instanceof TextField) {
     ((TextField) o).setText(value);
     ((TextField) o).setName(name);
     ((TextField) o).setBounds(reg);
     ((TextField) o).addMouseListener(this);
     ((TextField) o).addTextListener(this);
     ((TextField) o).addKeyListener(this);
     if (value.equalsIgnoreCase("password")) ((TextField) o).setEchoChar('*');
     this.add((TextField) o);
   } else if (o instanceof Button) {
     int len = (int) ((float) reg.width / FONTWIDTH);
     ((Button) o).setLabel(StringUtil_.splitStringSpace(value, len));
     ((Button) o).setName(name);
     ((Button) o).setBounds(reg);
     ((Button) o).addMouseListener(this);
     this.add((Button) o);
   } else if (o instanceof TextArea) {
     ((TextArea) o).setText(value);
     ((TextArea) o).setName(name);
     ((TextArea) o).setBounds(reg);
     ((TextArea) o).addMouseListener(this);
     ((TextArea) o).addTextListener(this);
     ((TextArea) o).addKeyListener(this);
     this.add((TextArea) o);
   } else if (o instanceof Choice) {
     String[] values = value.split(",");
     for (int ii = 0; ii < values.length; ii++) ((Choice) o).addItem(values[ii]);
     ((Choice) o).setName(name);
     ((Choice) o).setBounds(reg);
     ((Choice) o).addMouseListener(this);
     ((Choice) o).addItemListener(this);
     this.add((Choice) o);
   } else if (o instanceof Checkbox) {
     ((Checkbox) o).setLabel(value);
     ((Checkbox) o).setName(name);
     ((Checkbox) o).setBounds(reg);
     ((Checkbox) o).addMouseListener(this);
     ((Checkbox) o).addItemListener(this);
     this.add((Checkbox) o);
   } else if (o instanceof CheckboxGroup) {
     String[] values = value.split(",");
     for (int ii = 0; ii < values.length; ii++) {
       Checkbox chk = new Checkbox();
       chk.setLabel(values[ii]);
       chk.setName(name + ii);
       chk.setBounds(reg);
       reg.y += 25;
       chk.addMouseListener(this);
       chk.addItemListener(this);
       chk.setCheckboxGroup((CheckboxGroup) o);
       this.add(chk);
     }
   } else if (o instanceof List) {
     String[] values = value.split(",");
     ((List) o).setName(name);
     ((List) o).setBounds(reg);
     ((List) o).addMouseListener(this);
     ((List) o).addItemListener(this);
     for (int ii = 0; ii < values.length; ii++) ((List) o).add(values[ii]);
     this.add(((List) o));
   }
 }