コード例 #1
0
  private JTable createTabla(DefaultTableModel tableModel) {
    JTable table = new JTable();
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setCellSelectionEnabled(false);
    table.setColumnSelectionAllowed(false);
    table.setModel(tableModel);
    table.setRowSelectionAllowed(true);

    table.getColumnModel().getColumn(0).setResizable(false);
    table.getColumnModel().getColumn(0).setPreferredWidth(75);
    table.getColumnModel().getColumn(0).setMinWidth(75);
    table.getColumnModel().getColumn(0).setMaxWidth(75);
    table.getColumnModel().getColumn(1).setResizable(false);
    table.getColumnModel().getColumn(1).setPreferredWidth(125);
    table.getColumnModel().getColumn(1).setMinWidth(125);
    table.getColumnModel().getColumn(1).setMaxWidth(125);
    table.getColumnModel().getColumn(2).setPreferredWidth(50);
    table.getColumnModel().getColumn(2).setMinWidth(50);
    table.getColumnModel().getColumn(2).setMaxWidth(50);
    table.getColumnModel().getColumn(3).setPreferredWidth(85);
    table.getColumnModel().getColumn(3).setMinWidth(85);
    table.getColumnModel().getColumn(3).setMaxWidth(85);
    table.setBounds(10, 420, 350, 125);
    return table;
  }
コード例 #2
0
  public PretragaProzor(String pretraga, String vrednost) {
    super(615, 540);

    table = new JTable();
    table.setShowVerticalLines(false);
    table.setEnabled(false);
    model =
        new DefaultTableModel(
            new Object[][] {},
            new String[] {"Bar kod", "Naziv", "Cena", "Popust", "Kategorija", "Količina"});
    table.setModel(model);
    table.setBounds(0, 0, 600, 500);
    layeredPane.add(table);
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setBounds(0, 0, 600, 500);
    layeredPane.add(scrollPane);
    ArrayList<Artikal> artikli = (ArrayList<Artikal>) Artikal.ucitajSve(pretraga + vrednost);
    for (int i = 0; i < artikli.size(); i++) {
      String[] artikalString =
          new String[] {
            String.valueOf(artikli.get(i).getBarKod()),
            artikli.get(i).getNaziv(),
            String.valueOf(artikli.get(i).getCena()),
            String.valueOf(artikli.get(i).getPopust()),
            artikli.get(i).getKategorija(),
            String.valueOf(artikli.get(i).getKolicina())
          };
      model.addRow(artikalString);
    }
  }
コード例 #3
0
 private void table() {
   table = new JTable();
   table.setShowVerticalLines(false);
   table.setEnabled(false);
   model =
       new DefaultTableModel(
           new Object[][] {}, new String[] {"Bar kod", "Naziv", "Cena", "Kategorija", "Količina"});
   table.setModel(model);
   table.setBounds(10, 110, 500, 350);
   Iterator<Artikal> artikli = snabdevac.getArtikli().iterator(); // Popunjavanje tabele
   while (artikli.hasNext()) {
     Artikal a = artikli.next();
     String[] s =
         new String[] {
           String.valueOf(a.getBarKod()),
           a.getNaziv(),
           String.valueOf((a.getCena() - a.getPopust())),
           a.getKategorija(),
           String.valueOf(a.getKolicina())
         };
     model.addRow(s);
   }
   layeredPane.add(table);
   JScrollPane scrollPane = new JScrollPane(table);
   scrollPane.setBounds(10, 110, 500, 350);
   layeredPane.add(scrollPane);
 }
コード例 #4
0
ファイル: FriendList.java プロジェクト: Fsig/Underground-IM
  /** Constructor. */
  public FriendList() {
    this.setIconImage(Constants.icon);
    this.setTitle("Underground IM");
    this.setSize(300, 400);
    this.setLocationRelativeTo(null);
    this.setResizable(true);
    this.setJMenuBar(menuBar.getMenuBar());

    // Friend List
    friendListData =
        new DefaultTableModel(new Object[0][0], new String[] {"Status", "Friends"}) {
          private static final long serialVersionUID = -3666163903937562582L;

          @Override
          public boolean isCellEditable(int a, int b) {
            return false;
          }
        };

    friendList = new JTable(friendListData);
    friendList.setBounds(0, 0, getWidth() - 15, getHeight() - 60);
    friendList.setFont(new Font("Arial", Font.PLAIN, 12));
    friendList.getColumnModel().getColumn(0).setCellRenderer(new ImageRenderer());

    friendListContainer =
        new JScrollPane(
            friendList,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    friendListContainer.setBounds(0, 0, getWidth() - 15, getHeight() - 90);

    // Add components
    this.add(friendListContainer);

    popupMenu = new PopupMenu(null, friendList);

    TrayIcon trayIcon = null;
    if (SystemTray.isSupported()) {
      this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      SystemTray tray = SystemTray.getSystemTray();
      Image image = Constants.iconTray;

      ActionListener listener =
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {}
          };

      trayIcon = new TrayIcon(image, "Underground IM", popupMenu.getTrayMenu());
      trayIcon.addActionListener(listener);

      try {
        tray.add(trayIcon);
      } catch (AWTException e) {
        System.err.println(e);
      }
    } else {
      this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }
  }
コード例 #5
0
  public ViewTelaEscolhaAtividade() {

    setTitle("Check In/ Check Out");
    setBounds(100, 100, 735, 466);

    JPanel panel = new JPanel();
    panel.setBackground(new Color(255, 255, 255));
    getContentPane().add(panel, BorderLayout.CENTER);
    panel.setLayout(null);

    textField_PesquisarAtividade = new JTextField();
    textField_PesquisarAtividade.setBounds(85, 28, 487, 19);
    panel.add(textField_PesquisarAtividade);
    textField_PesquisarAtividade.setColumns(10);

    btnPesquisar = new JButton("Pesquisar");
    btnPesquisar.setBounds(584, 25, 117, 25);
    panel.add(btnPesquisar);

    table_AtividadeParticipante = new JTable();
    table_AtividadeParticipante.setBackground(new Color(50, 205, 50));
    table_AtividadeParticipante.setBounds(12, 59, 564, 351);

    table_AtividadeParticipante.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    table_AtividadeParticipante =
        new JTable() {
          @Override
          public boolean isCellEditable(int row, int column) {
            return false;
          }
        };

    btnCheckIn = new JButton("Check In");
    btnCheckIn.setBounds(584, 62, 117, 25);
    panel.add(btnCheckIn);

    btnCheckIn.setEnabled(false);

    btnCheckOut = new JButton("Check Out");
    btnCheckOut.setBounds(584, 99, 117, 25);
    panel.add(btnCheckOut);

    btnCheckOut.setEnabled(false);

    btnVoltar = new JButton("Voltar");
    btnVoltar.setBounds(596, 385, 117, 25);
    panel.add(btnVoltar);

    lblAtividade = new JLabel("Atividade:");
    lblAtividade.setBounds(12, 30, 87, 15);
    panel.add(lblAtividade);

    JScrollPane scrollPane = new JScrollPane(table_AtividadeParticipante);
    scrollPane.setBounds(12, 60, 560, 350);
    panel.add(scrollPane);

    this.setVisible(true);
  }
コード例 #6
0
 public void setBounds(final int x, final int y, final int width, final int height) {
   super.setBounds(x, y, width, height);
   final int portion = width / 100;
   int widthSum = 0;
   for (DataTableFieldWrapper field : this.colMetaData.values()) {
     final int colNum = field.getColNum();
     final TableColumn column = this.getColumnModel().getColumn(colNum);
     column.setPreferredWidth(field.getPreferredWidth() * portion);
     widthSum = widthSum + field.getPreferredWidth();
   }
   if (widthSum != 100) {
     LOG.error("Sum of column width is expected to be 100, now its " + widthSum);
   }
 }
コード例 #7
0
ファイル: Jtable1.java プロジェクト: kamalrana/Test
  public static void main(String args[]) {
    String[] columnNames = {"Name", "Lastname", "Id", "Style"};
    mysTable = new JTable(100, 3);
    mysTable.setBounds(20, 10, 300, 300);

    JFrame frame = new JFrame("King Musa Saloon Software");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(null);
    frame.setSize(500, 500);
    frame.setResizable(false);
    frame.setVisible(true);
    frame.add(mysTable);

    // frame.add(mysTable);
    try {
      Class.forName("org.sqlite.JDBC");
      System.out.println("Driver loading success!");
      String url = "jdbc:sqlite:d:/sqlite/testDB.db";
      String name = "";
      String password = "";
      try {

        java.sql.Connection con = DriverManager.getConnection(url, name, password);
        System.out.println("Connected.");
        // pull data from the database
        java.sql.Statement stmts = null;
        String query = "select  date, level, message from Test1 limit 100";
        stmts = con.createStatement();
        ResultSet rs = stmts.executeQuery(query);
        int li_row = 0;
        while (rs.next()) {
          mysTable.setValueAt(rs.getString("date"), li_row, 0);
          mysTable.setValueAt(rs.getString("level"), li_row, 1);
          mysTable.setValueAt(rs.getString("message"), li_row, 2);
          //    int userid = rs.getInt("userid");
          //    String username = rs.getString("username");
          //    String name1     = rs.getString("name");
          //    System.out.println(name1);
          li_row++;
        }

      } catch (SQLException e) {
        e.printStackTrace();
      }

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
  }
コード例 #8
0
ファイル: ScheduleTable.java プロジェクト: Coder-Wangk/TTMS
  // 创建JTable
  public void createTable(JScrollPane jp, Object[] columnNames, List<Schedule> scheduleList) {
    try {

      Object data[][] = new Object[scheduleList.size()][columnNames.length];

      Iterator<Schedule> itr = scheduleList.iterator();
      int i = 0;
      while (itr.hasNext()) {
        Schedule schedule = itr.next();
        data[i][0] = schedule.getSched_id();
        data[i][1] = studioSrv.Fetch("studio_id = " + schedule.getStudio_id()).get(0).getName();
        data[i][2] = playSrv.Fetch("play_id = " + schedule.getPlay_id()).get(0).getName();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date = df.format(schedule.getSched_time());
        data[i][3] = date;
        data[i][4] = schedule.getSched_ticket_price();
        i++;
      }

      // 生成JTable
      jt = new JTable(data, columnNames);
      jt.setBounds(0, 0, 700, 450);

      // 添加鼠标监听,监听到所选行
      ScheduleTableMouseListener tml = new ScheduleTableMouseListener(jt, columnNames, schedule);
      jt.addMouseListener(tml);

      // 设置可调整列宽
      jt.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

      jp.add(jt);
      jp.setViewportView(jt);

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #9
0
ファイル: ViewOperateUI.java プロジェクト: Goldenbullet/Code
  private void initPanel(int index) {

    JPanel p = panelList[index];
    p.setLayout(null);
    getdocs(index);

    String[] head = {"收款日期", "收款金额", "付款日期", "付款金额", "付款条目"};

    DefaultTableModel tableModel = new DefaultTableModel(docs, head);
    JTable operatetable = new JTable(tableModel);
    operatetable.getTableHeader().setFont(f);
    operatetable.setRowHeight(40);

    operatetable.setFont(f);
    operatetable.setBounds(2, 0, tablewidth - 7, tableheight - 30);
    // logtable.setBorder(BorderFactory.createEtchedBorder());
    // this.add(logtable);

    JScrollPane scrollPane = new JScrollPane(operatetable);
    scrollPane.setFont(font);
    // scrollPane.setViewportView(logtable);
    scrollPane.setBounds(2, 0, tablewidth - 7, tableheight - 30);
    p.add(scrollPane);
  }
コード例 #10
0
  public RedigerKategori() {

    this.setBackground(new Color(51, 161, 201));
    setLayout(null);

    JLabel TilføjKategori = new JLabel("Rediger Kategori");
    TilføjKategori.setIcon(
        new ImageIcon(TilføjVare.class.getResource("/presentation/resources/add32.png")));
    TilføjKategori.setFont(new Font("sansserif", Font.BOLD, 24));
    TilføjKategori.setForeground(Color.black);
    TilføjKategori.setBounds(30, 30, 250, 30);
    this.add(TilføjKategori);

    JLabel TilføjKategorinavn = new JLabel("Kategorinavn:");
    TilføjKategorinavn.setFont(new Font("Tahoma", Font.PLAIN, 12));
    TilføjKategorinavn.setBounds(140, 90, 140, 20);
    TilføjKategorinavn.setForeground(Color.black);
    add(TilføjKategorinavn);

    kategorinavnText = new JTextField();
    kategorinavnText.setBounds(230, 90, 300, 20);
    add(kategorinavnText);

    Button sletKategori = new Button("Slet");
    sletKategori.setBackground(new Color(255, 215, 10));
    sletKategori.setBounds(380, 160, 70, 22);
    sletKategori.setForeground(Color.black);
    add(sletKategori);

    sletKategori.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            controller.slet();
          }
        });

    Button TilføjKategori1 = new Button("Gem");
    TilføjKategori1.setBackground(new Color(255, 215, 10));
    TilføjKategori1.setBounds(460, 160, 70, 22);
    TilføjKategori1.setForeground(Color.black);
    add(TilføjKategori1);

    Ktable1 = new JTable();
    Ktable1.setBounds(12, 10, 710, 57);
    Ktable1.setBackground(new Color(238, 238, 238));
    add(Ktable1);

    JLabel TilføjOverKategori = new JLabel("Over kategori:");
    TilføjOverKategori.setFont(new Font("Tahoma", Font.PLAIN, 12));
    TilføjOverKategori.setBounds(140, 120, 140, 20);
    TilføjOverKategori.setForeground(Color.black);
    add(TilføjOverKategori);

    TilføjKategori1.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            System.out.println(controller);
            controller.updateKategori(kategorinavnText, combobox1);
          }
        });

    combobox1 = new JComboBox<String>();
    combobox1.setBounds(230, 120, 300, 20);
    add(combobox1);

    Ktable = new JTable();
    Ktable.setBounds(12, 71, 710, 405);
    Ktable.setBackground(new Color(238, 238, 238));
    add(Ktable);
  }
コード例 #11
0
  public ScoreGameTableScreen(ArrayList<Player> scoreTable, final Integer userType) {
    setTitle(LoginScreen.getTitleGame());
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            if (userType == 0) {
              AdminMenuScreen adminmenuscreen = new AdminMenuScreen();
              adminmenuscreen.setVisible(true);
            } else {
              UserMenuScreen usermenuscreen = new UserMenuScreen();
              usermenuscreen.setVisible(true);
            }
            setVisible(false);
          }
        });
    setBounds(100, 100, 352, 526);
    setLocationRelativeTo(null);
    setResizable(false);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    JLabel lblTablaDePuntuaciones = new JLabel("Tabla de puntuaciones de la partida");
    lblTablaDePuntuaciones.setFont(new Font("Verdana", Font.BOLD, 15));
    lblTablaDePuntuaciones.setBounds(21, 21, 327, 35);
    contentPane.add(lblTablaDePuntuaciones);

    table = new JTable();
    table.setShowGrid(false);
    table.setRowSelectionAllowed(false);
    table.setToolTipText("");
    table.setBackground(SystemColor.control);
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.setModel(
        new DefaultTableModel(
            new Object[][] {
              {null}, {null}, {null},
            },
            new String[] {"Puntuaci\u00F3n"}));
    table.setBounds(52, 110, 239, 201);

    tableModel.addColumn("Jugador");
    tableModel.addColumn("Puntuación");

    table.setRowHeight(30);
    for (int i = 0; i < scoreTable.size() && i < 10; i++) {
      if (!scoreTable.get(i).disconnectedWhilePlaying())
        tableModel.addRow(
            new String[] {scoreTable.get(i).getName(), scoreTable.get(i).getScore().toString()});
      else tableModel.addRow(new String[] {scoreTable.get(i).getName(), "Desconectado"});
    }

    table.setModel(tableModel);
    centerRenderer.setHorizontalAlignment(JLabel.CENTER);
    table.getColumnModel().getColumn(0).setCellRenderer(centerRenderer);
    table.getColumnModel().getColumn(1).setCellRenderer(centerRenderer);
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    header.setResizingAllowed(false);

    JPanel panel = new JPanel();
    panel.setBounds(34, 75, 264, 343);
    panel.setLayout(new BorderLayout(0, 0));
    panel.add(header, BorderLayout.NORTH);
    panel.add(table, BorderLayout.CENTER);

    contentPane.add(panel);

    JButton btnVolverAlMen = new JButton("Volver al men\u00FA principal");
    btnVolverAlMen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (userType == 0) {
              AdminMenuScreen adminmenuscreen = new AdminMenuScreen();
              adminmenuscreen.setVisible(true);
            } else {
              UserMenuScreen usermenuscreen = new UserMenuScreen();
              usermenuscreen.setVisible(true);
            }
            setVisible(false);
          }
        });
    btnVolverAlMen.setBounds(135, 453, 180, 23);
    contentPane.add(btnVolverAlMen);
  }
コード例 #12
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Windows".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception e) {
    }

    frmReporteDeVentas = new JFrame();
    frmReporteDeVentas.setResizable(false);
    frmReporteDeVentas.setTitle("Reporte de Ventas");
    frmReporteDeVentas.setBounds(100, 100, 768, 543);
    frmReporteDeVentas.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frmReporteDeVentas.getContentPane().setLayout(null);

    JLabel lblNewLabel_1 = new JLabel(PedidoDTO.generarFechaForm());
    lblNewLabel_1.setBounds(10, 0, 200, 50);
    frmReporteDeVentas.getContentPane().add(lblNewLabel_1);

    JButton btnNewButton = new JButton("Cerrar");
    btnNewButton.setBounds(625, 472, 89, 23);
    btnNewButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            frmReporteDeVentas.dispose();
          }
        });
    frmReporteDeVentas.getContentPane().add(btnNewButton);

    JLabel label_1 = new JLabel("Ingresos:");
    label_1.setBounds(453, 55, 200, 50);
    label_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
    frmReporteDeVentas.getContentPane().add(label_1);

    JSeparator separator = new JSeparator();
    separator.setBounds(36, 449, 709, 12);
    frmReporteDeVentas.getContentPane().add(separator);

    lblNewLabel_3 = new JLabel("0");
    lblNewLabel_3.setBounds(537, 55, 95, 50);
    lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 15));
    frmReporteDeVentas.getContentPane().add(lblNewLabel_3);

    JButton btnNewButton_1 = new JButton("Generar Contabilidad");
    btnNewButton_1.setBounds(36, 406, 166, 32);
    btnNewButton_1.setFont(new Font("Tahoma", Font.PLAIN, 13));
    btnNewButton_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {

            mapA = new HashMap();
            mapA.put("Monday", "Sunday");
            mapA.put("Tuesday", "Monday");
            mapA.put("Wednesday", "Tuesday");
            mapA.put("Thursday", "Wednesday");
            mapA.put("Friday", "Thursday");
            mapA.put("Saturday", "Friday");
            mapA.put("Sunday", "Saturday");

            mapB = new HashMap();
            mapB.put("Monday", "Tuesday");
            mapB.put("Tuesday", "Wednesday");
            mapB.put("Wednesday", "Thursday");
            mapB.put("Thursday", "Friday");
            mapB.put("Friday", "Saturday");
            mapB.put("Saturday", "Sunday");
            mapB.put("Sunday", "Monday");

            ingreso = 0;
            limpiaTablaIngreso();

            if (rdbtnDiario.isSelected()) {
              SimpleDateFormat FormatoDia = new SimpleDateFormat("dd");
              SimpleDateFormat FormatoMes = new SimpleDateFormat("MM");
              // traer ingresos
              List<PedidoDTO> pedidos = new ArrayList<>();
              pedidos =
                  PedidoDAO.obtenerPedidosPorUnDia(
                      "2015"
                          + "-"
                          + FormatoMes.format(dayChooser.getDate())
                          + "-"
                          + FormatoDia.format(dayChooser.getDate()));

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

                double cantidad = pedidos.get(i).getTotal();
                int nombre = pedidos.get(i).getIdDia();
                String fecha = pedidos.get(i).getFecha();

                ingreso = ingreso + cantidad;

                lblNewLabel_3.setText(Double.toString(ingreso));

                Object[] fila = {String.valueOf(nombre), fecha, String.valueOf(cantidad)};
                modelIngresos.addRow(fila);
              }

            } else if (rdbtnSemanal.isSelected()) {

              SimpleDateFormat Formato = new SimpleDateFormat("yyyy-MM-dd");
              SimpleDateFormat FormatoDia = new SimpleDateFormat("dd");
              SimpleDateFormat FormatoMes = new SimpleDateFormat("MM");
              SimpleDateFormat FormatoAnio = new SimpleDateFormat("yyyy");

              int diaComienzoSemana = Integer.valueOf(FormatoDia.format(calendar.getDate()));
              int diaFinSemana = Integer.valueOf(FormatoDia.format(calendar.getDate()));

              Calendar calendario = Calendar.getInstance();
              calendario.set(
                  2015,
                  Integer.valueOf(FormatoMes.format(calendar.getDate())) - 1,
                  Integer.valueOf(FormatoDia.format(calendar.getDate())));
              Date date = calendario.getTime();
              String diaComienzoz =
                  new SimpleDateFormat("EEEE", Locale.ENGLISH).format(calendario.getTime());
              String diaFinz =
                  new SimpleDateFormat("EEEE", Locale.ENGLISH).format(calendario.getTime());

              int ultimoDiaMes = calendario.getActualMaximum(Calendar.DAY_OF_MONTH);

              if (!diaComienzoz.equals("Monday")) {
                while ("Monday" != diaComienzoz) {
                  diaComienzoz = (String) mapA.get(diaComienzoz);
                  if (diaComienzoSemana <= 1) {
                    diaComienzoSemana = 1;
                    break;
                  }

                  diaComienzoSemana--;
                }
              }

              int diaDesde = diaComienzoSemana;

              if (!diaFinz.equals("Sunday")) {
                while ("Sunday" != diaFinz) {
                  diaFinz = (String) mapB.get(diaFinz);
                  if (diaFinSemana >= ultimoDiaMes) {
                    diaFinSemana = ultimoDiaMes;
                    break;
                  }
                  diaFinSemana++;
                }
                // if(diaComienzoSemana == 1 && diaComienzoz == "Sunday"){
                //	diaFinSemana = 1;
                // }

              }

              int diaHasta = diaFinSemana;

              Calendar calendarioDesde = Calendar.getInstance();
              calendarioDesde.set(
                  2015, Integer.valueOf(FormatoMes.format(calendar.getDate())) - 1, diaDesde);

              Calendar calendarioHasta = Calendar.getInstance();
              calendarioHasta.set(
                  2015, Integer.valueOf(FormatoMes.format(calendar.getDate())) - 1, diaHasta);

              List<PedidoDTO> pedidos = new ArrayList<>();

              pedidos =
                  PedidoDAO.obtenerPedidosPorFecha(
                      Formato.format(calendarioDesde.getTime()),
                      Formato.format(calendarioHasta.getTime()));

              for (int i = 0; i < pedidos.size(); i++) {
                double cantidad = pedidos.get(i).getTotal();
                int nombre = pedidos.get(i).getIdDia();
                String fecha = pedidos.get(i).getFecha();

                ingreso = ingreso + cantidad;

                lblNewLabel_3.setText(Double.toString(ingreso));

                Object[] fila = {String.valueOf(nombre), fecha, String.valueOf(cantidad)};
                modelIngresos.addRow(fila);
              }

              // primer dia de la semana

              // ultimo dia de la semana

            } else {
              // traer ingresos
              List<PedidoDTO> pedidos = new ArrayList<>();

              String desde =
                  yearChooser.getYear() + "-" + (monthChooser.getMonth() + 1) + "-" + "01";

              SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
              try {
                Date fecha = dateFormat.parse(desde);
              } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
              Calendar cal = Calendar.getInstance();
              cal.set(Calendar.MONTH, monthChooser.getMonth());
              Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH);

              String hasta =
                  yearChooser.getYear()
                      + "-"
                      + (monthChooser.getMonth() + 1)
                      + "-"
                      + cal.getActualMaximum(Calendar.DAY_OF_MONTH);

              pedidos = PedidoDAO.obtenerPedidosPorFecha(desde, hasta);

              for (int i = 0; i < pedidos.size(); i++) {
                double cantidad = pedidos.get(i).getTotal();
                int nombre = pedidos.get(i).getIdDia();
                String fecha = pedidos.get(i).getFecha();

                ingreso = ingreso + cantidad;

                lblNewLabel_3.setText(Double.toString(ingreso));

                Object[] fila = {String.valueOf(nombre), fecha, String.valueOf(cantidad)};
                modelIngresos.addRow(fila);
              }
            }

            /*




            // traer ingresos
            List<PedidoDTO> pedidos = new ArrayList<>();
            pedidos = PedidoDAO.obtenerPedidosPorFecha(getFecha(dateChooser), getFecha(dateChooser_1));

            for (int i=0; i<pedidos.size();i++)
            {
            	System.out.print("i" + i);
            	double cantidad= pedidos.get(i).getTotal();
            	int nombre= pedidos.get(i).getIdPedido();
            	String fecha= pedidos.get(i).getFecha();

            	ingreso = ingreso + cantidad  ;

            	lblNewLabel_3.setText(Double.toString(ingreso));

            	Object[] fila = {String.valueOf(nombre), fecha, String.valueOf(cantidad)};
            	modelIngresos.addRow(fila);

            }

            System.out.print(ingreso);

            */

          }
        });
    frmReporteDeVentas.getContentPane().add(btnNewButton_1);

    modelIngresos =
        new DefaultTableModel(null, columnas) {
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
          }
        };
    modelEgresos =
        new DefaultTableModel(null, columnas2) {
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
          }
        };

    // Tabla a
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBackground(Color.WHITE);
    scrollPane.setBounds(453, 116, 235, 243);
    frmReporteDeVentas.getContentPane().add(scrollPane);

    modelIngresos =
        new DefaultTableModel(null, columnas) {
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
          }
        };

    table = new JTable(modelIngresos);
    table.setBounds(239, 114, 203, 200);
    frmReporteDeVentas.getContentPane().add(scrollPane);
    scrollPane.setViewportView(table);

    rdbtnDiario = new JRadioButton("Diario");
    rdbtnDiario.setSelected(true);
    rdbtnDiario.setBounds(36, 119, 73, 23);
    frmReporteDeVentas.getContentPane().add(rdbtnDiario);

    rdbtnSemanal = new JRadioButton("Semanal");
    rdbtnSemanal.setBounds(36, 224, 73, 32);
    frmReporteDeVentas.getContentPane().add(rdbtnSemanal);

    rdbtnMensual = new JRadioButton("Mensual");
    rdbtnMensual.setBounds(36, 336, 79, 23);
    frmReporteDeVentas.getContentPane().add(rdbtnMensual);

    ButtonGroup group = new ButtonGroup();
    group.add(rdbtnDiario);
    group.add(rdbtnSemanal);
    group.add(rdbtnMensual);

    monthChooser = new JMonthChooser();
    monthChooser.setBounds(147, 336, 99, 20);
    frmReporteDeVentas.getContentPane().add(monthChooser);

    yearChooser = new JYearChooser();
    yearChooser.setBounds(253, 336, 47, 20);
    frmReporteDeVentas.getContentPane().add(yearChooser);

    dayChooser = new JCalendar();
    dayChooser.getDayChooser().setBorder(new LineBorder(new Color(0, 0, 0)));
    dayChooser.getDayChooser().getDayPanel().setBackground(Color.WHITE);
    dayChooser.setBounds(143, 50, 184, 130);
    frmReporteDeVentas.getContentPane().add(dayChooser);

    calendar = new JCalendar();
    calendar.getDayChooser().setBorder(new LineBorder(new Color(0, 0, 0)));
    calendar.getDayChooser().getDayPanel().setBackground(Color.WHITE);
    calendar.setBounds(143, 190, 184, 130);
    frmReporteDeVentas.getContentPane().add(calendar);

    // calendar.setBackground(getForeground());

    this.frmReporteDeVentas.setVisible(true);
  }
コード例 #13
0
ファイル: TelaSentencas.java プロジェクト: Gubetti/tempia
  /** Create the dialog. */
  public TelaSentencas(Regra regraEdit) {
    telaSentencas = this;
    textField = new JTextField();
    if (regraEdit == null) {
      regraInserir = new Regra();
      this.setTitle("Inserir regra");
    } else {
      regraEditar = regraEdit;
      textField.setText(regraEdit.getDescricao());
      copiarRegraEdit();
      this.setTitle("Editar regra");
    }

    this.setBounds(100, 100, 600, 400);
    this.setResizable(false);
    this.getContentPane().setLayout(null);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    this.setModal(true);
    int larguraMaxima = this.getWidth() - 8;
    int alturaMaxima = this.getHeight() - 35;
    int larguraPanelNome = 350;
    int alturaPanelNome = 60;
    int larguraPanelOkCancela = larguraMaxima - larguraPanelNome;
    int larguraPanelBotoes = 120;
    int alturaPremissas = alturaMaxima - alturaPanelNome;
    int larguraPremissas = (larguraMaxima - larguraPanelBotoes) / 2;
    int alturaBotao = 23;
    int larguraBotao = 89;
    int yBotaoOkCancela = (alturaPanelNome / 2) - (alturaBotao / 2);
    int espacamentoBotoes = 15;
    int xBotaoOk = (larguraPanelOkCancela - (larguraBotao * 2) - espacamentoBotoes) / 2;
    int xBotaoCancela = xBotaoOk + larguraBotao + espacamentoBotoes;
    int alturaLblDescricao = 14;
    int larguraLblDescricao = 46;
    int alturaTfDescricao = 20;
    int larguraTfDescricao = 250;
    int yLblDescricao = (alturaPanelNome - alturaLblDescricao) / 2;
    int xLblDescricao =
        (larguraPanelNome - larguraLblDescricao - larguraTfDescricao - espacamentoBotoes) / 2;
    int yTfDescricao = (alturaPanelNome - alturaTfDescricao) / 2;
    int xTfDescricao = xLblDescricao + larguraLblDescricao + espacamentoBotoes;

    JPanel panelNome = new JPanel();
    panelNome.setBounds(0, 0, larguraPanelNome, alturaPanelNome);
    this.getContentPane().add(panelNome);
    panelNome.setLayout(null);

    JLabel lblDescricao = new JLabel("Descrição");
    lblDescricao.setBounds(xLblDescricao, yLblDescricao, larguraLblDescricao, alturaLblDescricao);
    lblDescricao.setSize(lblDescricao.getPreferredSize());
    panelNome.add(lblDescricao);

    textField.setBounds(xTfDescricao, yTfDescricao, larguraTfDescricao, alturaTfDescricao);
    panelNome.add(textField);
    textField.setColumns(10);

    JPanel panelOkCancela = new JPanel();
    panelOkCancela.setBounds(larguraPanelNome, 0, larguraPanelOkCancela, alturaPanelNome);
    this.getContentPane().add(panelOkCancela);
    panelOkCancela.setLayout(null);

    JButton btnSalvar = new JButton("Salvar");
    btnSalvar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            salvar();
          }
        });
    btnSalvar.setBounds(xBotaoOk, yBotaoOkCancela, larguraBotao, alturaBotao);
    panelOkCancela.add(btnSalvar);

    JButton btnCancelar = new JButton("Cancelar");
    btnCancelar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cancelar();
          }
        });
    btnCancelar.setBounds(xBotaoCancela, yBotaoOkCancela, larguraBotao, alturaBotao);
    panelOkCancela.add(btnCancelar);

    JPanel panelPremissas = new JPanel();
    panelPremissas.setBounds(0, alturaPanelNome, larguraPremissas, alturaPremissas);
    this.getContentPane().add(panelPremissas);
    panelPremissas.setLayout(null);

    List<Sentenca> premissas;
    List<Sentenca> conclusoes;
    if (regraEdit == null) {
      premissas = regraInserir.getPremissas();
      conclusoes = regraInserir.getConclusoes();
    } else {
      premissas = regraEdit.getPremissas();
      conclusoes = regraEdit.getConclusoes();
    }
    tablePremissas = new JTable(new SentencaTableModel(premissas));
    tablePremissas.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tablePremissas.setBounds(10, 11, 1, 1);
    tablePremissas.setSize(tablePremissas.getPreferredSize());
    JScrollPane scrollPanePremissas = new JScrollPane(tablePremissas);
    scrollPanePremissas.setBounds(10, 10, larguraPremissas - 20, alturaPremissas - 20);
    panelPremissas.add(scrollPanePremissas);

    JPanel panelConclusoes = new JPanel();
    panelConclusoes.setBounds(larguraPremissas, alturaPanelNome, larguraPremissas, alturaPremissas);
    this.getContentPane().add(panelConclusoes);
    panelConclusoes.setLayout(null);

    tableConclusoes = new JTable(new SentencaTableModel(conclusoes));
    tableConclusoes.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tableConclusoes.setBounds(10, 11, 1, 1);
    tableConclusoes.setSize(tableConclusoes.getPreferredSize());
    JScrollPane scrollPaneConclusoes = new JScrollPane(tableConclusoes);
    scrollPaneConclusoes.setBounds(10, 10, larguraPremissas - 20, alturaPremissas - 20);
    panelConclusoes.add(scrollPaneConclusoes);

    JPanel panelBotoes = new JPanel();
    panelBotoes.setBounds(
        larguraPremissas * 2, alturaPanelNome, larguraPanelBotoes, alturaPremissas);
    this.getContentPane().add(panelBotoes);
    panelBotoes.setLayout(null);

    JPanel panel_1 = new JPanel();
    panel_1.setBorder(
        new TitledBorder(
            UIManager.getBorder("TitledBorder.border"),
            "Premissa",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_1.setBounds(2, 24, 116, 116);
    panelBotoes.add(panel_1);
    panel_1.setLayout(null);

    JPanel panel = new JPanel();
    panel.setBounds(8, 16, 100, 92);
    panel_1.add(panel);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JButton btnInserirPremissa = new JButton("Inserir");
    btnInserirPremissa.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (regraInserir != null) {
              new TelaSentenca(regraInserir, true, null, telaSentencas).setVisible(true);
            } else {
              new TelaSentenca(regraEditar, true, null, telaSentencas).setVisible(true);
            }
          }
        });
    panel.add(btnInserirPremissa);

    JButton btnEditarPremissa = new JButton("Editar");
    btnEditarPremissa.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            editar(true);
          }
        });
    panel.add(btnEditarPremissa);

    JButton btnExcluirPremissa = new JButton("Excluir");
    btnExcluirPremissa.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            excluir(tablePremissas);
          }
        });
    panel.add(btnExcluirPremissa);

    JPanel panel_3 = new JPanel();
    panel_3.setBorder(
        new TitledBorder(
            UIManager.getBorder("TitledBorder.border"),
            "Conclus\u00E3o",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_3.setBounds(0, 142, 118, 116);
    panelBotoes.add(panel_3);
    panel_3.setLayout(null);

    JPanel panel_2 = new JPanel();
    panel_2.setBounds(8, 16, 102, 92);
    panel_3.add(panel_2);
    panel_2.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JButton btnInserirConclusao = new JButton("Inserir");
    btnInserirConclusao.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (regraInserir != null) {
              new TelaSentenca(regraInserir, false, null, telaSentencas).setVisible(true);
            } else {
              new TelaSentenca(regraEditar, false, null, telaSentencas).setVisible(true);
            }
          }
        });
    panel_2.add(btnInserirConclusao);

    JButton btnEditarConclusao = new JButton("Editar");
    btnEditarConclusao.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            editar(false);
          }
        });
    panel_2.add(btnEditarConclusao);

    JButton btnExcluirConclusao = new JButton("Excluir");
    btnExcluirConclusao.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            excluir(tableConclusoes);
          }
        });
    panel_2.add(btnExcluirConclusao);
  }
コード例 #14
0
  public TelaFolhadePagamento() throws DaoException {
    setResizable(false);
    setIconImage(
        Toolkit.getDefaultToolkit()
            .getImage(TelaFolhadePagamento.class.getResource("/br/com/images/logo_transp.png")));
    setTitle("Folha de Pagamento");
    int width = 800;
    int height = 600;
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width - width) / 2;
    int y = (screen.height - height) / 3;
    setBounds(x, y, 821, 600);
    getContentPane().setLayout(null);

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setBackground(UIManager.getColor("Button.background"));
    buttonPanel.setBounds(0, 0, 152, 562);
    getContentPane().add(buttonPanel);
    buttonPanel.setLayout(null);

    txtPesq = new JXSearchField();
    txtPesq.addKeyListener(this);
    txtPesq.setPrompt("Nome funcionário");
    txtPesq.setToolTipText("Digite o nome do funcionário para pesquisar");
    txtPesq.setBounds(10, 76, 132, 20);
    buttonPanel.add(txtPesq);
    txtPesq.setColumns(10);

    JLabel lblPesquisar = new JLabel("Pesquisar");
    lblPesquisar.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 13));
    lblPesquisar.setBounds(40, 58, 79, 14);
    buttonPanel.add(lblPesquisar);

    formulario.setBounds(152, 0, 632, 562);
    getContentPane().add(formulario);
    formulario.setLayout(null);

    JPanel panel = new JPanel();
    panel.setBorder(
        new TitledBorder(
            new TitledBorder(
                new LineBorder(new Color(0, 0, 0)),
                "",
                TitledBorder.LEADING,
                TitledBorder.TOP,
                null,
                null),
            "Pagamento",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            new Color(0, 0, 0)));
    panel.setLayout(null);
    panel.setBounds(21, 33, 590, 290);
    formulario.add(panel);

    JPopupMenu popupMenu = new JPopupMenu();
    addPopup(panel, popupMenu);

    JMenuItem mntmPesquisarFuncionrio = new JMenuItem("Pesquisar Funcion\u00E1rio");
    mntmPesquisarFuncionrio.setIcon(
        new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/search.png")));
    mntmPesquisarFuncionrio.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            new ViewSelecionaFuncionario(1);
          }
        });
    popupMenu.add(mntmPesquisarFuncionrio);

    JLabel lblNome = new JLabel("Nome:");
    lblNome.setHorizontalAlignment(SwingConstants.RIGHT);
    lblNome.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblNome.setBounds(0, 89, 70, 18);
    panel.add(lblNome);

    JLabel lblSalrio = new JLabel("Sal\u00E1rio:");
    lblSalrio.setHorizontalAlignment(SwingConstants.RIGHT);
    lblSalrio.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblSalrio.setBounds(0, 171, 70, 18);
    panel.add(lblSalrio);

    JLabel lblProfisso = new JLabel("Profiss\u00E3o:");
    lblProfisso.setHorizontalAlignment(SwingConstants.RIGHT);
    lblProfisso.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblProfisso.setBounds(0, 129, 70, 18);
    panel.add(lblProfisso);

    JLabel lbln = new JLabel("N\u00BA:");
    lbln.setHorizontalAlignment(SwingConstants.RIGHT);
    lbln.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lbln.setBounds(10, 45, 56, 18);
    panel.add(lbln);

    JButton btnSalvar = new JButton("");
    btnSalvar.setIcon(
        new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/salvar.png")));
    btnSalvar.setToolTipText("Salvar Alt+S");
    btnSalvar.setMnemonic(KeyEvent.VK_S);
    btnSalvar.setBounds(504, 244, 56, 33);
    panel.add(btnSalvar);

    btnSalvar.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {

            if (validarFormulário()) {
              FolhaPagamento obj = new FolhaPagamento();

              // obj.setSalarioFunc(Double.parseDouble(MascaraUtil.hideMascaraMoeda(textField_3)));
              obj.setSalarioFunc(Double.parseDouble(textField_3.getText()));
              obj.setComissaoFuncTotal(Double.parseDouble(textField_2.getText()));
              // obj.setBonusFunc(Double.parseDouble(MascaraUtil.hideMascaraMoeda(textField_4)));
              obj.setBonusFunc(Double.parseDouble(textField_4.getText()));
              //	obj.setTotalFunc(Double.parseDouble(MascaraUtil.hideMascaraMoeda(textField_6)));
              obj.setTotalFunc(Double.parseDouble(textField_6.getText()));
              obj.setNomeFunc(textField_9.getText());
              obj.setNumFunc(Integer.parseInt(textField.getText()));
              obj.setProfissaoFunc(textField_1.getText());

              SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");

              try {
                obj.setDataInicio(df.parse(dateInicio.getEditor().getText()));
                obj.setDataFim(df.parse(dateFim.getEditor().getText()));
              } catch (ParseException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }

              FolhadePagamentoDao objDAO = new FolhadePagamentoDao();
              try {

                if (textField_5.getText().equals("")) {
                  objDAO.inserirPagamento(obj);
                  JOptionPane.showMessageDialog(formulario, "Dados salvos com sucesso!");
                  limpaFormulario();
                } else {
                  Integer matr = Integer.parseInt(textField_5.getText());
                  obj.setCodDep(matr);
                  objDAO.atualizarPagamento(obj);
                  JOptionPane.showMessageDialog(formulario, "Dados atualizados com sucesso!");
                }
                atualizaLista(table, "");
              } catch (DaoException e) {
                e.printStackTrace();
              }
            }
          }
        });

    JButton btnLimpar = new JButton("");
    btnLimpar.setIcon(
        new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/limpar.png")));
    btnLimpar.setToolTipText("Limpar Alt+L");
    btnLimpar.setMnemonic(KeyEvent.VK_L);
    btnLimpar.setBounds(438, 244, 56, 33);
    panel.add(btnLimpar);
    btnLimpar.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            limpaFormulario();
          }
        });

    textField = new JTextField();
    textField.setBounds(80, 45, 127, 20);
    panel.add(textField);
    textField.setColumns(10);

    textField_1 = new JTextField();
    textField_1.setBounds(80, 129, 335, 20);
    panel.add(textField_1);
    textField_1.setColumns(10);

    // textField_3 = new JFormattedTextField(MascaraUtil.setMascara("R$####,##"));
    textField_3 = new JFormattedTextField();
    //  textField_3.setDocument(new Moeda());
    textField_3.setBounds(80, 171, 70, 20);
    panel.add(textField_3);
    textField_3.setColumns(10);

    textField_5 = new JTextField();
    textField_5.setVisible(false);
    textField_5.setText("");
    panel.add(textField_5);

    textField_9 = new JTextField();
    textField_9.setBounds(80, 89, 335, 20);
    panel.add(textField_9);
    textField_9.setColumns(10);

    dateInicio = new JXDatePicker();
    dateInicio.getEditor().setToolTipText("Data ínicial para calcular a comissão!");
    dateInicio.getEditor();
    dateInicio.setFormats(new String[] {"dd/MM/yyyy"});
    dateInicio.setBounds(258, 171, 97, 20);
    panel.add(dateInicio);

    dateFim = new JXDatePicker();
    dateFim.getEditor().setToolTipText("Data final para calcular a comissão!");
    dateFim.getEditor();
    dateFim.setFormats(new String[] {"dd/MM/yyyy"});
    dateFim.setBounds(392, 171, 97, 20); //
    panel.add(dateFim);

    JButton btnOk = new JButton("");
    btnOk.setToolTipText("Procurar funcion\u00E1rio");
    btnOk.setIcon(
        new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/pesquisar.png")));
    btnOk.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // PESQUISAR NO BANCO DE DADOS O NÚMERO DO FUNCIONÁRIO
            String aux1;
            aux1 = textField.getText();
            //	if(aux.contains("^[a-Z]")){ //método para verificar se contém letras
            if (textField.getText().equals("")) {
              JOptionPane.showMessageDialog(null, "Digite um número!");
            } else if (aux1.matches("^[0-9]*$")) {
              chamaFuncionario(Integer.parseInt(textField.getText()));
            } else {
              JOptionPane.showMessageDialog(null, "Digite apenas número!");
            }
          }
        });
    btnOk.setBounds(217, 44, 56, 23);
    panel.add(btnOk);

    JLabel lblComisso = new JLabel("Comiss\u00E3o:");
    lblComisso.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblComisso.setBounds(0, 212, 80, 14);
    panel.add(lblComisso);

    JLabel lblBnus = new JLabel("B\u00F4nus:");
    lblBnus.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblBnus.setBounds(185, 212, 50, 14);
    panel.add(lblBnus);

    JLabel lblTotal = new JLabel("Total:");
    lblTotal.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblTotal.setBounds(24, 257, 46, 14);
    panel.add(lblTotal);

    textField_2 = new JTextField();
    textField_2.setToolTipText("Comiss\u00E3o calculada");
    textField_2.setBounds(80, 210, 70, 20);
    //   textField_2.setDocument(new Moeda());
    panel.add(textField_2);
    textField_2.setColumns(10);

    // textField_4 = new JFormattedTextField(MascaraUtil.setMascara("R$####,##"));
    textField_4 = new JTextField();
    //      textField_4.setDocument(new Moeda());
    textField_4.setBounds(245, 210, 80, 20);
    panel.add(textField_4);
    textField_4.setColumns(10);

    //  textField_6 = new JFormattedTextField(MascaraUtil.setMascara("R$####,##"));
    textField_6 = new JTextField();
    //     textField_6.setDocument(new Moeda());
    textField_6.setBounds(80, 255, 70, 20);
    panel.add(textField_6);
    textField_6.setColumns(10);

    JButton btnCalcular = new JButton("Somar tudo");
    btnCalcular.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Calcular quanto o funcionário irá receber
            //	bonus = 0.0;
            // textField 3(salario) e 4 (bonus) 2 (comissão)
            if (validarFormulárioCalculo()) {

              MonthDay inicio = new MonthDay(dateInicio.getDate());
              MonthDay fim = new MonthDay(dateFim.getDate());
              int mes = Months.monthsBetween(inicio, fim).getMonths();
              if (mes >= 2) {
                salario = Double.parseDouble(textField_3.getText()) * mes;
              } else {

                //		String aux = textField_4.getText().replace(",", ".").trim();
                //	bonus = Double.parseDouble(aux);
                bonus = Double.parseDouble(textField_4.getText());

                salario = Double.parseDouble(textField_3.getText());
                totalCom = Double.parseDouble(textField_2.getText());

                salarioTotal = totalCom + bonus + salario;

                textField_6.setText(String.valueOf(salarioTotal));
                textField_6.setEditable(false);
              }
            }
          }
        });
    btnCalcular.setBounds(343, 209, 89, 23);
    panel.add(btnCalcular);

    JLabel lblIncioDoMs = new JLabel("In\u00EDcio do m\u00EAs:");
    lblIncioDoMs.setFont(new Font("Arial Black", Font.PLAIN, 11));
    lblIncioDoMs.setBounds(160, 174, 95, 14);
    panel.add(lblIncioDoMs);

    JLabel lblAt = new JLabel("at\u00E9");
    lblAt.setFont(new Font("Arial Black", Font.PLAIN, 11));
    lblAt.setBounds(365, 173, 28, 14);
    panel.add(lblAt);

    JButton btnCalcular_Com = new JButton("Calcular");
    btnCalcular_Com.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            try {
              calcularComissao();
            } catch (ParseException e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
            }
          }
        });
    btnCalcular_Com.setToolTipText("Calcular comiss\u00E3o");
    btnCalcular_Com.setBounds(491, 170, 89, 23);
    panel.add(btnCalcular_Com);

    JLabel lblTodosOsCampos = new JLabel("Todos os campos s\u00E3o obrigat\u00F3rios!");
    lblTodosOsCampos.setForeground(Color.RED);
    lblTodosOsCampos.setFont(new Font("Tahoma", Font.PLAIN, 12));
    lblTodosOsCampos.setBounds(201, 263, 192, 14);
    panel.add(lblTodosOsCampos);

    JButton btnVoltar = new JButton("");
    btnVoltar.setIcon(
        new ImageIcon(TelaFolhadePagamento.class.getResource("/br/com/images/voltar.png")));
    btnVoltar.setToolTipText("Voltar");
    btnVoltar.setBounds(21, 340, 89, 23);
    formulario.add(btnVoltar);
    formulario.setVisible(false);

    btnVoltar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            lista.setVisible(true);
            buttonPanel.setVisible(true);
            formulario.setVisible(false);
          }
        });

    lista.setBounds(152, 0, 656, 562);
    getContentPane().add(lista);
    lista.setLayout(null);

    JLabel lblFuncionriosCadastrados = new JLabel("Pagamentos Efetuados");
    lblFuncionriosCadastrados.setFont(new Font("Kalinga", Font.BOLD, 16));
    lblFuncionriosCadastrados.setHorizontalAlignment(SwingConstants.CENTER);
    lblFuncionriosCadastrados.setBackground(Color.WHITE);
    lblFuncionriosCadastrados.setBounds(10, 11, 612, 29);
    lista.add(lblFuncionriosCadastrados);

    Button Novo = new Button("Adicionar");
    Novo.setBounds(10, 530, 70, 22);
    lista.add(Novo);
    lista.setVisible(true);
    buttonPanel.setVisible(true);
    table = new JTable();
    table.addMouseListener(
        new MouseListener() {

          @Override
          public void mouseReleased(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mousePressed(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseExited(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseEntered(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseClicked(MouseEvent arg0) {
            int linha = table.getSelectedRow();
            int coluna = table.getSelectedColumn();
            String matricula = (String) table.getValueAt(linha, 0);
            Integer mat = Integer.parseInt(matricula);
            if (coluna == 7) {
              int opcao;
              opcao =
                  JOptionPane.showConfirmDialog(
                      null,
                      "Deseja excluir o registro de matricula: " + matricula,
                      "Cuidado!!",
                      JOptionPane.YES_NO_OPTION);
              if (opcao == JOptionPane.YES_OPTION) {
                try {
                  folhaDao.excluirPagamento(mat);
                  atualizaLista(table, "");
                } catch (DaoException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
                JOptionPane.showMessageDialog(null, "Dados excluidos com sucesso!");
              }
            }
            if (coluna == 5) {
              FolhaPagamento objFolha = new FolhaPagamento();

              try {
                objFolha = folhaDao.consultarPagamentoID(mat);
                atualizaFormulario(objFolha);
                buttonPanel.setVisible(false);
              } catch (DaoException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
            }
            // Gera a folha pra imprimir
            if (coluna == 6) {
              FolhaControle controle = new FolhaControle();
              Funcionario objFunc = new Funcionario();
              FolhaPagamento objFolha = new FolhaPagamento();

              Integer qntd;

              String nome = (String) table.getValueAt(linha, 1);
              try {
                objFunc = funcDao.procurarFuncionarioNome(nome);
                objFolha = folhaDao.procurarDataPag(mat);
                qntd = folhaDao.quantidadePedido(objFunc.getNumFunc());
                if (qntd == 0) {
                  controle.gerarRelatorioFolhaSimples(
                      objFunc.getNumFunc(), objFolha.getDataInicio(), objFolha.getDataFim());
                } else
                  controle.gerarRelatorioFolha(
                      objFunc.getNumFunc(), objFolha.getDataInicio(), objFolha.getDataFim());
              } catch (DaoException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }
            }
          }
        });

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setModel(
        new DefaultTableModel(
            new Object[][] {},
            new String[] {
              "Nº",
              "Nome",
              "Profissão",
              "Salário",
              "Data Pagamento",
              "Editar",
              "Relatório",
              "Excluir"
            }) {
          private static final long serialVersionUID = 1L;

          @Override
          public boolean isCellEditable(int row, int col) {
            return false;
          }
        });
    table.getColumnModel().getColumn(0).setPreferredWidth(35);
    table.getColumnModel().getColumn(0).setMinWidth(35);
    table.getColumnModel().getColumn(1).setPreferredWidth(170);
    table.getColumnModel().getColumn(1).setMinWidth(170);
    table.getColumnModel().getColumn(2).setPreferredWidth(80);
    table.getColumnModel().getColumn(2).setMinWidth(80);
    table.getColumnModel().getColumn(3).setPreferredWidth(50);
    table.getColumnModel().getColumn(3).setMinWidth(50);

    table.getColumnModel().getColumn(4).setPreferredWidth(100);
    table.getColumnModel().getColumn(4).setMinWidth(100);
    table.getColumnModel().getColumn(5).setPreferredWidth(40);
    table.getColumnModel().getColumn(5).setMinWidth(40);
    table.getColumnModel().getColumn(6).setPreferredWidth(50);
    table.getColumnModel().getColumn(6).setMinWidth(50);

    table.getColumnModel().getColumn(7).setPreferredWidth(40);
    table.getColumnModel().getColumn(7).setMinWidth(40);
    table.setBounds(39, 175, 530, 232);
    atualizaLista(table, "");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 51, 636, 473);
    lista.add(scrollPane);

    scrollPane.setViewportView(table);

    Novo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            lista.setVisible(false);
            formulario.setVisible(true);
            buttonPanel.setVisible(false);
            limpaFormulario();
            try {
              atualizaLista(table, "");
            } catch (DaoException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });
  }
コード例 #15
0
  public Interface() throws HeadlessException {
    super();
    p1 = (JPanel) this.getContentPane();
    p1.setLayout(null);
    this.setSize(700, 800);
    this.setTitle("Projet");
    this.setLocationRelativeTo(null);
    // *
    model1 = (DefaultTableModel) t1.getModel();
    model1.setRowCount(0);
    model1.setColumnCount(4);
    Object[] row = new Object[4];

    row[0] = "Nom";
    row[1] = "Durée";
    row[2] = "Priorité";
    row[3] = "taille";

    model1.addRow(row);
    t1.setModel(model1);
    // mise en place

    p1.add(ne);
    ne.setBounds(10, 10, 500, 30);
    p1.add(n);
    n.setBounds(10, 40, 100, 30);
    p1.add(d);
    d.setBounds(10, 100, 100, 30);
    p1.add(k);
    k.setBounds(290, 40, 100, 30);
    p1.add(l);
    l.setBounds(290, 100, 100, 30);

    p1.add(nom);
    nom.setBounds(120, 40, 100, 30);
    p1.add(dure);
    dure.setBounds(120, 100, 100, 30);
    p1.add(priorité);
    priorité.setBounds(350, 40, 100, 30);
    p1.add(taille);
    taille.setBounds(350, 100, 100, 30);

    p1.add(ajout);
    ajout.setBounds(10, 160, 100, 30);

    p1.add(t1);
    t1.setBounds(10, 200, 650, 200);
    p1.add(fifo);
    fifo.setBounds(360, 400, 289, 30);

    p1.add(t2);
    t2.setBounds(10, 450, 650, 200);

    p1.add(ta);
    ta.setBounds(10, 670, 650, 30);

    p1.add(tr);
    tr.setBounds(10, 720, 650, 30);
    ajout.addActionListener(this);
    fifo.addActionListener(this);

    // ***

    model2 = (DefaultTableModel) t2.getModel();
    model2.setRowCount(0);
    model2.setColumnCount(5);

    Object[] row2 = new Object[5];
    row2[0] = "Nom";
    row2[1] = "Durée";
    row2[2] = "Date debut";
    row2[3] = "TR";
    row2[4] = "TA";

    model2.addRow(row2);
    t2.setModel(model2);
  }
コード例 #16
0
  public ListarReservasView(final MainFrame mainFrame) {
    this.mf = mainFrame;

    // TODO nao seria reservaControl aqui???
    DAO dao = new DAO();
    ReservaDAO rDAO = dao.getReservaDAO();
    final ArrayList<Reserva> reservas = rDAO.listaReservas();

    setBounds(100, 100, 514, 381);
    setBackground(new Color(0, 204, 255));
    setBorder(new EmptyBorder(5, 5, 5, 5));
    setLayout(null);

    String[] columnNames = {"#", "Passageiro", "Origem", "Destino", "Inicio", "Fim", "Status"};

    ArrayList<ArrayList<String>> data = new ArrayList<ArrayList<String>>();
    for (Reserva reserva : reservas) {
      data.add(new ArrayList<String>());
      data.get(data.size() - 1).add("" + reserva.getCodigo());
      data.get(data.size() - 1).add(reserva.getPassageiro().getNome());
      data.get(data.size() - 1).add(reserva.getPacote().getOrigem());
      data.get(data.size() - 1).add(reserva.getPacote().getDestino());
      data.get(data.size() - 1).add(reserva.getPacote().getDtInicio());
      data.get(data.size() - 1).add(reserva.getPacote().getDtFim());
      data.get(data.size() - 1).add(reserva.getStatus() == 1 ? "PAGO" : "NÃO PAGO");
    }
    Object[][] dados = new Object[data.size()][7];

    for (int i = 0; i < data.size(); i++) {
      for (int j = 0; j < data.get(i).size(); j++) {
        dados[i][j] = data.get(i).get(j);
      }
    }

    final JTable table = new JTable(dados, columnNames);

    table.setEnabled(false);
    table.setBounds(0, 0, 480, 248);
    table.getColumnModel().getColumn(0).setPreferredWidth(20);

    table.addMouseListener(
        new java.awt.event.MouseAdapter() {

          @Override
          public void mouseClicked(java.awt.event.MouseEvent evt) {
            if (evt.getClickCount() > 1) {
              int row = table.rowAtPoint(evt.getPoint());
              // JOptionPane.showMessageDialog(null, row);
              DetalharReservaView detalharReservaView =
                  new DetalharReservaView(mf, reservas.get(row));
              mf.addComponent(detalharReservaView, "Detalhar Reserva");
              mf.openView("Detalhar Reserva");
            }
          }
        });

    JScrollPane jScrollPane = new JScrollPane(table);
    jScrollPane.setBounds(10, 10, 480, 248);

    add(jScrollPane);

    JButton btnCancelar = new JButton("Cancelar");
    btnCancelar.setFont(new Font("Tahoma", Font.BOLD, 14));
    btnCancelar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mf.getContentPanel().removeAll();
            mf.openView("Main");
          }
        });
    btnCancelar.setBounds(40, 273, 175, 35);
    add(btnCancelar);
  }
コード例 #17
0
  private void initialize() {
    frame = new JFrame();
    frame.setSize(828, 520);
    frame.setLocationRelativeTo(null);
    frame.getContentPane().setLayout(null);
    textPane.setBounds(10, 5, 772, 125);
    textPane.setEditorKit(new HTMLEditorKit());

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setBounds(10, 11, 792, 301);
    frame.getContentPane().add(tabbedPane);

    JPanel panelCase = new JPanel();
    tabbedPane.addTab("Case Tab", null, panelCase, null);
    panelCase.setLayout(null);

    tableCase = new JTable();
    tableCase.setBounds(10, 11, 634, 219);
    caseRows = new ArrayList<CaseRow>();
    panelCase.add(tableCase);
    tableCaseModel = new CaseTableModel(caseRows);
    tableCase.setModel(tableCaseModel);

    JPanel panel_Query = new JPanel();
    panel_Query.setBounds(10, 323, 792, 141);
    frame.getContentPane().add(panel_Query);
    panel_Query.setLayout(null);
    panel_Query.add(textPane);

    JScrollPane scrollPaneCase = new JScrollPane(tableCase);
    scrollPaneCase.setBounds(10, 11, 754, 164);
    panelCase.add(scrollPaneCase);

    JPanel panelCoalesce = new JPanel();
    tabbedPane.addTab("Coalesce Tab", null, panelCoalesce, null);

    tableCoalesce = new JTable();
    tableCoalesce.setBounds(1, 36, 765, 0);
    panelCoalesce.add(tableCoalesce);
    panelCase.setLayout(null);
    coalesceRows = new ArrayList<CoalesceRow>();
    tableCoalesceModel = new CoalesceTableModel(coalesceRows);
    panelCoalesce.setLayout(null);
    tableCoalesce.setModel(tableCoalesceModel);

    JScrollPane scrollPaneCoalesce = new JScrollPane(tableCoalesce);
    scrollPaneCoalesce.setBounds(10, 11, 767, 131);
    panelCoalesce.add(scrollPaneCoalesce);

    JPanel coalesceButtonPanel = new JPanel();
    coalesceButtonPanel.setBounds(10, 201, 757, 50);
    panelCoalesce.add(coalesceButtonPanel);
    coalesceButtonPanel.setLayout(null);

    JButton coalesceAddBtn = new JButton("ADD");
    coalesceAddBtn.setIcon(new ImageIcon(TeslaCase.class.getResource("/png/addd.png")));
    coalesceAddBtn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (pojoRow.getRowType() == null) {
              pojoRow.setRowType("Coalesce");
              TeslaTransFunctions.initializeCoalesceTables();
            }
            tableCoalesce.editCellAt(-1, -1);
            if (txtEnterStringField.getText().equals("")) {
              query = TeslaTransFunctions.displayCoalesceQuery(coalesceRows);
              textPane.setText(QueryColorUtil.queryColorChange(query));
              tableCoalesceModel.updateUI(pojoRow);
              tableCoalesce.scrollRectToVisible(
                  tableCoalesce.getCellRect(tableCoalesce.getRowCount() - 1, 0, true));
            } else {
              pojoRow.setCoalesceString(txtEnterStringField.getText());
              query =
                  TeslaTransFunctions.displayCoalesceQuery_1(txtEnterStringField.getText(), query);
              tableCoalesce.editCellAt(-1, -1);
              frame.setVisible(false);
            }
          }
        });
    coalesceAddBtn.setBounds(286, 16, 115, 29);
    coalesceButtonPanel.add(coalesceAddBtn);

    JButton coalescebtnDone = new JButton("DONE");
    coalescebtnDone.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            tableCoalesce.editCellAt(-1, -1);
            if (txtEnterStringField.getText().equals("")) {
              query = TeslaTransFunctions.displayCoalesceQuery(coalesceRows);
              textPane.setText(QueryColorUtil.queryColorChange(query));
              tableCoalesceModel.updateUI(pojoRow);
              tableCoalesce.scrollRectToVisible(
                  tableCoalesce.getCellRect(tableCoalesce.getRowCount() - 1, 0, true));
            } else {
              pojoRow.setCoalesceString(txtEnterStringField.getText());
              query =
                  TeslaTransFunctions.displayCoalesceQuery_1(txtEnterStringField.getText(), query);
              tableCoalesce.editCellAt(-1, -1);
              frame.setVisible(false);
            }
            frame.setVisible(false);
          }
        });
    coalescebtnDone.setBounds(499, 19, 89, 23);
    coalesceButtonPanel.add(coalescebtnDone);

    txtEnterStringField = new JTextField();
    txtEnterStringField.setBounds(287, 158, 146, 26);
    panelCoalesce.add(txtEnterStringField);
    txtEnterStringField.setColumns(10);

    JLabel lblEnterText = new JLabel("Enter Text");
    lblEnterText.setBounds(125, 161, 119, 20);
    panelCoalesce.add(lblEnterText);

    JPanel panelCaseButton = new JPanel();
    panelCaseButton.setBounds(26, 202, 726, 44);
    panelCase.add(panelCaseButton);

    JButton btnAddCase = new JButton("ADD");
    btnAddCase.setBounds(288, 11, 89, 23);
    btnAddCase.setIcon(new ImageIcon(TeslaCase.class.getResource("/png/addd.png")));
    btnAddCase.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (pojoRow.getRowType() == null) {
              pojoRow.setRowType("Case");
              TeslaTransFunctions.initializeCaseTables();
            }
            tableCase.editCellAt(-1, -1);
            query = TeslaTransFunctions.displayCaseQuery(caseRows);
            textPane.setText(QueryColorUtil.queryColorChange(query));
            tableCaseModel.updateUI(pojoRow);
            tableCase.scrollRectToVisible(
                tableCase.getCellRect(tableCase.getRowCount() - 1, 0, true));
          }
        });
    panelCaseButton.setLayout(null);
    panelCaseButton.add(btnAddCase);

    JButton btnNewButton = new JButton("ELSE");
    btnNewButton.setIcon(new ImageIcon(TeslaCase.class.getResource("/png/Locking.png")));
    btnNewButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            tableCase.editCellAt(-1, -1);
            query = TeslaTransFunctions.displayCaseQuery(caseRows);
            textPane.setText(QueryColorUtil.queryColorChange(query));
            tableCaseModel.updateUI1(pojoRow);
            tableCase.scrollRectToVisible(
                tableCase.getCellRect(tableCase.getRowCount() - 1, 0, true));
          }
        });
    btnNewButton.setBounds(496, 11, 89, 23);
    panelCaseButton.add(btnNewButton);

    JButton btnElse = new JButton("DONE");
    btnElse.setIcon(new ImageIcon(TeslaCase.class.getResource("/png/Exit.png")));
    btnElse.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            tableCase.editCellAt(-1, -1);
            frame.setVisible(false);
          }
        });
    btnElse.setBounds(72, 11, 89, 23);
    panelCaseButton.add(btnElse);

    frame.setVisible(true);
  }
コード例 #18
0
  /** Initialize the contents of the frame. */
  private void initialize() {

    frame = new JFrame();
    frame.setBounds(100, 100, 450, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(new CardLayout(0, 0));

    final JPanel loginPanel = new JPanel();
    frame.getContentPane().add(loginPanel, "name_1447783491025678000");
    loginPanel.setLayout(null);

    passwordField = new JPasswordField();
    passwordField.setBounds(156, 171, 134, 28);
    loginPanel.add(passwordField);

    final JPanel studentPanel = new JPanel();
    frame.getContentPane().add(studentPanel, "name_1447783494532332000");
    studentPanel.setLayout(null);

    Button button = new Button("New button");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            populateTable();
          }
        });
    button.setBounds(157, 239, 117, 29);
    studentPanel.add(button);

    JButton btnTest = new JButton("test");
    btnTest.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            Connection conn;
            try {
              conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb", "root", "");
              PreparedStatement stmt = conn.prepareStatement("select * from class");

              ResultSet rs = stmt.executeQuery();
              System.out.println("entering loop");

              for (int i = 0; i <= table.getSelectedRow(); i++) {
                rs.next();
              }
              int classID = rs.getInt(1);

              PreparedStatement stmt2 =
                  conn.prepareStatement(
                      "insert into registered_in (studentID, classID) values (?,?)");
              stmt2.setInt(1, currentStudent);
              stmt2.setInt(2, classID);
              stmt2.execute();

            } catch (SQLException e1) {
              e1.printStackTrace();
            }
          }
        });
    btnTest.setBounds(157, 6, 117, 29);
    studentPanel.add(btnTest);

    table = new JTable();
    table.setBounds(91, 55, 285, 155);
    studentPanel.add(table);

    final JPanel teacherPanel = new JPanel();
    teacherPanel.setLayout(null);
    frame.getContentPane().add(teacherPanel, "name_1447794247375231000");

    final JPanel administratorPanel = new JPanel();
    administratorPanel.setLayout(null);
    frame.getContentPane().add(administratorPanel, "name_1447794265299764000");

    JLabel lblAdministratorPage = new JLabel("Administrator Page");
    lblAdministratorPage.setBounds(107, 124, 115, 16);
    administratorPanel.add(lblAdministratorPage);

    JButton btnGithubtest = new JButton("githubtest");
    btnGithubtest.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.out.println("hello");
          }
        });
    btnGithubtest.setBounds(117, 157, 117, 29);
    administratorPanel.add(btnGithubtest);

    usernameField = new JTextField();
    usernameField.setBounds(156, 125, 134, 28);
    loginPanel.add(usernameField);
    usernameField.setColumns(10);

    JLabel lblUsername = new JLabel("Username:"******"Password:"******"Sign In");
    signInButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String user = usernameField.getText();
            String pass = passwordField.getText();

            Connection conn = null;

            PreparedStatement stmt = null;
            PreparedStatement stmt2 = null;
            PreparedStatement stmt3 = null;

            try {
              Class.forName("com.mysql.jdbc.Driver");
              conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb", "root", "");
              stmt =
                  conn.prepareStatement("select * from student where email = ? and password = ?");
              stmt.setString(1, user); // username
              stmt.setString(2, pass); // eventname

              ResultSet rs1 = stmt.executeQuery();

              if (rs1.next()) {
                currentStudent = rs1.getInt(1);
                loginPanel.setVisible(false);
                studentPanel.setVisible(true);

              } else {
                stmt2 =
                    conn.prepareStatement("select * from teacher where email = ? and password = ?");
                stmt2.setString(1, user); // username
                stmt2.setString(2, pass); // eventname
                ResultSet rs2 = stmt2.executeQuery();
                if (rs2.next()) {
                  currentTeacher = rs2.getInt(1);
                  loginPanel.setVisible(false);
                  teacherPanel.setVisible(true);

                } else {

                  stmt3 =
                      conn.prepareStatement(
                          "select * from administrator where email = ? and password = ?");
                  stmt3.setString(1, user); // username
                  stmt3.setString(2, pass); // eventname
                  ResultSet rs3 = stmt3.executeQuery();
                  if (rs3.next()) {
                    currentAdmin = rs3.getInt(1);
                    loginPanel.setVisible(false);
                    administratorPanel.setVisible(true);
                  } else {
                    System.out.println("not found");
                  }
                }
              }

            } catch (ClassNotFoundException e1) {
              e1.printStackTrace();
            } catch (SQLException e1) {
              e1.printStackTrace();
            }
          }
        });
    signInButton.setBounds(166, 211, 117, 29);
    loginPanel.add(signInButton);
  }
コード例 #19
0
  @SuppressWarnings({"unchecked", "rawtypes"})
  public InterfaceTrans() {

    setTitle("Pantalla Principal");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setSize(1280, 720); // Tamaño
    setLocationRelativeTo(null); // Centrar ventana

    // donde se ejecute el programa
    setResizable(true);
    setVisible(true);

    // Quito la visibilidad de los elementos del padre que no necesito
    super.contentPane.setVisible(false); // para que se vea mi Panel en vez
    // del gris heredado
    super.menu2.setVisible(false);
    super.tb1.setVisible(false);

    // Añado a la barra los elementos que si necesito

    abrir = new JMenuItem("Abrir...   Alt+B");
    abrir.setMnemonic('B');
    abrir.setIcon(new ImageIcon(InterfaceTrans.class.getResource(""))); // ""
    // para
    // colocar
    // un
    // icono
    abrir.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            try {
              InterfaceTrans.archivotrans();
            } catch (Throwable e) {
              e.printStackTrace();
            }
          }
        });
    super.menu1.add(abrir);

    // -------------- Tabla ----------------------------------------------
    // -------------------------------------------------------------------

    tabla = new JTable();

    // ARRAY QUE CAPTURA EL CONTENIDO
    contenido = new Object[Tablas.transporte.size()][6];
    int contador = 0;
    for (Entry<Integer, Transporte> entrada : Tablas.transporte.entrySet()) {
      contenido[contador][0] = entrada.getValue().getId();
      contenido[contador][1] = entrada.getValue().getIdCliente();
      contenido[contador][2] = entrada.getValue().getIdProducto();
      contenido[contador][3] = entrada.getValue().isTipoViaje();
      contenido[contador][4] = entrada.getValue().getFechaEntrega();
      contenido[contador][5] = entrada.getValue().getFechaRecogida();
      contador++;
    }

    ModeloTablaTrans =
        new DefaultTableModel(contenido, columnas) {
          private static final long serialVersionUID = 1L;

          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
          }
        };
    // -----

    // COJEMO EL MODELO DE LA TABLA
    tabla = new JTable(ModeloTablaTrans);
    tabla.setShowVerticalLines(true);
    tabla.setShowHorizontalLines(true);
    tabla.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // SELECCION SENCILLA
    tabla.setVisible(true);

    sp = new JScrollPane(tabla); // Necesita un Scroll para que se vean las  columnas
    sp.setBounds(608, 182, 616, 337);

    // -------A partir de aqui el tabbedPaned-------------------

    separador = new JTabbedPane();
    panel1 = new JPanel();
    panel1.setBackground(Color.LIGHT_GRAY); // asi le damos color al panel
    panel1.setLayout(null);
    lblId_Transporte = new JLabel("N\u00BA Transporte:");
    lblId_Transporte.setFont(new Font("Arial", Font.BOLD, 13));
    lblId_Cliente = new JLabel("ID Cliente:");
    lblId_Cliente.setFont(new Font("Arial", Font.BOLD, 13));
    lblId_Producto = new JLabel("ID Producto:");
    lblId_Producto.setFont(new Font("Arial", Font.BOLD, 13));
    lblTipo_Viaje = new JLabel("Tipo Viaje:");
    lblTipo_Viaje.setFont(new Font("Arial", Font.BOLD, 13));
    lblFechaEnvio = new JLabel("Fecha Envio:");
    lblFechaEnvio.setFont(new Font("Arial", Font.BOLD, 13));
    lblFechaRecepcion = new JLabel("Fecha Rcogida:");
    lblFechaRecepcion.setFont(new Font("Arial", Font.BOLD, 13));

    // ----------cajas de texto ----------------

    cajaId_Transporte = new JTextField();
    cajaId_Transporte.setEnabled(false);
    cajaId_Cliente = new JTextField();
    cajaId_Producto = new JTextField();
    cajaTipo_Viaje = new JTextField();

    // --------botones-------------------

    guardar = new JButton("Guardar");
    guardar.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {

            Transporte t = new Transporte();
            Disparador d = new Disparador("idTransporte");
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            if (t.insertar(
                    d.nextValue(),
                    Integer.parseInt(cajaId_Cliente.getText()),
                    Integer.parseInt(cajaId_Producto.getText()),
                    cajaTipo_Viaje.getText(),
                    sdf.format(dateEnvio.getCalendar().getTime()),
                    sdf.format(dateRecep.getCalendar().getTime()))
                == true) {
              JOptionPane.showMessageDialog(
                  null, "El registro " + d.insert() + " se ha insertado correctamente");
            }
          }
        });

    borrar = new JButton("LIMPIAR REGISTRO");
    borrar.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) { // usado para dejar las vacías

            cajaId_Transporte.setText(null);
            cajaId_Cliente.setText(null);
            cajaId_Producto.setText(null);
            cajaTipo_Viaje.setText(null);
            dateRecep.setCalendar(null); // vaciamos la caja del calendario
            dateEnvio.setCalendar(null); // vaciamos la caja del calendario
          }
        });
    lblId_Transporte.setBounds(73, 181, 187, 28);
    lblId_Cliente.setBounds(73, 220, 187, 30);
    lblId_Producto.setBounds(73, 261, 187, 30);
    lblTipo_Viaje.setBounds(73, 302, 187, 30);
    lblFechaEnvio.setBounds(73, 343, 187, 28);
    lblFechaRecepcion.setBounds(73, 382, 187, 30);

    // ----------Cajas-------------

    cajaId_Transporte.setBounds(270, 179, 124, 30);
    cajaId_Cliente.setBounds(270, 221, 250, 30);
    cajaId_Producto.setBounds(270, 262, 250, 30);
    cajaTipo_Viaje.setBounds(270, 302, 85, 30);

    // ----------Botones-------------

    guardar.setBounds(270, 423, 85, 30);
    borrar.setBounds(384, 423, 136, 30);

    dateRecep.setBounds(270, 382, 250, 30);
    panel1.add(sp);

    panel1.add(guardar);
    panel1.add(borrar);
    panel1.add(lblId_Transporte);
    panel1.add(lblId_Cliente);
    panel1.add(lblId_Producto);
    panel1.add(lblTipo_Viaje);
    panel1.add(lblFechaEnvio);
    panel1.add(lblFechaRecepcion);

    panel1.add(cajaId_Transporte);
    panel1.add(cajaId_Cliente);
    panel1.add(cajaId_Producto);
    panel1.add(cajaTipo_Viaje);

    separador.addTab("Gestion  de Transporte", null, panel1, "Separador1"); // Añadimos
    // el
    // Panel1
    // al
    // separador

    panel1.add(dateRecep);

    dateEnvio = new JDateChooser();
    dateEnvio.setBounds(270, 343, 250, 30);
    panel1.add(dateEnvio);

    btnOk = new JButton("OK");
    btnOk.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cajaTipo_Viaje.setText((String) comboBox.getSelectedItem());
          }
        });
    btnOk.setBounds(473, 302, 47, 30);
    panel1.add(btnOk);

    comboBox = new JComboBox();
    comboBox.setModel(
        new DefaultComboBoxModel(new String[] {"Entrega", "Recogida", "Mixto", "Anulado"}));
    comboBox.setBounds(365, 302, 98, 30);
    panel1.add(comboBox);

    btnNewButton = new JButton("Generar N\u00BA");
    btnNewButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            cajaId_Transporte.setText(new Disparador("idTransporte").nextValue() + "");
          }
        });
    btnNewButton.setBounds(404, 182, 116, 26);
    panel1.add(btnNewButton);

    lblModuloTransporte = new JLabel("MODULO TRANSPORTE");
    lblModuloTransporte.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 30));
    lblModuloTransporte.setBounds(101, 28, 362, 37);
    panel1.add(lblModuloTransporte);

    JSeparator separatortitulo = new JSeparator();
    separatortitulo.setBackground(Color.BLACK);
    separatortitulo.setBounds(46, 68, 417, 10);
    panel1.add(separatortitulo);

    label = new JLabel("");
    label.setIcon(
        new ImageIcon(InterfaceTrans.class.getResource("/FinalLaGestionTransport/truckmini.png")));
    label.setBounds(47, 11, 62, 54);
    panel1.add(label);

    label_logo = new JLabel("");
    label_logo.setIcon(
        new ImageIcon(InterfaceTrans.class.getResource("/FinalLaGestionTransport/mini-logo.png")));
    label_logo.setBounds(1058, 11, 207, 114);
    panel1.add(label_logo);
    getContentPane().add(separador); // sin esto no se veria nada, añadimos
    // al JFrame el JTabbedPane

    // ------------------------------------------------------------------------------------------------
    // --------------------------A partir de aquí el panel 2
    // ------------------------------------------
    // ------------------------------------------------------------------------------------------------
    panel2 = new JPanel();
    panel2.setBackground(Color.LIGHT_GRAY); // asi le damos color al panel1
    panel2.setLayout(null);

    separador.addTab("Conductores", null, panel2, "Separador1");

    btnAgregarCondutores = new JButton("MODIFICAR CONDUCTORES");
    btnAgregarCondutores.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent arg0) {
            //				AddConductores verformulario2 = new AddConductores();
            //				verformulario2.setVisible(true);

            try {
              Runtime.getRuntime()
                  .exec("rundll32 url.dll,FileProtocolHandler C:\\LaGestion\\Conductores.xls");
            } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });

    tabla2 = new JTable();
    tabla21 = new DefaultTableModel();
    tabla2.setModel(tabla21);
    tabla2.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
    tabla2.setBackground(Color.LIGHT_GRAY);
    tabla2.setBounds(601, 189, 648, 400);
    // No queremos ver las lineas verticales
    tabla2.setShowVerticalLines(true);
    // No queremos ver las lineas verticales
    tabla2.setShowHorizontalLines(true);
    panel2.add(tabla2);

    btnAgregarCondutores.setBounds(384, 216, 207, 103);
    panel2.add(btnAgregarCondutores);

    labelLogo = new JLabel("");
    labelLogo.setIcon(
        new ImageIcon(InterfaceTrans.class.getResource("/FinalLaGestionTransport/mini-logo.png")));
    labelLogo.setBounds(1042, 11, 207, 114);
    panel2.add(labelLogo);

    labelConductor = new JLabel("LISTADO CONDUCTORES");
    labelConductor.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 30));
    labelConductor.setBounds(100, 33, 402, 37);
    panel2.add(labelConductor);

    label_2 = new JLabel("");
    label_2.setIcon(
        new ImageIcon(InterfaceTrans.class.getResource("/FinalLaGestionTransport/truckmini.png")));
    label_2.setBounds(51, 16, 62, 54);
    panel2.add(label_2);

    separatorTitulo = new JSeparator();
    separatorTitulo.setBackground(Color.BLACK);
    separatorTitulo.setBounds(61, 72, 441, 10);
    panel2.add(separatorTitulo);

    // RELOJ
    hilo = new Thread(this);
    hilo.start();
    lblReloj = new JLabel("");
    lblReloj.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 22));
    lblReloj.setBounds(61, 189, 312, 201);
    panel2.add(lblReloj);

    // Label Turno
    lblTurno = new JLabel("HORARIO/TURNO");
    lblTurno.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 18));
    lblTurno.setBounds(61, 401, 186, 27);
    panel2.add(lblTurno);

    lblVerturno = new JLabel("");
    lblVerturno.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 24));
    lblVerturno.setForeground(Color.BLUE);
    lblVerturno.setBounds(61, 446, 233, 66);
    panel2.add(lblVerturno);

    btnVerConductores = new JButton("VER CONDUCTORES");
    btnVerConductores.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {

            String ruta = "C:\\LaGestion\\Conductores.xls";
            JFileChooser excel = new JFileChooser();
            excel.setSelectedFile(new File(ruta));
            File archivoexcel = null;
            archivoexcel = excel.getSelectedFile().getAbsoluteFile();

            try {

              Workbook leerEx = Workbook.getWorkbook(archivoexcel);

              for (int hoja = 0; hoja < leerEx.getNumberOfSheets(); hoja++) {

                Sheet hojap = leerEx.getSheet(hoja);
                int colum2 = hojap.getColumns();
                int filas1 = hojap.getRows();
                Object data[] = new Object[colum2];

                for (int fila = 0; fila < filas1; fila++) {
                  for (int colum1 = 0; colum1 < colum2; colum1++) {
                    if (fila == 0) {
                      tabla21.addColumn(hojap.getCell(colum1, fila).getContents());
                    }
                    //										System.out.println(hojap.getCell(colum1, fila).getContents());
                    if (fila >= 1) data[colum1] = hojap.getCell(colum1, fila).getContents();
                  }
                  tabla21.addRow(data);
                }
              }

              // opcional
              tabla21.removeRow(0);
            } catch (Exception e) {

            }
            // FIN DE LEER EXCEL

            btnVerConductores.setEnabled(false);
          }
        });
    btnVerConductores.setBounds(601, 141, 153, 37);
    panel2.add(btnVerConductores);

    // Separador
    getContentPane().add(separador); // sin esto no se veria nada, añadimos
    // al JFrame el JTabbedPane

  }
コード例 #20
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    JFrame frmEditdeleteAuciton = new JFrame();
    frmEditdeleteAuciton.setResizable(false);
    frmEditdeleteAuciton.setTitle("Edit/Delete Auciton");
    frmEditdeleteAuciton.setBounds(100, 100, 712, 467);
    frmEditdeleteAuciton.setLocationRelativeTo(null);
    frmEditdeleteAuciton.getContentPane().setLayout(null);
    frmEditdeleteAuciton.setLocationRelativeTo(null);
    frmEditdeleteAuciton.setVisible(true);

    JButton btnSearch = new JButton("SHOW AUCTIONS CREATED BY YOU");
    btnSearch.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            AuctionMethods.showmyauction(table);
          }
        });
    btnSearch.setFont(new Font("Tahoma", Font.PLAIN, 15));
    btnSearch.setBounds(170, 11, 346, 33);
    frmEditdeleteAuciton.getContentPane().add(btnSearch);

    textField_1 = new JTextField();
    textField_1.setColumns(10);
    textField_1.setBounds(164, 262, 166, 30);
    frmEditdeleteAuciton.getContentPane().add(textField_1);

    textField_2 = new JTextField();
    textField_2.setColumns(10);
    textField_2.setBounds(164, 302, 166, 30);
    frmEditdeleteAuciton.getContentPane().add(textField_2);

    textField_3 = new JTextField();
    textField_3.setColumns(10);
    textField_3.setBounds(164, 341, 166, 30);
    frmEditdeleteAuciton.getContentPane().add(textField_3);

    JLabel lblNewCategory = new JLabel("New Category");
    lblNewCategory.setFont(new Font("Tahoma", Font.PLAIN, 15));
    lblNewCategory.setBounds(10, 341, 144, 30);
    frmEditdeleteAuciton.getContentPane().add(lblNewCategory);

    JLabel lblNewStartingBid = new JLabel("New Starting Bid");
    lblNewStartingBid.setFont(new Font("Tahoma", Font.PLAIN, 15));
    lblNewStartingBid.setBounds(10, 302, 144, 28);
    frmEditdeleteAuciton.getContentPane().add(lblNewStartingBid);

    JLabel lblNewAuctionName = new JLabel("New Auction Name");
    lblNewAuctionName.setFont(new Font("Tahoma", Font.PLAIN, 15));
    lblNewAuctionName.setBounds(10, 262, 144, 29);
    frmEditdeleteAuciton.getContentPane().add(lblNewAuctionName);

    table = new JTable();
    table.setShowVerticalLines(false);
    table.setShowHorizontalLines(false);
    table.setShowGrid(false);
    table.setRowSelectionAllowed(false);
    table.setFont(new Font("Tahoma", Font.PLAIN, 12));
    table.setEnabled(false);
    table.setBounds(119, 76, 450, 82);
    frmEditdeleteAuciton.getContentPane().add(table);

    JTextPane txtpnAuctionName = new JTextPane();
    txtpnAuctionName.setText("Auction Name");
    txtpnAuctionName.setForeground(Color.WHITE);
    txtpnAuctionName.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtpnAuctionName.setEditable(false);
    txtpnAuctionName.setBackground(Color.DARK_GRAY);
    txtpnAuctionName.setBounds(119, 55, 150, 19);
    frmEditdeleteAuciton.getContentPane().add(txtpnAuctionName);

    JTextPane txtpnCategory = new JTextPane();
    txtpnCategory.setText("Category");
    txtpnCategory.setForeground(Color.WHITE);
    txtpnCategory.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtpnCategory.setEditable(false);
    txtpnCategory.setBackground(Color.DARK_GRAY);
    txtpnCategory.setBounds(269, 55, 150, 19);
    frmEditdeleteAuciton.getContentPane().add(txtpnCategory);

    JTextPane txtpnStaringBid = new JTextPane();
    txtpnStaringBid.setText("Staring Bid");
    txtpnStaringBid.setForeground(Color.WHITE);
    txtpnStaringBid.setFont(new Font("Tahoma", Font.PLAIN, 13));
    txtpnStaringBid.setEditable(false);
    txtpnStaringBid.setBackground(Color.DARK_GRAY);
    txtpnStaringBid.setBounds(419, 55, 150, 19);
    frmEditdeleteAuciton.getContentPane().add(txtpnStaringBid);

    JButton btnEdit = new JButton("EDIT");
    btnEdit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String name = textField.getText();
            String newname = textField_1.getText();
            String bid = textField_2.getText();
            String category = textField_3.getText();
            AuctionMethods.editauction(name, newname, bid, category);

            frmEditdeleteAuciton.dispose();
          }
        });
    btnEdit.setFont(new Font("Tahoma", Font.PLAIN, 15));
    btnEdit.setBounds(93, 382, 137, 33);
    frmEditdeleteAuciton.getContentPane().add(btnEdit);

    JSeparator separator = new JSeparator();
    separator.setOrientation(SwingConstants.VERTICAL);
    separator.setBounds(340, 262, 38, 153);
    frmEditdeleteAuciton.getContentPane().add(separator);

    JLabel lblAreYouSure = new JLabel("Are you sure you want to delete the Auction?");
    lblAreYouSure.setHorizontalAlignment(SwingConstants.CENTER);
    lblAreYouSure.setFont(new Font("Tahoma", Font.PLAIN, 15));
    lblAreYouSure.setBounds(340, 262, 346, 33);
    frmEditdeleteAuciton.getContentPane().add(lblAreYouSure);

    JLabel label = new JLabel("This option CANNOT be undone!!");
    label.setHorizontalAlignment(SwingConstants.CENTER);
    label.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 16));
    label.setBounds(358, 322, 328, 31);
    frmEditdeleteAuciton.getContentPane().add(label);

    JButton button = new JButton("YES");
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String name = textField.getText();
            AuctionMethods.deleteauction(name);

            textField.setText(null);
          }
        });
    button.setFont(new Font("Tahoma", Font.BOLD, 20));
    button.setBounds(358, 364, 127, 51);
    frmEditdeleteAuciton.getContentPane().add(button);

    JButton button_1 = new JButton("NO");
    button_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            textField.setText(null);
          }
        });
    button_1.setFont(new Font("Tahoma", Font.BOLD, 20));
    button_1.setBounds(559, 364, 127, 51);
    frmEditdeleteAuciton.getContentPane().add(button_1);

    JSeparator separator_1 = new JSeparator();
    separator_1.setBounds(55, 169, 578, 19);
    frmEditdeleteAuciton.getContentPane().add(separator_1);

    JLabel lblEnterNameOf_1 = new JLabel("Enter name of Auction you want to edit or delete");
    lblEnterNameOf_1.setHorizontalAlignment(SwingConstants.CENTER);
    lblEnterNameOf_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
    lblEnterNameOf_1.setBounds(91, 189, 328, 33);
    frmEditdeleteAuciton.getContentPane().add(lblEnterNameOf_1);

    textField = new JTextField();
    textField.setColumns(10);
    textField.setBounds(432, 189, 174, 33);
    frmEditdeleteAuciton.getContentPane().add(textField);
  }
コード例 #21
0
ファイル: ReporteAlumnos.java プロジェクト: edariasm/SAYD
  public ReporteAlumnos() {

    conn = conectionTest.conectaraDB();

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setBounds(100, 100, 1500, 644);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);
    setLocationRelativeTo(null);

    JLabel lblReporteAlumnos = new JLabel("Reportes de alumnos");
    lblReporteAlumnos.setFont(new Font("Tahoma", Font.PLAIN, 18));
    lblReporteAlumnos.setBounds(10, 11, 194, 30);
    contentPane.add(lblReporteAlumnos);

    JButton btnBuscarAlumno = new JButton("Buscar alumno");
    btnBuscarAlumno.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {

            String nombreAlumno = txtNombre.getText();
            String apellidoAlumno = txtApellido1.getText();
            String querybuscarAlumno =
                "Select * "
                    + "from Alumnos "
                    + "where Nombre = '"
                    + nombreAlumno
                    + "'"
                    + "and [Apellido 1] = '"
                    + apellidoAlumno
                    + "'";
            String queryultpago =
                "Select Alumnos.Nombre,Alumnos.[Apellido 1],Pagos.Monto_pago,Pagos.Fecha_pago,Pagos.Concepto_pago "
                    + "from Alumnos inner join Pagos on Alumnos.Id_Alumno = Pagos.ID_Alumno "
                    + "Where Nombre = '"
                    + nombreAlumno
                    + "' and Fecha_pago < GETDATE()";
            String queryAsistencia =
                "Select Count(Asistencia.Fecha) "
                    + "from Alumnos inner join Asistencia	on Alumnos.Id_Alumno = Asistencia.ID_Alumno "
                    + "where Nombre = '"
                    + nombreAlumno
                    + "' and [Apellido 1] = '"
                    + apellidoAlumno
                    + "' and Fecha < GETDATE()";
            String queryAsistDetalle =
                "Select Asistencia.Fecha, alumnos.nombre, alumnos.[Apellido 1] "
                    + "from Alumnos inner join Asistencia  on Alumnos.Id_Alumno = Asistencia.ID_Alumno "
                    + "where Nombre = '"
                    + nombreAlumno
                    + "' and [Apellido 1] = '"
                    + apellidoAlumno
                    + "' and Fecha < GETDATE()";
            String querypruebas =
                "select Alumnos.Nombre, "
                    + "Alumnos.[Apellido 1], "
                    + "Mediciones.FechaPrueba, "
                    + "Mediciones.LadoALado, "
                    + "Mediciones.Seguidillas, "
                    + "Mediciones.SaltoLargo, "
                    + "Mediciones.Abs, "
                    + "Mediciones.Peso, "
                    + "Mediciones.Talla "
                    + "from Alumnos inner join Mediciones on Alumnos.Id_Alumno = Mediciones.ID_Alumno Where "
                    + "Nombre = '"
                    + nombreAlumno
                    + "' and [Apellido 1] = '"
                    + apellidoAlumno
                    + "' and FechaPrueba < GETDATE()";

            try {

              // crear un statement
              Statement stmt = conn.createStatement();
              // crear un result set
              ResultSet rs =
                  stmt.executeQuery(
                      querybuscarAlumno); // esta linea crea un result set con el query que
                                          // definimos en la variable query

              Statement stmt2 = conn.createStatement();
              ResultSet rs2 = stmt2.executeQuery(queryultpago);

              Statement stmt3 = conn.createStatement();
              ResultSet rs3 = stmt3.executeQuery(queryAsistencia);

              Statement stmt4 = conn.createStatement();
              ResultSet rs4 = stmt4.executeQuery(queryAsistDetalle);

              Statement stmt5 = conn.createStatement();
              ResultSet rs5 = stmt5.executeQuery(querypruebas);

              while (rs.next()) {

                String Nombre =
                    rs.getString(
                        "Nombre"); // crea el string nombre y le asigna el valor del result set que
                                   // tiene la columna nombre
                String Apellido1 = rs.getString("Apellido 1");
                String nombreCompleto1 = Nombre + " " + Apellido1;
                String Mensualidad = rs.getString("Mensualidad");

                nombreCompleto.setText(nombreCompleto1);
                txtMensualidad.setText(Mensualidad);
              }

              while (rs2.next()) {
                String montoultpago = rs2.getString("Monto_pago");
                String concultpago = rs2.getString("Concepto_pago");
                txtUltimoPago.setText(montoultpago);
                txtConcepto.setText(concultpago);
              }

              while (rs3.next()) {
                int reslt = rs3.getInt(1);
                String resultado = String.valueOf(reslt);
                txtAsistencia.setText(resultado);
              }

              table_2.setModel(
                  DbUtils.resultSetToTableModel(
                      rs4)); // llena la tabla 2 con los resultados del result set. Utiliza el jar
                             // r2xml
              table_3.setModel(DbUtils.resultSetToTableModel(rs5));

            } catch (SQLException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });

    btnBuscarAlumno.setBounds(348, 60, 138, 23);
    contentPane.add(btnBuscarAlumno);

    table = new JTable();
    table.setBounds(34, 263, 149, -143);
    table.setBackground(Color.white);
    table.setOpaque(true);
    contentPane.add(table);

    txtNombre = new JTextField();
    txtNombre.setText("Nombre");
    txtNombre.setBounds(31, 61, 121, 20);
    contentPane.add(txtNombre);
    txtNombre.setColumns(10);

    txtApellido1 = new JTextField();
    txtApellido1.setText("Apellido 1");
    txtApellido1.setBounds(180, 61, 110, 20);
    contentPane.add(txtApellido1);
    txtApellido1.setColumns(10);

    JLabel lblNombreCompleto = new JLabel("Nombre completo");
    lblNombreCompleto.setBounds(34, 92, 194, 14);
    contentPane.add(lblNombreCompleto);

    nombreCompleto = new JTextField();
    nombreCompleto.setEnabled(false);
    nombreCompleto.setBounds(34, 106, 194, 20);
    contentPane.add(nombreCompleto);
    nombreCompleto.setColumns(10);

    JLabel lblFechaInicial = new JLabel("Inicio del reporte");
    lblFechaInicial.setBounds(34, 199, 118, 14);
    contentPane.add(lblFechaInicial);

    txtDeEnero = new JTextField();
    txtDeEnero.setEnabled(false);
    txtDeEnero.setText("4 de enero 2016");
    txtDeEnero.setBounds(162, 196, 103, 20);
    contentPane.add(txtDeEnero);
    txtDeEnero.setColumns(10);

    JLabel lblMensualidad = new JLabel("Mensualidad");
    lblMensualidad.setBounds(34, 137, 86, 14);
    contentPane.add(lblMensualidad);

    txtMensualidad = new JTextField();
    txtMensualidad.setEnabled(false);
    txtMensualidad.setBounds(34, 156, 86, 20);
    contentPane.add(txtMensualidad);
    txtMensualidad.setColumns(10);

    txtUltimoPago = new JTextField();
    txtUltimoPago.setEnabled(false);
    txtUltimoPago.setBounds(152, 156, 86, 20);
    contentPane.add(txtUltimoPago);
    txtUltimoPago.setColumns(10);

    JLabel lblUltimoPago = new JLabel("Ultimo pago");
    lblUltimoPago.setBounds(152, 137, 86, 14);
    contentPane.add(lblUltimoPago);

    JLabel lblNewLabel = new JLabel("Concepto");
    lblNewLabel.setBounds(267, 137, 159, 14);
    contentPane.add(lblNewLabel);

    txtConcepto = new JTextField();
    txtConcepto.setEnabled(false);
    txtConcepto.setBounds(267, 156, 279, 20);
    contentPane.add(txtConcepto);
    txtConcepto.setColumns(10);

    JLabel lblAsistenciaDuranteEl = new JLabel("Asistencia durante el periodo");
    lblAsistenciaDuranteEl.setBounds(85, 263, 186, 14);
    contentPane.add(lblAsistenciaDuranteEl);

    txtAsistencia = new JTextField();
    txtAsistencia.setEnabled(false);
    txtAsistencia.setBounds(130, 283, 53, 20);
    contentPane.add(txtAsistencia);
    txtAsistencia.setColumns(10);

    JLabel lblDetalle = new JLabel("Detalle de asistencia");
    lblDetalle.setBounds(100, 314, 149, 14);
    contentPane.add(lblDetalle);

    JLabel lblComptenciasDuranteEl = new JLabel("Comptencias durante el periodo");
    lblComptenciasDuranteEl.setBounds(431, 263, 209, 14);
    contentPane.add(lblComptenciasDuranteEl);

    textField_7 = new JTextField();
    textField_7.setEnabled(false);
    textField_7.setBounds(477, 283, 53, 20);
    contentPane.add(textField_7);
    textField_7.setColumns(10);

    JLabel lblDetalle_1 = new JLabel("Detalle de Competencias");
    lblDetalle_1.setBounds(450, 314, 159, 14);
    contentPane.add(lblDetalle_1);

    JLabel lblMedicionesFisicas = new JLabel("Mediciones fisicas");
    lblMedicionesFisicas.setBounds(809, 263, 138, 14);
    contentPane.add(lblMedicionesFisicas);

    JLabel lblDetalle_2 = new JLabel("Detalle de mediciones");
    lblDetalle_2.setBounds(809, 314, 127, 14);
    contentPane.add(lblDetalle_2);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(34, 338, 289, 245);
    contentPane.add(scrollPane);

    table_2 = new JTable();
    scrollPane.setViewportView(table_2);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(699, 363, 606, 210);
    contentPane.add(scrollPane_1);

    table_3 = new JTable();
    scrollPane_1.setViewportView(table_3);

    JButton btnMenuPrincipal = new JButton("Menu Principal");
    btnMenuPrincipal.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            MainMenu mm = new MainMenu();
            mm.setVisible(true);
            close();
          }
        });
    btnMenuPrincipal.setBounds(496, 60, 121, 23);
    contentPane.add(btnMenuPrincipal);

    table_1 = new JTable();
    table_1.setModel(new DefaultTableModel(new Object[][] {}, new String[] {"New column"}));
  }
コード例 #22
0
  // Build the form
  public PackagesFrame() {
    super("Packages", true, true, true, true);
    // Hide the frame when closed, don't destroy it as it is only created
    // once
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    getContentPane().setLayout(null);
    getContentPane().setSize(800, 550);

    // Add CRUD buttons
    // Add all panels to form
    getContentPane().add(new JLabel("Viewing Packages"), "North");
    getContentPane().add(pnlCrudPanel, "South");
    pnlCrudPanel.setBounds(0, 496, 756, 31);
    pnlCrudPanel.add(btnDelete);
    pnlCrudPanel.add(btnSave);
    pnlCrudPanel.add(btnEdit);
    {
      jScrollPane1 = new JScrollPane();
      getContentPane().add(jScrollPane1);
      jScrollPane1.setBounds(12, 34, 774, 223);
      btnNew.setBounds(304, 415, 35, 21);
      btnNew.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              addNewRow();
            }
          });
      btnEdit.setBounds(350, 415, 32, 21);
      pnlCrudPanel.add(btnNew);
      btnEdit.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              btnEditMouseClicked(e);
            }
          });
      btnSave.setBounds(393, 415, 38, 21);
      btnSave.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              btnSaveMouseClicked(e);
            }
          });
      btnDelete.setBounds(442, 415, 45, 21);
      btnDelete.addActionListener(
          new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
              btnDeleteMouseClicked(e);
            }
          });
      {
        tblPackages = new JTable();
        jScrollPane1.setViewportView(tblPackages);
        tblPackages.setRowHeight(25);
        // initialize package table with result set
        pkgTblModel = new PackagesTableModel();
        tblPackages.setSurrendersFocusOnKeystroke(true);
        tblPackages.setBorder(BorderFactory.createBevelBorder(1));
        tblPackages.addMouseListener(
            new MouseAdapter() {
              public void mousePressed(MouseEvent evt) {}

              public void mouseClicked(java.awt.event.MouseEvent e) {
                int clicked = e.getClickCount();
                if (clicked == 2) {
                  Point pt = e.getPoint();
                  int i = tblPackages.rowAtPoint(pt);
                  int j = tblPackages.columnAtPoint(pt);
                  // System.out.println("<" + i + "," + j + ">");
                  if (j == PackagesTableModel.START_DATE || j == PackagesTableModel.END_DATE) {
                    // show calendar
                    if (JOptionPane.showConfirmDialog(null, calStartDate)
                        == JOptionPane.OK_OPTION) {
                      java.sql.Date d =
                          new java.sql.Date(calStartDate.getCalendar().getTimeInMillis());
                      pkgTblModel.setValueAt(d, i, j);
                    }
                  }
                }
              }
            });
        tblPackages
            .getSelectionModel()
            .addListSelectionListener(
                new ListSelectionListener() {
                  @Override
                  public void valueChanged(ListSelectionEvent e) {
                    //								if (e.getValueIsAdjusting()
                    //										&& (e.getFirstIndex() != e
                    //												.getLastIndex()))
                    listSelectionChaged(e);
                  }
                });

        tblPackages.setModel(pkgTblModel);
        initTable(pkgTblModel, -1);
        // sorter = new TableRowSorter<PackagesTableModel>(pkgTblModel);
        // sorter confuses my table model
        // tblPackages.setRowSorter(sorter);

        tblPackages.setDefaultRenderer(Object.class, new EvenOddRenderer());
        // final NumericTextField ntf = new NumericTextField(currency);
        final NumericTextField ntf = new NumericTextField();
        tblPackages
            .getColumnModel()
            .getColumn(PackagesTableModel.COMMISSION)
            .setCellEditor(new DefaultCellEditor(ntf));
        tblPackages
            .getColumnModel()
            .getColumn(PackagesTableModel.PRICE)
            .setCellEditor(new DefaultCellEditor(ntf));
        ntf.addFocusListener(
            new FocusListener() {
              @Override
              public void focusGained(FocusEvent e) {
                eraseNonNumeric(e);
                NumberFormat currency = NumberFormat.getCurrencyInstance(Locale.CANADA);
                try {
                  Double dblValue =
                      currency.parse(((JTextField) e.getComponent()).getText()).doubleValue();
                  ((JTextField) e.getComponent()).setText(dblValue.toString());
                } catch (ParseException e1) {
                  e1.printStackTrace();
                }
              }

              @Override
              public void focusLost(FocusEvent e) {}
            });
        ntf.addKeyListener(
            new KeyAdapter() {
              public void keyTyped(KeyEvent e) {
                TXLogger.logger.debug("NumericTextFiled: " + e.getKeyCode());
                // System.out.println("NumericTextFiled: "
                // + e.getKeyChar());
                String txtOld = ((JTextField) e.getComponent()).getText();
                if (e.getKeyChar() >= KeyEvent.VK_0 && e.getKeyChar() <= KeyEvent.VK_9) {
                  if (txtOld.indexOf('.') == -1 && txtOld.length() >= 15) {
                    e.consume();
                    return;
                  }
                  return;
                } else if (e.getKeyChar() == '.') {
                  if (((JTextField) e.getComponent()).getText().indexOf('.') > -1) e.consume();
                  TXLogger.logger.debug(
                      "index of ." + ((JTextField) e.getComponent()).getText().indexOf('.'));
                  // System.out.println("index of ."
                  // + ((JTextField) e.getComponent()).getText()
                  // .indexOf('.'));
                } else if (e.getKeyCode() != '\n') {
                  e.consume();
                }
              }
            });
        JTextField cellNotNull = new JTextField();
        tblPackages
            .getColumnModel()
            .getColumn(PackagesTableModel.PACKAGE_NAME)
            .setCellEditor(new DefaultCellEditor(cellNotNull));
        tblPackages
            .getColumnModel()
            .getColumn(PackagesTableModel.DESCRIPTION)
            .setCellEditor(new DefaultCellEditor(cellNotNull));
        cellNotNull.addFocusListener(
            new FocusListener() {
              @Override
              public void focusGained(FocusEvent e) {
                String txt = ((JTextField) (e.getComponent())).getText();
                if ((txt.indexOf((VALUE_REQUIRED)) >= 0)) {
                  ((JTextField) (e.getComponent())).setText("");
                }
              }

              @Override
              public void focusLost(FocusEvent e) {}
            });
        // Column 5 and 6 only accept numeric input
        cellNotNull.addKeyListener(
            new KeyAdapter() {
              public void keyTyped(KeyEvent e) {
                TXLogger.logger.debug(e.getKeyChar());
                // System.out.println(e.getKeyChar());
                if (((JTextField) e.getComponent()).getText().length() >= 100) {
                  e.consume();
                  return;
                }
              }
            });
        // popup memu
        tblPackages.addMouseListener(
            new MouseAdapter() {
              public void mousePressed(MouseEvent evt) {
                if (tblPackages.getSelectedRow() >= 0 && evt.getButton() == MouseEvent.BUTTON3) {
                  popupMenu.show(evt.getComponent(), evt.getX(), evt.getY());
                }
              }
            });
        cellNotNull.addFocusListener(
            new FocusListener() {
              @Override
              public void focusGained(FocusEvent e) {
                if (((JTextField) e.getComponent()).getText().trim().equals(VALUE_REQUIRED)) {
                  ((JTextField) e.getComponent()).setText("");
                }
                ((JTextField) e.getComponent()).setBackground(Color.RED);
              }

              @Override
              public void focusLost(FocusEvent e) {}
            });
        tblPackages.setBounds(32, 12, 700, 203);
        tblPackages.setPreferredSize(new java.awt.Dimension(756, 422));
        popupMenu = new JPopupMenu();

        copyItem = new JMenuItem("Copy and create a new package");
        copyItem.addActionListener(
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                copyAndCreate(tblPackages.getSelectedRow());
              }
            });
        JMenuItem deleteItem = new JMenuItem("Delete");
        deleteItem.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                btnDeleteMouseClicked(null);
              }
            });

        JMenuItem newItem = new JMenuItem("New");
        newItem.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                addNewRow();
              }
            });
        JMenuItem editItem = new JMenuItem("Edit");
        editItem.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                btnEditMouseClicked(null);
              }
            });
        JMenuItem saveItem = new JMenuItem("Save");
        saveItem.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                btnSaveMouseClicked(null);
              }
            });
        JMenuItem printItem = new JMenuItem("Print");
        printItem.addActionListener(
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                try {
                  // openURL("http://google.com");
                  openURL("http://localhost:8081/CrystalWeb2/PackageList.rpt-viewer.jsp");
                } catch (RuntimeException e1) {
                  TXLogger.logger.error(e1.getMessage());
                  // e1.printStackTrace();
                } catch (IOException e2) {
                  TXLogger.logger.error(e2.getMessage());
                  // e2.printStackTrace();
                }
              }
            });
        popupMenu.add(copyItem);
        popupMenu.addSeparator();
        popupMenu.add(deleteItem);
        popupMenu.add(saveItem);
        popupMenu.add(editItem);
        popupMenu.add(newItem);
        popupMenu.addSeparator();
        popupMenu.add(printItem);
      }
    }
    {
      cmbProdFilterModel = new DefaultComboBoxModel();
      cmbProdFilter = new JComboBox();
      getContentPane().add(cmbProdFilter);
      cmbProdFilter.setModel(cmbProdFilterModel);
      cmbProdFilter.setBounds(436, 283, 204, 21);
      cmbProdFilter.setEditable(true);
      cmbProdFilter.addItemListener(
          new ItemListener() {
            public void itemStateChanged(ItemEvent evt) {
              cmbProdFilterItemStateChanged(evt);
            }
          });
    }
    {
      jLabel1 = new JLabel();
      getContentPane().add(jLabel1);
      jLabel1.setBounds(33, 9, 129, 14);
      jLabel1.setName("jLabel1");
    }
    {
      jLabel2 = new JLabel();
      getContentPane().add(jLabel2);
      jLabel2.setBounds(34, 248, 94, 14);
      jLabel2.setName("jLabel2");
    }
    {
      jLabel3 = new JLabel();
      getContentPane().add(jLabel3);
      jLabel3.setBounds(436, 248, 119, 14);
      jLabel3.setName("jLabel3");
    }
    {
      btnInc = new JButton("<");
      getContentPane().add(btnInc);
      btnInc.setBounds(351, 327, 52, 21);
      btnInc.setName("btnInc");
      btnInc.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent evt) {
              TXLogger.logger.debug("btnInc.mouseClicked, event");
              // System.out.println("btnInc.mouseClicked, event=" + evt);
              btnIncMouseClicked(evt);
            }
          });
    }
    {
      btnIncAll = new JButton("<<");
      getContentPane().add(btnIncAll);
      btnIncAll.setBounds(351, 362, 52, 21);
      btnIncAll.setName("btnIncAll");
      btnIncAll.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent evt) {
              btnIncAllMouseClicked(evt);
            }
          });
    }
    {
      btnExc = new JButton(">");
      getContentPane().add(btnExc);
      btnExc.setBounds(351, 394, 52, 21);
      btnExc.setName("btnExc");
      btnExc.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent evt) {
              btnExcMouseClicked(evt);
            }
          });
    }
    {
      btnExcAll = new JButton(">>");
      getContentPane().add(btnExcAll);
      btnExcAll.setBounds(351, 426, 52, 21);
      btnExcAll.setName("btnExcAll");
      btnExcAll.addMouseListener(
          new MouseAdapter() {
            public void mouseClicked(MouseEvent evt) {
              btnExcAllMouseClicked(evt);
            }
          });
    }
    {
      jScrollPane3 = new JScrollPane();
      getContentPane().add(jScrollPane3);
      jScrollPane3.setBounds(437, 306, 286, 169);
      {
        ListModel jList1Model = new DefaultComboBoxModel(new String[] {"Item One", "Item Two"});
        lstProdAvi =
            new JList(new Object[] {"First Class Flight", "Car Rental", "Scuba Diving Adventure"});
        jScrollPane3.setViewportView(lstProdAvi);
        lstProdAvi.setModel(jList1Model);
        lstProdAvi.setBorder(
            BorderFactory.createTitledBorder(
                BorderFactory.createBevelBorder(1), "Product--Supplier"));
        lstProdAvi.setBounds(436, 284, 286, 169);
        dlmAvi = new DefaultListModel();
        lstProdAvi.setModel(dlmAvi);
      }
    }
    {
      jScrollPane2 = new JScrollPane();
      getContentPane().add(jScrollPane2);
      getContentPane().add(getJLabel4());
      getContentPane().add(getJLabel5());
      getContentPane().add(getJLabel7());
      getContentPane().add(getCmbPkgFilter());
      getContentPane().add(getJLabel8());
      getContentPane().add(getJLabel6());
      getContentPane().add(getCmbOrderBy());
      jScrollPane2.setBounds(34, 303, 286, 166);
      jScrollPane2.setViewportView(lstProdInc);
    }
    // Draw fancy border for the list
    lstProdInc.setBorder(
        BorderFactory.createTitledBorder(BorderFactory.createBevelBorder(1), "Product--Supplier"));
    lstProdInc.setBounds(33, 281, 286, 166);
    lstProdInc.setModel(dlmInc);
    validate();
    pack();
    Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
    getAllProdList("");
    initCboProdFilter();
    tblPackages.getColumn(pkgTblModel.getColumnName(0)).setPreferredWidth(15);
    tblPackages.getColumn(pkgTblModel.getColumnName(1)).setPreferredWidth(100);
    tblPackages.getColumn(pkgTblModel.getColumnName(2)).setPreferredWidth(40);
    tblPackages.getColumn(pkgTblModel.getColumnName(3)).setPreferredWidth(40);
    tblPackages.getColumn(pkgTblModel.getColumnName(4)).setPreferredWidth(200);
    tblPackages.getColumn(pkgTblModel.getColumnName(5)).setPreferredWidth(40);
    tblPackages.getColumn(pkgTblModel.getColumnName(6)).setPreferredWidth(40);
    tblPackages.setName("tblPackages");
    setButtonState(false);
  }
コード例 #23
0
ファイル: CadFornecedor.java プロジェクト: KPaes/ProDentSys
  public CadFornecedor() throws DaoException {
    setResizable(false);
    setIconImage(
        Toolkit.getDefaultToolkit()
            .getImage(CadFornecedor.class.getResource("/br/com/images/logo_sys.png")));
    setTitle("Cadastro de Fornecedores");
    // setIconImage(Toolkit.getDefaultToolkit().getImage(CadFuncionario.class.getResource("/br/com/images/cadForm.jpg")));
    int width = 800;
    int height = 600;
    setModal(true);
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width - width) / 2;
    int y = (screen.height - height) / 3;
    setBounds(x, y, 821, 600);
    getContentPane().setLayout(null);

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setBackground(UIManager.getColor("Button.background"));
    buttonPanel.setBounds(0, 0, 152, 562);
    getContentPane().add(buttonPanel);
    buttonPanel.setLayout(null);

    JLabel lblPesquisar = new JLabel("Pesquisar");
    lblPesquisar.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 13));
    lblPesquisar.setBounds(40, 66, 75, 14);
    buttonPanel.add(lblPesquisar);

    txtPesq = new JXSearchField();
    txtPesq.addKeyListener(this);
    txtPesq.setFont(new Font("Tahoma", Font.PLAIN, 11));
    txtPesq.setPrompt("Nome do fornecedor");
    txtPesq.setToolTipText("Digite o nome do fornecedor");
    txtPesq.setBounds(0, 84, 152, 20);
    buttonPanel.add(txtPesq);
    txtPesq.setColumns(10);

    formulario.setBounds(152, 0, 632, 562);
    getContentPane().add(formulario);
    formulario.setLayout(null);

    JPanel panel = new JPanel();
    panel.setBorder(
        new TitledBorder(
            new TitledBorder(
                new LineBorder(new Color(0, 0, 0)),
                "",
                TitledBorder.LEADING,
                TitledBorder.TOP,
                null,
                null),
            "Dados pessoais",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            new Color(0, 0, 0)));
    panel.setLayout(null);
    panel.setBounds(21, 35, 590, 288);
    formulario.add(panel);

    JLabel lblnome = new JLabel("*Nome:");
    lblnome.setHorizontalAlignment(SwingConstants.RIGHT);
    lblnome.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblnome.setBounds(12, 31, 70, 18);
    panel.add(lblnome);

    JLabel lbltelefone = new JLabel("*Telefone:");
    lbltelefone.setHorizontalAlignment(SwingConstants.RIGHT);
    lbltelefone.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lbltelefone.setBounds(12, 60, 70, 18);
    panel.add(lbltelefone);

    JLabel lblrua = new JLabel("*Rua:");
    lblrua.setHorizontalAlignment(SwingConstants.RIGHT);
    lblrua.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblrua.setBounds(12, 89, 70, 18);
    panel.add(lblrua);

    JLabel lbln = new JLabel("*N\u00BA:");
    lbln.setHorizontalAlignment(SwingConstants.RIGHT);
    lbln.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lbln.setBounds(356, 89, 50, 18);
    panel.add(lbln);

    JLabel lblbairro = new JLabel("*Bairro:");
    lblbairro.setHorizontalAlignment(SwingConstants.RIGHT);
    lblbairro.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblbairro.setBounds(12, 147, 70, 18);
    panel.add(lblbairro);

    JLabel lblcidade = new JLabel("*Cidade:");
    lblcidade.setHorizontalAlignment(SwingConstants.RIGHT);
    lblcidade.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblcidade.setBounds(12, 176, 70, 18);
    panel.add(lblcidade);

    JLabel lblcep = new JLabel("*CEP:");
    lblcep.setHorizontalAlignment(SwingConstants.RIGHT);
    lblcep.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblcep.setBounds(12, 205, 70, 18);
    panel.add(lblcep);

    JButton button = new JButton("");
    button.setToolTipText("Salvar Alt+S");
    button.setMnemonic(KeyEvent.VK_S);
    button.setIcon(new ImageIcon(CadFornecedor.class.getResource("/br/com/images/salvar.png")));
    button.setBounds(491, 242, 63, 35);
    panel.add(button);

    button.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {

            if (validarFormulário()) {
              Fornecedor obj = new Fornecedor();

              obj.setTelFornec(textField_2.getText());
              obj.setRuaFornec(textField_4.getText());
              obj.setNumEndFornec(textField_6.getText());
              obj.setBairroFornec(textField_7.getText());
              obj.setCidadeFornec(textField_8.getText());
              obj.setNomeFornec(textField.getText());
              obj.setCepFornec(textField_3.getText());
              obj.setComplFornec(textField_9.getText());

              FornecedorDao objDAO = new FornecedorDao();
              try {

                if (textField_5.getText().equals("")) {
                  objDAO.inserirFornecedores(obj);
                  JOptionPane.showMessageDialog(formulario, "Dados salvos com sucesso!");
                  limpaFormulario();
                } else {
                  Integer matr = Integer.parseInt(textField_5.getText());
                  obj.setNumFornec(matr);
                  objDAO.atualizarFornecedor(obj);
                  JOptionPane.showMessageDialog(formulario, "Dados atualizados com sucesso!");
                }
                atualizaLista(table, "");
              } catch (DaoException e) {
                e.printStackTrace();
              }
            }
          }
        });

    JButton button_1 = new JButton("");
    button_1.setIcon(new ImageIcon(CadFornecedor.class.getResource("/br/com/images/limpar.png")));
    button_1.setMnemonic(KeyEvent.VK_L);
    button_1.setToolTipText("Limpar Alt+L");
    button_1.setBounds(418, 242, 63, 35);
    panel.add(button_1);
    button_1.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            limpaFormulario();
          }
        });

    textField = new JTextField();
    textField.setBounds(92, 31, 389, 20);
    panel.add(textField);
    textField.setColumns(10);
    try {
      textField_2 = new JFormattedTextField(MascaraUtil.setMaskTelefoneInTf(textField_2));
    } catch (ParseException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    textField_2.setBounds(92, 60, 127, 20);
    panel.add(textField_2);
    textField_2.setColumns(10);
    try {
      textField_3 = new JFormattedTextField(MascaraUtil.setMaskCepInTf(textField_3));
    } catch (ParseException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }
    textField_3.setBounds(92, 205, 127, 20);
    panel.add(textField_3);
    textField_3.setColumns(10);

    textField_4 = new JTextField();
    textField_4.setBounds(92, 89, 254, 20);
    panel.add(textField_4);
    textField_4.setColumns(10);

    textField_6 = new JTextField();
    textField_6.setBounds(411, 89, 70, 20);
    panel.add(textField_6);
    textField_6.setColumns(10);

    textField_7 = new JTextField();
    textField_7.setBounds(92, 147, 254, 20);
    panel.add(textField_7);
    textField_7.setColumns(10);

    textField_8 = new JTextField();
    textField_8.setBounds(92, 176, 254, 20);
    panel.add(textField_8);
    textField_8.setColumns(10);

    textField_5 = new JTextField();
    textField_5.setVisible(false);
    textField_5.setText("");
    panel.add(textField_5);

    JLabel lblTodosOsCampos = new JLabel("*Campos obrigat\u00F3rios!");
    lblTodosOsCampos.setForeground(new Color(255, 0, 0));
    lblTodosOsCampos.setFont(new Font("Tahoma", Font.PLAIN, 12));
    lblTodosOsCampos.setBounds(122, 257, 206, 14);
    panel.add(lblTodosOsCampos);

    JLabel lblComplemento = new JLabel("Compl.:");
    lblComplemento.setHorizontalAlignment(SwingConstants.RIGHT);
    lblComplemento.setFont(new Font("Arial Black", Font.PLAIN, 12));
    lblComplemento.setBounds(12, 118, 70, 18);
    panel.add(lblComplemento);

    textField_9 = new JTextField();
    textField_9.setBounds(91, 116, 255, 20);
    panel.add(textField_9);
    textField_9.setColumns(10);

    JButton btnVoltar = new JButton("");
    btnVoltar.setIcon(new ImageIcon(CadFornecedor.class.getResource("/br/com/images/voltar.png")));
    btnVoltar.setToolTipText("Voltar");
    btnVoltar.setBounds(21, 340, 89, 23);
    formulario.add(btnVoltar);

    lista.setBounds(152, 0, 656, 562);
    getContentPane().add(lista);
    lista.setLayout(null);

    JLabel lblFuncionriosCadastrados = new JLabel("Fornecedores Cadastrados");
    lblFuncionriosCadastrados.setFont(new Font("Kalinga", Font.BOLD, 16));
    lblFuncionriosCadastrados.setHorizontalAlignment(SwingConstants.CENTER);
    lblFuncionriosCadastrados.setBackground(Color.WHITE);
    lblFuncionriosCadastrados.setBounds(10, 11, 612, 29);
    lista.add(lblFuncionriosCadastrados);

    Button Novo = new Button("Adicionar");
    Novo.setBounds(10, 530, 70, 22);
    lista.add(Novo);
    lista.setVisible(true);
    table = new JTable();

    table.addMouseListener(
        new MouseListener() {

          @Override
          public void mouseReleased(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mousePressed(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseExited(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseEntered(MouseEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseClicked(MouseEvent arg0) {
            int linha = table.getSelectedRow();
            int coluna = table.getSelectedColumn();
            String matricula = (String) table.getValueAt(linha, 0);
            Integer mat = Integer.parseInt(matricula);
            if (coluna == 4) {
              int opcao;
              opcao =
                  JOptionPane.showConfirmDialog(
                      null,
                      "Deseja excluir o fornecedor de matricula: " + matricula,
                      "Cuidado!!",
                      JOptionPane.YES_NO_OPTION);
              if (opcao == JOptionPane.YES_OPTION) {
                try {
                  fornecDao.excluirFornecedores(mat);
                  atualizaLista(table, "");
                } catch (DaoException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
                JOptionPane.showMessageDialog(null, "Dados excluídos com sucesso!");
              }
            }
            if (coluna == 3) {
              Fornecedor objFornec = new Fornecedor();

              try {
                objFornec = fornecDao.consultarFornecedorID(mat);
                atualizaFormulario(objFornec);
                buttonPanel.setVisible(false);
              } catch (DaoException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
            }
          }
        });

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setModel(
        new DefaultTableModel(
            new Object[][] {}, new String[] {"Número", "Nome", "Telefone", "Editar", "Excluir"}) {

          private static final long serialVersionUID = 1L;

          @Override
          public boolean isCellEditable(int row, int col) {
            return false;
          }
        });
    table.getColumnModel().getColumn(0).setPreferredWidth(55);
    table.getColumnModel().getColumn(0).setMinWidth(55);
    table.getColumnModel().getColumn(1).setPreferredWidth(220);
    table.getColumnModel().getColumn(1).setMinWidth(220);
    table.getColumnModel().getColumn(2).setPreferredWidth(80);
    table.getColumnModel().getColumn(2).setMinWidth(80);
    table.getColumnModel().getColumn(3).setPreferredWidth(70);
    table.getColumnModel().getColumn(3).setMinWidth(70);
    table.getColumnModel().getColumn(4).setPreferredWidth(60);
    table.getColumnModel().getColumn(4).setMinWidth(60);
    table.setBounds(39, 175, 530, 232);

    atualizaLista(table, "");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 51, 636, 473);
    lista.add(scrollPane);

    scrollPane.setViewportView(table);

    Novo.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            lista.setVisible(false);
            formulario.setVisible(true);
            buttonPanel.setVisible(false);
            limpaFormulario();
            try {
              atualizaLista(table, "");
            } catch (DaoException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });
    formulario.setVisible(false);

    btnVoltar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            lista.setVisible(true);
            formulario.setVisible(false);
            buttonPanel.setVisible(true);
          }
        });
  }