public CombatViewer() { super("Combat Tracker"); setLookAndFeel(); setSize(500, 400); FlowLayout layout = new FlowLayout(FlowLayout.CENTER, 10, 10); setLayout(layout); String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"}; Object[][] data = { {"Kathy", "Smith", "Snowboarding", new Integer(5), new Boolean(false)}, {"John", "Doe", "Rowing", new Integer(3), new Boolean(true)}, {"Sue", "Black", "Knitting", new Integer(2), new Boolean(false)}, {"Jane", "White", "Speed reading", new Integer(20), new Boolean(true)}, {"Joe", "Brown", "Pool", new Integer(10), new Boolean(false)} }; JTable table = new JTable(data, columnNames); JScrollPane scrollPane = new JScrollPane(table); table.setFillsViewportHeight(true); panel1.setLayout(new BorderLayout()); panel1.add(table.getTableHeader(), BorderLayout.PAGE_START); panel1.add(table, BorderLayout.CENTER); add(panel1); panel2.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10)); panel2.add(testBox); add(panel2); setVisible(true); }
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; }
protected void setupTable(JTable table) { table.setFillsViewportHeight(true); table.getColumnModel().getColumn(2).setMaxWidth(150); table.getColumnModel().getColumn(1).setMaxWidth(150); table.getColumnModel().getColumn(0).setMaxWidth(150); // table.getColumnModel().getColumn(0).setPreferredWidth(10); table.setDefaultRenderer(Color.class, new ColorTableCellRenderer()); }
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; }
// Panel que muestra la tabla private Container tabla() { JPanel pnl = new JPanel(new GridLayout(2, 0)); String[] columnNames = { "Marca", "Modelo", "Color", "Precio", "Clave", "Procesador", "RAM", "HDD", "Tarjeta de video", "Tarjeta de audio" }; final JTable table = new JTable(getModeloDatos(), columnNames); table.setPreferredScrollableViewportSize(new Dimension(470, 340)); table.setFillsViewportHeight(true); JScrollPane scrollPane = new JScrollPane(table); pnl.add(scrollPane); // Se añaden los botones al panel regresar = new JButton("Regresar"); comprar = new JButton("Comprar"); buscar = new JButton("Buscar"); add(regresar); add(comprar); add(buscar); // Event-handles para los botones de Regresar, Comprar y Buscar regresar.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { sistema.mostrarPanel(PanelBase.PANEL_INICIO); } }); comprar.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { comprar(table); } }); buscar.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { buscarComputadora(table); } }); return pnl; }
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 + ")"); }
public MainWindow() { setTitle(PRODUCT_NAME); rosterTable = new JTable(); rosterScrollPane = new JScrollPane(rosterTable); rosterTable.setFillsViewportHeight(true); getContentPane().add(rosterScrollPane, BorderLayout.CENTER); makeMenu(); pack(); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); setLocationRelativeTo(null); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent ev) { closeWindow(); } }); setTournament(null, new Tournament()); }
public JComponent createContestantList() { JPanel contListPanel = new JPanel(); MyTableModel contTable = new MyTableModel(); JTable table = new JTable(contTable); table.setPreferredScrollableViewportSize(new Dimension(WIDTH, HEIGHT)); table.setFillsViewportHeight(true); table.setAutoCreateRowSorter(true); table.setRowHeight(77); table.setFont(new Font("Viner Hand ITC", Font.PLAIN, 18)); table.setForeground(Color.BLUE); table.setSelectionForeground(Color.RED); table.setSelectionBackground( new Color(0, 0, 0, 64)); // When a cell is selected, this entire row is highlighted. // Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); contListPanel.add(scrollPane); return contListPanel; }
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 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 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); }
public AutoFocusator() { super(new BorderLayout()); taskList = new TaskList(); Task task0 = new Task("Use right click to change the states of the tasks."); taskList.add(task0); Task task1 = new Task("Just play araound with this small app."); taskList.add(task1); Task task2 = new Task("Check http://sourceforge.net/projects/autofocusator/"); taskList.add(task2); // task1.setState(State.crossed); // task0.setState(State.dismissed); table = new JTable(taskList); table.setPreferredScrollableViewportSize(new Dimension(500, 700)); table.setFillsViewportHeight(true); table.getColumnModel().getColumn(0).setPreferredWidth(300); table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); table.setRowSelectionAllowed(true); table.getColumnModel().getColumn(0).setCellRenderer(new TaskRenderer()); // TableCellRenderer renderer = table.getColumnModel().getColumn(0).getCellRenderer(); // double height = ((TaskRenderer)renderer).getRendererHeight(); // @todo: The height should be set dependent on the content table.setRowHeight(28); table.getModel().addTableModelListener(this); toolBar = new JToolBar("Autofocusator - Toolbar"); JButton buttonAddTask = new JButton("Add a Task", new ImageIcon(loadPics("res/list-add.png"))); buttonAddTask.setActionCommand("addTask"); buttonAddTask.addActionListener(this); toolBar.add(buttonAddTask); JButton buttonDeleteTask = new JButton("Delete a Task", new ImageIcon(loadPics("res/list-remove.png"))); buttonDeleteTask.setActionCommand("deleteTask"); buttonDeleteTask.addActionListener(this); toolBar.add(buttonDeleteTask); JButton buttonSave = new JButton("Save", new ImageIcon(loadPics("res/document-save-as.png"))); buttonSave.setActionCommand("save"); buttonSave.addActionListener(this); toolBar.add(buttonSave); JButton buttonOpen = new JButton("open", new ImageIcon(loadPics("res/document-open.png"))); buttonOpen.setActionCommand("open"); buttonOpen.addActionListener(this); toolBar.add(buttonOpen); add(toolBar, BorderLayout.NORTH); contextMenu = new JPopupMenu(); JMenuItem contextMenuItem; contextMenuItem = new JMenuItem("delete Task"); contextMenuItem.addActionListener(this); contextMenuItem.setActionCommand("deleteTask"); contextMenu.add(contextMenuItem); contextMenuItem = new JMenuItem("add Task"); contextMenuItem.addActionListener(this); contextMenuItem.setActionCommand("addTask"); contextMenu.add(contextMenuItem); contextMenu.addSeparator(); contextMenuItem = new JMenuItem("cross"); contextMenuItem.addActionListener(this); contextMenuItem.setActionCommand("cross"); contextMenu.add(contextMenuItem); contextMenuItem = new JMenuItem("dismiss"); contextMenuItem.addActionListener(this); contextMenuItem.setActionCommand("dismiss"); contextMenu.add(contextMenuItem); contextMenuItem = new JMenuItem("worked on"); contextMenuItem.addActionListener(this); contextMenuItem.setActionCommand("workedOn"); contextMenu.add(contextMenuItem); fileChooser = new JFileChooser(); FileFilter filter = new FileNameExtensionFilter("XML File", "xml"); fileChooser.addChoosableFileFilter(filter); table.addMouseListener(this); JScrollPane scrollPane = new JScrollPane(table); add(scrollPane, BorderLayout.CENTER); }