@SuppressWarnings("serial") public void GegevensTabel(int i) { String[] header = {"Spelernaam", "Pnt", "Res", "Krt"}; String[][] data = null; data = oc.VulTabelRonde(i); spKaarten = new JScrollPane(); getContentPane().add(spKaarten); spKaarten.setBounds(14, 168, 308, 126); spKaarten.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 0, false)); spKaarten.setFont(new java.awt.Font("Arial", 0, 12)); { tKaarten = new JTable(data, header) { public Component prepareRenderer( TableCellRenderer renderer, int rowIndex, int vColIndex) { Component c = super.prepareRenderer(renderer, rowIndex, vColIndex); if (rowIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) { c.setBackground(new java.awt.Color(202, 240, 202)); } else { // If not shaded, match the table's // background c.setBackground(getBackground()); } return c; } }; naamKolom = tKaarten.getColumn(header[0]); naamKolom.setPreferredWidth(150); inzetKolom = tKaarten.getColumn(header[1]); inzetKolom.setPreferredWidth(30); resKolom = tKaarten.getColumn(header[2]); resKolom.setPreferredWidth(50); kaartKolom = tKaarten.getColumn(header[3]); kaartKolom.setPreferredWidth(30); spKaarten.setViewportView(tKaarten); tKaarten.setPreferredSize(new java.awt.Dimension(301, 126)); tKaarten.setGridColor(new java.awt.Color(255, 255, 255)); tKaarten.setBorder(new LineBorder(new java.awt.Color(90, 90, 90), 1, false)); FlowLayout tKaartenLayout = new FlowLayout(); tKaartenLayout.setAlignment(FlowLayout.LEFT); tKaarten.setLayout(tKaartenLayout); tKaarten.setFont(new java.awt.Font("Tahoma", 0, 12)); } } // public void GegevensTabel(int i)
public NetworkTable(Properties display) { this.display = display; model = new GenericTableModel( new String[] {" ", "Address", "Label", "Description", "Pivot"}, "Address", 256); table = new ATable(model); TableRowSorter sorter = new TableRowSorter(model); sorter.toggleSortOrder(1); Comparator hostCompare = new Comparator() { public int compare(Object a, Object b) { long aa = Route.ipToLong(a + ""); long bb = Route.ipToLong(b + ""); if (aa > bb) { return 1; } else if (aa < bb) { return -1; } else { return 0; } } public boolean equals(Object a, Object b) { return (a + "").equals(b + ""); } }; sorter.setComparator(1, hostCompare); sorter.setComparator(4, hostCompare); table.setRowSorter(sorter); table.setColumnSelectionAllowed(false); table.getColumn("Address").setPreferredWidth(125); table.getColumn("Label").setPreferredWidth(125); table.getColumn("Pivot").setPreferredWidth(125); table.getColumn(" ").setPreferredWidth(32); table.getColumn(" ").setMaxWidth(32); table.getColumn("Description").setPreferredWidth(500); final TableCellRenderer parent = table.getDefaultRenderer(Object.class); table.setDefaultRenderer( Object.class, new TableCellRenderer() { public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { JLabel component = (JLabel) parent.getTableCellRendererComponent(table, value, isSelected, false, row, col); if (col == 4 && Boolean.TRUE.equals(model.getValueAt(table, row, "Active"))) { component.setFont(component.getFont().deriveFont(Font.BOLD)); } else if (col == 1 && !"".equals(model.getValueAt(table, row, "Description"))) { component.setFont(component.getFont().deriveFont(Font.BOLD)); } else { component.setFont(component.getFont().deriveFont(Font.PLAIN)); } String tip = model.getValueAt(table, row, "Tooltip") + ""; if (tip.length() > 0) { component.setToolTipText(tip); } return component; } }); table .getColumn(" ") .setCellRenderer( new TableCellRenderer() { public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { JLabel component = (JLabel) parent.getTableCellRendererComponent( table, value, isSelected, false, row, col); component.setIcon(new ImageIcon((Image) model.getValueAt(table, row, "Image"))); component.setText(""); String tip = model.getValueAt(table, row, "Tooltip") + ""; if (tip.length() > 0) { component.setToolTipText(tip); } return component; } }); table.addMouseListener( new MouseAdapter() { public void all(MouseEvent ev) { if (ev.isPopupTrigger()) { popup.showGraphPopup(getSelectedHosts(), ev); ev.consume(); } } public void mouseClicked(MouseEvent ev) { all(ev); } public void mousePressed(MouseEvent ev) { all(ev); } public void mouseReleased(MouseEvent ev) { all(ev); } }); setLayout(new BorderLayout()); scroller = new JScrollPane(table); add(scroller, BorderLayout.CENTER); }
public JunctionLinkDataFrame(final JunctionLink jl) { super( jl.getCurrName() + " properties", false, // resizable false, // closable false, // maximizable true); // iconifiable // PSRender.onHold(); super.setBackground(back_color); super.addInternalFrameListener( new InternalFrameAdapter() { public void internalFrameActivated(InternalFrameEvent e) { reload(); SelectedObject.setSelectedObject(jl); } }); PSRender.moveToTop(jl.getBound(), 0.5); ml = jl; setLocation(50, 50); dataModelMain = new HeadTable(jl); tableMain = new JTable(dataModelMain); tableMain.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN); tableMain.setPreferredScrollableViewportSize(new Dimension(500, 20)); // tableMain.setBackground(back_color); // code TableColumn column_code = tableMain.getColumn("Code"); DefaultTableCellRenderer rendererCode = new DefaultTableCellRenderer(); rendererCode.setToolTipText("Enter new code for this path"); column_code.setCellRenderer(rendererCode); column_code.setCellEditor(new TextFieldEditor()); // name TableColumn column_name = tableMain.getColumn("Name"); LanguageButtonRender render_name = new LanguageButtonRender(); render_name.setToolTipText("Path name. Press for change name"); column_name.setCellRenderer(render_name); LanguageButtonEditor editor_name = new LanguageButtonEditor(new JCheckBox()); column_name.setCellEditor(editor_name); // junction 1 TableColumn column_junc_1 = tableMain.getColumn("Junction 1"); MLButtonRenderer rendererJunc_1 = new MLButtonRenderer(); rendererJunc_1.setToolTipText("Code of first Junction, click for open properties"); column_junc_1.setCellRenderer(rendererJunc_1); MLButtonEditor editorJunc = new MLButtonEditor(new JCheckBox()); column_junc_1.setCellEditor(editorJunc); // junction 2 TableColumn column_junc_2 = tableMain.getColumn("Junction 2"); MLButtonRenderer rendererJunc_2 = new MLButtonRenderer(); rendererJunc_2.setToolTipText("Code of second Junction, click for open properties"); column_junc_2.setCellRenderer(rendererJunc_2); column_junc_2.setCellEditor(editorJunc); // type JComboBox comboBoxType = new JComboBox(); String roadNames[] = jl.getTypeNames(); for (int i = 0, len = roadNames.length; i < len; i++) { comboBoxType.addItem(roadNames[i]); } TableColumn column_type = tableMain.getColumn("Type"); DefaultTableCellRenderer rendererType = new DefaultTableCellRenderer(); rendererType.setToolTipText("To change road type click for combo box"); column_type.setCellRenderer(rendererType); column_type.setCellEditor(new DefaultCellEditor(comboBoxType)); // legth TableColumn column_length = tableMain.getColumn("Length"); DefaultTableCellRenderer rendererLen = new DefaultTableCellRenderer(); rendererLen.setToolTipText("The path length in meters"); column_length.setCellRenderer(rendererLen); scrollpaneMain = new JScrollPane(tableMain); scrollpaneMain.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollpaneMain.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); scrollpaneMain.setPreferredSize(new Dimension(500, 50)); Container contentPane = super.getContentPane(); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); contentPane.setLayout(gridbag); c.ipady = 0; // make this component tall c.weightx = 0.5; c.gridwidth = 4; c.gridx = 0; c.gridy = 0; gridbag.setConstraints(scrollpaneMain, c); // scrollpaneMain.setBackground(back_color); // scrollpaneMain.setForeground(back_color); contentPane.add(scrollpaneMain); TableModel dataModelPoints = new PointTableModel(jl); tablePoints = new JTable(dataModelPoints); tablePoints.setPreferredScrollableViewportSize( new Dimension(200, dataModelPoints.getRowCount() * tablePoints.getRowHeight())); ListModel lm = new AbstractListModel() { public int getSize() { return 1000; } public Object getElementAt(int index) { return "" + index; } }; JList rowHeader = new JList(lm); rowHeader.setFixedCellWidth(20); rowHeader.setFixedCellHeight(tablePoints.getRowHeight()); // + tablePoints.getRowMargin()); rowHeader.setCellRenderer(new RowHeaderRenderer(tablePoints)); scrollPanePoints = new JScrollPane(tablePoints); scrollPanePoints.setWheelScrollingEnabled(true); scrollPanePoints.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPanePoints.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); int mh; if (dataModelPoints.getRowCount() * tablePoints.getRowHeight() > 100) { mh = 100; } else { mh = dataModelPoints.getRowCount() * tablePoints.getRowHeight(); } scrollPanePoints.setPreferredSize(new Dimension(200, mh)); scrollPanePoints.setRowHeaderView(rowHeader); c.ipadx = 200; c.weightx = 0.5; c.gridwidth = 3; c.gridx = 1; c.gridy = 1; gridbag.setConstraints(scrollPanePoints, c); // scrollPanePoints.setBackground(back_color); contentPane.add(scrollPanePoints); button_ok = new JButton("Ok"); button_ok.addActionListener(this); JPanel buttonPane = new JPanel(null); buttonPane.setPreferredSize(new Dimension(500, 100)); button_ok.setBounds(205, 40, 90, 40); buttonPane.add(button_ok); c.ipady = 10; // make this component tall c.ipadx = 10; c.weightx = 0.5; c.gridwidth = 4; c.gridx = 2; c.gridy = 2; gridbag.setConstraints(buttonPane, c); buttonPane.setBackground(back_color); contentPane.add(buttonPane); super.pack(); super.setVisible(true); // MapApplication.getDesktop().setSelectedFrame(this); }