public CenterPanel(RegisterPanel rp) {
   super();
   setLayout(new BorderLayout());
   this.rp = rp;
   rp.setJT(jt);
   JScrollPane jsp = new JScrollPane(jt);
   setBackground(Color.BLACK);
   add(jsp, BorderLayout.CENTER);
   tm = (DefaultTableModel) jt.getModel();
   tm.addColumn("ID");
   tm.addColumn("Barcode");
   tm.addColumn("Name");
   tm.addColumn("Qty");
   tm.addColumn("Price");
   tm.addColumn("Tax");
   tm.addColumn("Total");
   // tm.setRowCount(50);
   // jt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   jt.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
   jt.getColumnModel().getColumn(0).setPreferredWidth(20);
   jt.getColumnModel().getColumn(1).setPreferredWidth(150);
   jt.getColumnModel().getColumn(2).setPreferredWidth(300);
   jt.getColumnModel().getColumn(3).setPreferredWidth(20);
   jt.setFont(new Font("Arial", Font.BOLD, 18));
   jt.setRowHeight(30);
 }
 public CFSecuritySwingISOTimezoneFinderJPanel(ICFSecuritySwingSchema argSchema) {
   super();
   final String S_ProcName = "construct-schema-focus";
   if (argSchema == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 1, "argSchema");
   }
   swingSchema = argSchema;
   dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
   dataTable.addMouseListener(getDataListMouseAdapter());
   dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   dataTable.setUpdateSelectionOnSort(true);
   dataTable.setRowHeight(25);
   getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
   dataScrollPane =
       new JScrollPane(
           dataTable,
           ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
           ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
   dataScrollPane.setColumnHeader(
       new JViewport() {
         @Override
         public Dimension getPreferredSize() {
           Dimension sz = super.getPreferredSize();
           sz.height = 25;
           return (sz);
         }
       });
   dataTable.setFillsViewportHeight(true);
   add(dataScrollPane);
   loadData(true);
   doLayout();
   swingIsInitializing = false;
 }
  // Fees update method
  private void updateFeesData(long id) {
    String columns[] = {"Course", "Fees Payed", "Total fees", "Installments"};
    try {
      Database db = new Database();

      panel_7.removeAll();

      feestablemodel = new MyTableModel(db.getFeeData(id), columns);

      feestable = new JTable(feestablemodel);
      feestable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
      feestable.getSelectionModel().addListSelectionListener(this);

      feesscrollpane = new JScrollPane(feestable);
      panel_7.add(feesscrollpane);

      // change fees payed label
      feespayedlabel.setText("Fees Payed");
      feesduelabel.setText("Fees Due");
      totalfeeslabel.setText("Total Fees");

      panel_7.revalidate();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, e.getMessage(), null, JOptionPane.ERROR_MESSAGE);
    }
  }
 public CFInternetSwingVersionListJPanel(
     ICFInternetSwingSchema argSchema,
     ICFLibAnyObj argContainer,
     ICFInternetVersionObj argFocus,
     Collection<ICFInternetVersionObj> argDataCollection,
     ICFJRefreshCallback refreshCallback,
     boolean sortByChain) {
   super();
   final String S_ProcName = "construct-schema-focus";
   if (argSchema == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 1, "argSchema");
   }
   // argFocus is optional; focus may be set later during execution as
   // conditions of the runtime change.
   swingSchema = argSchema;
   swingFocus = argFocus;
   swingContainer = argContainer;
   swingRefreshCallback = refreshCallback;
   swingSortByChain = sortByChain;
   setSwingDataCollection(argDataCollection);
   dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
   dataTable.addMouseListener(getDataListMouseAdapter());
   dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   dataTable.setUpdateSelectionOnSort(true);
   dataTable.setRowHeight(25);
   getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
   dataScrollPane =
       new JScrollPane(
           dataTable,
           ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
           ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
   dataScrollPane.setColumnHeader(
       new JViewport() {
         @Override
         public Dimension getPreferredSize() {
           Dimension sz = super.getPreferredSize();
           sz.height = 25;
           return (sz);
         }
       });
   dataTable.setFillsViewportHeight(true);
   // Do initial layout
   setSize(1024, 480);
   JMenuBar menuBar = getPanelMenuBar();
   add(menuBar);
   menuBar.setBounds(0, 0, 1024, 25);
   add(dataScrollPane);
   dataScrollPane.setBounds(0, 25, 1024, 455);
   adjustListMenuBar();
   doLayout();
   swingIsInitializing = false;
 }
  private JTable createAdaptersPanel() {
    java.util.List<ToolAdapterOperatorDescriptor> toolboxSpis = new ArrayList<>();
    toolboxSpis.addAll(
        ToolAdapterRegistry.INSTANCE
            .getOperatorMap()
            .values()
            .stream()
            .map(e -> (ToolAdapterOperatorDescriptor) e.getOperatorDescriptor())
            .collect(Collectors.toList()));
    toolboxSpis.sort((o1, o2) -> o1.getAlias().compareTo(o2.getAlias()));
    OperatorsTableModel model = new OperatorsTableModel(toolboxSpis);
    operatorsTable = new JTable(model);
    operatorsTable.getColumnModel().getColumn(0).setMaxWidth(250);
    operatorsTable.getColumnModel().getColumn(1).setMaxWidth(LABEL_COLUMN_WIDTH);
    operatorsTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    operatorsTable.addMouseListener(
        new MouseListener() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() >= 2) {
              int selectedRow = operatorsTable.getSelectedRow();
              // operatorsTable.getModel().setValueAt(true, selectedRow, 0);
              operatorsTable.repaint();
              ToolAdapterOperatorDescriptor operatorDesc =
                  ((OperatorsTableModel) operatorsTable.getModel()).getObjectAt(selectedRow);
              ToolAdapterEditorDialog dialog =
                  new ToolAdapterEditorDialog(appContext, operatorDesc, false);
              dialog.show();
              refreshContent();
            }
          }

          @Override
          public void mousePressed(MouseEvent e) {}

          @Override
          public void mouseReleased(MouseEvent e) {}

          @Override
          public void mouseEntered(MouseEvent e) {}

          @Override
          public void mouseExited(MouseEvent e) {}
        });
    return operatorsTable;
  }
  private void loadView() {
    // main views
    mTableModel = new SpreadsheetTableModel();

    mTableView = new JTable(mTableModel);
    mTableView.setRowSelectionAllowed(false);
    mTableView.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    mTableView.setFillsViewportHeight(true);
    mTableView.setDefaultRenderer(String.class, new ColorCellRenderer(TABLE_CELL_COLOR));
    mTableView.setDefaultEditor(
        String.class, new SpreadsheetCellEditor(mTableView.getDefaultEditor(String.class)));
    mTableView.getSelectionModel().addListSelectionListener(new SpreadsheetSelectionListener());
    mTableView
        .getColumnModel()
        .getSelectionModel()
        .addListSelectionListener(new SpreadsheetSelectionListener());

    JTable rowHeaderTable = new JTable(new RowHeaderTableModel());
    rowHeaderTable.setCellSelectionEnabled(false);
    rowHeaderTable.setPreferredScrollableViewportSize(new Dimension(50, Integer.MAX_VALUE));
    rowHeaderTable.setDefaultRenderer(Object.class, new ColorCellRenderer(ROW_HEADER_COLOR));

    mFormulaTextField = new BindableTextField();
    mFormulaTextField.setEditable(false);
    mFormulaTextField.setFocusable(false);

    JScrollPane scrollView = new JScrollPane(mTableView);
    scrollView.setRowHeaderView(rowHeaderTable);

    add(mFormulaTextField, BorderLayout.BEFORE_FIRST_LINE);
    add(scrollView, BorderLayout.CENTER);

    // helpers

    mFileChooser = new SingleExtensionFileChooser();
    String extension = SpreadsheetPersistenceManager.SPREADSHEET_FILE_EXTENSION;
    mFileChooser.setFileExtension(extension, "Spreadsheets file (." + extension + ")");
  }
Exemple #7
0
  private void initTable() {
    JScrollPane scrTraces = new JScrollPane();

    tblTraces = new JTable(tbmTraces);
    tbmTraces.adjustColumns(tblTraces);
    tblTraces.setAutoscrolls(false);

    tblTraces.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            TracePanel.this.pnlTraceDetail.setTrace(
                dataSet, tbmTraces.get(tblTraces.getSelectedRow()));
          }
        });

    tblTraces.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    scrTraces.setMinimumSize(new Dimension(200, 384));
    scrTraces.setViewportView(tblTraces);

    add(scrTraces, BorderLayout.CENTER);
  }
  void tableInitialise(JTable table) {

    JScrollPane scroll;
    TableColumn column = null;

    int colunms = table.getColumnCount();
    for (int y = 0; y < colunms; y++) {
      column = table.getColumnModel().getColumn(y);
      /*将每一列的默认宽度设置为100*/
      column.setPreferredWidth(100);
    }
    /*
     * 设置JTable自动调整列表的状态,此处设置为关闭
     */
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

    table.setFont(new Font("Menu.font", Font.PLAIN, 14));
    table.getTableHeader().setFont(new Font("Menu.font", Font.BOLD, 15));
    /*用JScrollPane装载JTable,这样超出范围的列就可以通过滚动条来查看*/

    scroll = new JScrollPane(table);
    TablePanel.removeAll();

    TablePanel.setLayout(new BoxLayout(TablePanel, BoxLayout.Y_AXIS));
    TablePanel.add(scroll);

    TablePanel.revalidate();

    table.setRowSelectionAllowed(true); // 设置JTable可被选择
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // 设置JTable为单行选择
    table.getTableHeader().setBackground(new Color(206, 231, 255)); // 设置JTable表头颜色
    table.getTableHeader().setReorderingAllowed(false); // 设置JTable每个字段的顺序不可以改变
    table.getTableHeader().setResizingAllowed(false); // 设置JTable每个表头的大小不可以改变
    makeFace(table); // 设置JTable 颜色

    table.setVisible(true);
  }
 private void jbInit() throws Exception {
   panel1.setLayout(borderLayout1);
   okButton.setText("OK");
   okButton.addActionListener(new MimeTypeEditor_okButton_actionAdapter(this));
   filtersTable.setRowSelectionAllowed(true);
   filtersTable.setPreferredSize(new Dimension(418, 200));
   filtersTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
   filtersTable.setCellSelectionEnabled(true);
   filtersTable.setColumnSelectionAllowed(false);
   filtersTable.setModel(m_model);
   addButton.setToolTipText(
       "Add a new " + mimeTypeEditorBuilder.getValueName() + " for a MIME type");
   addButton.setText("Add");
   addButton.addActionListener(new MimeTypeEditor_addButton_actionAdapter(this));
   cancelButton.setText("Cancel");
   cancelButton.addActionListener(new MimeTypeEditor_cancelButton_actionAdapter(this));
   deleteButton.setToolTipText("Delete the currently selected item.");
   deleteButton.setText("Delete");
   deleteButton.addActionListener(new MimeTypeEditor_deleteButton_actionAdapter(this));
   upButton.setText("Up");
   upButton.addActionListener(new MimeTypeEditor_upButton_actionAdapter(this));
   dnButton.setText("Down");
   dnButton.addActionListener(new MimeTypeEditor_dnButton_actionAdapter(this));
   panel1.setPreferredSize(new Dimension(418, 200));
   jScrollPane1.setMinimumSize(new Dimension(200, 80));
   jScrollPane1.setOpaque(true);
   buttonPanel.add(dnButton, null);
   buttonPanel.add(upButton, null);
   buttonPanel.add(addButton, null);
   buttonPanel.add(deleteButton, null);
   buttonPanel.add(okButton, null);
   buttonPanel.add(cancelButton, null);
   getContentPane().add(panel1);
   panel1.add(buttonPanel, BorderLayout.SOUTH);
   panel1.add(jScrollPane1, BorderLayout.CENTER);
   jScrollPane1.getViewport().add(filtersTable, null);
 }
 public CFInternetSwingISOCountryPickerJPanel(
     ICFInternetSwingSchema argSchema,
     ICFSecurityISOCountryObj argFocus,
     ICFLibAnyObj argContainer,
     Collection<ICFSecurityISOCountryObj> argDataCollection,
     ICFInternetSwingISOCountryChosen whenChosen) {
   super();
   final String S_ProcName = "construct-schema-focus";
   if (argSchema == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 1, "argSchema");
   }
   if (whenChosen == null) {
     throw CFLib.getDefaultExceptionFactory()
         .newNullArgumentException(getClass(), S_ProcName, 5, "whenChosen");
   }
   invokeWhenChosen = whenChosen;
   // argFocus is optional; focus may be set later during execution as
   // conditions of the runtime change.
   swingSchema = argSchema;
   swingFocus = argFocus;
   swingContainer = argContainer;
   setSwingDataCollection(argDataCollection);
   dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
   dataTable.addMouseListener(getDataListMouseAdapter());
   dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
   dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   dataTable.setUpdateSelectionOnSort(true);
   dataTable.setRowHeight(25);
   getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
   dataScrollPane =
       new JScrollPane(
           dataTable,
           ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
           ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
   dataScrollPane.setColumnHeader(
       new JViewport() {
         @Override
         public Dimension getPreferredSize() {
           Dimension sz = super.getPreferredSize();
           sz.height = 25;
           return (sz);
         }
       });
   dataTable.setFillsViewportHeight(true);
   actionCancel = new ActionCancel();
   buttonCancel = new JButton(actionCancel);
   actionChooseNone = new ActionChooseNone();
   buttonChooseNone = new JButton(actionChooseNone);
   actionChooseSelected = new ActionChooseSelectedISOCountry();
   buttonChooseSelected = new JButton(actionChooseSelected);
   // Do initial layout
   setSize(1024, 480);
   add(buttonChooseNone);
   add(buttonChooseSelected);
   add(buttonCancel);
   add(dataScrollPane);
   dataScrollPane.setBounds(0, 35, 1024, 455);
   doLayout();
   setSwingFocusAsISOCountry(argFocus);
 }
  public UnitPersonnelPanel(Unit u) {
    _Unit = u;
    _Model = new PersonnelTableModel(_Unit);
    _Sorter.setTableModel(_Model);
    _PersonnelTable.setModel(_Sorter);
    _Sorter.setTableHeader(_PersonnelTable.getTableHeader());
    _PersonnelTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    _PersonnelTable.setPreferredSize(new Dimension(1000, 600));
    _PersonnelTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    _PersonnelTable.addMouseListener(this);
    _ScrollPane =
        new JScrollPane(
            _PersonnelTable,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    _EditPanel.setBorder(BorderFactory.createEtchedBorder());
    _EditPanel.setLayout(new BoxLayout(_EditPanel, BoxLayout.Y_AXIS));
    _EditPanel.add(
        SwingHelper.GetTextFieldWithAction(
            _NameTextField,
            "Name",
            "Name of the Unit member",
            true,
            "RandomName",
            "Generate a Random Name",
            this));
    _EditPanel.add(
        SwingHelper.GetTextField(_CallsignTextField, "Callsign", "The Person's callsign", true));
    _EditPanel.add(SwingHelper.GetComboBox(_RankCombo, "Rank", "The persons Rank", true));
    _EditPanel.add(
        SwingHelper.GetComboBox(_HomePlanetCombo, "Home Planet", "The persons Home Planet", true));
    _EditPanel.add(
        SwingHelper.GetComboBox(_RatingCombo, "Rating", "The persons experience rating", true));
    _EditPanel.add(
        SwingHelper.GetComboBox(
            _JobTypeCombo, "Job Type", "The job type this person is used for", true));
    _EditPanel.add(
        SwingHelper.GetTextFieldWithAction(
            _AssetAssignmentTextField,
            "Asset Assignment",
            "The Asset this person is assigned to",
            true,
            "AssetAssignment",
            "Set asset assignment for this person",
            this));
    _EditPanel.add(
        SwingHelper.GetTextArea(_NotesTextArea, "Notes", "Notes for this Personnel record", true));

    _AddPersonnelButton.setActionCommand("AddPersonnel");
    _AddPersonnelButton.addActionListener(this);
    _RemovePersonnelButton.setActionCommand("RemovePersonnel");
    _RemovePersonnelButton.addActionListener(this);

    _AssetAssignmentTextField.setEditable(false);

    _ButtonPanel.setLayout(new BorderLayout());
    _ButtonPanel.add(_AddPersonnelButton, BorderLayout.WEST);
    _ButtonPanel.add(_RemovePersonnelButton, BorderLayout.EAST);

    setLayout(new BorderLayout());
    add(_EditPanel, BorderLayout.NORTH);
    add(_ScrollPane, BorderLayout.CENTER);
    add(_ButtonPanel, BorderLayout.SOUTH);

    FillCombos();

    _CurrentPersonnel = null;
    _PreviousPersonnel = null;

    setVisible(true);
  }
  private JTable createPropertiesPanel() {
    DefaultTableModel model =
        new DefaultTableModel(1, 2) {
          @Override
          public boolean isCellEditable(int row, int column) {
            return column == 1;
          }
        };
    model.setValueAt(Bundle.PathLabel_Text(), 0, 0);
    model.setValueAt(ToolAdapterIO.getUserAdapterPath(), 0, 1);
    model.addTableModelListener(
        l -> {
          String newPath = model.getValueAt(0, 1).toString();
          File path = new File(newPath);
          if (!path.exists()
              && SnapDialogs.Answer.YES
                  == SnapDialogs.requestDecision(
                      "Path does not exist",
                      "The path you have entered does not exist.\nDo you want to create it?",
                      true,
                      "Don't ask me in the future")) {
            if (!path.mkdirs()) {
              SnapDialogs.showError("Path could not be created!");
            }
          }
          if (path.exists()) {
            File oldPath = ToolAdapterIO.getUserAdapterPath();
            ToolAdapterOperatorDescriptor[] operatorDescriptors =
                ToolAdapterActionRegistrar.getActionMap()
                    .values()
                    .toArray(
                        new ToolAdapterOperatorDescriptor
                            [ToolAdapterActionRegistrar.getActionMap().values().size()]);
            for (ToolAdapterOperatorDescriptor descriptor : operatorDescriptors) {
              ToolAdapterActionRegistrar.removeOperatorMenu(descriptor);
            }
            ToolAdapterIO.setAdaptersPath(Paths.get(newPath));
            if (!newPath.equals(oldPath.getAbsolutePath())) {
              Collection<ToolAdapterOpSpi> toolAdapterOpSpis =
                  ToolAdapterIO.searchAndRegisterAdapters();
              for (ToolAdapterOpSpi spi : toolAdapterOpSpis) {
                ToolAdapterActionRegistrar.registerOperatorMenu(
                    (ToolAdapterOperatorDescriptor) spi.getOperatorDescriptor());
              }
              refreshContent();
            }
          }
        });
    JTable table = new JTable(model);
    TableColumn labelColumn = table.getColumnModel().getColumn(0);
    labelColumn.setPreferredWidth((CHECK_COLUMN_WIDTH + LABEL_COLUMN_WIDTH) / 2);
    TableColumn pathColumn = table.getColumnModel().getColumn(1);
    pathColumn.setPreferredWidth(COLUMN_WIDTH);
    pathColumn.setCellEditor(new FileChooserCellEditor());
    table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
    table.setRowHeight(PATH_ROW_HEIGHT);
    table.setBorder(BorderFactory.createLineBorder(Color.black));
    table.addFocusListener(
        new FocusListener() {
          @Override
          public void focusGained(FocusEvent e) {}

          @Override
          public void focusLost(FocusEvent e) {
            Object source = e.getSource();
            if (!table.equals(source)) {
              table.editingCanceled(new ChangeEvent(source));
              table.clearSelection();
            }
          }
        });
    return table;
  }
Exemple #13
0
  public void setContent(String cat) {
    cat = cat.trim();
    selectAllCB.setVisible(false);
    selectAllCB.setSelected(false);
    deleteBut.setVisible(false);
    restoreBut.setVisible(false);
    refreshBut.setVisible(true);
    Object columns[] = null;
    int count = 0;
    switch (cat) {
      case "Inbox":
        columns = new Object[] {"", "From", "Date", "Subject", "Content"};
        count = Database.getCount("Inbox");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id desc");
        ;
        break;
      case "SentMail":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Sentmail");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id desc");
        break;
      case "Draft":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Draft");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id desc");
        break;
      case "Outbox":
        columns = new Object[] {"", "To", "Date", "Subject", "Content"};
        count = Database.getCount("Outbox");
        workingSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id desc");
        break;
      case "Trash":
        //                restoreBut.setVisible(true);
        columns = new Object[] {"", "To/From", "Date", "Subject", "Content"};
        count = Database.getCount("Trash");
        workingSet =
            db.getData(
                "SELECT * FROM messages,trash WHERE messages.tag='trash' and messages.msg_id=trash.msg_id ORDER BY deleted_at desc");
        break;
      default:
        System.out.println("in default case");
    }
    if (count > 0) {
      selectAllCB.setVisible(true);
      rows = new Object[count][];
      msgID = new int[count];
      try {
        workingSet.beforeFirst();
        for (int i = 0; i < count && workingSet.next(); i++) {
          msgID[i] = workingSet.getInt(1);
          rows[i] =
              new Object[] {
                false,
                workingSet.getString(2),
                workingSet.getDate(3),
                workingSet.getString(4),
                workingSet.getString(5)
              };
        }
      } catch (SQLException sqlExc) {
        JOptionPane.showMessageDialog(null, sqlExc, "EXCEPTION", JOptionPane.ERROR_MESSAGE);
        sqlExc.printStackTrace();
      }

      tableModel = new MyDefaultTableModel(rows, columns);
      table = new JTable(tableModel);
      table.getSelectionModel().addListSelectionListener(this);
      table.addMouseListener(this);
      table.getTableHeader().setOpaque(true);
      table.getTableHeader().setReorderingAllowed(false);
      //            table.getTableHeader().setBackground(Color.blue);
      table.getTableHeader().setForeground(Color.blue);
      //        table.setRowSelectionAllowed(false);
      //            table.setColumnSelectionAllowed(false);
      table.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14));
      table.setRowHeight(20);
      table.setFillsViewportHeight(true);

      TableColumn column = null;
      for (int i = 0; i < 5; i++) {
        column = table.getColumnModel().getColumn(i);
        if (i == 0) {
          column.setPreferredWidth(6);
        } else if (i == 3) {
          column.setPreferredWidth(250);
        } else if (i == 4) {
          column.setPreferredWidth(450);
        } else {
          column.setPreferredWidth(40);
        }
      }
      table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

      remove(contentPan);
      contentPan = new JScrollPane(table);
      contentPan.setBackground(Color.orange);
      contentPan.setOpaque(true);
      contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      add(contentPan, "Center");
      Home.home.homeFrame.setVisible(true);
    } else {
      JPanel centPan = new JPanel(new GridBagLayout());
      centPan.setBackground(new Color(52, 86, 70));
      JLabel label = new JLabel("No Messages In This Category");
      label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 22));
      label.setForeground(Color.orange);
      centPan.add(label);
      remove(contentPan);
      contentPan = new JScrollPane(centPan);
      contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
      add(contentPan, "Center");
      contentPan.repaint();
    }
  }
  public FrontEnd() {
    setLocation(0, 0);
    setSize(1285, 750);
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    table =
        new JTable(dtm) {
          @Override
          public boolean isCellEditable(int row, int column) {
            if (column == 0 || column == 1) return false;
            else return true;
          }
        };
    final JComboBox comboBoxRun = new JComboBox();
    comboBoxRun.setEditable(true);
    comboBoxRun.addItem("Run all tests");
    comboBoxRun.addItem("Run all tests and then rerun Failed tests");
    comboBoxRun.addItem("Only run Failed tests");
    table.getColumnModel().getColumn(0).setPreferredWidth(422);
    table.getColumnModel().getColumn(1).setPreferredWidth(460);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setRowSelectionAllowed(false);
    table.getTableHeader().setReorderingAllowed(false);
    table.getTableHeader().setPreferredSize(new Dimension(100, HEADER_HEIGHT));
    table.getTableHeader().setFont(new Font(null, Font.BOLD, 12));
    table.getTableHeader().setBackground(Color.LIGHT_GRAY);
    table.getTableHeader().setPreferredSize(new Dimension(10000, 32));
    JScrollPane sp = new JScrollPane(table);
    JPanel subPanel = new JPanel();
    JPanel subPanel1 = new JPanel();
    openF = new JButton("Choose File");
    openFo = new JButton("Choose Folder");
    selFo = new JButton("Select Single Folder");
    canF = new JButton("Cancel");
    canF.setEnabled(false);
    resLab = new JLabel("Results Path");
    Launch = new JButton("Launch");
    foSel = new JButton("...");
    foSel.setPreferredSize(new Dimension(18, 18));
    resBox = new JTextField(placeS);
    resBox.setPreferredSize(new Dimension(500, 24));
    resBox.setEditable(false);
    duplC = new JCheckBox("Remove Duplicates");
    duplC.setSelected(true);
    subPanel.add(openF);
    subPanel.add(openFo);
    subPanel.add(selFo);
    subPanel.add(canF);
    subPanel.add(Launch);
    subPanel.add(duplC);
    subPanel.add(comboBoxRun);
    subPanel1.add(resLab);
    subPanel1.add(resBox);
    subPanel1.add(foSel);

    initUI();
    getContentPane().add(sp, BorderLayout.CENTER);
    getContentPane().add(subPanel, BorderLayout.SOUTH);
    getContentPane().add(subPanel1, BorderLayout.NORTH);
    sValue = (String) comboBoxRun.getSelectedItem();
    comboBoxRun.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            String sValue = (String) comboBoxRun.getSelectedItem();
            if (sValue.equals("Run all Tests")) {
              flagF = 1;
            }
            if (sValue.contains("Run all tests and then rerun Failed tests")) {
              flagF = 2;
            }
            if (sValue.contains("Only run Failed tests")) {
              flagF = 3;
            }
            System.out.println(flagF);
          }
        });
    openF.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            openFile();
          }
        });
    openFo.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            openFolder();
          }
        });
    selFo.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            selFolder();
          }
        });
    canF.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            cancelSel();
          }
        });
    foSel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            resFol();
            resBox.setText(placeS);
          }
        });
    Launch.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent ae) {
            try {
              doLaunch();
            } catch (IOException ex) {
              Logger.getLogger(FrontEnd.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        });

    table.addMouseListener(
        new java.awt.event.MouseAdapter() {
          @Override
          public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
              // Bring up pop up on row/col of right click
              JTable source = (JTable) e.getSource();
              int row = source.rowAtPoint(e.getPoint());
              int column = source.columnAtPoint(e.getPoint());
              if (!source.isRowSelected(row) || !source.isColumnSelected(column))
                source.changeSelection(row, column, false, false);
              doPop(e);
            }
          }
        });
  }
  // Method to update Table and related components
  private void update() {
    Database db = new Database();
    String column[] = {
      "ID",
      "NAME",
      "GENDER",
      "GUARDIAN_ROLE",
      "GUARDIAN_NAME",
      "PRESENT_ADDRESS",
      "PRESENT_CITY",
      "PRESENT_PHONE"
    };

    try {
      // Update table
      if (searchcombobox.getSelectedIndex() == 0 && allfieldcheckbox.isSelected()) {
        mytablemodel = new MyTableModel(db.getAllStudent(), db.getColumnNameFromStudent());
      } else if (searchcombobox.getSelectedIndex() == 0 && !allfieldcheckbox.isSelected()) {
        mytablemodel = new MyTableModel(db.getSomeFieldsFromStudent(), column);
      } else if (searchcombobox.getSelectedIndex() == 1 && allfieldcheckbox.isSelected()) {
        String query =
            "SELECT * FROM Student WHERE NAME = \'" + searchtextfield.getText().trim() + "\'";
        mytablemodel = new MyTableModel(db.getData(query), db.getColumnNameFromStudent());
      } else if (searchcombobox.getSelectedIndex() == 1 && !allfieldcheckbox.isSelected()) {
        String query =
            "SELECT ID, NAME, GENDER, GUARDIAN_ROLE, GUARDIAN_NAME, PRESENT_ADDRESS, PRESENT_CITY, PRESENT_PHONE FROM Student WHERE NAME = \'"
                + searchtextfield.getText().trim()
                + "\'";
        mytablemodel = new MyTableModel(db.getData(query), column);
      } else if (searchcombobox.getSelectedIndex() == 2 && allfieldcheckbox.isSelected()) {
        String query =
            "SELECT * FROM Student WHERE GUARDIAN_NAME = \'"
                + searchtextfield.getText().trim()
                + "\'";
        mytablemodel = new MyTableModel(db.getData(query), db.getColumnNameFromStudent());
      } else if (searchcombobox.getSelectedIndex() == 2 && !allfieldcheckbox.isSelected()) {
        String query =
            "SELECT ID, NAME, GENDER, GUARDIAN_ROLE, GUARDIAN_NAME, PRESENT_ADDRESS, PRESENT_CITY, PRESENT_PHONE FROM Student WHERE GUARDIAN_NAME = \'"
                + searchtextfield.getText().trim()
                + "\'";
        mytablemodel = new MyTableModel(db.getData(query), column);
      } else if (searchcombobox.getSelectedIndex() == 3 && allfieldcheckbox.isSelected()) {
        String query =
            "SELECT * FROM Student WHERE ID = ANY(SELECT SID FROM Fee WHERE CID = ANY(SELECT ID FROM CourseInfo WHERE NAME = \'"
                + searchtextfield.getText().trim()
                + "\'))";
        mytablemodel = new MyTableModel(db.getData(query), db.getColumnNameFromStudent());
      } else if (searchcombobox.getSelectedIndex() == 3 && !allfieldcheckbox.isSelected()) {
        String query =
            "SELECT ID, NAME, GENDER, GUARDIAN_ROLE, GUARDIAN_NAME, PRESENT_ADDRESS, PRESENT_CITY, PRESENT_PHONE FROM Student WHERE ID = ANY(SELECT SID FROM Fee WHERE CID = ANY(SELECT ID FROM CourseInfo WHERE NAME = \'"
                + searchtextfield.getText().trim()
                + "\'))";
        mytablemodel = new MyTableModel(db.getData(query), column);
      } else if (searchcombobox.getSelectedIndex() == 4 && allfieldcheckbox.isSelected()) {
        String query =
            "SELECT * FROM Student WHERE ID = ANY(SELECT SID FROM Fee WHERE TOTAL_FEES - FEES_PAYED >= 0)";
        mytablemodel = new MyTableModel(db.getData(query), db.getColumnNameFromStudent());
      } else {
        String query =
            "SELECT ID, NAME, GENDER, GUARDIAN_ROLE, GUARDIAN_NAME, PRESENT_ADDRESS, PRESENT_CITY, PRESENT_PHONE FROM Student WHERE ID = ANY(SELECT SID FROM Fee WHERE TOTAL_FEES - FEES_PAYED >= 0)";
        mytablemodel = new MyTableModel(db.getData(query), column);
      }

      table = new JTable(mytablemodel);
      table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
      // Add list selection listener to table
      table.getSelectionModel().addListSelectionListener(this);

      TableColumn col = null;
      for (int i = 3; i < table.getColumnCount(); i++) {
        col = table.getColumnModel().getColumn(i);
        col.setPreferredWidth(200);
      }

      scrollpane = new JScrollPane(table);

      panel_3.removeAll();
      panel_3.add(scrollpane);

      // Update total student label
      int total = db.getTotalStudent();
      totalstudentlabel.setText("Total Student = " + total);

      // Clear search combo box
      searchtextfield.setText("");

      this.revalidate();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }
  }
  public MessageStrategy() {

    JButton button = new JButton("刷新");
    button.addActionListener(new newListener());

    // 获取表格数据信息
    StrategyController controller = new StrategyController();
    int count = 0;
    ArrayList<DiscountStrategyVO> discounts = controller.getAllDiscounts();
    for (int t = 0; t < discounts.size(); t++) {
      int client = discounts.get(t).getRank();
      data[t][0] = discounts.get(t).getId();
      data[t][1] =
          "折扣:"
              + Double.toString(discounts.get(t).getDiscount())
              + "      "
              + "客户级别:"
              + Integer.toString(client);
      count++;
    }
    ArrayList<VoucherStrategyVO> vouchers = controller.getAllVouchers();
    for (int t = 0; t < vouchers.size(); t++) {
      int client = vouchers.get(t).getRank();
      data[count][0] = vouchers.get(t).getId();
      data[count][1] =
          "代金券:"
              + Double.toString(vouchers.get(t).getVoucher())
              + "      "
              + "客户级别:"
              + Integer.toString(client);
      count++;
    }
    ArrayList<CombinationStrategyVO> combinations = controller.getAllCombinations();
    for (int t = 0; t < combinations.size(); t++) {
      ArrayList<CombinationItemVO> comdities = combinations.get(t).getList();
      String comdity = "";
      for (int k = 0; k < comdities.size(); k++) {
        comdity =
            comdity
                + comdities.get(k).getCommodity()
                + ","
                + comdities.get(k).getModel()
                + ","
                + Integer.toString(comdities.get(k).getNumber())
                + ";";
      }
      data[count][0] = combinations.get(t).getId();
      data[count][1] =
          "组合商品:"
              + comdity
              + "     "
              + "原价:"
              + Double.toString(combinations.get(t).getInitialMoney())
              + "     "
              + "现价:"
              + Double.toString(combinations.get(t).getLaterMoney());
      count++;
    }
    ArrayList<GiftStrategyVO> giftClient = controller.getAllGifts();
    for (int t = 0; t < giftClient.size(); t++) {
      int client = giftClient.get(t).getRank();
      ArrayList<GiftItemVO> items = giftClient.get(t).getList();
      String giftItem = "";
      for (int k = 0; k < items.size(); k++) {
        giftItem =
            giftItem
                + items.get(k).getCommodity()
                + ","
                + items.get(k).getModel()
                + ","
                + Integer.toString(items.get(k).getNumber())
                + ";";
      }
      data[count][0] = giftClient.get(t).getId();
      data[count][1] = "客户级别:" + Integer.toString(client) + "     " + "赠品:" + giftItem;
      count++;
    }
    ArrayList<GiftBasedOnTotalMoneyVO> giftMoney = controller.getAllGBOTMs();
    for (int t = 0; t < giftMoney.size(); t++) {
      ArrayList<GBOTMItemVO> items = giftMoney.get(t).getList();
      String giftItem = "";
      for (int k = 0; k < items.size(); k++) {
        giftItem =
            giftItem
                + items.get(k).getCommodity()
                + ","
                + items.get(k).getModel()
                + ","
                + Integer.toString(items.get(k).getNumber())
                + ";";
      }
      data[count][0] = giftMoney.get(t).getId();
      data[count][1] =
          "价格下限:"
              + Double.toString(giftMoney.get(t).getLower())
              + "     "
              + "价格上限:"
              + Double.toString(giftMoney.get(t).getUpper())
              + "     "
              + "赠品:"
              + giftItem;
      count++;
    }
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(true);

    JScrollPane scroller = new JScrollPane();
    scroller.getViewport().add(table);
    scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    table.getColumnModel().getColumn(1).setPreferredWidth(800);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    panel.setLayout(null);
    button.setBounds(330, 3, 65, 25);
    scroller.setBounds(0, 40, 410, 420);

    panel.add(button);
    panel.add(scroller);
  }