private Component table() { String[] titles = { "Year", "Starting Balance", "Starting Principal", "Withdrawals", "Appreciation", "Deposits", "Ending Balance" }; tableModel = new DefaultTableModel(titles, 0); for (int i = 0; i < 12800; i++) { tableModel.addRow( new Integer[] {1900 + i, 10000 + i, 8000 + i, 50 + i, 905 + i, 2000 + i, 12000 + i}); } JTable table = new CustomTable(tableModel); int preferredWidth = 0; for (int i = 0; i < table.getColumnCount(); i++) { int width = packColumn(table, i, 2); preferredWidth += width; } Dimension preferredSize = new Dimension(preferredWidth, 400); table.setPreferredScrollableViewportSize(preferredSize); this.setMinimumSize(preferredSize); JScrollPane scrollPane = new JScrollPane(table); return scrollPane; }
private Component getTable() { if (tableView == null) { JTable table = new JTable(getTableModel(), getTableColumnModel()); JScrollPane scrollPane = new JScrollPane(table); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); tableView = scrollPane; } return tableView; }
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; }
SwingTableDemo() { // Create a new JFrame container. JFrame jfrm = new JFrame("JTable Demo"); // Specify FlowLayout for the layout manager. jfrm.setLayout(new FlowLayout()); // Give the frame an initial size. jfrm.setSize(460, 180); // Terminate the program when the user closes the application. jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create a table that displays order data. jtabOrders = new JTable(data, headings); // Wrap the table in a scroll pane. JScrollPane jscrlp = new JScrollPane(jtabOrders); // Set the scrollable viewport size. jtabOrders.setPreferredScrollableViewportSize(new Dimension(420, 62)); // Create the radio buttons that determine // what type of selections are allowed. jrbRows = new JRadioButton("Select Rows", true); jrbColumns = new JRadioButton("Select Columns"); jrbCells = new JRadioButton("Select Cells"); // Add the radio buttons to a group. ButtonGroup bg = new ButtonGroup(); bg.add(jrbRows); bg.add(jrbColumns); bg.add(jrbCells); // Radio button events are handled in common by the // actionPerformed() method implemented by TableDemo. jrbRows.addActionListener(this); jrbColumns.addActionListener(this); jrbCells.addActionListener(this); // Create the Single Selection Mode check box. // When checked, only single selections are allowed. jcbSingle = new JCheckBox("Single Selection Mode"); // Add item listener for jcbSingle. jcbSingle.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent ie) { if (jcbSingle.isSelected()) // Allow single selections. jtabOrders.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); else // Allow multiple selections. jtabOrders.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } }); // Add the components to the content pane. jfrm.add(jscrlp); jfrm.add(jrbRows); jfrm.add(jrbColumns); jfrm.add(jrbCells); jfrm.add(jcbSingle); // Display the frame. jfrm.setVisible(true); }
/** Generates Configuration tab. */ private void fillConfigurationPanel() { JPanel desc = new JPanel(new GridLayout(2, 0)); desc.setBorder(BorderFactory.createTitledBorder("Description")); desc.add( new JLabel("<html><font color=\"blue\">" + myMonitor.getDescription() + "</font></html>")); desc.add(cbEnabled); cbEnabled.setSelected(enabled); cbEnabled.addChangeListener(this); confPanel.add(desc); JPanel mlpanel = new JPanel(new GridLayout(1, 0)); mlpanel.setBorder(BorderFactory.createTitledBorder("Monitored Network Elements")); montable = new JTable(montablemodel); montable.setPreferredScrollableViewportSize(new Dimension(200, 100)); montable.getColumnModel().getColumn(0).setPreferredWidth(140); montable.getColumnModel().getColumn(1).setPreferredWidth(60); montable.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int row = montable.rowAtPoint(new Point(e.getX(), e.getY())); AbstractNetworkElement ne = null; if ((row >= 0) && (row < myMonitor.getPredecessors().size())) ne = myMonitor.getPredecessors().get(row); else return; treePane.actionSelected(ne, true); } return; } }); mlpanel.add(new JScrollPane(montable)); confPanel.add(mlpanel); JPanel cpanel = new JPanel(new GridLayout(1, 0)); cpanel.setBorder(BorderFactory.createTitledBorder("Controlleded Network Elements")); ctrltable = new JTable(ctrltablemodel); ctrltable.setPreferredScrollableViewportSize(new Dimension(200, 100)); ctrltable.getColumnModel().getColumn(0).setPreferredWidth(140); ctrltable.getColumnModel().getColumn(1).setPreferredWidth(60); ctrltable.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int row = ctrltable.rowAtPoint(new Point(e.getX(), e.getY())); AbstractNetworkElement ne = null; if ((row >= 0) && (row < myMonitor.getSuccessors().size())) ne = myMonitor.getSuccessors().get(row); else return; treePane.actionSelected(ne, true); } return; } }); cpanel.add(new JScrollPane(ctrltable)); confPanel.add(cpanel); JPanel pcl = new JPanel(new FlowLayout()); // controller list buttonProp.setEnabled(false); buttonProp.setActionCommand(cmdCtrlProp); buttonProp.addActionListener(this); pcl.setBorder(BorderFactory.createTitledBorder("Complex Controller")); buttonProp.setEnabled(false); listCControllers = new JComboBox(); listCControllers.addItem("None"); String[] ctrlClasses = myMonitor.getComplexControllerClasses(); for (int i = 0; i < ctrlClasses.length; i++) { if ((myController != null) && (myController.getClass().getName().compareTo(ctrlClasses[i]) == 0)) { listCControllers.addItem(myController); listCControllers.setSelectedIndex(i + 1); buttonProp.setEnabled(true); } else { try { Class cl = Class.forName(ctrlClasses[i]); AbstractControllerComplex cc = (AbstractControllerComplex) cl.newInstance(); cc.setMyMonitor(myMonitor); cc.initialize(); listCControllers.addItem(cc); } catch (Exception e) { } } } listCControllers.setActionCommand(cmdCtrlList); listCControllers.addActionListener(this); pcl.add(listCControllers); pcl.add(buttonProp); confPanel.add(pcl); return; }
/** Fills the panel with SWARM specific fields. */ public void fillPanel() { // Zone initialization ControllerSWARM z = (ControllerSWARM) controller; Vector<Zone> cz = z.zones; for (int i = 0; i < cz.size(); i++) zones.add(cz.get(i).clone()); // Parameter initialization density_sample_size = z.P.SWARM_DENSITY_SAMPLE_SIZE; epsilon = z.P.epsilon; forecast_lead_time = z.P.SWARM_FORECAST_LEAD_TIME; input_var_lane = z.P.input_var_lane; meas_var_lane = z.P.meas_var_lane; phi = z.P.swarm_phi; psi = z.P.swarm_psi; sat_den_multiplier = z.P.SWARM_SAT_DEN_NUMBER; sat_smoother = z.P.sat_smoother; slope_sample_size = z.P.SWARM_SLOPE_SAMPLE_SIZE; // Components JPanel comp = new JPanel(new FlowLayout()); comp.setBorder(BorderFactory.createTitledBorder("Components")); cbsw1.setSelected(z.P.SWARM1); comp.add(cbsw1); comp.add(new JLabel(" ")); cbsw2a.setSelected(z.P.SWARM2A); comp.add(cbsw2a); comp.add(new JLabel(" ")); cbsw2b.setSelected(z.P.SWARM2B); comp.add(cbsw2b); comp.add(new JLabel(" ")); cbdynbott.setEnabled(false); comp.add(cbdynbott); add(comp); // Zones JPanel zone = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); zone.setBorder(BorderFactory.createTitledBorder("Zones")); zonetab.setPreferredScrollableViewportSize(new Dimension(400, 30)); setUpBottleneckColumn(); setUpFromOnrampColumn(); setUpToOnrampColumn(); c.fill = GridBagConstraints.HORIZONTAL; c.ipady = 45; c.weightx = 0.5; c.gridwidth = 3; c.gridx = 0; c.gridy = 0; zone.add(new JScrollPane(zonetab), c); c.ipady = 0; c.gridy = 1; c.gridwidth = 1; c.gridx = 0; zone.add(buttonAdd, c); c.gridx = 1; zone.add(buttonDelete, c); // configure buttons buttonAdd.setEnabled(true); buttonAdd.setActionCommand(cmdAdd); buttonAdd.addActionListener(this); buttonDelete.setEnabled(true); buttonDelete.setActionCommand(cmdDelete); buttonDelete.addActionListener(this); add(zone); // Parameters JPanel param = new JPanel(new GridLayout(1, 0)); param.setBorder(BorderFactory.createTitledBorder("Parameters")); final JTable paramtab = new JTable(paramTM); paramtab.setPreferredScrollableViewportSize(new Dimension(500, 160)); param.add(new JScrollPane(paramtab)); add(param); return; }
/** 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 ItensVendidos() { super("Itens Vendidos"); JButton imprimir; final DefaultTableModel modelo = new DefaultTableModel(); // constrói a tabela JTable tabela = new JTable(modelo); // Cria duas colunas modelo.addColumn("Código"); modelo.addColumn("Vendedor"); modelo.addColumn("Produto"); modelo.addColumn("Quantidade"); imprimir = new JButton("Imprimir"); imprimir.setBounds(100, 450, 30, 24); // exibe os dados da tabela MySQL // Conexao banco = new Conexao(); String retorno = "erro"; try { // Connection ExConn = (Connection) banco.abrirBDconn(); Class.forName("com.mysql.jdbc.Driver"); Connection conexao = DriverManager.getConnection("jdbc:mysql://localhost/banco", "root", ""); Statement stmt = conexao.createStatement(); // procedimentos para obter os dados de uma tabela String query = "SELECT * FROM venda2"; ResultSet rs = stmt.executeQuery(query); while (rs.next()) { int id = rs.getInt("idVendedor"); String nome = rs.getString("nomeVendedor"); String produto = rs.getString("produto"); int qtd = rs.getInt("qtd"); modelo.addRow(new Object[] {new Integer(id), nome, produto, new Integer(qtd)}); } // fim procedimento para obter os dados } catch (SQLException ex) { System.out.println("SQLException: " + ex.getMessage()); System.out.println("SQLState: " + ex.getSQLState()); System.out.println("VendorError: " + ex.getErrorCode()); } catch (Exception e) { System.out.println("Problemas ao tentar conectar com o banco de dados"); } // fim MySQL tabela.setPreferredScrollableViewportSize(new Dimension(350, 50)); Container c = getContentPane(); c.setLayout(new FlowLayout()); JScrollPane scrollPane = new JScrollPane(tabela); c.add(scrollPane); c.add(imprimir); setSize(400, 300); setVisible(true); }
/** Fills the panel with simple signal specific fields. */ protected void fillPanel() { if (controller != null) { Vector<CycleDataRow> cd = ((ControllerSimpleSignal) controller).getCycleTable(); for (int i = 0; i < cd.size(); i++) { CycleDataRow cdr = ((ControllerSimpleSignal) controller) .new CycleDataRow(cd.get(i).getTime(), cd.get(i).getGreen(), cd.get(i).getRed()); cycledata.add(cdr); } } // offset JPanel pO = new JPanel(new BorderLayout()); pO.setBorder(BorderFactory.createTitledBorder("Offset (sec.)")); offset = new JSpinner( new SpinnerNumberModel( ((ControllerSimpleSignal) controller).getOffset() * conversion, 0.0, 99999.99, 10)); offset.setEditor(new JSpinner.NumberEditor(offset, "####0.##")); pO.add(offset); add(pO); // table JPanel tabpanel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); tabpanel.setBorder(BorderFactory.createTitledBorder("Cycle Schedule")); cycletable = new JTable(cycletablemodel); cycletable.setPreferredScrollableViewportSize(new Dimension(200, 50)); cycletable.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { int row = cycletable.rowAtPoint(new Point(e.getX(), e.getY())); if ((row > cycledata.size() - 1) || (row < 0)) return; try { WindowEdit winEdit = new WindowEdit(null, cycledata.get(row)); winEdit.setVisible(true); cycletablemodel.deleterow(row); cycletablemodel.addrow(winEdit.getMyRow()); } catch (Exception excp) { } } } }); c.fill = GridBagConstraints.HORIZONTAL; c.ipady = 100; c.weightx = 0.5; c.gridwidth = 3; c.gridx = 0; c.gridy = 0; tabpanel.add(new JScrollPane(cycletable), c); c.ipady = 0; c.gridy = 1; c.gridwidth = 1; c.gridx = 0; tabpanel.add(buttonAdd, c); c.gridx = 1; tabpanel.add(buttonDelete, c); add(tabpanel); // configure buttons buttonAdd.setEnabled(true); buttonAdd.addActionListener(new ButtonAddListener()); buttonDelete.setEnabled(true); buttonDelete.addActionListener(new ButtonDeleteListener()); return; }
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); }