public void initializePropertyTable() { scrollPane_ = new JScrollPane(); scrollPane_.setFont(new Font("Arial", Font.PLAIN, 10)); scrollPane_.setBorder(new BevelBorder(BevelBorder.LOWERED)); getContentPane().add(scrollPane_); springLayout_.putConstraint( SpringLayout.SOUTH, scrollPane_, -5, SpringLayout.SOUTH, getContentPane()); springLayout_.putConstraint( SpringLayout.NORTH, scrollPane_, scrollPaneTop_, SpringLayout.NORTH, getContentPane()); springLayout_.putConstraint( SpringLayout.EAST, scrollPane_, -5, SpringLayout.EAST, getContentPane()); springLayout_.putConstraint( SpringLayout.WEST, scrollPane_, 5, SpringLayout.WEST, getContentPane()); table_ = new JTable(); table_.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table_.setAutoCreateColumnsFromModel(false); scrollPane_.setViewportView(table_); table_.setModel(data_); if (numColumns_ == 3) { table_.addColumn(new TableColumn(0, 200, new PropertyNameCellRenderer(), null)); table_.addColumn( new TableColumn(1, 75, new PropertyUsageCellRenderer(), new PropertyUsageCellEditor())); table_.addColumn( new TableColumn( 2, 200, new PropertyValueCellRenderer(true), new PropertyValueCellEditor(true))); } else if (numColumns_ == 2) { table_.addColumn(new TableColumn(0, 200, new PropertyNameCellRenderer(), null)); table_.addColumn( new TableColumn( 1, 200, new PropertyValueCellRenderer(false), new PropertyValueCellEditor(false))); } }
/** * This method initializes tb_result * * @return javax.swing.JTable */ private JTable getTb_result() { if (tb_result == null) { TableColumn tc_press = new TableColumn(); tc_press.setModelIndex(2); tc_press.setHeaderValue("출판사"); TableColumn tc_author = new TableColumn(); tc_author.setModelIndex(1); tc_author.setHeaderValue("저자"); TableColumn tc_title = new TableColumn(); tc_title.setHeaderValue("제목"); tb_result = new JTable(); tb_result.setAutoCreateColumnsFromModel(false); tb_result.setFont(new Font("Dialog", Font.PLAIN, 14)); tb_result.setRowHeight(30); tb_result.addColumn(tc_title); tb_result.addColumn(tc_author); tb_result.addColumn(tc_press); tb_result.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseReleased(java.awt.event.MouseEvent e) { if (tableMouseClickedCount == 0) { tableMouseClickedCount++; return; } Const.goToDetailPage(detailBrowser, getTb_result().getSelectedRow()); tableMouseClickedCount = 0; } }); } return tb_result; }
public ExceptionTableDetails(ArrayList al) { super("Exception Table Details"); vars = al; this.setToolTipText("Select Help For Interpreting Table Details"); excptabdata = new ExceptionTableDataReport(this, vars); table = new JTable(); table.setAutoCreateColumnsFromModel(false); table.setModel(excptabdata); for (int k = 0; k < 5; k++) { TableCellRenderer renderer; DefaultTableCellRenderer textRenderer = new DefaultTableCellRenderer(); renderer = textRenderer; TableCellEditor editor; editor = new DefaultCellEditor(new JTextField()); TableColumn column = new TableColumn(k, 80, renderer, editor); table.addColumn(column); } JScrollPane ps = new JScrollPane(); // ps.setSize(550, 150); ps.setSize(getRightTabbedPane().getWidth(), 100); ps.setMaximumSize(new Dimension(getRightTabbedPane().getWidth(), 100)); ps.getViewport().add(table); getContentPane().add(ps, BorderLayout.SOUTH); if (excptabdata.getExcepDataList().size() == 0) JOptionPane.showMessageDialog( UILauncher.getMainFrame(), "Exception Table Empty For Chosen Method...", "Exception Table Message", JOptionPane.INFORMATION_MESSAGE); setVisible(true); }
/** Create the panel */ public LabelsPage(Preferences prefs) { super(); title_ = "Define position labels for state devices"; helpText_ = "State devices with discrete positions, such as filter changers or objective turrets, etc. can have mnemonic labels assigned for each position.\n\n" + "Select the device in the left-hand list and edit corresponding position labels in the right-hand list.\n\n" + "Use the 'Read' button to read label info from the hardware. This will override your changes!\n\n"; setHelpFileName("conf_labels_page.html"); prefs_ = prefs; setLayout(null); final JScrollPane labelsScrollPane = new JScrollPane(); labelsScrollPane.setBounds(186, 10, 269, 254); add(labelsScrollPane); labelTable_ = new JTable(); labelTable_.setModel(new LabelTableModel()); labelTable_.setAutoCreateColumnsFromModel(false); labelTable_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); InputMap im = labelTable_.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "none"); labelsScrollPane.setViewportView(labelTable_); GUIUtils.setClickCountToStartEditing(labelTable_, 1); GUIUtils.stopEditingOnLosingFocus(labelTable_); final JScrollPane devScrollPane = new JScrollPane(); devScrollPane.setBounds(10, 10, 162, 255); add(devScrollPane); devTable_ = new JTable(); DevTableModel m = new DevTableModel(); devTable_.setModel(m); devTable_.getSelectionModel().addListSelectionListener(new SelectionListener(devTable_)); devTable_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); devScrollPane.setViewportView(devTable_); final JButton readButton = new JButton(); readButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { // read labels from hardware readFromHardware(); } }); readButton.setText("Read"); readButton.setBounds(469, 10, 93, 23); add(readButton); final JButton resetButton = new JButton(); resetButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { // read labels from hardware resetLabels(); } }); resetButton.setText("Reset"); resetButton.setBounds(469, 43, 93, 23); add(resetButton); }
private void initReviewTable() { reviewTable.setAutoCreateColumnsFromModel(false); reviewTable.setModel(new FileChooseTableModel()); reviewTable.addColumn(new TableColumn(0, 100)); reviewTable.addColumn(new TableColumn(1, 100)); reviewTable.addColumn(new TableColumn(2, 320)); reviewTable.getTableHeader().setReorderingAllowed(false); }
/** * This method initializes jTable * * @return javax.swing.JTable */ JTable getJTable() { if (jTable == null) { Event event = new Event(); AdministrateEventController controller = new AdministrateEventController(); event = controller.processRetrieve(); int colWidth = 100; Object[] colNames = {"Event ID", "Event Date", "Event Time", "Event Name", "Status"}; Object[][] data = new Object[event.getEventID_list().size()][colSize]; for (int i = 0; i < event.getEventID_list().size(); i++) { data[i][0] = event.getEventID_list().get(i); data[i][1] = controller.calendarToString(event.getEventDate_list().get(i)); data[i][2] = event.getEventTime_list().get(i); data[i][3] = event.getEventName_list().get(i); data[i][4] = event.getEventStatus_list().get(i); } model.setDataVector(data, colNames); jTable = new JTable(model); if (viewModel != null) { jTable.setModel(viewModel); viewModel = null; } jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); for (int i = 0; i < colSize; i++) { jTable.getColumnModel().getColumn(i).setCellRenderer(new Renderer()); jTable.getColumnModel().getColumn(i).setPreferredWidth(colWidth); } jTable.getColumnModel().getColumn(3).setPreferredWidth(250); jTable.getColumnModel().getColumn(4).setPreferredWidth(172); jTable.setAutoCreateColumnsFromModel(false); sortAllRowsBy(model, 0, true); jTable.setEnabled(false); JTableHeader header = jTable.getTableHeader(); header.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { JTableHeader h = (JTableHeader) e.getSource(); int nColumn = h.columnAtPoint(e.getPoint()); if (nColumn != -1) sortAllRowsBy(model, nColumn, true); } }); etbml = new EventTableButtonMouseListener(jTable, source, crudFf); etbml.setSelection(selection); jTable.addMouseListener(etbml); } return jTable; }
/** * Delegation to create the Bundle view panel * * @return the JPanel that is responsible for showing the bundle in a tble format */ private JComponent buildBundlePanel() { // build the table table.setColumnSelectionAllowed(true); table.setCellSelectionEnabled(true); table.setAutoCreateColumnsFromModel(true); table.getTableHeader().setUpdateTableInRealTime(false); table.setModel(model); table.setColumnModel(new BundleTableColumnData()); refreshTableData(); table.addMouseListener( new MouseAdapter() { /** @see java.awt.event.MouseAdapter#mousePressed(java.awt.event.MouseEvent) */ @Override public void mousePressed(MouseEvent me) { maybeShowPopup(me); } /** @see java.awt.event.MouseAdapter#mouseReleased(java.awt.event.MouseEvent) */ @Override public void mouseReleased(MouseEvent me) { maybeShowPopup(me); } /** @param me */ private void maybeShowPopup(MouseEvent me) { // only do for popup menu ctrl if (me.isPopupTrigger() && table.isEnabled()) { Point p = new Point(me.getX(), me.getY()); int rowNum = table.rowAtPoint(p); if (rowNum >= 0 && rowNum < table.getRowCount()) { // create & show the context menu JPopupMenu contextMenu = createContextMenu(rowNum); if (contextMenu != null && contextMenu.getComponentCount() > 0) { contextMenu.show(table, p.x, p.y); } } } } }); // now create the scroll pane to house the table JScrollPane ret = new JScrollPane(); ret.doLayout(); ret.getViewport().setBackground(table.getBackground()); ret.getViewport().add(table); return ret; }
public AppointmentGUI() { setDefaultCloseOperation(DISPOSE_ON_CLOSE); setBounds(100, 100, 500, 600); // window size setTitle("Appointment List"); // window title contentPane = new JPanel(); contentPane.setBorder( new EmptyBorder(3, 6, 3, 6)); // distance the plane is from the edges of the window setContentPane(contentPane); contentPane.setLayout(new BorderLayout(0, 0)); scrollPane = new JScrollPane(); contentPane.add(scrollPane, BorderLayout.CENTER); table = new JTable( new DefaultTableModel(new Object[] {"Doctor's Name", "Location", "Date", "Time"}, 60)) { public boolean isCellEditable( int row, int column) { // prevents user from editing cells; there apparently is not a cleaner // way of doing this return false; } }; table.setShowHorizontalLines(false); table.setShowVerticalLines(false); table.setShowGrid(false); table.getTableHeader().setReorderingAllowed(false); // prevent user from swapping columns table.getTableHeader().setResizingAllowed(false); // prevent user from resizing columns table.setSelectionMode( ListSelectionModel .SINGLE_INTERVAL_SELECTION); // prevent user from selecting multiple doctors table.setAutoCreateColumnsFromModel( false); // forgot why I have this here; it's probably important scrollPane.setViewportView(table); // lets table be scroll able btnPane = new JPanel(); btnPane.setLayout(new GridLayout(0, 2, 0, 0)); contentPane.add(btnPane, BorderLayout.SOUTH); btnViewAppointment = new JButton("View Appointment"); btnPane.add(btnViewAppointment); btnCancelAppointment = new JButton("Cancel Appointment"); btnPane.add(btnCancelAppointment); btnUpdateAppointment = new JButton("Update Appointment"); btnPane.add(btnUpdateAppointment); btnGoBack = new JButton("Go Back"); btnPane.add(btnGoBack); }
public static void initializeTable(JTable classLevelTable) { JTableHeader tableHeader = classLevelTable.getTableHeader(); tableHeader.setResizingAllowed(false); tableHeader.setReorderingAllowed(false); TableColumnModel columnModel = new DefaultTableColumnModel(); TableCellRenderer headerRenderer = tableHeader.getDefaultRenderer(); columnModel.addColumn(Utilities.createTableColumn(0, "Level", headerRenderer, false)); columnModel.addColumn(Utilities.createTableColumn(1, "HP", headerRenderer, false)); columnModel.addColumn( Utilities.createTableColumn(2, "Class (All Levels In Class)", headerRenderer, true)); classLevelTable.setColumnModel(columnModel); classLevelTable.setAutoCreateColumnsFromModel(false); classLevelTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); classLevelTable.setFocusable(false); classLevelTable.setCellSelectionEnabled(false); classLevelTable.setRowHeight(20); }
private JPanel createStatsTable(String title, Map<String, String> data) { JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(new JLabel(title), BorderLayout.NORTH); StatisticsModel model = new StatisticsModel(); model.setData(data); JTable table = new JTable(model); table.setAutoCreateColumnsFromModel(true); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); table.setAutoCreateRowSorter(true); JScrollPane scrollPane = new JScrollPane(table); table.addNotify(); scrollPane.getViewport().setOpaque(false); scrollPane.getColumnHeader().setOpaque(false); panel.add(scrollPane, BorderLayout.CENTER); panel.setPreferredSize(new Dimension(300, (data.size() + 2) * 17)); return panel; }
/** build the form */ public void initForm() { this.setLayout(new BorderLayout()); // and the table _myTableModel = new javax.swing.table.DefaultTableModel(); _myTable = new JTable(_myTableModel); // format the table _myTable.setAutoCreateColumnsFromModel(true); _myTable.setRowSelectionAllowed(false); _myTable.setColumnSelectionAllowed(false); _myTable.setMinimumSize(new Dimension(200, 400)); // and store the table this.add(_myTable, BorderLayout.CENTER); // sort out the table header this.add(_myTable.getTableHeader(), BorderLayout.NORTH); }
public Image_Upload() { setBounds(0, 0, 1020, 665); setLayout(new MigLayout("", "[996px,grow]", "[300px,grow][326px]")); ms_connect = new Ms_Connect(); JPanel panel = new JPanel(); panel.setBorder(new LineBorder(new Color(0, 0, 0))); add(panel, "cell 0 0,grow"); panel.setLayout( new MigLayout( "", "[200px,grow][99px][278px][12px][97px,grow][97px][89px][64px]", "[23px][158px][10px][31px][10px][45px,grow]")); text_path = new JTextField(); panel.add(text_path, "cell 0 0,growx,aligny center"); text_path.setColumns(10); text_path.setText("C:\\"); JButton btn_path = new JButton("< \uD3F4\uB354\uC120\uD0DD"); panel.add(btn_path, "cell 1 0,growx,aligny top"); btn_path.addActionListener(this); JButton btn_upload = new JButton("\uC5C5\uB85C\uB4DC >>"); panel.add(btn_upload, "cell 1 5,grow"); btn_upload.addActionListener(this); dlm = new DefaultListModel<String>(); list_image = new JList<String>(); list_image.setBounds(0, 0, 274, 254); // panel.add(list_image); list_image.setModel(dlm); JScrollPane jsp = new JScrollPane(); jsp.setViewportView(list_image); panel.add(jsp, "cell 0 1 1 5,grow"); JLabel lblFtp = new JLabel("\uB2E8\uB3C5\uD3F4\uB354 FTP \uC774\uBBF8\uC9C0"); lblFtp.setFont(new Font("굴림", Font.PLAIN, 13)); lblFtp.setHorizontalAlignment(SwingConstants.CENTER); panel.add(lblFtp, "cell 2 0,growx,aligny center"); JScrollPane scrollPane = new JScrollPane(); panel.add(scrollPane, "cell 2 1 3 5,grow"); DefaultTableCellRenderer celAlignCenter = new DefaultTableCellRenderer(); celAlignCenter.setHorizontalAlignment(JLabel.CENTER); DefaultTableCellRenderer celAlignRight = new DefaultTableCellRenderer(); celAlignRight.setHorizontalAlignment(JLabel.RIGHT); String[] head = {"순번", "파일명(바코드)", "확장자", "비고"}; dtm = new DefaultTableModel(); dtm.setColumnIdentifiers(head); table_ftp_view = new JTable(); table_ftp_view.setModel(dtm); // 헤더의 컬럼의 라벨을 내가 직접제어할 수있도록, 자동생성하는 것을 금지한다. table_ftp_view.setAutoCreateColumnsFromModel(false); // 테이블의 선택모드를 설정한다 table_ftp_view.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scrollPane.setViewportView(table_ftp_view); // 스크롤페인에 배경색을 흰색으로 변경한다. scrollPane.getViewport().setBackground(Color.WHITE); // 자동정렬 기능을 사용한다. table_ftp_view.setAutoCreateRowSorter(true); // 자동정렬 기능을 첨가한다. table_ftp_view.setRowSorter(new TableRowSorter<TableModel>(dtm)); table_ftp_view.getTableHeader().setReorderingAllowed(false); // 이동불가 table_ftp_view.getTableHeader().getColumnModel().getColumn(0).setCellRenderer(celAlignCenter); table_ftp_view.getColumn("순번").setPreferredWidth(40); table_ftp_view.getColumn("순번").setCellRenderer(celAlignCenter); table_ftp_view.getColumn("파일명(바코드)").setPreferredWidth(80); table_ftp_view.getColumn("확장자").setPreferredWidth(40); table_ftp_view.getColumn("비고").setPreferredWidth(100); table_ftp_view.addMouseListener( new MouseListener() { @Override public void mouseReleased(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent e) { // TODO Auto-generated method stub } @Override public void mouseClicked(MouseEvent e) { // TODO Auto-generated method stub if (e.getButton() == 1) { System.out.println("마우스 클릭 됐습니다."); // 이미지를 불러옵니다. image_Show(); } } }); JButton btn_ftpview = new JButton("\uAC80\uC0C9"); panel.add(btn_ftpview, "cell 4 0,growx,aligny top"); btn_ftpview.setActionCommand("검색"); btn_ftpview.addActionListener(this); label_show_image = new JLabel(); label_show_image.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null)); // label_show_image.setBounds(0, 0, 250, 250); panel.add(label_show_image, "cell 5 1 3 5,grow"); JButton btn_delete = new JButton("\uC0AD\uC81C"); btn_delete.addActionListener(this); panel.add(btn_delete, "cell 7 0,growx,aligny top"); JButton btn_download = new JButton("\uB2E4\uC6B4\uB85C\uB4DC"); btn_download.addActionListener(this); panel.add(btn_download, "cell 5 0,growx,aligny top"); JButton btn_all_select = new JButton("< \uC804\uCCB4\uC120\uD0DD"); btn_all_select.addActionListener(this); panel.add(btn_all_select, "cell 1 3,grow"); JButton btn_select_delete = new JButton("< \uC120\uD0DD\uC0AD\uC81C"); btn_select_delete.addActionListener(this); panel.add(btn_select_delete, "cell 1 1,growx,aligny bottom"); JPanel panel_1 = new JPanel(); panel_1.setBorder(new LineBorder(new Color(0, 0, 0))); add(panel_1, "cell 0 1,grow"); panel_1.setLayout(new MigLayout("", "[]", "[]")); }
/** * Constructor. * * @param passedRecordList List of Records that Passed over Filter. * @param peName Name of Physical Entity. * @param bpContainer */ public DownloadDetails( List<BasicRecordType> passedRecordList, String peName, CPath2Factory factory) { super(); this.factory = factory; this.peName = peName; this.setTitle("Retrieval Confirmation"); this.setModal(true); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); GradientHeader header = new GradientHeader("Confirm Retrieval: " + passedRecordList.size() + " records"); contentPane.add(header, BorderLayout.NORTH); DefaultTableModel tableModel = new NonEditableTableModel(); Vector headerList = new Vector(); headerList.add("Name (if available)"); headerList.add("Type"); headerList.add("Data Source"); tableModel.setColumnIdentifiers(headerList); tableModel.setRowCount(passedRecordList.size()); JTable table = new JTable(tableModel); // Adjust width / height of viewport; fixes bug #1620. Dimension d = table.getPreferredSize(); d.width = d.width * 2; if (d.height > 200) { d.height = 200; } table.setPreferredScrollableViewportSize(d); table.setAutoCreateColumnsFromModel(true); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ids = new long[passedRecordList.size()]; int i = 0; for (BasicRecordType record : passedRecordList) { if (record.getName().equalsIgnoreCase("N/A")) { record.setName("---"); } tableModel.setValueAt(record.getName(), i, 0); tableModel.setValueAt(record.getEntityType(), i, 1); if (record.getDataSource() != null) { tableModel.setValueAt(record.getDataSource().getName(), i, 2); } else { tableModel.setValueAt("---", i, 3); } ids[i++] = record.getPrimaryId(); } JScrollPane scrollPane = new JScrollPane(table); scrollPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.add(scrollPane, BorderLayout.CENTER); JPanel buttonPanel = createButtonPanel(this); mergePanel = factory.createMergePanel(); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); if (mergePanel != null) { panel.add(mergePanel); } panel.add(buttonPanel); contentPane.add(panel, BorderLayout.SOUTH); pack(); setLocationRelativeTo(factory.getCySwingApplication().getJFrame()); }
public ConstructionProtocolViewD(final AppD app) { // cpPanel = new JPanel(new BorderLayout()); this.app = app; kernel = app.getKernel(); data = new ConstructionTableData(this); useColors = true; addIcons = false; table = new JTable(); table.setAutoCreateColumnsFromModel(false); table.setModel(((GAbstractTableModelD) data.getImpl()).getImpl()); table.setRowSelectionAllowed(true); table.setGridColor(Color.lightGray); table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); // header JTableHeader header = table.getTableHeader(); // header.setUpdateTableInRealTime(true); header.setReorderingAllowed(false); // init model ConstructionTableCellRenderer renderer; HeaderRenderer headerRend = new HeaderRenderer(); tableColumns = new TableColumn[data.columns.length]; for (int k = 0; k < data.columns.length; k++) { renderer = new ConstructionTableCellRenderer(); renderer.setHorizontalAlignment(data.columns[k].getAlignment()); tableColumns[k] = new TableColumn(k, data.columns[k].getPreferredWidth(), renderer, null); tableColumns[k].setMinWidth(data.columns[k].getMinWidth()); tableColumns[k].setHeaderRenderer(headerRend); if (data.columns[k].getInitShow()) table.addColumn(tableColumns[k]); if (data.columns[k].getTitle() == "Caption") { tableColumns[k].setCellEditor(new ConstructionTableCellEditor()); } } // first column "No." should have fixed width tableColumns[0].setMaxWidth(tableColumns[0].getMinWidth()); table .getColumnModel() .addColumnModelListener(((ConstructionTableData) data).new ColumnMovementListener()); scrollPane = new JScrollPane(table); scrollPane.getViewport().setBackground(Color.white); // cpPanel.add(scrollPane, BorderLayout.CENTER); // clicking ConstructionMouseListener ml = new ConstructionMouseListener(); table.addMouseListener(ml); table.addMouseMotionListener(ml); header.addMouseListener(ml); // double clicking, right-click menu scrollPane.addMouseListener(ml); // right-click menu // keys ConstructionKeyListener keyListener = new ConstructionKeyListener(); table.addKeyListener(keyListener); app.getGuiManager().registerConstructionProtocolView(this); // navigation bar // protNavBar = new ConstructionProtocolNavigationD(app); // protNavBar.register(this); // protNavBar.setPlayButtonVisible(false); // protNavBar.setConsProtButtonVisible(false); // this.cpPanel.add(protNavBar.getImpl(), BorderLayout.SOUTH); // org.geogebra.desktop.util.Util.addKeyListenerToAll(protNavBar.getImpl(), // keyListener); initGUI(); initActions(); ConstructionProtocolSettings cps = app.getSettings().getConstructionProtocol(); settingsChanged(cps); cps.addListener(this); }
public RosterTable(boolean editable, int selectionMode) { super(); dataModel = new RosterTableModel(editable); sorter = new TableSorter(dataModel); dataTable = new JTable(sorter); sorter.setTableHeader(dataTable.getTableHeader()); dataScroll = new JScrollPane(dataTable); // set initial sort TableSorter tmodel = ((TableSorter) dataTable.getModel()); tmodel.setSortingStatus(RosterTableModel.ADDRESSCOL, TableSorter.ASCENDING); // Use a "Numeric, if not, Alphanumeric" comparator tmodel.setColumnComparator(String.class, new jmri.util.PreferNumericComparator()); // allow reordering of the columns dataTable.getTableHeader().setReorderingAllowed(true); // have to shut off autoResizeMode to get horizontal scroll to work (JavaSwing p 541) dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); dataTable.setColumnModel(columnModel); dataModel.setColumnModel(columnModel); dataTable.createDefaultColumnsFromModel(); dataTable.setAutoCreateColumnsFromModel(false); TableColumn tc = columnModel.getColumnByModelIndex(RosterTableModel.PROTOCOL); columnModel.setColumnVisible(tc, false); for (String s : Roster.instance().getAllAttributeKeys()) { if (!s.contains("RosterGroup") && !s.toLowerCase().startsWith("sys") && !s.toUpperCase().startsWith("VSD")) { // NOI18N String[] r = s.split("(?=\\p{Lu})"); // NOI18N StringBuilder sb = new StringBuilder(); sb.append(r[0].trim()); // System.out.println("'"+r[0]+","); for (int j = 1; j < r.length; j++) { // System.out.println("'"+r[j]+","); sb.append(" "); sb.append(r[j].trim()); } TableColumn c = new TableColumn(dataModel.getColumnCount()); c.setHeaderValue((sb.toString()).trim()); dataTable.addColumn(c); dataModel.addColumn(c.getHeaderValue()); columnModel.setColumnVisible(c, false); } } // resize columns as requested resetColumnWidths(); // general GUI config setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // install items in GUI add(dataScroll); // set Viewport preferred size from size of table java.awt.Dimension dataTableSize = dataTable.getPreferredSize(); // width is right, but if table is empty, it's not high // enough to reserve much space. dataTableSize.height = Math.max(dataTableSize.height, 400); dataTableSize.width = Math.max(dataTableSize.width, 400); dataScroll.getViewport().setPreferredSize(dataTableSize); dataTable.setSelectionMode(selectionMode); MouseListener mouseHeaderListener = new tableHeaderListener(); dataTable.getTableHeader().addMouseListener(mouseHeaderListener); dataTable.setDefaultEditor(Object.class, new RosterCellEditor()); dataTable .getSelectionModel() .addListSelectionListener( tableSelectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { selectedRosterEntries = null; // clear cached list of selections if (dataTable.getSelectedRowCount() == 1) { re = Roster.instance() .getEntryForId( sorter .getValueAt( dataTable.getSelectedRow(), RosterTableModel.IDCOL) .toString()); } else if (dataTable.getSelectedRowCount() > 1) { re = null; } // leave last selected item visible if no selection } else if (e.getFirstIndex() == -1) { // A reorder of the table might of occured therefore we are going to make sure // that the selected item is still in view moveTableViewToSelected(); } } }); }
/** * Initializes the layout of this pane. * * @return The container with all its widgets */ protected void initializeLayout() { GridBagConstraints constraints = new GridBagConstraints(); selectionModel = buildPropertySelectionModel(); // Property table table = SwingComponentFactory.buildTable( this.buildPropertyTableAdapter(), this.buildTableColumnModel(), this.selectionModel); table.setAutoCreateColumnsFromModel(false); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); table.setAutoscrolls(true); table.setSurrendersFocusOnKeystroke(true); table.getTableHeader().setReorderingAllowed(false); table.addPropertyChangeListener("enabled", new PropertyChangeHandler()); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 3; constraints.weightx = 1; constraints.weighty = 1; constraints.fill = GridBagConstraints.BOTH; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(0, 0, 0, 0); scrollPane = new JScrollPane(table); scrollPane.setMinimumSize(new Dimension(0, 0)); scrollPane.setPreferredSize(new Dimension(0, 0)); scrollPane.getViewport().setBackground(table.getBackground()); add(scrollPane, constraints); // Add button addButton = buildButton("LOGIN_PROPERTY_ADD_BUTTON"); addButton.addActionListener(buildAddActionListener()); constraints.gridx = 1; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(0, 5, 0, 0); add(addButton, constraints); // Edit button editButton = buildButton("LOGIN_PROPERTY_EDIT_BUTTON"); editButton.addActionListener(buildEditActionListener()); editButton.setEnabled(false); constraints.gridx = 1; constraints.gridy = 1; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.CENTER; constraints.insets = new Insets(5, 5, 0, 0); add(editButton, constraints); buildEditButtonEnabler(); // Remove button removeButton = buildButton("LOGIN_PROPERTY_REMOVE_BUTTON"); removeButton.addActionListener(buildRemoveActionListener(selectionModel)); removeButton.setEnabled(false); constraints.gridx = 1; constraints.gridy = 2; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.PAGE_START; constraints.insets = new Insets(5, 5, 0, 0); add(removeButton, constraints); buildRemoveButtonEnabler(); addHelpTopicId(this, "session.login.properties"); }
private JComponent createCenterPane() { MyTableRenderer mtr = new MyTableRenderer(); JPanel toReturn = new JPanel(new BorderLayout()); JLabel lab = new JLabel(getText("found")); lab.setBorder(BorderFactory.createEmptyBorder(0, 0, 6, 0)); toReturn.add(lab, BorderLayout.NORTH); tableTb = new JTable(); tableTb.setAutoCreateColumnsFromModel(false); TableColumn col = new TableColumn(0); col.setHeaderValue(getText("tclocale")); col.setCellRenderer(mtr); tableTb.addColumn(col); col = new TableColumn(1); col.setHeaderValue(getText("tcmodified")); col.setCellRenderer(mtr); tableTb.addColumn(col); col = new TableColumn(2); col.setHeaderValue(getText("tcsize")); col.setCellRenderer(mtr); tableTb.addColumn(col); col = new TableColumn(3); col.setHeaderValue(getText("tcurl")); col.setPreferredWidth(200); col.setCellRenderer(mtr); tableTb.addColumn(col); JScrollPane tscroll = new JScrollPane(tableTb); tscroll.setPreferredSize(new Dimension(tableTb.getPreferredSize().width, 300)); toReturn.add(tscroll, BorderLayout.CENTER); new TableCellTipManager(tableTb); tableTb.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); refreshBt = new JButton(); refreshBt.setMargin(new Insets(1, 1, 1, 1)); JPRManagerLauncher.getResourceData().configureButton("form.dictInWeb.refreshBt", refreshBt); installBt = new JButton(); installBt.setMargin(new Insets(1, 1, 1, 1)); installBt.setEnabled(false); JPRManagerLauncher.getResourceData().configureButton("form.dictInWeb.indexBt", installBt); Box bts = Box.createVerticalBox(); bts.add(refreshBt); bts.add(Box.createVerticalStrut(5)); bts.add(installBt); bts.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); toReturn.add(bts, BorderLayout.EAST); JPanel southPn = new JPanel(new BorderLayout()); notesLb = new JTextPane(); notesLb.setOpaque(false); notesLb.setEditable(false); notesLb.setFocusable(false); notesLb.setContentType("text/html"); notesLb.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { BrowserLauncher.openURL(e.getURL().toString()); } catch (IOException _e) { JPRManagerLauncher.getMessageHandler() .showMessage( DictionariesInWebForm.this, MessageConstants.OPEN_URL_ERROR, new Object[] {e.getURL().toString()}, _e); } } } }); JScrollPane nscroll = new JScrollPane(notesLb); nscroll.setBorder(BorderFactory.createEmptyBorder(5, 0, 6, 0)); nscroll.setPreferredSize(new Dimension(200, 80)); southPn.add(nscroll, BorderLayout.CENTER); JPanel progressPn = new JPanel(new BorderLayout()); progressPb = new JProgressBar(); progressPb.setStringPainted(true); progressPb.setString(""); progressPb.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(2, 0, 3, 5), progressPb.getBorder())); cancelBt = new JButton(JPRManagerLauncher.getResourceData().getText("form.cancel")); progressPn.add(progressPb, BorderLayout.CENTER); progressPn.add(cancelBt, BorderLayout.EAST); southPn.add(progressPn, BorderLayout.SOUTH); toReturn.add(southPn, BorderLayout.SOUTH); return toReturn; }
private void createGUI() { // set table and column renderers dataTable.setDefaultRenderer(Object.class, new MyCellRenderer()); columnHeader = new MyColumnHeaderRenderer(); columnHeader.setPreferredSize( new Dimension(preferredColumnWidth, SpreadsheetSettings.TABLE_CELL_HEIGHT)); for (int i = 0; i < dataTable.getColumnCount(); ++i) { dataTable.getColumnModel().getColumn(i).setHeaderRenderer(columnHeader); dataTable.getColumnModel().getColumn(i).setPreferredWidth(preferredColumnWidth); } // disable row selection (for now) dataTable.setColumnSelectionAllowed(false); dataTable.setRowSelectionAllowed(false); // dataTable.setAutoResizeMode(JTable.); dataTable.setPreferredScrollableViewportSize(dataTable.getPreferredSize()); dataTable.setMinimumSize(new Dimension(100, 50)); // dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); dataTable.setAutoCreateColumnsFromModel(false); dataTable.setGridColor(TABLE_GRID_COLOR); // create a scrollPane for the table scrollPane = new JScrollPane(dataTable); scrollPane.setBorder(BorderFactory.createEmptyBorder()); // create row header rowHeader = new MyRowHeader(this, dataTable); scrollPane.setRowHeaderView(rowHeader); // create enableAll button and put it in the upper left corner CheckBoxIcon cbIcon = new CheckBoxIcon(13); ImageIcon iconUnChecked = cbIcon.createCheckBoxImageIcon(false, false); ImageIcon iconChecked = cbIcon.createCheckBoxImageIcon(true, false); btnEnableAll = new JButton(); btnEnableAll.setIcon(iconUnChecked); btnEnableAll.setDisabledIcon(iconChecked); btnEnableAll.setEnabled(false); btnEnableAll.setBorderPainted(false); btnEnableAll.setBackground( geogebra.awt.Color.getAwtColor(GeoGebraColorConstants.TABLE_BACKGROUND_COLOR_HEADER)); btnEnableAll.setContentAreaFilled(false); btnEnableAll.setHorizontalAlignment(SwingConstants.LEFT); btnEnableAll.addActionListener(this); Corner upperLeftCorner = new Corner(); upperLeftCorner.setLayout(new BorderLayout()); upperLeftCorner.add(btnEnableAll, BorderLayout.WEST); upperLeftCorner.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(0, 0, 1, 1, TABLE_GRID_COLOR), BorderFactory.createEmptyBorder(0, 5, 0, 2))); // set the other corners scrollPane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, upperLeftCorner); scrollPane.setCorner(ScrollPaneConstants.LOWER_LEFT_CORNER, new Corner()); scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, new Corner()); lblHeader = new JLabel(); lblHeader.setHorizontalAlignment(JLabel.LEFT); lblHeader.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEtchedBorder(), BorderFactory.createEmptyBorder(2, 5, 2, 2))); // finally, load up our JPanel this.setLayout(new BorderLayout()); this.add(lblHeader, BorderLayout.NORTH); this.add(scrollPane, BorderLayout.CENTER); this.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); this.setMinimumSize(dataTable.getPreferredSize()); }
/** * Inicializa todos los elementos del panel y los coloca en su posicion. Carga la tabla y le * asigna los modos que queremos. Se sobreescribe el TableCellEditor para que devuelva el array de * referencias del expediente de la fila. */ private void inicializaTabla() { expedientesTable = new JTable() { public TableCellEditor getCellEditor(int row, int column) { if (column == 7) return (TableCellEditor) editors.get(row); else return super.getCellEditor(row, column); } }; editors = new ArrayList(); identificadores = new String[10]; modelo = new DefaultTableModel() { public boolean isCellEditable(int row, int column) { if (column == 7) return true; else return false; } }; renombrarComponentes(); expedientesTable.setModel(modelo); expedientesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); expedientesTable.setCellSelectionEnabled(false); expedientesTable.setColumnSelectionAllowed(false); expedientesTable.setRowSelectionAllowed(true); expedientesTable.getTableHeader().setReorderingAllowed(false); expedientesTable.getTableHeader().setResizingAllowed(true); expedientesTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // Disable autoCreateColumnsFromModel otherwise all the column customizations // and adjustments will be lost when the model data is sorted expedientesTable.setAutoCreateColumnsFromModel(false); expedientesTable .getTableHeader() .addMouseListener( new MouseListener() { public void mouseClicked(MouseEvent e) { int columna = expedientesTable.columnAtPoint(e.getPoint()); sorted = !sorted; sortAllRowsBy(modelo, columna, sorted); // e.getClickCount()%2 == 0? false : true); } public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} }); tablaScrollPanel = new JScrollPane(expedientesTable); this.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); this.add(tablaScrollPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 20, 640, 170)); }