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; }
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; }
public static void main(String[] args) { PropertyTableModel model = new PropertyTableModel(System.getProperties()); JTable table = new JTable(); table.setModel(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane spane = new JScrollPane(table); JFrame frame = new JFrame("System Properties"); frame.getContentPane().add(spane); frame.pack(); frame.setVisible(true); frame.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { System.exit(0); }; }); }
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); }
@Override public void downloadBatch(DownloadBatch_Result result) { table = new JTable(); tableModel = new TableModel(bState, result); table.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { cells = bState.cells; JTable target = (JTable) e.getSource(); int row = target.getSelectedRow(); int column = target.getSelectedColumn() - 1; for (ArrayList<Cell> cellRow : cells) { for (Cell cell : cellRow) { if (cell.record == row && cell.field == column) { bState.setSelectedCell(cell); } } } } }); table.addKeyListener( new KeyListener() { @Override public void keyTyped(KeyEvent e) { // TODO Auto-generated method stub } @Override public void keyPressed(KeyEvent e) { // TODO Auto-generated method stub } @Override public void keyReleased(KeyEvent e) { JTable target = (JTable) e.getSource(); int row = target.getSelectedRow(); int column = target.getSelectedColumn() - 1; if (e.getKeyCode() == KeyEvent.VK_TAB) { for (ArrayList<Cell> cellRow : cells) { for (Cell cell : cellRow) { if (cell.record == row && cell.field == column) { bState.setSelectedCell(cell); } } } } } }); table.setModel(tableModel); table.setRowHeight(20); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setCellSelectionEnabled(true); table.getTableHeader().setReorderingAllowed(false); TableColumnModel columnModel = table.getColumnModel(); for (int i = 0; i < tableModel.getColumnCount(); ++i) { TableColumn column = columnModel.getColumn(i); column.setPreferredWidth(100); } for (int i = 0; i < tableModel.getColumnCount(); ++i) { TableColumn column = columnModel.getColumn(i); column.setCellRenderer(new CellRenderer()); // column.setCellEditor(new CellEditor()); } BoxLayout box = new BoxLayout(this, BoxLayout.Y_AXIS); setLayout(box); add(table.getTableHeader()); add(table); revalidate(); }
public void makeGUI() { frm = new JFrame(); c = frm.getContentPane(); btnImport = new JButton("Import"); btnImport.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureImport(); } }); btnMove = new JButton("Move"); btnMove.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureMove(); } }); btnDelete = new JButton("Delete"); btnDelete.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureDelete(); } }); btnAnalyse = new JButton("Analyse"); btnAnalyse.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureAnalysis(); } }); tblItems = new JTable(store); tblItems.setRowSorter(tableSorter); tblItems.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tblItems.setFillsViewportHeight(true); tblItems.getRowSorter().toggleSortOrder(Storage.COL_DATE); tblItems.addMouseListener( new MouseListener() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { tblItems.setRowSelectionInterval( e.getY() / tblItems.getRowHeight(), e.getY() / tblItems.getRowHeight()); } if (e.getClickCount() > 1 || e.getButton() == MouseEvent.BUTTON3) { int idx = tblItems.convertRowIndexToModel(tblItems.getSelectedRow()); secureExport(idx); } } public void mouseEntered(MouseEvent arg0) {} public void mouseExited(MouseEvent arg0) {} public void mousePressed(MouseEvent arg0) {} public void mouseReleased(MouseEvent arg0) {} }); txaStatus = new JTextArea(TXA_HEIGHT, TXA_WIDTH); txaStatus.setEditable(false); txaStatus.setBorder(BorderFactory.createTitledBorder("Status")); txaSearch = new JTextArea(4, TXA_WIDTH); txaSearch.setBorder(BorderFactory.createTitledBorder("Search")); txaSearch.addKeyListener( new KeyListener() { public void keyPressed(KeyEvent arg0) {} public void keyReleased(KeyEvent arg0) { filterBase(txaSearch.getText()); // EXPORT settings here, as in mass export (export everything) if (allowExport && txaSearch.getText().equalsIgnoreCase(CMD_EXPORT)) { // txaSearch.setText(""); if (JOptionPane.showConfirmDialog( frm, "Do you really want to export the whole secure base?", "Confirm Export", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { totalExport(); } } // LOST X IMPORT asin look through the store for files not listed if (txaSearch.getText().equalsIgnoreCase(CMD_STOCKTAKE)) { for (int i = 0; i < storeLocs.size(); i++) { if (store.stockTake(i)) needsSave = true; } } } public void keyTyped(KeyEvent arg0) {} }); JPanel pnlTop = new JPanel(new GridLayout(1, 4)); JPanel pnlEast = new JPanel(new BorderLayout()); JPanel pnlCenterEast = new JPanel(new BorderLayout()); JScrollPane jspItems = new JScrollPane(tblItems); pnlTop.add(btnImport); pnlTop.add(btnMove); pnlTop.add(btnDelete); pnlTop.add(btnAnalyse); pnlCenterEast.add(txaStatus, BorderLayout.CENTER); pnlCenterEast.add(txaSearch, BorderLayout.NORTH); // pnlEast.add(pswPass, BorderLayout.NORTH); pnlEast.add(pnlCenterEast, BorderLayout.CENTER); c.setLayout(new BorderLayout()); c.add(pnlTop, BorderLayout.NORTH); c.add(pnlEast, BorderLayout.EAST); c.add(jspItems, BorderLayout.CENTER); frm.setContentPane(c); }
/** * Create a new, empty, not-visible TaxRef window. Really just activates the setup frame and setup * memory monitor components, then starts things off. */ public MainFrame() { setupMemoryMonitor(); // Set up the main frame. mainFrame = new JFrame(basicTitle); mainFrame.setJMenuBar(setupMenuBar()); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Set up the JTable. table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setSelectionBackground(COLOR_SELECTION_BACKGROUND); table.setShowGrid(true); // Add a blank table model so that the component renders properly on // startup. table.setModel(blankDataModel); // Add a list selection listener so we can tell the matchInfoPanel // that a new name was selected. table .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (currentCSV == null) return; int row = table.getSelectedRow(); int column = table.getSelectedColumn(); columnInfoPanel.columnChanged(column); Object o = table.getModel().getValueAt(row, column); if (Name.class.isAssignableFrom(o.getClass())) { matchInfoPanel.nameSelected(currentCSV.getRowIndex(), (Name) o, row, column); } else { matchInfoPanel.nameSelected(currentCSV.getRowIndex(), null, -1, -1); } } }); // Set up the left panel (table + matchInfoPanel) JPanel leftPanel = new JPanel(); matchInfoPanel = new MatchInformationPanel(this); leftPanel.setLayout(new BorderLayout()); leftPanel.add(matchInfoPanel, BorderLayout.SOUTH); leftPanel.add(new JScrollPane(table)); // Set up the right panel (columnInfoPanel) JPanel rightPanel = new JPanel(); columnInfoPanel = new ColumnInformationPanel(this); progressBar.setStringPainted(true); rightPanel.setLayout(new BorderLayout()); rightPanel.add(columnInfoPanel); rightPanel.add(progressBar, BorderLayout.SOUTH); // Set up a JSplitPane to split the panels up. JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, leftPanel, rightPanel); split.setResizeWeight(1); mainFrame.add(split); mainFrame.pack(); // Set up a drop target so we can pick up files mainFrame.setDropTarget( new DropTarget( mainFrame, new DropTargetAdapter() { @Override public void dragEnter(DropTargetDragEvent dtde) { // Accept any drags. dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); } @Override public void dragOver(DropTargetDragEvent dtde) {} @Override public void dropActionChanged(DropTargetDragEvent dtde) {} @Override public void dragExit(DropTargetEvent dte) {} @Override public void drop(DropTargetDropEvent dtde) { // Accept a drop as long as its File List. if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); Transferable t = dtde.getTransferable(); try { java.util.List<File> files = (java.util.List<File>) t.getTransferData(DataFlavor.javaFileListFlavor); // If we're given multiple files, pick up only the last file and load that. File f = files.get(files.size() - 1); loadFile(f, DarwinCSV.FILE_CSV_DELIMITED); } catch (UnsupportedFlavorException ex) { dtde.dropComplete(false); } catch (IOException ex) { dtde.dropComplete(false); } } } })); }
/** Constructor (create and layout page) */ public SOAPMonitorPage(String host_name) { host = host_name; // Set up default filter (show all messages) filter = new SOAPMonitorFilter(); // Use borders to help improve appearance etched_border = new EtchedBorder(); // Build top portion of split (list panel) model = new SOAPMonitorTableModel(); table = new JTable(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setRowSelectionInterval(0, 0); table.setPreferredScrollableViewportSize(new Dimension(600, 96)); table.getSelectionModel().addListSelectionListener(this); scroll = new JScrollPane(table); remove_button = new JButton("Remove"); remove_button.addActionListener(this); remove_button.setEnabled(false); remove_all_button = new JButton("Remove All"); remove_all_button.addActionListener(this); filter_button = new JButton("Filter ..."); filter_button.addActionListener(this); list_buttons = new JPanel(); list_buttons.setLayout(new FlowLayout()); list_buttons.add(remove_button); list_buttons.add(remove_all_button); list_buttons.add(filter_button); list_panel = new JPanel(); list_panel.setLayout(new BorderLayout()); list_panel.add(scroll, BorderLayout.CENTER); list_panel.add(list_buttons, BorderLayout.SOUTH); list_panel.setBorder(empty_border); // Build bottom portion of split (message details) details_time = new JLabel("Time: ", SwingConstants.RIGHT); details_target = new JLabel("Target Service: ", SwingConstants.RIGHT); details_status = new JLabel("Status: ", SwingConstants.RIGHT); details_time_value = new JLabel(); details_target_value = new JLabel(); details_status_value = new JLabel(); Dimension preferred_size = details_time.getPreferredSize(); preferred_size.width = 1; details_time.setPreferredSize(preferred_size); details_target.setPreferredSize(preferred_size); details_status.setPreferredSize(preferred_size); details_time_value.setPreferredSize(preferred_size); details_target_value.setPreferredSize(preferred_size); details_status_value.setPreferredSize(preferred_size); details_header = new JPanel(); details_header_layout = new GridBagLayout(); details_header.setLayout(details_header_layout); details_header_constraints = new GridBagConstraints(); details_header_constraints.fill = GridBagConstraints.BOTH; details_header_constraints.weightx = 0.5; details_header_layout.setConstraints(details_time, details_header_constraints); details_header.add(details_time); details_header_layout.setConstraints(details_time_value, details_header_constraints); details_header.add(details_time_value); details_header_layout.setConstraints(details_target, details_header_constraints); details_header.add(details_target); details_header_constraints.weightx = 1.0; details_header_layout.setConstraints(details_target_value, details_header_constraints); details_header.add(details_target_value); details_header_constraints.weightx = .5; details_header_layout.setConstraints(details_status, details_header_constraints); details_header.add(details_status); details_header_layout.setConstraints(details_status_value, details_header_constraints); details_header.add(details_status_value); details_header.setBorder(etched_border); request_label = new JLabel("SOAP Request", SwingConstants.CENTER); request_text = new SOAPMonitorTextArea(); request_text.setEditable(false); request_scroll = new JScrollPane(request_text); request_panel = new JPanel(); request_panel.setLayout(new BorderLayout()); request_panel.add(request_label, BorderLayout.NORTH); request_panel.add(request_scroll, BorderLayout.CENTER); response_label = new JLabel("SOAP Response", SwingConstants.CENTER); response_text = new SOAPMonitorTextArea(); response_text.setEditable(false); response_scroll = new JScrollPane(response_text); response_panel = new JPanel(); response_panel.setLayout(new BorderLayout()); response_panel.add(response_label, BorderLayout.NORTH); response_panel.add(response_scroll, BorderLayout.CENTER); details_soap = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); details_soap.setTopComponent(request_panel); details_soap.setRightComponent(response_panel); details_soap.setResizeWeight(.5); details_panel = new JPanel(); layout_button = new JButton("Switch Layout"); layout_button.addActionListener(this); reflow_xml = new JCheckBox("Reflow XML text"); reflow_xml.addActionListener(this); details_buttons = new JPanel(); details_buttons.setLayout(new FlowLayout()); details_buttons.add(reflow_xml); details_buttons.add(layout_button); details_panel.setLayout(new BorderLayout()); details_panel.add(details_header, BorderLayout.NORTH); details_panel.add(details_soap, BorderLayout.CENTER); details_panel.add(details_buttons, BorderLayout.SOUTH); details_panel.setBorder(empty_border); // Add the two parts to the age split pane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setTopComponent(list_panel); split.setRightComponent(details_panel); // Build status area start_button = new JButton("Start"); start_button.addActionListener(this); stop_button = new JButton("Stop"); stop_button.addActionListener(this); status_buttons = new JPanel(); status_buttons.setLayout(new FlowLayout()); status_buttons.add(start_button); status_buttons.add(stop_button); status_text = new JLabel(); status_text.setBorder(new BevelBorder(BevelBorder.LOWERED)); status_text_panel = new JPanel(); status_text_panel.setLayout(new BorderLayout()); status_text_panel.add(status_text, BorderLayout.CENTER); status_text_panel.setBorder(empty_border); status_area = new JPanel(); status_area.setLayout(new BorderLayout()); status_area.add(status_buttons, BorderLayout.WEST); status_area.add(status_text_panel, BorderLayout.CENTER); status_area.setBorder(etched_border); // Add the split and status area to page setLayout(new BorderLayout()); add(split, BorderLayout.CENTER); add(status_area, BorderLayout.SOUTH); }
public DownloadGUI() { setTitle("Rav's Download Manager"); setSize(640, 480); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { actionExit(); } }); JPanel addPanel = new JPanel(); pauseButton = new JButton("", new ImageIcon("icons/pause.gif")); pauseButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { actionPause(); } }); pauseButton.setEnabled(false); addPanel.add(pauseButton); resumeButton = new JButton("", new ImageIcon("icons/resume.gif")); resumeButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { actionResume(); } }); resumeButton.setEnabled(false); addPanel.add(resumeButton); cancelButton = new JButton("", new ImageIcon("icons/cancel.gif")); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { actionCancel(); } }); cancelButton.setEnabled(false); addPanel.add(cancelButton); clearButton = new JButton("", new ImageIcon("icons/clear.gif")); clearButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { actionClear(); } }); clearButton.setEnabled(false); addPanel.add(clearButton); JPanel addPane2 = new JPanel(); addTextField = new JTextField(30); addPane2.add(addTextField); JButton addButton = new JButton("", new ImageIcon("icons/add.gif")); addButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { actionAdd(); } }); addPane2.add(addButton); tableModel = new DownloadList(); table = new JTable(tableModel); table .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { tableSelectionChanged(); } }); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ProgressBar renderer = new ProgressBar(0, 100); renderer.setStringPainted(true); table.setDefaultRenderer(JProgressBar.class, renderer); table.setRowHeight((int) renderer.getPreferredSize().getHeight()); JPanel downloadsPanel = new JPanel(); downloadsPanel.setBorder(BorderFactory.createTitledBorder("Downloads")); downloadsPanel.setLayout(new BorderLayout()); downloadsPanel.add(new JScrollPane(table), BorderLayout.CENTER); getContentPane().setLayout(new GridLayout(3, 1)); getContentPane().add(addPane2); getContentPane().add(addPanel); getContentPane().add(downloadsPanel); }
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); }
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 }
public MemoryPanel(final Debugger debugger, boolean is64Bit) { super(); this.debugger = debugger; this.is64Bit = is64Bit; if (is64Bit) { addressSize = 8; unmappedAddrString = "??????????????????"; } else { addressSize = 4; unmappedAddrString = "??????????"; } setLayout(new BorderLayout()); setupScrollBar(); add(scrollBar, BorderLayout.EAST); model = new AbstractTableModel() { public int getRowCount() { return numVisibleRows; } public int getColumnCount() { return 2; } public Object getValueAt(int row, int column) { switch (column) { case 0: return bigIntToHexString( startVal.add(new BigInteger(Integer.toString((row * addressSize))))); case 1: { try { Address addr = bigIntToAddress( startVal.add(new BigInteger(Integer.toString((row * addressSize))))); if (addr != null) { return addressToString(addr.getAddressAt(0)); } return unmappedAddrString; } catch (UnmappedAddressException e) { return unmappedAddrString; } } default: throw new RuntimeException("Column " + column + " out of bounds"); } } public boolean isCellEditable(int row, int col) { return false; } }; // View with JTable with no header table = new JTable(model); table.setTableHeader(null); table.setShowGrid(false); table.setIntercellSpacing(new Dimension(0, 0)); table.setCellSelectionEnabled(true); table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); table.setDragEnabled(true); Font font = GraphicsUtilities.lookupFont("Courier"); if (font == null) { throw new RuntimeException("Error looking up monospace font Courier"); } table.setFont(font); // Export proper data. // We need to keep our own notion of the selection in order to // properly export data, since the selection can go beyond the // visible area on the screen (and since the table's model doesn't // back all of those slots). // Code thanks to Shannon.Hickey@sfbay table.setTransferHandler( new TransferHandler() { protected Transferable createTransferable(JComponent c) { JTable table = (JTable) c; if (haveSelection()) { StringBuffer buf = new StringBuffer(); int iDir = (getRowAnchor() < getRowLead() ? 1 : -1); int jDir = (getColAnchor() < getColLead() ? 1 : -1); for (int i = getRowAnchor(); i != getRowLead() + iDir; i += iDir) { for (int j = getColAnchor(); j != getColLead() + jDir; j += jDir) { Object val = model.getValueAt(i, j); buf.append(val == null ? "" : val.toString()); if (j != getColLead()) { buf.append("\t"); } } if (i != getRowLead()) { buf.append("\n"); } } return new StringTransferable(buf.toString()); } return null; } public int getSourceActions(JComponent c) { return COPY; } public boolean importData(JComponent c, Transferable t) { if (canImport(c, t.getTransferDataFlavors())) { try { String str = (String) t.getTransferData(DataFlavor.stringFlavor); handleImport(c, str); return true; } catch (UnsupportedFlavorException ufe) { } catch (IOException ioe) { } } return false; } public boolean canImport(JComponent c, DataFlavor[] flavors) { for (int i = 0; i < flavors.length; i++) { if (DataFlavor.stringFlavor.equals(flavors[i])) { return true; } } return false; } private void handleImport(JComponent c, String str) { // do whatever you want with the string here try { makeVisible(debugger.parseAddress(str)); clearSelection(); table.clearSelection(); } catch (NumberFormatException e) { System.err.println("Unable to parse address \"" + str + "\""); } } }); // Supporting keyboard scrolling // See src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java, // search for Table.AncestorInputMap // Actions to override: // selectPreviousRow, selectNextRow, // scrollUpChangeSelection, scrollDownChangeSelection, // selectPreviousRowExtendSelection, selectNextRowExtendSelection, // scrollDownExtendSelection, scrollUpExtendSelection (Shift-PgDn/PgUp) ActionMap map = table.getActionMap(); // Up arrow installActionWrapper( map, "selectPreviousRow", new ActionWrapper() { public void actionPerformed(ActionEvent e) { beginUpdate(); clearSelection(); if (table.getSelectedRow() == 0) { scrollBar.scrollUpOrLeft(); table.setRowSelectionInterval(0, 0); } else { super.actionPerformed(e); } maybeGrabSelection(); endUpdate(); } }); // Down arrow installActionWrapper( map, "selectNextRow", new ActionWrapper() { public void actionPerformed(ActionEvent e) { beginUpdate(); clearSelection(); int row = table.getSelectedRow(); if (row >= numUsableRows) { scrollBar.scrollDownOrRight(); table.setRowSelectionInterval(row, row); } else { super.actionPerformed(e); } maybeGrabSelection(); endUpdate(); } }); // Page up installActionWrapper( map, "scrollUpChangeSelection", new ActionWrapper() { public void actionPerformed(ActionEvent e) { beginUpdate(); clearSelection(); int row = table.getSelectedRow(); scrollBar.pageUpOrLeft(); if (row >= 0) { table.setRowSelectionInterval(row, row); } maybeGrabSelection(); endUpdate(); } }); // Page down installActionWrapper( map, "scrollDownChangeSelection", new ActionWrapper() { public void actionPerformed(ActionEvent e) { beginUpdate(); clearSelection(); int row = table.getSelectedRow(); scrollBar.pageDownOrRight(); if (row >= 0) { table.setRowSelectionInterval(row, row); } maybeGrabSelection(); endUpdate(); } }); // Shift + Up arrow installActionWrapper( map, "selectPreviousRowExtendSelection", new ActionWrapper() { public void actionPerformed(ActionEvent e) { beginUpdate(); if (!haveAnchor()) { setAnchorFromTable(); setLeadFromTable(); // setAnchor(table.getSelectedRow()); // setLead(table.getSelectedRow()); } int newLead = getRowLead() - 1; int newAnchor = getRowAnchor(); if (newLead < 0) { scrollBar.scrollUpOrLeft(); ++newLead; ++newAnchor; } setSelection(newAnchor, newLead, getColAnchor(), getColLead()); // printSelection(); endUpdate(); } }); // Shift + Left arrow installActionWrapper( map, "selectPreviousColumnExtendSelection", new ActionWrapper() { public void actionPerformed(ActionEvent e) { beginUpdate(); if (!haveAnchor()) { setAnchorFromTable(); setLeadFromTable(); } int newLead = Math.max(0, getColLead() - 1); setSelection(getRowAnchor(), getRowLead(), getColAnchor(), newLead); // printSelection(); endUpdate(); } }); // Shift + Down arrow installActionWrapper( map, "selectNextRowExtendSelection", new ActionWrapper() { public void actionPerformed(ActionEvent e) { beginUpdate(); if (!haveAnchor()) { setAnchorFromTable(); setLeadFromTable(); // setAnchor(table.getSelectedRow()); // setLead(table.getSelectedRow()); } int newLead = getRowLead() + 1; int newAnchor = getRowAnchor(); if (newLead > numUsableRows) { scrollBar.scrollDownOrRight(); --newLead; --newAnchor; } setSelection(newAnchor, newLead, getColAnchor(), getColLead()); // printSelection(); endUpdate(); } }); // Shift + Right arrow installActionWrapper( map, "selectNextColumnExtendSelection", new ActionWrapper() { public void actionPerformed(ActionEvent e) { beginUpdate(); if (!haveAnchor()) { setAnchorFromTable(); setLeadFromTable(); } int newLead = Math.min(model.getColumnCount() - 1, getColLead() + 1); setSelection(getRowAnchor(), getRowLead(), getColAnchor(), newLead); // printSelection(); endUpdate(); } }); // Shift + Page up installActionWrapper( map, "scrollUpExtendSelection", new ActionWrapper() { public void actionPerformed(ActionEvent e) { beginUpdate(); if (!haveAnchor()) { setAnchorFromTable(); setLeadFromTable(); // setAnchor(table.getSelectedRow()); // setLead(table.getSelectedRow()); } int newLead = getRowLead() - numUsableRows; int newAnchor = getRowAnchor(); if (newLead < 0) { scrollBar.pageUpOrLeft(); newLead += numUsableRows; newAnchor += numUsableRows; } setSelection(newAnchor, newLead, getColAnchor(), getColLead()); // printSelection(); endUpdate(); } }); // Shift + Page down installActionWrapper( map, "scrollDownExtendSelection", new ActionWrapper() { public void actionPerformed(ActionEvent e) { beginUpdate(); if (!haveAnchor()) { setAnchorFromTable(); setLeadFromTable(); // setAnchor(table.getSelectedRow()); // setLead(table.getSelectedRow()); } int newLead = getRowLead() + numUsableRows; int newAnchor = getRowAnchor(); if (newLead > numUsableRows) { scrollBar.pageDownOrRight(); newLead -= numUsableRows; newAnchor -= numUsableRows; } setSelection(newAnchor, newLead, getColAnchor(), getColLead()); // printSelection(); endUpdate(); } }); // Clear our notion of selection upon mouse press table.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { if (shouldIgnore(e)) { return; } // Make shift-clicking work properly if (e.isShiftDown()) { maybeGrabSelection(); return; } // System.err.println(" Clearing selection on mouse press"); clearSelection(); } }); // Watch for mouse going out of bounds table.addMouseMotionListener( new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { if (shouldIgnore(e)) { // System.err.println(" (Ignoring consumed mouse event)"); return; } // Look for drag events outside table and scroll if necessary Point p = e.getPoint(); if (table.rowAtPoint(p) == -1) { // See whether we are above or below the table Rectangle rect = new Rectangle(); getBounds(rect); beginUpdate(); if (p.y < rect.y) { // System.err.println(" Scrolling up due to mouse event"); // Scroll up scrollBar.scrollUpOrLeft(); setSelection(getRowAnchor(), 0, getColAnchor(), getColLead()); } else { // System.err.println(" Scrolling down due to mouse event"); // Scroll down scrollBar.scrollDownOrRight(); setSelection(getRowAnchor(), numUsableRows, getColAnchor(), getColLead()); } // printSelection(); endUpdate(); } else { maybeGrabSelection(); } } }); add(table, BorderLayout.CENTER); // Make sure we recompute number of visible rows addComponentListener( new ComponentAdapter() { public void componentResized(ComponentEvent e) { recomputeNumVisibleRows(); constrain(); } }); addHierarchyListener( new HierarchyListener() { public void hierarchyChanged(HierarchyEvent e) { recomputeNumVisibleRows(); constrain(); } }); updateFromScrollBar(); }