예제 #1
0
  public MediaTable() {
    super();
    setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    table =
        new JTable() {
          private static final long serialVersionUID = 20100125;

          public boolean isCellEditable(int x, int y) {
            return false;
          }
        };
    DefaultTableModel model = new DefaultTableModel();
    model.addColumn("Artist");
    model.addColumn("Title");
    model.addColumn("Album");
    model.addColumn("Length");
    String string[] = {"This", "feature", "is not implemented", "yet"};

    model.addRow(string);

    table.setBackground(Color.WHITE);
    table.setModel(model);
    table.getTableHeader().setReorderingAllowed(false);
    add(table);
    setViewportView(table);
  }
예제 #2
0
 public void unGreyTable() {
   sitesTable.setSelectionBackground(oldSelectionBackground);
   sitesTable.setSelectionForeground(oldSelectionForeground);
   sitesTable.setForeground(Color.BLACK);
   sitesTable.setBackground(Color.WHITE);
   sitesTable.setEnabled(true);
 }
  /**
   * Constructor de la clase, crea la tabla y de da todas las propiedades para mostrarla en la
   * aplicacion.
   */
  public PanelHojaCalculo() {
    modelo = new ModeloTabla();
    columnasTabla = new ModeloColumnasTabla();
    tabla = new JTable(modelo, columnasTabla);
    tablaAux = new JTable(modelo, filasTabla);

    tabla.createDefaultColumnsFromModel();
    tablaAux.createDefaultColumnsFromModel();

    tabla.setColumnSelectionAllowed(true);
    tabla.setRowSelectionAllowed(true);

    tablaAux.setSelectionModel(tabla.getSelectionModel());
    tablaAux.setMaximumSize(new Dimension(40, 10000));
    tablaAux.setBackground(new Color(238, 238, 238));
    // Se puede pasar a true si se quiere seleccionar las filas
    tablaAux.setEnabled(false);
    tablaAux.setColumnSelectionAllowed(false);
    tablaAux.setCellSelectionEnabled(false);

    viewPort = new JViewport();
    viewPort.setView(tablaAux);
    viewPort.setPreferredSize(tablaAux.getMaximumSize());

    tabla.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    tablaAux.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    scrollPane = new JScrollPane(tabla);
    scrollPane.setRowHeader(viewPort);
    scrollPane.setPreferredSize(new Dimension(790, 500));
    add(scrollPane);
  }
  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);
  }
 private void setDataTebleLockState(boolean b) {
   passwd.setText("");
   unlock.setEnabled(b);
   lock.setEnabled(!b);
   if (b) {
     table.setEnabled(false);
     table.setBackground(Color.white);
   } else {
     table.setEnabled(true);
     table.setBackground(Color.yellow);
     JOptionPane.showMessageDialog(
         null,
         "Administration Mode Unlocked",
         "Administration Mode",
         JOptionPane.INFORMATION_MESSAGE);
   }
 }
예제 #6
0
 private void init_table_bg() {
   Color ivory = new Color(255, 255, 255);
   tbl_chats.setOpaque(true);
   jScrollPane1.setBorder(
       javax.swing.BorderFactory.createLineBorder(new java.awt.Color(237, 237, 237)));
   tbl_chats.setFillsViewportHeight(true);
   tbl_chats.setBackground(ivory);
 }
예제 #7
0
  public hostelStatus() {
    setTitle("Hostel");
    connect();
    updateRecord();

    JFrame fr = new JFrame();
    Toolkit tkt = fr.getToolkit();
    Dimension frsize = tkt.getScreenSize();
    setBounds(frsize.width / 4, frsize.height / 12, frsize.width / 2, frsize.height / 8);
    setLayout(null);

    cn = getContentPane();
    cn.setBackground(new Color(190, 180, 170));

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    tl = new JLabel("Current Hostels Status");
    tl.setFont(new Font("Engravers MT", 1, 25));
    tl.setForeground(new Color(247, 251, 249));

    p1 = new JPanel();
    p1.setBounds(0, 0, 600, 50);
    p1.add(tl);
    p1.setBackground(new Color(31, 88, 166));
    cn.add(p1);

    b1 = new JButton("LOAD");
    b1.setMnemonic('L');
    b1.addActionListener(new dispListener());
    b1.setBounds(230, 320, 120, 30);

    b2 = new JButton("EXIT");
    b2.setMnemonic('X');
    b2.addActionListener(new exitListener());
    b2.setBounds(350, 320, 100, 30);

    cn.add(b1);
    cn.add(b2);

    table = new JTable(data, col);
    table.setFont(new Font("Serif", Font.BOLD, 16));
    table.setBackground(new Color(250, 250, 250));
    table.setEnabled(false);

    JScrollPane jsp = new JScrollPane(table);
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setBounds(5, 100, 590, 200);
    cn.add(jsp);

    screensize = Toolkit.getDefaultToolkit().getScreenSize();

    setSize(600, 400);
    setVisible(true);
    setVisible(true);
    setResizable(true);
    connect();
  }
예제 #8
0
 void greyOutTable() {
   sitesTable.setEnabled(false);
   oldSelectionBackground = sitesTable.getSelectionBackground();
   oldSelectionForeground = sitesTable.getSelectionForeground();
   sitesTable.setSelectionBackground(Color.GRAY);
   sitesTable.setSelectionForeground(Color.DARK_GRAY);
   sitesTable.setForeground(Color.GRAY);
   sitesTable.setBackground(null);
 }
예제 #9
0
 public static void main(String[] args) {
   /*
   构造函数有很多下面先介绍几个:
   JTable()
   JTable(int numRows, int numColumns)
   JTable(Object[][] rowData, Object[] columnNames)
   */
   JTable example1 = new JTable(); // 看不到但存在
   JTable example2 = new JTable(8, 6);
   final Object[] columnNames = {
     "姓名", "性别", "家庭地址", // 列名最好用final修饰
     "电话号码", "生日", "工作", "收入", "婚姻状况", "恋爱状况"
   };
   Object[][] rowData = {
     {"ddd", "男", "江苏南京", "1378313210", "03/24/1985", "学生", "寄生中", "未婚", "没"},
     {"eee", "女", "江苏南京", "13645181705", "xx/xx/1985", "家教", "未知", "未婚", "好象没"},
     {"fff", "男", "江苏南京", "13585331486", "12/08/1985", "汽车推销员", "不确定", "未婚", "有"},
     {"ggg", "女", "江苏南京", "81513779", "xx/xx/1986", "宾馆服务员", "确定但未知", "未婚", "有"},
     {"hhh", "男", "江苏南京", "13651545936", "xx/xx/1985", "学生", "流放中", "未婚", "无数次分手后没有"}
   };
   JTable friends = new JTable(rowData, columnNames);
   friends.setPreferredScrollableViewportSize(new Dimension(600, 100)); // 设置表格的大小
   friends.setRowHeight(30); // 设置每行的高度为20
   friends.setRowHeight(0, 20); // 设置第1行的高度为15
   friends.setRowMargin(5); // 设置相邻两行单元格的距离
   friends.setRowSelectionAllowed(true); // 设置可否被选择.默认为false
   friends.setSelectionBackground(Color.white); // 设置所选择行的背景色
   friends.setSelectionForeground(Color.red); // 设置所选择行的前景色
   friends.setGridColor(Color.black); // 设置网格线的颜色
   friends.selectAll(); // 选择所有行
   friends.setRowSelectionInterval(0, 2); // 设置初始的选择行,这里是1到3行都处于选择状态
   friends.clearSelection(); // 取消选择
   friends.setDragEnabled(false); // 不懂这个
   friends.setShowGrid(false); // 是否显示网格线
   friends.setShowHorizontalLines(false); // 是否显示水平的网格线
   friends.setShowVerticalLines(true); // 是否显示垂直的网格线
   friends.setValueAt("tt", 0, 0); // 设置某个单元格的值,这个值是一个对象
   friends.doLayout();
   friends.setBackground(Color.lightGray);
   JScrollPane pane1 = new JScrollPane(example1); // JTable最好加在JScrollPane上
   JScrollPane pane2 = new JScrollPane(example2);
   JScrollPane pane3 = new JScrollPane(friends);
   JPanel panel = new JPanel(new GridLayout(0, 1));
   panel.setPreferredSize(new Dimension(600, 400));
   panel.setBackground(Color.black);
   panel.add(pane1);
   panel.add(pane2);
   panel.add(pane3);
   JFrame frame = new JFrame("JTableDemo");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setContentPane(panel);
   frame.pack();
   frame.show();
 }
예제 #10
0
파일: GUI.java 프로젝트: kryukov/jimm-multi
 /**
  * This method initializes compareTable
  *
  * @return javax.swing.JTable
  */
 private JTable getCompareTable() {
   if (compareTable == null) {
     compareTable = new JTable();
     compareTable.setBackground(java.awt.Color.white);
     compareTable.setFont(new Font("DialogInput", Font.PLAIN, 12));
     compareTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
     compareTable.setModel(getDefaultTableModel(false));
     setTableProps();
   }
   return compareTable;
 }
 private void buildWin() {
   jpbLoading = new JProgressBar(0, 100);
   jfcBrowse = new JFileChooser(Initial.DB_CONFIG_PATH);
   jlConfigPath = new JLabel("配置文件路径:");
   jlStatus = new JLabel("未操作");
   jlConfigPath.setFont(SwingContainerFactory.getFont());
   jlStatus.setFont(SwingContainerFactory.getFont());
   jlStatus.setForeground(Color.RED);
   jpOperatingDbInfo = new JPanel();
   jpStatusBar = new JPanel(new BorderLayout());
   jpDisplay = new JPanel(new BorderLayout());
   jbAddDbInfo = new JButton("添加");
   jbDelDbInfo = new JButton("删除");
   jbSaveDbInfo = new JButton("保存");
   jbBrowse = new JButton("浏览...");
   jbLoadDbInfo = new JButton("加载");
   jbClearDbInfo = new JButton("清空");
   jtfConfigPath = new JTextField(20);
   jbAddDbInfo.setFont(SwingContainerFactory.getFont());
   jbDelDbInfo.setFont(SwingContainerFactory.getFont());
   jbSaveDbInfo.setFont(SwingContainerFactory.getFont());
   jbBrowse.setFont(SwingContainerFactory.getFont());
   jbLoadDbInfo.setFont(SwingContainerFactory.getFont());
   jbClearDbInfo.setFont(SwingContainerFactory.getFont());
   jpOperatingDbInfo.add(jbAddDbInfo);
   jpOperatingDbInfo.add(jbDelDbInfo);
   jpOperatingDbInfo.add(jbClearDbInfo);
   jpOperatingDbInfo.add(jbSaveDbInfo);
   jpOperatingDbInfo.add(jlConfigPath);
   jpOperatingDbInfo.add(jtfConfigPath);
   jpOperatingDbInfo.add(jbBrowse);
   jpOperatingDbInfo.add(jbLoadDbInfo);
   jpStatusBar.add(jpbLoading, BorderLayout.CENTER);
   jpStatusBar.add(jlStatus, BorderLayout.WEST);
   tmDbInfo = new Table();
   jtDbinfo = new JTable(tmDbInfo);
   jtDbinfo.setRowHeight(20);
   jtDbinfo.setBackground(Color.white);
   jtDbinfo.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   TableColumnModel tcm = jtDbinfo.getColumnModel();
   for (int i = 0; i < tcm.getColumnCount(); i++) {
     tcm.getColumn(i).setPreferredWidth(80);
   }
   tcm.getColumn(10).setPreferredWidth(150);
   tcm.getColumn(11).setPreferredWidth(300);
   tcm.getColumn(3).setCellEditor(new DefaultCellEditor(new JComboBox<DBType>(DBType.values())));
   jspDbInfo = new JScrollPane(jtDbinfo);
   jpDisplay.add(jspDbInfo, BorderLayout.CENTER);
   jpDisplay.add(jpOperatingDbInfo, BorderLayout.NORTH);
   this.add(jpDisplay, BorderLayout.CENTER);
   this.add(jpStatusBar, BorderLayout.SOUTH);
 }
예제 #12
0
 private void jbInit() throws Exception {
   setTitle("DIARIO CONTADO");
   frmDatosVenta = new FrmDatosVenta(engine);
   frmDatosVenta.setLocationRelativeTo(this);
   getContentPane().setLayout(borderLayout1);
   jLabel1.setFont(new java.awt.Font("Arial", Font.PLAIN, 18));
   jLabel1.setToolTipText("");
   jLabel1.setText("DIARIO DE ENTRADAS");
   pnlCentro.setLayout(borderLayout2);
   cmdCerrar.setText("CERRAR");
   cmdCerrar.addActionListener(new FrmDiarioDeEntradas_cmdCerrar_actionAdapter(this));
   cmdImprimir.setText("IMPRIMIR");
   tblDiario.setBackground(new Color(255, 240, 255));
   tblDiario.setFont(new java.awt.Font("Arial", Font.PLAIN, 12));
   tblDiario.setModel(modelDiarioVentasDeContado1);
   tblDiario.addMouseListener(new FrmDiarioDeEntradas_tblDiario_mouseAdapter(this));
   this.addWindowListener(new FrmDiarioDeEntradas_this_windowAdapter(this));
   jLabel2.setFont(new java.awt.Font("Arial", Font.BOLD, 20));
   jLabel2.setText("Total:");
   lblTotal.setFont(new java.awt.Font("Arial", Font.BOLD, 20));
   lblTotal.setText("");
   this.getContentPane().setBackground(Color.white);
   this.addKeyListener(new FrmDiarioDeEntradas_this_keyAdapter(this));
   pnlCentro.setBackground(Color.white);
   pnlNorte.setBackground(Color.white);
   pnlNorte.setLayout(borderLayout4);
   scrollDiario.getViewport().setBackground(Color.white);
   scrollDiario.setPreferredSize(new Dimension(800, 600));
   lblFecha.setFont(new java.awt.Font("Arial", Font.BOLD, 16));
   lblFecha.setText("");
   jPanel1.setLayout(borderLayout3);
   pnlSur.setMaximumSize(new Dimension(4000, 200));
   jPanel1.setBackground(Color.white);
   jPanel2.setBackground(Color.white);
   this.getContentPane().add(pnlCentro, java.awt.BorderLayout.CENTER);
   pnlCentro.add(pnlNorte, java.awt.BorderLayout.CENTER);
   pnlCentro.add(scrollDiario, java.awt.BorderLayout.NORTH);
   scrollDiario.getViewport().add(tblDiario);
   this.getContentPane().add(pnlSur, java.awt.BorderLayout.SOUTH);
   pnlSur.add(cmdImprimir);
   pnlSur.add(cmdCerrar);
   this.getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
   jPanel1.add(lblFecha, java.awt.BorderLayout.EAST);
   jPanel1.add(jLabel1, java.awt.BorderLayout.WEST);
   pnlNorte.add(jPanel2, java.awt.BorderLayout.EAST);
   jPanel2.add(jLabel2);
   jPanel2.add(lblTotal);
   this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
 }
예제 #13
0
파일: Frame1.java 프로젝트: elbelife/ctl
 @SuppressWarnings("unused")
 private void jbInit() throws Exception {
   for (int i = 0; i < 4; i++) for (int j = 0; j < 4; j++) data[i][j] = new Integer(i * 10 + j);
   System.out.println("Header length=" + header[1]);
   jTable1 = new JTable(data, header);
   jTable1.setCellSelectionEnabled(true);
   this.setTitle("Excel Lent JTABLE");
   jTable1.setBackground(Color.pink);
   this.setLayout(borderLayout1);
   this.setSize(new Dimension(400, 300));
   this.setBackground(Color.white);
   JScrollPane scrollPane = new JScrollPane(jTable1);
   this.add(scrollPane, BorderLayout.CENTER);
   // This is the line that does all the magic!
   ExcelAdapter myAd = new ExcelAdapter(jTable1);
 }
예제 #14
0
  public DependencyPanel() {
    dataControl = new AnalyseUIController();
    this.indirectFilterBox = new JCheckBox(dataControl.translate("ShowIndirectDependencies"));
    this.indirectFilterBox.addActionListener(this);
    createLayout();

    dependencyTable = new JTable();
    tableModel = new DependencyTableModel(new ArrayList<DependencyDTO>(), dataControl);

    dependencyTable.setModel(tableModel);
    dependencyScrollPane.setViewportView(dependencyTable);
    dependencyTable.setBackground(UIManager.getColor("Panel.background"));
    dependencyTable.setAutoCreateRowSorter(true);
    initialiseTrees();

    setLayout(theLayout);
  }
예제 #15
0
  public void makePartTable() throws SQLiteException, PartException {
    PartTableModel model = new PartTableModel();

    model.addColumn("Id");
    model.addColumn("Name");
    model.addColumn("Material");
    model.addColumn("Projekt Nr.");
    model.addColumn("Erstellt am");

    sqLite.dbConnect();

    datensatz = new PartList(sqLite);

    List<IPart> list = datensatz.getDataListSort();

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

      IPart d = list.get(i);
      model.addRow(
          new Object[] {
            d.getId(),
            d.getName(),
            d.getMaterialId(),
            d.getProjektNr(),
            PartUtil.erstellDatumFormatieren(d.getErstellDatum())
          });
    }
    sqLite.close();

    partTable = new JTable(model);

    partTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);

    partTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    partTable.getColumnModel().getColumn(0).setPreferredWidth(20);
    partTable.getColumnModel().getColumn(1).setPreferredWidth(400);
    partTable.getColumnModel().getColumn(2).setPreferredWidth(150);
    partTable.getColumnModel().getColumn(3).setPreferredWidth(200);
    partTable.getColumnModel().getColumn(4).setPreferredWidth(120);
    partTable.setBackground(Format.BGCOLOR);

    JTableHeader header = partTable.getTableHeader();
    header.setBackground(Color.LIGHT_GRAY);
    header.setForeground(Color.black);
  }
예제 #16
0
  public prueba() {
    setBorder(new LineBorder(new Color(0, 0, 0), 2, true));

    setBounds(0, 0, 800, 600);
    setOpaque(false);

    setLayout(null);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(new Rectangle(500, 0, 250, 400));
    scrollPane_1.setBounds(50, 50, 650, 450);
    add(scrollPane_1);
    leftTable = new JTable(new SimpleColorTableModel());
    leftTable.setBackground(new Color(153, 204, 255));
    scrollPane_1.setViewportView(leftTable);

    setupTable(leftTable);

    populate((SimpleColorTableModel) leftTable.getModel());

    setSize(800, 600);
  }
예제 #17
0
  public GoodsInfoDialog(Frame f, String title, boolean model, GoodsBean gb) {
    super(f, title, model);
    getContentPane().setBackground(new Color(175, 238, 238));
    this.gb = gb;
    lblGoods = new JLabel("输入相关商品信息进行查询(商品编号、名称):");
    btnAdd = new JButton("增加");
    btnAdd.setBackground(new Color(176, 224, 230));
    btnUpdate = new JButton("修改");
    btnUpdate.setBackground(new Color(176, 224, 230));
    btnDel = new JButton("删除");
    btnDel.setBackground(new Color(176, 224, 230));
    btnExit = new JButton("退出");
    btnExit.setBackground(new Color(176, 224, 230));
    textGoods = new JTextField();
    table = new JTable();
    table.setBackground(new Color(176, 224, 230));
    GoodsDAO = new GoodsDAOImpl();
    init();
    // JCheckBox chckbxNewCheckBox = new JCheckBox("显示禁用商品");
    // chckbxNewCheckBox.setBounds(676, 65, 103, 23);
    // getContentPane().add(chckbxNewCheckBox);

  }
예제 #18
0
  public void initTableVente() {
    // Desactivation de l'edition d'un cellule lors d'un double click
    tableVente =
        new JTable() {
          public boolean isCellEditable(int row, int column) {
            boolean temp = false;
            if (column == 4) {
              temp = true;
            }

            return temp;
          }
        };
    tableVente.setName("tableVente");
    tableVente.setBackground(new Color(201, 241, 253));
    tableVente.setShowGrid(false);
    MAJTableVente();

    // ajout d'une scrollbare au tableau
    JScrollPane scrollPane = new JScrollPane(tableVente);
    scrollPane.getViewport().setBackground(new Color(201, 241, 253));

    paneVente.add(scrollPane, BorderLayout.CENTER);
  }
예제 #19
0
  private void createTicker() {
    setBackground(ColorAndFontConstants.BACKGROUND_COLOR);
    setLayout(new GridBagLayout());
    setOpaque(false);
    setFocusable(false);

    setToolTipText(
        HelpContentsPanel.createMultilineTooltipText(
            new String[] {
              controller.getLocaliser().getString("tickerTablePanel.tooltip"),
              "\n ",
              controller.getLocaliser().getString("tickerTablePanel.tooltip.clickToConfigure")
            }));

    // on mouse click - view the exchanges tab
    MouseListener viewPreferencesMouseListener =
        new MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent arg0) {
            controller.displayView(View.PREFERENCES_VIEW);
          }
        };

    String tickerTooltipText =
        HelpContentsPanel.createMultilineTooltipText(
            new String[] {
              controller.getLocaliser().getString("tickerTablePanel.tooltip"),
              "\n ",
              controller.getLocaliser().getString("tickerTablePanel.tooltip.clickToConfigure")
            });

    addMouseListener(viewPreferencesMouseListener);

    GridBagConstraints constraints = new GridBagConstraints();

    tickerTableModel = new TickerTableModel(this.exchangeController);

    table = new JTable(tickerTableModel);
    table.setOpaque(true);
    table.setShowGrid(true);
    table.setGridColor(Color.lightGray);
    table.setBackground(ColorAndFontConstants.BACKGROUND_COLOR);
    table.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, SystemColor.windowBorder));

    table.setComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    table.setRowHeight(getFontMetrics(FontSizer.INSTANCE.getAdjustedDefaultFont()).getHeight());

    table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    table.setRowSelectionAllowed(false);
    table.setColumnSelectionAllowed(false);
    table.getTableHeader().setReorderingAllowed(false);

    table.setToolTipText(tickerTooltipText);
    table.addMouseListener(viewPreferencesMouseListener);
    table.getTableHeader().addMouseListener(viewPreferencesMouseListener);
    table.getTableHeader().setToolTipText(tickerTooltipText);
    table.getTableHeader().setFont(FontSizer.INSTANCE.getAdjustedDefaultFontWithDelta(-1));

    int tableHeaderHeight =
        fontMetrics.getHeight()
            + table.getTableHeader().getInsets().top
            + table.getTableHeader().getInsets().bottom;

    // Windows 8 has slightly taller headers so add a tweak for that.
    if (System.getProperty("os.name", "unknown").startsWith("Win")) {
      tableHeaderHeight = tableHeaderHeight + WINDOWS_TABLE_HEADER_HEIGHT_TWEAK;
    }

    int tickerWidth = setupColumnWidths();
    setupTableHeaders();

    idealHeight =
        (fontMetrics.getHeight() + table.getRowMargin()) * tickerTableModel.getRowCount()
            + tableHeaderHeight
            + tickerTableModel.getRowCount()
            + 10;

    setPreferredSize(new Dimension(tickerWidth, idealHeight));

    scrollPane =
        new JScrollPane(
            table,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    scrollPane.setComponentOrientation(
        ComponentOrientation.getOrientation(controller.getLocaliser().getLocale()));
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    scrollPane.setViewportBorder(BorderFactory.createEmptyBorder());
    scrollPane.addMouseListener(viewPreferencesMouseListener);

    setupScrollPane(tickerWidth);

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.weightx = 1;
    constraints.weighty = 1;
    constraints.anchor = GridBagConstraints.CENTER;

    add(scrollPane, constraints);
  }
  public pnl_wheels_view(int width, int height) {
    setBackground(Color.WHITE);

    setSize(width, height - 30);

    window_width = this.getWidth();
    window_height = this.getHeight();

    setLayout(null);

    tbl_service_details =
        new JTable() {

          private static final long serialVersionUID = 1L;

          protected JTableHeader createDefaultTableHeader() {
            return new JTableHeader(columnModel) {

              private static final long serialVersionUID = 1L;

              public String getToolTipText(MouseEvent e) {
                String tip = null;
                java.awt.Point p = e.getPoint();
                int index = columnModel.getColumnIndexAtX(p.x);

                if (index == 8) {
                  tip = "Enable checkbox if Free checkup is Completed";
                }

                return tip;
              }
            };
          }

          @Override
          public Component prepareRenderer(TableCellRenderer renderer, int row, int col) {
            Component comp = super.prepareRenderer(renderer, row, col);
            int index = (int) getModel().getValueAt(row, 0);
            int due_date = fcd_completed_due_date.get(index - 1);
            if (col == 8) {
              if (due_date == 0) {
                comp.setBackground(Color.LIGHT_GRAY);
              }
            }
            return comp;
          }
        };

    tbl_service_details.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    tbl_service_details.setRowSelectionAllowed(false);
    mdl_service_details =
        new DefaultTableModel() {

          private static final long serialVersionUID = 1L;

          public boolean isCellEditable(int row, int col) {

            if (col == 9) return true;
            else if (col == 8 && fcd_completed_due_date.get((int) getValueAt(row, 0) - 1) != 0)
              return true;
            else return false;
          }

          public Class<?> getColumnClass(int c) {

            if (this.getRowCount() >= 1) {
              return getValueAt(0, c).getClass();
            } else {
              return new String().getClass();
            }
          }
        };

    String[] columns = {
      "S.NO",
      "Customer Name",
      "Mobile No",
      "Vehicle No",
      "Bill Date",
      "Remarks",
      "Particulars",
      "Total",
      "FCD",
      "Info"
    };

    mdl_service_details.setColumnIdentifiers(columns);

    load_all_sbd();

    tbl_service_details.setModel(mdl_service_details);
    tbl_service_details.setFont(new Font("Arial", Font.PLAIN, 14));
    tbl_service_details.setForeground(Color.DARK_GRAY);
    tbl_service_details.setGridColor(Color.BLUE);
    tbl_service_details.setBackground(Color.WHITE);
    tbl_service_details.setRowMargin(5);
    tbl_service_details.setRowHeight(50);

    tbl_service_details.getColumn("Particulars").setCellRenderer(new SubTableRenderer());
    tbl_service_details.getColumn("Customer Name").setCellRenderer(new WrapCellRenderer());
    tbl_service_details.getColumn("Mobile No").setCellRenderer(new WrapCellRenderer());
    tbl_service_details.getColumn("Vehicle No").setCellRenderer(new WrapCellRenderer());
    tbl_service_details.getColumn("Bill Date").setCellRenderer(new WrapCellRenderer());
    tbl_service_details.getColumn("Remarks").setCellRenderer(new WrapCellRenderer());

    Action update_fcd =
        new AbstractAction() {

          private static final long serialVersionUID = 1L;

          @Override
          public void actionPerformed(ActionEvent e) {

            int row = Integer.valueOf(e.getActionCommand());

            int completed_date = fcd_completed_date.get(row);

            int due_date = fcd_completed_due_date.get(row);

            if (due_date > 0) {
              String msg = "";
              if (completed_date > 0) {
                msg =
                    "<html><Table>"
                        + "<tr>"
                        + "<td><font color='green'> FreeCheckup Status </font></td>"
                        + "<td> : </td>"
                        + "<td><font color='green'> Completed </font></td>"
                        + "</tr>"
                        + "<tr>"
                        + "<td><font color='green'> Completed Date </font></td>"
                        + "<td> : </td>"
                        + "<td><font color='green'>"
                        + Time.get_date(completed_date, "dd/MM/yyyy hh:mm:ss a")
                        + " </font></td>"
                        + "</tr>"
                        + "</Table></html>";

              } else if (completed_date == 0) {
                msg =
                    "<html><Table>"
                        + "<tr>"
                        + "<td><font color='red'> FreeCheckup Status </font></td>"
                        + "<td> : </td>"
                        + "<td><font color='red'> Not Completed </font></td>"
                        + "</tr>"
                        + "<tr>"
                        + "<td><font color='red'> Due Date </font></td>"
                        + "<td> : </td>"
                        + "<td><font color='red'>"
                        + Time.get_date(due_date)
                        + " </font></td>"
                        + "</tr>"
                        + "</Table></html>";
              }
              JOptionPane.showMessageDialog(tbl_service_details, msg);
            } else {
              JOptionPane.showMessageDialog(
                  tbl_service_details, " This bill don't have any service which has Free Checkup");
            }
          }
        };

    @SuppressWarnings("unused")
    ButtonColumn buttonColumn = new ButtonColumn(tbl_service_details, update_fcd, 9);

    tbl_service_details.addMouseListener(
        new java.awt.event.MouseAdapter() {
          @Override
          public void mouseClicked(java.awt.event.MouseEvent evt) {

            int col = tbl_service_details.columnAtPoint(evt.getPoint());
            int row = tbl_service_details.rowAtPoint(evt.getPoint());

            ServiceBill obj_service_bill = null;

            int index = (int) tbl_service_details.getValueAt(row, 0) - 1;

            boolean is_fcd_update =
                (col == 8 && fcd_completed_due_date.get(index) > 0) ? true : false;

            if (col == 0 || is_fcd_update) {
              String date_str = tbl_service_details.getValueAt(row, 4).toString();

              obj_service_bill = dbh.get_service_bill(vehicle_id.get(index), date_str);
            }

            if ((col == 0 || is_fcd_update) && obj_service_bill == null) {

              JOptionPane.showMessageDialog(
                  tbl_service_details, "Error while getting service bill object");
              Logger.log.severe(
                  "Error while getting service bill object for service bill id " + index);

            } else if (col == 0) {

              wheel_bill_print obj_wbp = new wheel_bill_print(obj_service_bill.getId());

              obj_wbp.setVisible(true);

            } else if (is_fcd_update) {

              int epoch = (boolean) tbl_service_details.getValueAt(row, col) ? Time.now() : 0;

              fcd_completed_date.set(index, epoch);

              obj_service_bill.setFree_checkup_completed(epoch);
              dbh.update(obj_service_bill);
            }
          }
        });

    JTableHeader obj_jtable_header = tbl_service_details.getTableHeader();
    obj_jtable_header.setBackground(Color.BLUE);
    obj_jtable_header.setForeground(Color.WHITE);
    obj_jtable_header.setFont(new Font("Dialog", Font.BOLD | Font.ITALIC, 12));

    JScrollPane jsp_service_details = new JScrollPane(tbl_service_details);
    jsp_service_details.setForeground(new Color(102, 153, 255));
    jsp_service_details.setBorder(new MatteBorder(3, 3, 3, 3, (Color) new Color(204, 51, 102)));
    jsp_service_details.setBackground(new Color(204, 102, 153));
    jsp_service_details.setBounds(20, 120, window_width - 40, window_height - 220);
    add(jsp_service_details);

    int tbl_width = jsp_service_details.getWidth();

    tbl_service_details.getColumn("S.NO").setMaxWidth((tbl_width / 100) * 4);
    tbl_service_details.getColumn("Customer Name").setPreferredWidth((tbl_width / 100) * 9);
    tbl_service_details.getColumn("Mobile No").setWidth((tbl_width / 100) * 9);
    tbl_service_details.getColumn("Vehicle No").setWidth((tbl_width / 100) * 7);
    tbl_service_details.getColumn("Bill Date").setWidth((tbl_width / 100) * 10);
    tbl_service_details.getColumn("Remarks").setPreferredWidth((tbl_width / 100) * 8);
    tbl_service_details.getColumn("Total").setMaxWidth((tbl_width / 100) * 8);
    tbl_service_details.getColumn("FCD").setMaxWidth((tbl_width / 100) * 10);
    tbl_service_details.getColumn("Info").setMaxWidth((tbl_width / 100) * 8);
    tbl_service_details.getColumn("Particulars").setPreferredWidth((tbl_width / 100) * 28);

    rowSorter = new TableRowSorter<>(tbl_service_details.getModel());
    tbl_service_details.setRowSorter(rowSorter);

    JPanel pnl_search = new JPanel();
    pnl_search.setBackground(new Color(204, 51, 153));
    pnl_search.setBorder(new MatteBorder(3, 3, 3, 3, (Color) new Color(204, 51, 153)));
    pnl_search.setBounds(20, 95, tbl_width, 30);
    add(pnl_search);
    pnl_search.setLayout(new BoxLayout(pnl_search, BoxLayout.X_AXIS));

    JLabel lbl_search_word = new JLabel("Search Text        ");
    lbl_search_word.setBackground(new Color(204, 153, 0));
    lbl_search_word.setAlignmentX(Component.CENTER_ALIGNMENT);
    pnl_search.add(lbl_search_word);
    lbl_search_word.setForeground(new Color(255, 255, 153));
    lbl_search_word.setFont(new Font("Bitstream Charter", Font.BOLD | Font.ITALIC, 18));

    txt_search_word = new JTextField();
    txt_search_word.setBackground(new Color(255, 255, 255));
    pnl_search.add(txt_search_word);
    txt_search_word.setColumns(10);
    txt_search_word
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent e) {

                String text = txt_search_word.getText();

                if (text.trim().length() == 0) {
                  rowSorter.setRowFilter(null);
                } else {
                  rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text));
                }
                calculate_total();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {

                String text = txt_search_word.getText();

                if (text.trim().length() == 0) {
                  rowSorter.setRowFilter(null);
                } else {
                  rowSorter.setRowFilter(RowFilter.regexFilter("(?i)" + text));
                }
                calculate_total();
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                throw new UnsupportedOperationException(
                    "Not supported yet."); // To change body of generated methods, choose Tools |
                                           // Templates.
              }
            });

    JPanel pnl_total = new JPanel();
    pnl_total.setBackground(Color.WHITE);
    pnl_total.setBorder(new MatteBorder(3, 3, 3, 3, (Color) new Color(204, 51, 153)));
    pnl_total.setBounds(20, window_height - 105, tbl_width, 40);
    add(pnl_total);
    pnl_total.setLayout(new BoxLayout(pnl_total, BoxLayout.X_AXIS));

    pnl_total.add(Box.createHorizontalGlue());

    lbl_total = new JLabel("Total        ");
    lbl_total.setBackground(new Color(204, 153, 0));
    lbl_total.setAlignmentX(Component.CENTER_ALIGNMENT);
    pnl_total.add(lbl_total);
    lbl_total.setForeground(Color.BLUE);
    lbl_total.setVisible(false);
    lbl_total.setFont(new Font("Bitstream Charter", Font.BOLD | Font.ITALIC, 18));

    btn_toggle_total = new JButton("Show Total");
    btn_toggle_total.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            String btn_text = btn_toggle_total.getText();

            if (btn_text.equals("Show Total")) {
              lbl_total.setVisible(true);
              btn_toggle_total.setText("Hide Total");
            } else {
              lbl_total.setVisible(false);
              btn_toggle_total.setText("Show Total");
            }
          }
        });
    pnl_total.add(btn_toggle_total);

    cmb_search_catagory = new JComboBox<String>();
    cmb_search_catagory.setBounds((window_width / 2) - 245, 45, 225, 24);
    cmb_search_catagory.addItem("Vehicle Number");
    cmb_search_catagory.addItem("Customer Name");
    cmb_search_catagory.addItem("Date Period");
    cmb_search_catagory.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (cmb_search_catagory.getSelectedIndex() != 2) {
              load_all_sbd();
              calculate_total();
              jdp_from.setVisible(false);
              jdp_to.setVisible(false);
              txt_search_text.setVisible(true);
            } else {
              jdp_from.setVisible(true);
              jdp_to.setVisible(true);
              txt_search_text.setVisible(false);
            }
          }
        });
    add(cmb_search_catagory);

    jdp_from = new JXDatePicker();
    jdp_from.setDate(Calendar.getInstance().getTime());
    jdp_from.setFormats(new SimpleDateFormat("dd.MM.yyyy"));
    jdp_from.setBounds((window_width / 2), 28, 225, 24);
    jdp_from.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            load_sbd_bw_date_range();
          }
        });
    add(jdp_from);
    jdp_from.setVisible(false);

    jdp_to = new JXDatePicker();
    jdp_to.setDate(Calendar.getInstance().getTime());
    jdp_to.setFormats(new SimpleDateFormat("dd.MM.yyyy"));
    jdp_to.setBounds((window_width / 2), 58, 225, 24);
    jdp_to.setVisible(false);
    jdp_to.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jdp_from.getMonthView().setUpperBound(jdp_to.getDate());
            load_sbd_bw_date_range();
          }
        });
    add(jdp_to);

    txt_search_text = new JTextField();
    txt_search_text.setBorder(new LineBorder(new Color(0, 0, 0)));
    txt_search_text.setBounds((window_width / 2), 45, 225, 24);
    add(txt_search_text);
    txt_search_text
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              @Override
              public void insertUpdate(DocumentEvent e) {
                update_filter();
                calculate_total();
              }

              @Override
              public void removeUpdate(DocumentEvent e) {
                update_filter();
                calculate_total();
              }

              @Override
              public void changedUpdate(DocumentEvent e) {
                update_filter();
                calculate_total();
              }
            });

    calculate_total();

    txt_search_word.setText(Time.get_current_date_time());
  }
예제 #21
0
 public void setTagInfos(TagInfo tagInfo) {
   this.tagInfo = tagInfo;
   infoTable.setBackground(Color.WHITE);
   infoTable.setModel(new InfoTableModel("general"));
 }
  @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

  }
예제 #23
0
  public PathDialog(JFrame frame, ArrayList<Path> list, ArrayList<Edge> elist) {
    super(frame, true);
    setLocation(new Point(200, 100));
    setSize(new Dimension(800, 521));
    setTitle("Set Path");
    pathsList = list;
    edgesList = elist;
    JPanel tablePanel = new JPanel();
    tablePanel.setBorder(null);

    JPanel buttonPanel = new JPanel();

    JPanel bottomPanel = new JPanel();

    JPanel dataEntryPanel = new JPanel();
    GroupLayout groupLayout = new GroupLayout(getContentPane());
    groupLayout.setHorizontalGroup(
        groupLayout
            .createParallelGroup(Alignment.TRAILING)
            .addGroup(
                groupLayout
                    .createSequentialGroup()
                    .addGroup(
                        groupLayout
                            .createParallelGroup(Alignment.LEADING)
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addGap(14)
                                    .addComponent(
                                        dataEntryPanel,
                                        GroupLayout.DEFAULT_SIZE,
                                        766,
                                        Short.MAX_VALUE))
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addContainerGap()
                                    .addGroup(
                                        groupLayout
                                            .createParallelGroup(Alignment.TRAILING)
                                            .addGroup(
                                                groupLayout
                                                    .createSequentialGroup()
                                                    .addComponent(
                                                        tablePanel,
                                                        GroupLayout.DEFAULT_SIZE,
                                                        657,
                                                        Short.MAX_VALUE)
                                                    .addPreferredGap(ComponentPlacement.RELATED)
                                                    .addComponent(
                                                        buttonPanel,
                                                        GroupLayout.PREFERRED_SIZE,
                                                        GroupLayout.DEFAULT_SIZE,
                                                        GroupLayout.PREFERRED_SIZE))
                                            .addComponent(
                                                bottomPanel,
                                                GroupLayout.DEFAULT_SIZE,
                                                768,
                                                Short.MAX_VALUE))))
                    .addContainerGap()));
    groupLayout.setVerticalGroup(
        groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                groupLayout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        groupLayout
                            .createParallelGroup(Alignment.LEADING)
                            .addComponent(
                                buttonPanel,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                tablePanel,
                                GroupLayout.PREFERRED_SIZE,
                                240,
                                GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(
                        dataEntryPanel, GroupLayout.PREFERRED_SIZE, 172, GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(
                        bottomPanel, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    tablePanel.setLayout(new BoxLayout(tablePanel, BoxLayout.X_AXIS));

    String columnNames[] = {"Name", "Edges", "Max Speed", "Vehicle/Min"};
    model = new DefaultTableModel(columnNames, 0);

    table = new JTable(model);
    table.setGridColor(Color.LIGHT_GRAY);
    table.setBackground(Color.WHITE);
    table.setBorder(null);
    table.setPreferredScrollableViewportSize(new Dimension(650, 170));
    table.setFillsViewportHeight(true);

    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setBorder(null);
    tablePanel.add(scrollPane);

    JLabel lblName = new JLabel("Name :");

    JLabel lblEdges = new JLabel("Edges :");

    JLabel lblMaxSpeed = new JLabel("Max Speed :");

    JLabel lblVehiclemin = new JLabel("Vehicle/min :");

    txtPathName = new JTextField();
    txtPathName.setColumns(10);

    txtMaxSpeed = new JTextField();
    txtMaxSpeed.setColumns(10);

    txtVehicleMin = new JTextField();
    txtVehicleMin.setColumns(10);

    txtEdges = new JTextField();
    txtEdges.setColumns(10);
    GroupLayout gl_dataEntryPanel = new GroupLayout(dataEntryPanel);
    gl_dataEntryPanel.setHorizontalGroup(
        gl_dataEntryPanel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_dataEntryPanel
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        gl_dataEntryPanel
                            .createParallelGroup(Alignment.LEADING)
                            .addComponent(lblName)
                            .addComponent(lblEdges)
                            .addComponent(lblMaxSpeed)
                            .addComponent(lblVehiclemin))
                    .addGap(49)
                    .addGroup(
                        gl_dataEntryPanel
                            .createParallelGroup(Alignment.LEADING)
                            .addComponent(
                                txtVehicleMin, GroupLayout.DEFAULT_SIZE, 502, Short.MAX_VALUE)
                            .addGroup(
                                gl_dataEntryPanel
                                    .createParallelGroup(Alignment.TRAILING)
                                    .addComponent(txtMaxSpeed)
                                    .addComponent(txtEdges, Alignment.LEADING)
                                    .addComponent(
                                        txtPathName,
                                        Alignment.LEADING,
                                        GroupLayout.DEFAULT_SIZE,
                                        502,
                                        Short.MAX_VALUE)))
                    .addContainerGap(117, GroupLayout.PREFERRED_SIZE)));
    gl_dataEntryPanel.setVerticalGroup(
        gl_dataEntryPanel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_dataEntryPanel
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        gl_dataEntryPanel
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(lblName)
                            .addComponent(
                                txtPathName,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(
                        gl_dataEntryPanel
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(lblEdges)
                            .addComponent(
                                txtEdges,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(
                        gl_dataEntryPanel
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(lblMaxSpeed)
                            .addComponent(
                                txtMaxSpeed,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addGroup(
                        gl_dataEntryPanel
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(
                                txtVehicleMin,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblVehiclemin))
                    .addGap(40)));
    dataEntryPanel.setLayout(gl_dataEntryPanel);

    JButton btnAdd = new JButton("Add");
    btnAdd.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            addValuesToTable();
            txtPathName.setText("");
            txtEdges.setText("");
            txtMaxSpeed.setText("");
            txtVehicleMin.setText("");
          }
        });

    JButton btnRemove = new JButton("Delete");
    btnRemove.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            removeRows(table.getSelectedRow());
            txtPathName.setText("");
            txtEdges.setText("");
            txtMaxSpeed.setText("");
            txtVehicleMin.setText("");
          }
        });
    GroupLayout gl_buttonPanel = new GroupLayout(buttonPanel);
    gl_buttonPanel.setHorizontalGroup(
        gl_buttonPanel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_buttonPanel
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        gl_buttonPanel
                            .createParallelGroup(Alignment.LEADING)
                            .addComponent(btnRemove, Alignment.TRAILING)
                            .addComponent(
                                btnAdd,
                                Alignment.TRAILING,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                Short.MAX_VALUE))
                    .addContainerGap()));
    gl_buttonPanel.setVerticalGroup(
        gl_buttonPanel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_buttonPanel
                    .createSequentialGroup()
                    .addGap(49)
                    .addComponent(btnAdd)
                    .addPreferredGap(ComponentPlacement.UNRELATED)
                    .addComponent(btnRemove)
                    .addContainerGap(55, Short.MAX_VALUE)));
    buttonPanel.setLayout(gl_buttonPanel);

    JButton btnApply = new JButton("Apply");
    btnApply.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            getValuesFromTable();
            setVisible(false);
          }
        });

    JButton btnCancel = new JButton("Cancel");
    btnCancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            setVisible(false);
          }
        });
    GroupLayout gl_bottomPanel = new GroupLayout(bottomPanel);
    gl_bottomPanel.setHorizontalGroup(
        gl_bottomPanel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                Alignment.TRAILING,
                gl_bottomPanel
                    .createSequentialGroup()
                    .addContainerGap(359, Short.MAX_VALUE)
                    .addComponent(btnCancel)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(btnApply)
                    .addContainerGap()));
    gl_bottomPanel.setVerticalGroup(
        gl_bottomPanel
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                Alignment.TRAILING,
                gl_bottomPanel
                    .createSequentialGroup()
                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(
                        gl_bottomPanel
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(btnApply)
                            .addComponent(btnCancel))
                    .addContainerGap()));
    bottomPanel.setLayout(gl_bottomPanel);
    getContentPane().setLayout(groupLayout);
  }
  /**
   * Create a JTable with data Model.
   *
   * @param columnsName : Titles of JTable columns.
   */
  public SwingScilabVariableBrowser(String[] columnsName, int[] aligment) {
    super(UiDataMessages.VARIABLE_BROWSER, VARBROWSERUUID);

    setAssociatedXMLIDForHelp("browsevar");

    buildMenuBar();
    addMenuBar(menuBar);

    ToolBar toolBar = ScilabToolBar.createToolBar();
    toolBar.add(RefreshAction.createButton(UiDataMessages.REFRESH));
    toolBar.addSeparator();
    toolBar.add(ModifyAction.createButton(this, UiDataMessages.MODIFY));
    toolBar.add(DeleteAction.createButton(this, UiDataMessages.DELETE));
    toolBar.addSeparator();
    toolBar.add(HelpAction.createButton(UiDataMessages.HELP));
    filteringButton = ScilabVarFilteringButtonAction.createButton("Show/hide Scilab variable");
    //        toolBar.add(filteringButton);
    addToolBar(toolBar);

    dataModel = new SwingTableModel<Object>(columnsName);

    table =
        new JTable(dataModel) {
          // Implement table cell tool tips.
          public String getToolTipText(MouseEvent e) {
            String tip = null;
            TableModel model = ((JTable) e.getSource()).getModel();
            java.awt.Point p = e.getPoint();
            int rowIndex = rowAtPoint(p);

            if (rowIndex >= 0) {
              rowIndex = convertRowIndexToModel(rowIndex);
              int colIndex = columnAtPoint(p);
              if (colIndex == BrowseVar.TYPE_DESC_COLUMN_INDEX) {
                  /* Scilab type */
                try {
                  tip =
                      Messages.gettext("Scilab type:")
                          + " "
                          + model.getValueAt(rowIndex, BrowseVar.TYPE_COLUMN_INDEX).toString();
                } catch (IllegalArgumentException exception) {
                  /* If the type is not known/managed, don't crash */
                }
              } else {

                if (colIndex == BrowseVar.SIZE_COLUMN_INDEX) {
                  /* Use the getModel() method because the
                   * column 5 has been removed from display
                   * but still exist in the model */
                  tip =
                      Messages.gettext("Bytes:")
                          + " "
                          + model.getValueAt(rowIndex, BrowseVar.BYTES_COLUMN_INDEX).toString();
                }
              }
            }
            return tip;
          }
        };

    table.setFillsViewportHeight(true);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    table.setAutoCreateRowSorter(true);

    /* Size of the icon column */
    table.getColumnModel().getColumn(0).setPreferredWidth(30);

    /* Hide the columns. But keep it in memory for the tooltip */
    TableColumn column = table.getColumnModel().getColumn(BrowseVar.NB_COLS_INDEX);
    table.removeColumn(column);

    /* The order to removing does matter since it changes the positions */

    column = table.getColumnModel().getColumn(BrowseVar.NB_ROWS_INDEX);
    table.removeColumn(column);

    column = table.getColumnModel().getColumn(BrowseVar.TYPE_COLUMN_INDEX);
    table.removeColumn(column);

    column = table.getColumnModel().getColumn(BrowseVar.FROM_SCILAB_COLUMN_INDEX);
    table.removeColumn(column);

    column = table.getColumnModel().getColumn(BrowseVar.BYTES_COLUMN_INDEX);
    table.removeColumn(column);

    table.addMouseListener(new BrowseVarMouseListener());
    // Mouse selection mode
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setCellSelectionEnabled(true);

    table.setBackground(Color.WHITE);
    if (table.getGridColor().equals(Color.WHITE)) {
      table.setGridColor(new Color(128, 128, 128));
    }
    table.setShowHorizontalLines(true);
    table.setShowVerticalLines(true);

    for (int i = 0; i < aligment.length; i++) {
      align(table, columnsName[i], aligment[i]);
    }

    // Plug the shortcuts
    ExportToCsvAction.registerAction(this, table);

    JScrollPane scrollPane = new JScrollPane(table);
    setContentPane(scrollPane);
    WindowsConfigurationManager.restorationFinished(this);
  }
예제 #25
0
  /**
   * Constructor initialises the table and a popup tool, as well as initialising the required GUI
   * elements. It adds action listeners for the three main buttons, which include basic user input
   * validation checking.
   */
  public TableAttributeEditor(JFrame MyOwner) {
    // As usual, it is insanely hard to get the swing components to display
    // and work properly.  If JTable is not displayed in a scroll pane no headers are
    // displayed, and you have to do it manually.  (If you *do* display it
    // in a scrollbar, in this instance, it screws up sizing)
    // The broken header mis-feature is only mentioned in the tutorial,
    // not in the api doco - go figure.

    super();

    owner = MyOwner;

    // final JPanel mainPanel = (JPanel)this;

    tableData = new AttributeTableModel();

    attributeTable = new JTable(tableData);
    // attributeTable.setRowHeight(20);	// This may be needed, depends on how fussy people get about
    // the bottom of letters like 'y' getting cut off when the cell is selected - bug 3013.

    popupTableTool = new SmartPopupTableTool(attributeTable, tableData, (JXplorerBrowser) owner);

    // Set the renderer for the attribute type...
    final AttributeTypeCellRenderer typeRenderer = new AttributeTypeCellRenderer();

    attributeTable.setDefaultRenderer(AttributeNameAndType.class, typeRenderer);

    // Set the renderer for the attribute value...
    final AttributeValueCellRenderer valueRenderer = new AttributeValueCellRenderer();

    attributeTable.setDefaultRenderer(AttributeValue.class, valueRenderer);

    // Set the editor for the attribute value...
    myEditor = new AttributeValueCellEditor(owner);

    attributeTable.setDefaultEditor(AttributeValue.class, myEditor);

    attributeTable.getTableHeader().setReorderingAllowed(false);

    currentDN = null;

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    buttonPanel.add(
        submit =
            new CBButton(
                CBIntText.get("Submit"), CBIntText.get("Submit your changes to the Directory.")));
    buttonPanel.add(
        reset =
            new CBButton(
                CBIntText.get("Reset"),
                CBIntText.get("Reset this entry i.e. cancels any changes.")));
    buttonPanel.add(
        changeClass =
            new CBButton(
                CBIntText.get("Change Classes"),
                CBIntText.get("Change the Object Class of this entry.")));
    buttonPanel.add(
        opAttrs =
            new CBButton(
                CBIntText.get("Properties"),
                CBIntText.get("View the Operational Attributes of this entry.")));

    // I don't really understand why we have to do this...
    // but without it these buttons over ride the default
    // button (Search Bar's search button), if they have
    // been clicked and the user hits the enter key?
    opAttrs.setDefaultCapable(false);
    submit.setDefaultCapable(false);
    reset.setDefaultCapable(false);
    changeClass.setDefaultCapable(false);

    setLayout(new BorderLayout(10, 10));

    tableScroller = new JScrollPane();
    attributeTable.setBackground(Color.white);
    tableScroller.setPreferredSize(new Dimension(300, 285));
    tableScroller.setViewportView(attributeTable);
    add(tableScroller, BorderLayout.CENTER);
    add(buttonPanel, BorderLayout.SOUTH);

    if ("true".equals(JXConfig.getProperty("lock.read.only")))
      title = CBIntText.get("Table Viewer");
    else title = CBIntText.get("Table Editor");

    setVisible(true);

    // triggers adding operational attributes of the current entry.
    opAttrs.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            displayOperationalAttributes();
          }
        });

    reset.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            myEditor.stopCellEditing();
            // tableData.reset();
            displayEntry(originalEntry, dataSource, false);
          }
        });

    submit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doSubmit();
          }
        });

    // This allows the user to change the objectclass attribute.
    // This is pretty tricky, because it changes what attributes are available.
    changeClass.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            changeClass();
          }
        });

    attributeTable.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent e) {
            if (!doPopupStuff(e)) super.mousePressed(e);
          }

          public void mouseReleased(MouseEvent e) {
            if (!doPopupStuff(e)) super.mouseReleased(e);
          }

          // TODO need to have a way to call this from a keystroke...
          public boolean doPopupStuff(MouseEvent e) {
            if (e.isPopupTrigger() == false) return false;

            int row = attributeTable.rowAtPoint(new Point(e.getX(), e.getY()));

            attributeTable.clearSelection();
            attributeTable.addRowSelectionInterval(row, row);
            attributeTable.repaint();

            popupTableTool.registerCurrentRow(
                (AttributeNameAndType) attributeTable.getValueAt(row, 0),
                (AttributeValue) attributeTable.getValueAt(row, 1),
                row,
                tableData.getRDN()); // active path also set by valueChanged
            popupTableTool.show(attributeTable, e.getX(), e.getY());
            popupTableTool.registerCellEditor(myEditor); // TE: for bug fix 3107.
            return true;
          }
        });
  }
  public PantallaPuntaje() {
    setBounds(100, 100, 590, 432);
    this.setLocationRelativeTo(PantallaPrincipal.getInstance());
    this.setResizable(false);
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    getContentPane().setLayout(null);
    JLabel label_1 = new JLabel(""); // Boton atras
    label_1.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            PantallaPrincipal.getInstance().setLocationRelativeTo(PantallaPuntaje.this);
            setVisible(false);
            PantallaPrincipal.getInstance().setVisible(true);
          }
        });

    Font font = null;
    try {
      font =
          Font.createFont(
              Font.TRUETYPE_FONT,
              getClass().getResourceAsStream("/res/fuente/VCR_OSD_MONO_1.001.ttf"));
    } catch (FontFormatException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    genv.registerFont(font);
    font = font.deriveFont(12f);

    label_1.setIcon(new ImageIcon(PantallaAyuda.class.getResource("/res/flecha_final.png")));
    label_1.setBounds(16, 17, 52, 52);
    getContentPane().add(label_1);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(BorderFactory.createMatteBorder(2, 2, 2, 2, Color.BLACK));
    scrollPane.setBounds(81, 82, 450, 231);
    getContentPane().add(scrollPane);

    Object[][] datos = new Object[MainJuego.getTopFive().size()][2];
    for (int i = 0; i < MainJuego.getTopFive().size(); i++) {
      datos[i][0] = MainJuego.getTopFive().get(i).getNombre();
      datos[i][1] = MainJuego.getTopFive().get(i).getPuntos();
    }

    String[] columnas = {"NOMBRE", " PUNTAJE"};

    DefaultTableCellRenderer Alinear = new DefaultTableCellRenderer();
    Alinear.setHorizontalAlignment(SwingConstants.CENTER);
    DefaultTableModel dtm = new DefaultTableModel(datos, columnas);

    table = new JTable(dtm);
    scrollPane.setViewportView(table);
    scrollPane.setBackground(Color.black);

    table.setBackground(Color.black);
    table.getTableHeader().setFont(font.deriveFont(Font.PLAIN, 40f));
    table.getTableHeader().setForeground(Color.YELLOW);
    table.getTableHeader().setBackground(Color.BLACK);
    table.setRowHeight(37);
    table.setFont(font.deriveFont(Font.PLAIN, 23f));
    table.setBorder(null);
    table.setForeground(Color.WHITE);
    table.setShowGrid(false);
    table.getTableHeader().setReorderingAllowed(false);
    table.getTableHeader().setResizingAllowed(false);
    table.getColumnModel().getColumn(1).setCellRenderer(Alinear);
    table.setFocusable(false);
    table.setEnabled(false);

    JLabel lblNewLabel = new JLabel("New label");
    lblNewLabel.setIcon(new ImageIcon(PantallaPuntaje.class.getResource("/res/fondo puntaje.jpg")));
    lblNewLabel.setBounds(0, 0, 590, 410);
    getContentPane().add(lblNewLabel);
    this.setResizable(false);
  }
  /** Create the frame. */
  @SuppressWarnings({"unchecked", "rawtypes"})
  public MembersManagement() {
    connection = DBConnector.dbConnector();
    setIconImage(
        Toolkit.getDefaultToolkit()
            .getImage(
                MembersManagement.class.getResource(
                    "/Resources/Custo.Man.Christmas.Folder.Library.ico.png")));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 1366, 768);
    contentPane = new JPanel();
    contentPane.setBackground(Color.DARK_GRAY);
    contentPane.setBorder(new LineBorder(Color.BLUE, 1, true));
    setContentPane(contentPane);
    StartPosition.centerOnScreen(this);

    String[] MemberType = new String[] {"Students", "Teachers"};

    JButton button = new JButton("_");
    button.setBounds(1234, 1, 44, 23);
    button.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            MinFrame();
          }
        });
    contentPane.setLayout(null);
    button.setForeground(Color.WHITE);
    button.setFocusable(false);
    button.setBackground(Color.DARK_GRAY);
    contentPane.add(button);

    JButton button_1 = new JButton("");
    button_1.setBounds(1277, 1, 44, 23);
    button_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            MaxFrame();
          }
        });
    button_1.setIcon(new ImageIcon(MembersManagement.class.getResource("/Resources/Maximize.png")));
    button_1.setForeground(Color.WHITE);
    button_1.setFocusable(false);
    button_1.setBackground(Color.DARK_GRAY);
    contentPane.add(button_1);

    JButton button_2 = new JButton("X");
    button_2.setBounds(1321, 1, 44, 23);
    button_2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            CloseFrame();
          }
        });
    button_2.setForeground(Color.WHITE);
    button_2.setFont(new Font("Ubuntu", Font.BOLD, 8));
    button_2.setFocusable(false);
    button_2.setBackground(Color.RED);
    contentPane.add(button_2);

    Border emptyBorder = BorderFactory.createEmptyBorder();

    JLabel lblStudentsManagement = new JLabel("Members Management");
    lblStudentsManagement.setBounds(403, 34, 543, 78);
    lblStudentsManagement.setHorizontalAlignment(SwingConstants.CENTER);
    lblStudentsManagement.setForeground(new Color(255, 255, 255));
    lblStudentsManagement.setFont(new Font("Ubuntu", Font.BOLD, 36));
    contentPane.add(lblStudentsManagement);

    String[] searchCriteria = new String[] {"Name", "Registration Number"};

    JPanel panel3 = new JPanel();
    panel3.setBackground(Color.DARK_GRAY);
    panel3.setBorder(new LineBorder(Color.BLUE));
    panel3.setBounds(14, 187, 1340, 568);
    contentPane.add(panel3);
    panel3.setLayout(null);
    panel3.setVisible(false);

    JLabel lblSelectSearchCriteria = new JLabel("Select Search Criteria");
    lblSelectSearchCriteria.setForeground(Color.WHITE);
    lblSelectSearchCriteria.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblSelectSearchCriteria.setBounds(487, 39, 149, 21);
    panel3.add(lblSelectSearchCriteria);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(10, 99, 1320, 402);
    panel3.add(scrollPane_1);

    table_1 = new JTable();
    table_1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    table_1.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    scrollPane_1.setViewportView(table_1);

    JLabel lblCriteria = new JLabel("Name");
    lblCriteria.setForeground(Color.WHITE);
    lblCriteria.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblCriteria.setBounds(952, 39, 149, 21);
    panel3.add(lblCriteria);

    JComboBox cmbSearchCriteria = new JComboBox(searchCriteria);
    cmbSearchCriteria.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (cmbSearchCriteria.getSelectedItem().toString() == "Name") {
              lblCriteria.setText("Name");
              txtSearch.setBounds(1001, 37, 160, 25);
            } else if (cmbSearchCriteria.getSelectedItem().toString() == "Registration Number") {
              lblCriteria.setText("Registration Number");
              txtSearch.setBounds(1100, 37, 160, 25);
            }
          }
        });
    cmbSearchCriteria.setForeground(Color.WHITE);
    cmbSearchCriteria.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    cmbSearchCriteria.setBorder(emptyBorder);
    cmbSearchCriteria.setBackground(Color.DARK_GRAY);
    cmbSearchCriteria.setBounds(646, 39, 160, 20);
    panel3.add(cmbSearchCriteria);

    JComboBox cmbType = new JComboBox(MemberType);
    cmbType.setForeground(Color.WHITE);
    cmbType.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    cmbType.setBackground(Color.DARK_GRAY);
    cmbType.setBounds(246, 39, 160, 20);
    panel3.add(cmbType);

    JLabel lblSearchBy = new JLabel("Search By");
    lblSearchBy.setForeground(Color.WHITE);
    lblSearchBy.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblSearchBy.setBounds(885, 39, 75, 21);
    panel3.add(lblSearchBy);

    txtSearch = new JTextField();
    txtSearch.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyTyped(KeyEvent e) {
            String type = cmbType.getSelectedItem().toString();
            String sCriteria = cmbSearchCriteria.getSelectedItem().toString();
            if (type == "Students") {
              if (sCriteria == "Name") {
                try {
                  LibMemberDM bDM = new LibMemberDM();
                  table_1.setModel(
                      DbUtils.resultSetToTableModel(bDM.searchByNameS(txtSearch.getText())));
                } catch (Exception ex) {
                  JOptionPane.showMessageDialog(null, ex.getMessage());
                }
              } else if (sCriteria == "Registration Number") {
                try {
                  LibMemberDM bDM = new LibMemberDM();
                  table_1.setModel(
                      DbUtils.resultSetToTableModel(bDM.searchByRegNoS(txtSearch.getText())));
                } catch (Exception ex) {
                  JOptionPane.showMessageDialog(null, ex.getMessage());
                }
              }
            } else if (type == "Teachers") {
              if (sCriteria == "Name") {
                try {
                  LibMemberDM bDM = new LibMemberDM();
                  table_1.setModel(
                      DbUtils.resultSetToTableModel(bDM.searchByNameT(txtSearch.getText())));
                } catch (Exception ex) {
                  JOptionPane.showMessageDialog(null, ex.getMessage());
                }
              } else if (sCriteria == "Registration Number") {
                try {
                  LibMemberDM bDM = new LibMemberDM();
                  table_1.setModel(
                      DbUtils.resultSetToTableModel(bDM.searchByRegNoT(txtSearch.getText())));
                } catch (Exception ex) {
                  JOptionPane.showMessageDialog(null, ex.getMessage());
                }
              }
            }
          }
        });
    txtSearch.setForeground(Color.WHITE);
    txtSearch.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    txtSearch.setBorder(emptyBorder);
    txtSearch.setBackground(Color.GRAY);
    txtSearch.setBounds(1001, 37, 200, 25);
    panel3.add(txtSearch);
    txtSearch.setColumns(10);

    JButton btnUpdate = new JButton("Update");
    btnUpdate.setFont(new Font("Ubuntu", Font.PLAIN, 12));
    btnUpdate.setBackground(Color.DARK_GRAY);
    btnUpdate.setForeground(Color.WHITE);
    btnUpdate.setBounds(518, 523, 89, 23);
    panel3.add(btnUpdate);

    JButton btnRemove = new JButton("Remove");
    btnRemove.setFont(new Font("Ubuntu", Font.PLAIN, 12));
    btnRemove.setBackground(Color.DARK_GRAY);
    btnRemove.setForeground(Color.WHITE);
    btnRemove.setBounds(676, 523, 89, 23);
    panel3.add(btnRemove);

    JLabel lblSelectMemberType = new JLabel("Select Member Type");
    lblSelectMemberType.setForeground(Color.WHITE);
    lblSelectMemberType.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblSelectMemberType.setBounds(97, 39, 149, 21);
    panel3.add(lblSelectMemberType);

    JPanel panel1 = new JPanel();
    panel1.setBorder(new LineBorder(Color.BLUE));
    panel1.setBackground(Color.DARK_GRAY);
    panel1.setBounds(14, 187, 1340, 568);
    contentPane.add(panel1);
    panel1.setVisible(true);
    panel1.setLayout(null);

    JComboBox cmbMemType = new JComboBox(MemberType);
    cmbMemType.setForeground(Color.WHITE);
    cmbMemType.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    cmbMemType.setBorder(emptyBorder);
    cmbMemType.setBackground(Color.DARK_GRAY);
    cmbMemType.setBounds(449, 39, 146, 25);
    panel1.add(cmbMemType);

    JButton btnView = new JButton("View Members");
    btnView.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            String Type = cmbMemType.getSelectedItem().toString();
            try {
              if (Type == "Students") {
                String Query =
                    "select t2.MemID, t1.FullName, t1.Address, t1.DOB, t1.NIC, t1.Sex, t1.ContactNo, t1.CurrentGrade, t1.CurrentClass from StudentsMF t1, LibMem t2 where t1.RegNo = t2.RegNoS";
                PreparedStatement pst = connection.prepareStatement(Query);
                ResultSet rs = pst.executeQuery();
                table.setModel(DbUtils.resultSetToTableModel(rs));

                rs.close();
                pst.close();
              } else if (Type == "Teachers") {
                String Query =
                    "select t2.MemID, t1.Name, t1.Adress, t1.DOB, t1.NIC, t1.Sex, t1.ContactNo, t1.TGrade, t1.Type from TeachersMF t1, LibMem t2 where t1.RegNo = t2.RegNoT";
                PreparedStatement pst = connection.prepareStatement(Query);
                ResultSet rs = pst.executeQuery();
                table.setModel(DbUtils.resultSetToTableModel(rs));

                rs.close();
                pst.close();
              }
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });
    btnView.setForeground(Color.WHITE);
    btnView.setBackground(Color.DARK_GRAY);
    btnView.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    btnView.setBounds(736, 36, 131, 30);
    panel1.add(btnView);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 99, 1320, 458);
    panel1.add(scrollPane);

    table = new JTable();
    table.setGridColor(Color.GRAY);
    table.setFont(new Font("Ubuntu", Font.PLAIN, 11));
    table.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    table.setBackground(Color.WHITE);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    scrollPane.setViewportView(table);

    JPanel panel2 = new JPanel();
    panel2.setBorder(new LineBorder(Color.BLUE));
    panel2.setBackground(Color.DARK_GRAY);
    panel2.setBounds(14, 187, 1340, 568);
    contentPane.add(panel2);
    panel2.setLayout(null);

    JLabel lblISBN = new JLabel("Registration Number");
    lblISBN.setForeground(Color.WHITE);
    lblISBN.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblISBN.setBounds(232, 183, 142, 22);
    panel2.add(lblISBN);

    txtRegNo = new JTextField();
    txtRegNo.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    txtRegNo.setBackground(Color.GRAY);
    txtRegNo.setForeground(Color.WHITE);
    txtRegNo.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    txtRegNo.setBounds(413, 182, 208, 24);
    txtRegNo.setBorder(emptyBorder);
    panel2.add(txtRegNo);
    txtRegNo.setColumns(10);

    txtPassword = new JTextField();
    txtPassword.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    txtPassword.setForeground(Color.WHITE);
    txtPassword.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    txtPassword.setBorder(emptyBorder);
    txtPassword.setColumns(10);
    txtPassword.setBackground(Color.GRAY);
    txtPassword.setBounds(413, 214, 208, 24);
    panel2.add(txtPassword);

    JLabel lblName = new JLabel("Password");
    lblName.setForeground(Color.WHITE);
    lblName.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblName.setBounds(232, 215, 142, 22);
    panel2.add(lblName);

    JLabel lblNicNumber = new JLabel("Re-Enter Password");
    lblNicNumber.setForeground(Color.WHITE);
    lblNicNumber.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    lblNicNumber.setBounds(232, 248, 142, 22);
    panel2.add(lblNicNumber);

    txtRPassword = new JTextField();
    txtRPassword.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    txtRPassword.setForeground(Color.WHITE);
    txtRPassword.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    txtRPassword.setBorder(emptyBorder);
    txtRPassword.setColumns(10);
    txtRPassword.setBackground(Color.GRAY);
    txtRPassword.setBounds(413, 247, 208, 24);
    panel2.add(txtRPassword);

    JButton btnClear = new JButton("Clear");
    btnClear.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            clearFeilds();
          }
        });
    btnClear.setForeground(Color.WHITE);
    btnClear.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    btnClear.setBackground(Color.DARK_GRAY);
    btnClear.setBounds(474, 344, 110, 32);
    panel2.add(btnClear);

    JButton btnAddMember = new JButton("Add Member");
    btnAddMember.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (!txtRPassword.getText().equals("")
                || !txtPassword.getText().equals("")
                || !txtRegNo.getText().equals("")) {
              if (txtPassword.getText().equals(txtRPassword.getText())) {
                try {
                  LibMemberDM mDM = new LibMemberDM();
                  LibMember member = new LibMember();
                  member.setMemID(txtRegNo.getText());
                  member.setPassword(txtPassword.getText());

                  // checking whether RegNo exist in the database {
                  String query1 = "select RegNo from TeachersMF where RegNo=?";
                  String query2 = "select RegNo from StudentsMF where RegNo=?";
                  PreparedStatement pst1 = connection.prepareStatement(query1);
                  pst1.setString(1, member.getMemID());
                  PreparedStatement pst2 = connection.prepareStatement(query2);
                  pst2.setString(1, member.getMemID());
                  ResultSet rs1 = pst1.executeQuery();
                  ResultSet rs2 = pst2.executeQuery();

                  int count1 = 0, count2 = 0;
                  while (rs1.next()) count1++;
                  while (rs2.next()) count2++;

                  if (count1 == 0 && count2 == 0)
                    JOptionPane.showMessageDialog(
                        null,
                        "Registration Number does not exist!",
                        "Error",
                        JOptionPane.WARNING_MESSAGE);
                  else if (count1 == 1 && count2 == 0) {
                    String query3 =
                        "select MemID from LibMem where MemID='" + member.getMemID() + "'";
                    PreparedStatement pst3 = connection.prepareStatement(query3);
                    ResultSet rs3 = pst3.executeQuery();
                    int count3 = 0;
                    while (rs3.next()) count3++;
                    if (count3 != 0) JOptionPane.showMessageDialog(null, "User Already Exist!");
                    else if (count3 == 0) {
                      if (mDM.insertMemberT(member)) {
                        JOptionPane.showMessageDialog(null, "Successful");
                        clearFeilds();
                      } else JOptionPane.showMessageDialog(null, "Failed");
                      rs3.close();
                      pst3.close();
                    }
                  } else if (count1 == 0 && count2 == 1) {
                    String query6 = "select * from LibMem where MemID='" + member.getMemID() + "'";
                    PreparedStatement pst5 = connection.prepareStatement(query6);
                    ResultSet rs4 = pst5.executeQuery();
                    int count3 = 0;
                    while (rs4.next()) count3++;
                    if (count3 != 0) JOptionPane.showMessageDialog(null, "User Already Exist!");
                    else if (count3 == 0) {
                      if (mDM.insertMemberS(member)) {
                        JOptionPane.showMessageDialog(null, "Successful");
                        clearFeilds();
                      } else JOptionPane.showMessageDialog(null, "Failed");

                      rs4.close();
                      pst5.close();
                    }
                  }

                  rs1.close();
                  rs2.close();
                  pst1.close();
                  pst2.close();

                } catch (Exception x) {
                  JOptionPane.showMessageDialog(null, x);
                  System.out.println(x);
                }
              } else JOptionPane.showMessageDialog(null, "Passwords do not Match");
            } else JOptionPane.showMessageDialog(null, "Fill in All the Details");
          }
        });
    btnAddMember.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    btnAddMember.setBackground(Color.DARK_GRAY);
    btnAddMember.setForeground(Color.WHITE);
    btnAddMember.setBounds(265, 344, 125, 32);
    panel2.add(btnAddMember);

    JLabel label = new JLabel("");
    label.setIcon(
        new ImageIcon(MembersManagement.class.getResource("/Resources/sign-up-icon.png")));
    label.setBounds(856, 140, 256, 226);
    panel2.add(label);
    panel2.setVisible(false);

    // Creating Tab Buttons of Tabs Pane
    JButton btnEditStudentDetails = new JButton("Edit Member Details");
    JButton btnAddStudents = new JButton("Add Members");
    JButton btnViewStudents = new JButton("View Members");

    btnViewStudents.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    btnViewStudents.setForeground(Color.WHITE);
    btnViewStudents.setBackground(Color.BLUE);
    btnViewStudents.setBounds(14, 164, 124, 23);
    contentPane.add(btnViewStudents);

    btnAddStudents.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            if (btnAddStudents.hasFocus()) {
              btnAddStudents.setBackground(Color.BLUE);
              btnAddStudents.setForeground(Color.WHITE);
              btnViewStudents.setBackground(Color.DARK_GRAY);
              btnViewStudents.setForeground(Color.WHITE);
              btnEditStudentDetails.setBackground(Color.DARK_GRAY);
              btnEditStudentDetails.setForeground(Color.WHITE);
            }

            if (panel2.isVisible() == false) {
              panel2.setVisible(true);
              panel1.setVisible(false);
              panel3.setVisible(false);
            }
          }
        });
    btnAddStudents.setForeground(Color.WHITE);
    btnAddStudents.setBorder(BorderFactory.createLineBorder(Color.BLUE));
    btnAddStudents.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    btnAddStudents.setBackground(Color.DARK_GRAY);
    btnAddStudents.setBounds(137, 164, 144, 23);
    contentPane.add(btnAddStudents);

    btnEditStudentDetails.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            if (btnEditStudentDetails.hasFocus()) {
              btnEditStudentDetails.setBackground(Color.BLUE);
              btnEditStudentDetails.setForeground(Color.WHITE);
              btnAddStudents.setBackground(Color.DARK_GRAY);
              btnAddStudents.setForeground(Color.WHITE);
              btnViewStudents.setBackground(Color.DARK_GRAY);
              btnViewStudents.setForeground(Color.WHITE);
            }

            if (panel3.isVisible() == false) {
              panel3.setVisible(true);
              panel1.setVisible(false);
              panel2.setVisible(false);
            }
          }
        });
    btnEditStudentDetails.setForeground(Color.WHITE);
    btnEditStudentDetails.setBorder(BorderFactory.createLineBorder(Color.BLUE));
    btnEditStudentDetails.setFont(new Font("Ubuntu", Font.PLAIN, 13));
    btnEditStudentDetails.setBackground(Color.DARK_GRAY);
    btnEditStudentDetails.setBounds(280, 164, 169, 23);
    contentPane.add(btnEditStudentDetails);

    btnViewStudents.setBorder(BorderFactory.createLineBorder(Color.BLUE));
    btnViewStudents.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {

            if (btnViewStudents.hasFocus()) {
              btnViewStudents.setBackground(Color.BLUE);
              btnViewStudents.setForeground(Color.WHITE);
              btnAddStudents.setBackground(Color.DARK_GRAY);
              btnAddStudents.setForeground(Color.WHITE);
              btnEditStudentDetails.setBackground(Color.DARK_GRAY);
              btnEditStudentDetails.setForeground(Color.WHITE);
            }

            if (panel1.isVisible() == false) {
              panel1.setVisible(true);
              panel2.setVisible(false);
              panel3.setVisible(false);
            }
          }
        });
  }
예제 #28
0
  private JPanel localVendListStockPanel() {
    JPanel mainListPanel = new JPanel();
    mainListPanel.setLayout(new BoxLayout(mainListPanel, BoxLayout.Y_AXIS));
    JPanel headerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    headerPanel.setPreferredSize(new Dimension(600, 60));
    JLabel header = new JLabel("LIST STOCK");
    header.setFont(new Font("Verdana", Font.BOLD, 25));
    headerPanel.add(header);
    mainListPanel.add(headerPanel);

    for (int j = 0; j < numOfSelected.length; ++j) {
      int ID = numOfSelected[j];

      JPanel stockPanel = new JPanel();

      BorderLayout listItemsLayout = new BorderLayout(0, 20);
      stockPanel.setLayout(listItemsLayout);
      Object[] columnHeading = {"Row", "Column", "Item Name", "Amount", "Price", "Total"};
      try {
        itemsArray = getStock(ID);
      } catch (Exception e) {
        e.printStackTrace();
        System.out.println("Failed to populate itemsArray...");
        System.out.println("Quitting the Marketing manager...");
        System.exit(DISPOSE_ON_CLOSE);
      }
      DefaultTableModel tableModel =
          new DefaultTableModel(itemsArray, columnHeading) {

            /** */
            private static final long serialVersionUID = 1L;

            @Override
            public boolean isCellEditable(int row, int column) {
              // all cells false
              return false;
            }
          };
      // tableModel.setRowCount(itemsArray.length);

      JTable stockTable = new JTable(tableModel);
      stockTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      stockTable.setFont(new Font("Verdana", 20, 15));
      stockTable.setRowHeight(40);
      stockTable.getColumnModel().getColumn(0).setMaxWidth(50);
      stockTable.getColumnModel().getColumn(0).setMinWidth(50);
      stockTable.getColumnModel().getColumn(1).setMaxWidth(50);
      stockTable.getColumnModel().getColumn(1).setMinWidth(50);
      stockTable.setBackground(Color.white);
      stockTable.setGridColor(Color.BLACK);
      stockTable.setFont(new Font("Verdana", 20, 15));
      stockTable.setRowHeight(40);

      stockTable.getTableHeader().setResizingAllowed(false);
      stockTable.getTableHeader().setReorderingAllowed(false);
      stockTable.getTableHeader().setRequestFocusEnabled(false);

      JScrollPane scrollStock = new JScrollPane(stockTable);
      JPanel stockScrollPanel = new JPanel(new FlowLayout());
      // stockTable.setPreferredSize(new Dimension(800, 400));
      // stockScrollPanel.setPreferredSize(new Dimension(800, 600));
      stockScrollPanel.add(scrollStock);
      int row = stockTable.getRowCount();
      double totalPrice = 0;
      int totalAmount = 0;
      for (int i = 0; i < row; i++) {
        totalPrice += (Double) stockTable.getValueAt(i, 5);
        totalAmount += (Integer) stockTable.getValueAt(i, 3);
      }

      // String totalPriceResult = new Double(totalPrice).toString();
      String totalAmountResult = new Integer(totalAmount).toString();

      JLabel totalPriceLabel = new JLabel("Total Price in Stock     ");
      totalPriceLabel.setFont(new Font("Verdana", Font.BOLD, 18));
      JLabel totalPriceText = new JLabel(df.format(totalPrice));
      totalPriceText.setFont(new Font("Arial", Font.PLAIN, 16));

      JLabel totalAmountLabel = new JLabel("Total Amount in Stock    ");
      totalAmountLabel.setFont(new Font("Verdana", Font.BOLD, 18));
      JLabel totalAmountText = new JLabel(totalAmountResult);
      totalAmountText.setFont(new Font("Arial", Font.PLAIN, 16));

      JPanel southLayout = new JPanel(new GridLayout(1, 1));
      JPanel priceLayout = new JPanel(new FlowLayout());
      JPanel amountLayout = new JPanel(new FlowLayout());

      priceLayout.add(totalPriceLabel);
      priceLayout.add(totalPriceText);

      amountLayout.add(totalAmountLabel);
      amountLayout.add(totalAmountText);

      southLayout.add(amountLayout);
      southLayout.add(priceLayout);

      JLabel northLabel = new JLabel("MACHINE " + (ID + 1));
      northLabel.setHorizontalAlignment(SwingConstants.CENTER);
      northLabel.setFont(new Font("Verdana", Font.BOLD, 25));

      stockPanel.add(northLabel, BorderLayout.NORTH);
      stockPanel.add(stockScrollPanel, BorderLayout.CENTER);
      stockPanel.add(southLayout, BorderLayout.SOUTH);

      mainListPanel.add(stockPanel);
    }
    return mainListPanel;
  }
예제 #29
0
  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"}));
  }
예제 #30
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);
  }