コード例 #1
0
ファイル: EncodeFileBrowser.java プロジェクト: philres/IGV
  private void init(final EncodeTableModel model) {
    setModal(true);
    setTitle("Encode Production Data");

    table.setAutoCreateRowSorter(true);
    table.setModel(model);
    table.setRowSorter(model.getSorter());
    try {
      rowCountLabel.setText(numberFormatter.valueToString(table.getRowCount()) + " rows");
    } catch (ParseException e) {

    }

    table.setRowSelectionAllowed(false);
    table.setColumnSelectionAllowed(false);

    filterTextField
        .getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void changedUpdate(DocumentEvent e) {
                updateFilter();
              }

              public void insertUpdate(DocumentEvent e) {
                updateFilter();
              }

              public void removeUpdate(DocumentEvent e) {
                updateFilter();
              }
            });
  }
コード例 #2
0
 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);
 }
コード例 #3
0
  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);
  }
コード例 #4
0
  public static void main(String args[]) {
    // style that is necessary
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException e) {
    } catch (InstantiationException e) {
    } catch (IllegalAccessException e) {
    } catch (UnsupportedLookAndFeelException e) {
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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