List of usage examples for javax.swing JScrollPane setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:teambootje.A1.java
public A1() { initComponents();//ww w .j a v a2s .com setLocationRelativeTo(null); setLayout(new BorderLayout()); setSize(500, 500); //Create and set up the window. setTitle("SS Rotterdam Analyse || Analyse 1"); ImageIcon icon = new ImageIcon("img/bootje.jpg"); setIconImage(icon.getImage()); // back BTN JButton back = new JButton("Back"); add(back, BorderLayout.NORTH); back.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); // panel JPanel ana = new JPanel(); add(ana, BorderLayout.CENTER); //tabel String nvt = "SELECT Geslacht, COUNT(*) AS Aantal FROM persoon GROUP BY geslacht"; String male = "SELECT Geslacht AS male, COUNT(*) AS Aantal_Male FROM persoon WHERE Geslacht = 'man'"; String Female = "SELECT Geslacht AS female, COUNT(*) AS Aantal_Female FROM persoon WHERE Geslacht = 'vrouw'"; List<Object[]> list = new ArrayList<Object[]>(); ResultSet rs = null; try { rs = db.runSql(nvt); while (rs.next()) { String geslacht = rs.getString("Geslacht"); int aantal = rs.getInt("Aantal"); String[] row = new String[rs.getMetaData().getColumnCount()]; for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { row[i - 1] = rs.getString(i); } list.add(row); try { rs = db.runSql(male); while (rs.next()) { String man = rs.getString("male"); int am = rs.getInt("Aantal_Male"); String[] row1 = new String[rs.getMetaData().getColumnCount()]; for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { row1[i - 1] = rs.getString(i); } try { rs = db.runSql(Female); while (rs.next()) { String vrouw = rs.getString("female"); int af = rs.getInt("Aantal_Female"); String[] row2 = new String[rs.getMetaData().getColumnCount()]; for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { row2[i - 1] = rs.getString(i); } Object[][] array = new Object[list.size()][]; Object columnNames[] = { "Geslacht", "Aantal" }; list.toArray(array); JTable table = new JTable(array, columnNames); JScrollPane scroll = new JScrollPane(table); scroll.setPreferredSize(new Dimension(400, 400)); ana.add(scroll); //chart JButton chart = new JButton("Chart"); add(chart, BorderLayout.SOUTH); chart.addActionListener(new ActionListener() { String g1 = geslacht; String m = man; String v = vrouw; int a1 = aantal; int a2 = am; int a3 = af; @Override public void actionPerformed(ActionEvent e) { DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("Niet vrij gegeven", a1); pieDataset.setValue("Man", a2); pieDataset.setValue("vrouw", a3); JFreeChart chart = ChartFactory.createPieChart3D("Aantal mannen en vrouwen", pieDataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); //p.setForegroundAlpha(TOP_ALIGNMENT); ChartFrame pie = new ChartFrame("Aantal mannen en vrouwen", chart); pie.setVisible(true); pie.setSize(500, 500); pie.setLocationRelativeTo(null); //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); } } catch (SQLException v) { JOptionPane.showMessageDialog(null, v); } } } catch (SQLException m) { JOptionPane.showMessageDialog(null, m); } } } catch (SQLException e) { JOptionPane.showMessageDialog(null, e); } }
From source file:teambootje.A9.java
/** * Creates new form A9/*from w w w. ja v a2 s . c o m*/ */ public A9() { initComponents(); setLocationRelativeTo(null); setLayout(new BorderLayout()); //Create and set up the window. setTitle("SS Rotterdam Analyse || Analyse 9"); ImageIcon icon = new ImageIcon("img/bootje.jpg"); setIconImage(icon.getImage()); // back BTN JButton back = new JButton("Back"); add(back, BorderLayout.NORTH); back.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); // panel en Label JPanel ana = new JPanel(); add(ana, BorderLayout.CENTER); //tabel String sql = "SELECT persoon.Name, COUNT(post) AS Aantal FROM persoon, posts WHERE persoon.AID = posts.AID GROUP BY persoon.Name"; List<Object[]> list = new ArrayList<Object[]>(); ResultSet rs = null; try { rs = db.runSql(sql); while (rs.next()) { String name = rs.getString("persoon.Name"); int amount = rs.getInt("Aantal"); String[] row = new String[rs.getMetaData().getColumnCount()]; for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) { row[i - 1] = rs.getString(i); } list.add(row); //chart JButton chart = new JButton("Chart"); add(chart, BorderLayout.SOUTH); chart.addActionListener(new ActionListener() { String n1 = name; int a1 = amount; @Override public void actionPerformed(ActionEvent e) { DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue(n1, a1); pieDataset.setValue("WestCordHotels", new Integer(1)); pieDataset.setValue("Voetbalr", new Integer(2)); pieDataset.setValue("VeraBauman", new Integer(1)); pieDataset.setValue("TonWesselink", new Integer(2)); pieDataset.setValue("Stoomschip Rotterdam", new Integer(25)); pieDataset.setValue("shirleys86", new Integer(2)); pieDataset.setValue("SevereWeather_N", new Integer(2)); pieDataset.setValue("SalvatoreOrtisi", new Integer(4)); pieDataset.setValue("RuudvEck", new Integer(2)); pieDataset.setValue("RuudvandenBos", new Integer(1)); pieDataset.setValue("Roffa85", new Integer(1)); pieDataset.setValue("RichardPh0t0", new Integer(2)); pieDataset.setValue("RebekkaKadijk", new Integer(2)); pieDataset.setValue("ray_rademaker", new Integer(6)); pieDataset.setValue("PoushNL", new Integer(1)); pieDataset.setValue("popupsquare", new Integer(2)); pieDataset.setValue("Plan_78", new Integer(3)); pieDataset.setValue("Petrahoogenboom", new Integer(1)); pieDataset.setValue("PatriciaBenard", new Integer(2)); pieDataset.setValue("OVKatendrecht", new Integer(2)); pieDataset.setValue("OdileHemmen", new Integer(2)); pieDataset.setValue("NLMaritiem", new Integer(2)); pieDataset.setValue("Nellyvdvlies", new Integer(1)); pieDataset.setValue("meerkatting", new Integer(2)); pieDataset.setValue("MeerkatsNow", new Integer(2)); pieDataset.setValue("marygoossens1", new Integer(1)); pieDataset.setValue("MarjoleinNagel", new Integer(1)); pieDataset.setValue("MaaikeMaasdijk", new Integer(1)); pieDataset.setValue("KidsErOpUit", new Integer(2)); pieDataset.setValue("Katendrechtnr1", new Integer(25)); pieDataset.setValue("jpsoree", new Integer(2)); pieDataset.setValue("JolandaBolscher", new Integer(2)); pieDataset.setValue("jes4life", new Integer(1)); pieDataset.setValue("JaccoScheer", new Integer(1)); pieDataset.setValue("GwNpop", new Integer(2)); pieDataset.setValue("Gerarddegraaff", new Integer(1)); pieDataset.setValue("FR12Patrick", new Integer(3)); pieDataset.setValue("FlorentinaNow", new Integer(1)); pieDataset.setValue("FIVBWorldChamps", new Integer(2)); pieDataset.setValue("FIVBVolleyball", new Integer(2)); pieDataset.setValue("FeestdjNik", new Integer(1)); pieDataset.setValue("ensanne", new Integer(1)); pieDataset.setValue("elsekramer", new Integer(1)); pieDataset.setValue("EelcoBeijl", new Integer(1)); pieDataset.setValue("EdwindeKoning1", new Integer(2)); pieDataset.setValue("DMiddelman", new Integer(3)); pieDataset.setValue("de_rotterdam", new Integer(2)); pieDataset.setValue("CvanAdrighem", new Integer(2)); pieDataset.setValue("carolinedejager", new Integer(1)); pieDataset.setValue("CaatVanEnst", new Integer(1)); pieDataset.setValue("BotlekBusiness", new Integer(2)); pieDataset.setValue("AnneWallisDeVri", new Integer(2)); pieDataset.setValue("010byday", new Integer(4)); JFreeChart chart = ChartFactory.createPieChart3D("Aantal posts per personen", pieDataset, true, true, true); PiePlot3D p = (PiePlot3D) chart.getPlot(); //p.setForegroundAlpha(TOP_ALIGNMENT); ChartFrame pie = new ChartFrame("Aantal posts per personen", chart); pie.setVisible(true); pie.setSize(500, 500); pie.setLocationRelativeTo(null); //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }); } } catch (SQLException e) { JOptionPane.showMessageDialog(null, e); } Object[][] array = new Object[list.size()][]; Object columnNames[] = { "Naam", "Aantal" }; list.toArray(array); JTable table = new JTable(array, columnNames); JScrollPane scroll = new JScrollPane(table); scroll.setPreferredSize(new Dimension(400, 400)); ana.add(scroll); }
From source file:table.FrequencyTablePanel.java
public FrequencyTablePanel(String[] datas, String[] values) { super(new GridLayout(1, 0)); super.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); data = new ArrayList<>(); tableModel = new MyTableModel(data); table = new JTable(tableModel); table.setRowHeight(40);/*from www.j a va2s . c o m*/ // table.getColumnModel().getColumn(0).setResizable(false); // table.getColumnModel().getColumn(0).setMaxWidth(120); // table.getColumnModel().getColumn(1).setResizable(false); // table.getColumnModel().getColumn(1).setMaxWidth(120); table.setDefaultRenderer(Object.class, new MyTableCellRenderer2()); for (int i = 0; i < tableModel.getColumnCount(); i++) { table.getTableHeader().getColumnModel().getColumn(i) .setHeaderRenderer(new HeaderRenderer(table, alignments[1])); // table.getColumnModel().getColumn(i).setCellRenderer(new // MyTableCellRenderer()); } table.getTableHeader().setReorderingAllowed(false); table.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); // table.setPreferredScrollableViewportSize(new Dimension(10000, 200)); // Create the scroll pane and add the table to it. for (int i = 0; i < datas.length; i++) { String[] a = new String[2]; a[0] = datas[i]; a[1] = values[i]; this.tableModel.addRow(a); } JScrollPane scrollPane = new JScrollPane(table); scrollPane.setPreferredSize(new Dimension(7000, 20)); // scrollPane.setHorizontalScrollBar(new // JScrollBar(JScrollBar.HORIZONTAL)); // Add the scroll pane to this panel. add(scrollPane); }
From source file:com.opendoorlogistics.components.geocode.postcodes.impl.SummaryPanel.java
public SummaryPanel() { setLayout(new BorderLayout()); text.setEditable(false);/* www.jav a 2 s.com*/ JScrollPane scrollpane = new JScrollPane(text); scrollpane.setViewportView(text); add(scrollpane, BorderLayout.CENTER); Dimension size = new Dimension(350, 100); scrollpane.setMinimumSize(new Dimension(1, (int) size.getHeight())); scrollpane.setPreferredSize(size); scrollpane.setMaximumSize(new Dimension(2000, (int) size.getHeight())); text.setBackground(new Color(220, 220, 220)); text.setOpaque(true); }
From source file:InternalFrameEventDemo.java
protected void createDisplayWindow() { JButton b1 = new JButton("Show internal frame"); b1.setActionCommand(SHOW);/* ww w .j a v a 2s . c o m*/ b1.addActionListener(this); JButton b2 = new JButton("Clear event info"); b2.setActionCommand(CLEAR); b2.addActionListener(this); display = new JTextArea(3, 30); display.setEditable(false); JScrollPane textScroller = new JScrollPane(display); // Have to supply a preferred size, or else the scroll // area will try to stay as large as the text area. textScroller.setPreferredSize(new Dimension(200, 75)); textScroller.setMinimumSize(new Dimension(10, 10)); displayWindow = new JInternalFrame("Event Watcher", true, // resizable false, // not closable false, // not maximizable true); // iconifiable JPanel contentPane = new JPanel(); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); b1.setAlignmentX(CENTER_ALIGNMENT); contentPane.add(b1); contentPane.add(Box.createRigidArea(new Dimension(0, 5))); contentPane.add(textScroller); contentPane.add(Box.createRigidArea(new Dimension(0, 5))); b2.setAlignmentX(CENTER_ALIGNMENT); contentPane.add(b2); displayWindow.setContentPane(contentPane); displayWindow.pack(); displayWindow.setVisible(true); }
From source file:DragListDemo.java
public DragListDemo() { arrayListHandler = new ArrayListTransferHandler(); JList list1, list2;/*from w w w .ja v a 2 s. com*/ DefaultListModel list1Model = new DefaultListModel(); list1Model.addElement("0 (list 1)"); list1Model.addElement("1 (list 1)"); list1Model.addElement("2 (list 1)"); list1Model.addElement("3 (list 1)"); list1Model.addElement("4 (list 1)"); list1Model.addElement("5 (list 1)"); list1Model.addElement("6 (list 1)"); list1 = new JList(list1Model); list1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); list1.setTransferHandler(arrayListHandler); list1.setDragEnabled(true); JScrollPane list1View = new JScrollPane(list1); list1View.setPreferredSize(new Dimension(200, 100)); JPanel panel1 = new JPanel(); panel1.setLayout(new BorderLayout()); panel1.add(list1View, BorderLayout.CENTER); panel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); DefaultListModel list2Model = new DefaultListModel(); list2Model.addElement("0 (list 2)"); list2Model.addElement("1 (list 2)"); list2Model.addElement("2 (list 2)"); list2Model.addElement("3 (list 2)"); list2Model.addElement("4 (list 2)"); list2Model.addElement("5 (list 2)"); list2Model.addElement("6 (list 2)"); list2 = new JList(list2Model); list2.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); list2.setTransferHandler(arrayListHandler); list2.setDragEnabled(true); JScrollPane list2View = new JScrollPane(list2); list2View.setPreferredSize(new Dimension(200, 100)); JPanel panel2 = new JPanel(); panel2.setLayout(new BorderLayout()); panel2.add(list2View, BorderLayout.CENTER); panel2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setLayout(new BorderLayout()); add(panel1, BorderLayout.LINE_START); add(panel2, BorderLayout.LINE_END); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:InternalFrameEventDemo.java
protected void createDisplayWindow() { JButton b1 = new JButton("Show internal frame"); b1.setActionCommand(SHOW);/*from ww w .j av a2s .com*/ b1.addActionListener(this); JButton b2 = new JButton("Clear event info"); b2.setActionCommand(CLEAR); b2.addActionListener(this); display = new JTextArea(3, 30); display.setEditable(false); JScrollPane textScroller = new JScrollPane(display); //Have to supply a preferred size, or else the scroll //area will try to stay as large as the text area. textScroller.setPreferredSize(new Dimension(200, 75)); textScroller.setMinimumSize(new Dimension(10, 10)); displayWindow = new JInternalFrame("Event Watcher", true, //resizable false, //not closable false, //not maximizable true); //iconifiable JPanel contentPane = new JPanel(); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); b1.setAlignmentX(CENTER_ALIGNMENT); contentPane.add(b1); contentPane.add(Box.createRigidArea(new Dimension(0, 5))); contentPane.add(textScroller); contentPane.add(Box.createRigidArea(new Dimension(0, 5))); b2.setAlignmentX(CENTER_ALIGNMENT); contentPane.add(b2); displayWindow.setContentPane(contentPane); displayWindow.pack(); displayWindow.setVisible(true); }
From source file:com.apatar.webdav.ui.JWebDavTreeModePanel.java
private JPanel getFoldersPanel() { JPanel panel = new JPanel(); panel.setOpaque(false);/* ww w . java 2 s. co m*/ JScrollPane srollPane = new JScrollPane(createFolderTable()); srollPane.setPreferredSize(new Dimension(470, 320)); srollPane.setBorder(null); panel.add(srollPane); return panel; }
From source file:com.att.aro.ui.view.menu.file.BPVideoWarnFailPanel.java
private Component getGridPanel() { JScrollPane scrollPane = new JScrollPane(); scrollPane.setViewportView(getTable()); int height = 70; if (Util.isWindowsOS()) { height = 78;/*w ww .ja v a2 s . c o m*/ } scrollPane.setPreferredSize(new Dimension(550, height)); return scrollPane; }
From source file:edu.ucla.stat.SOCR.chart.demo.AreaChartDemo1.java
protected void setGraphPanel() { // System.out.println("setGraphPanel called"); chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y)); graphPanel.add(chartPanel);//from w w w . ja va2 s . com JScrollPane legendPane = new JScrollPane(legendPanel); legendPane.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 3)); graphPanel.add(legendPane); }