List of usage examples for javax.swing JPanel setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:charts.Chart.java
public static Vector MultipleStepChartOverlayedMA(CategoryDataset[] datasets, String title, String x_axis_label, String y_axis_label, boolean showlegend, float maxvalue, float minvalue, boolean showchart) { CategoryAxis domainAxis = new CategoryAxis(x_axis_label); ValueAxis rangeAxis = new NumberAxis(y_axis_label); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); rangeAxis.setAutoRange(true);// ww w . jav a 2 s . c o m CombinedDomainCategoryPlot parent = new CombinedDomainCategoryPlot(new CategoryAxis(x_axis_label)); DefaultCategoryItemRenderer renderer0 = new DefaultCategoryItemRenderer(); renderer0.setBaseStroke(new BasicStroke(2.0f)); renderer0.setBaseSeriesVisibleInLegend(showlegend); renderer0.setSeriesPaint(0, Color.RED);//sinal original renderer0.setShapesVisible(false); CategoryPlot subplot = new CategoryPlot(datasets[0], domainAxis, rangeAxis, renderer0); subplot.setBackgroundPaint(Color.white); subplot.setRangeGridlinePaint(Color.black); subplot.setDomainGridlinesVisible(true); parent.add(subplot); CategoryAxis domainAxis1 = new CategoryAxis(x_axis_label); ValueAxis rangeAxis1 = new NumberAxis(y_axis_label); rangeAxis1.setStandardTickUnits(NumberAxis.createStandardTickUnits()); rangeAxis1.setAutoRange(true); CategoryItemRenderer renderer1 = new CategoryStepRenderer(true); renderer1.setBaseStroke(new BasicStroke(2.0f)); renderer1.setBaseSeriesVisibleInLegend(showlegend); renderer1.setSeriesPaint(0, Color.BLUE);//sinal quantizado CategoryPlot subplot1 = new CategoryPlot(datasets[1], domainAxis1, rangeAxis1, renderer1); //subplot.setDataset(1, datasets[1]); //subplot.setRenderer(1, renderer1); parent.add(subplot1); DefaultCategoryItemRenderer renderer2 = new DefaultCategoryItemRenderer(); renderer2.setBaseStroke(new BasicStroke(2.0f)); renderer2.setBaseSeriesVisibleInLegend(showlegend); renderer2.setShapesVisible(false); renderer2.setSeriesPaint(0, Color.BLACK);//sinal normalizado subplot1.setDataset(1, datasets[2]); subplot1.setRenderer(1, renderer2); for (int i = 3; i < datasets.length; i++) { DefaultCategoryItemRenderer renderer3 = new DefaultCategoryItemRenderer(); renderer3.setBaseStroke(new BasicStroke(2.0f)); renderer3.setBaseSeriesVisibleInLegend(showlegend); renderer3.setShapesVisible(false); renderer3.setSeriesPaint(0, Color.LIGHT_GRAY);//limiares utilizados para quantizacao. subplot1.setDataset(i - 1, datasets[i]); subplot1.setRenderer(i - 1, renderer3); } JFreeChart jfreechart = new JFreeChart(title, parent); JPanel jpanel = new ChartPanel(jfreechart); JPanel retorno = new ChartPanel(jfreechart); retorno.setPreferredSize(new Dimension(defaultwidth, defaultheight)); jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight)); JFrame chartwindow = new JFrame(title); chartwindow.setContentPane(jpanel); chartwindow.pack(); RefineryUtilities.centerFrameOnScreen(chartwindow); chartwindow.setVisible(showchart); Vector res = new Vector(); res.add(0, jfreechart); res.add(1, chartwindow); res.add(2, retorno); return res; }
From source file:org.jfree.chart.demo.XYBoxAnnotationDemo1.java
public XYBoxAnnotationDemo1(String s) { super(s);/*from w w w .j a v a2s. c o m*/ JPanel jpanel = createDemoPanel(); jpanel.setPreferredSize(new Dimension(500, 270)); setContentPane(jpanel); }
From source file:hspc.submissionsprogram.AppDisplay.java
AppDisplay() { this.setTitle("Dominion High School Programming Contest"); this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.setResizable(false); WindowListener exitListener = new WindowAdapter() { @Override// w ww . j av a2 s . com public void windowClosing(WindowEvent e) { System.exit(0); } }; this.addWindowListener(exitListener); JTabbedPane pane = new JTabbedPane(); this.add(pane); JPanel submitPanel = new JPanel(null); submitPanel.setPreferredSize(new Dimension(500, 500)); UIManager.put("FileChooser.readOnly", true); JFileChooser fileChooser = new JFileChooser(); fileChooser.setBounds(0, 0, 500, 350); fileChooser.setVisible(true); FileNameExtensionFilter javaFilter = new FileNameExtensionFilter("Java files (*.java)", "java"); fileChooser.setFileFilter(javaFilter); fileChooser.setAcceptAllFileFilterUsed(false); fileChooser.setControlButtonsAreShown(false); submitPanel.add(fileChooser); JSeparator separator1 = new JSeparator(); separator1.setBounds(12, 350, 476, 2); separator1.setForeground(new Color(122, 138, 152)); submitPanel.add(separator1); JLabel problemChooserLabel = new JLabel("Problem:"); problemChooserLabel.setBounds(12, 360, 74, 25); submitPanel.add(problemChooserLabel); String[] listOfProblems = Main.Configuration.get("problem_names") .split(Main.Configuration.get("name_delimiter")); JComboBox problems = new JComboBox<>(listOfProblems); problems.setBounds(96, 360, 393, 25); submitPanel.add(problems); JButton submit = new JButton("Submit"); submit.setBounds(170, 458, 160, 30); submit.addActionListener(e -> { try { File file = fileChooser.getSelectedFile(); try { CloseableHttpClient httpClient = HttpClients.createDefault(); HttpPost uploadFile = new HttpPost(Main.Configuration.get("submit_url")); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); builder.addTextBody("accountID", Main.accountID, ContentType.TEXT_PLAIN); builder.addTextBody("problem", String.valueOf(problems.getSelectedItem()), ContentType.TEXT_PLAIN); builder.addBinaryBody("submission", file, ContentType.APPLICATION_OCTET_STREAM, file.getName()); HttpEntity multipart = builder.build(); uploadFile.setEntity(multipart); CloseableHttpResponse response = httpClient.execute(uploadFile); HttpEntity responseEntity = response.getEntity(); String inputLine; BufferedReader br = new BufferedReader(new InputStreamReader(responseEntity.getContent())); try { if ((inputLine = br.readLine()) != null) { int rowIndex = Integer.parseInt(inputLine); new ResultWatcher(rowIndex); } br.close(); } catch (IOException ex) { ex.printStackTrace(); } } catch (Exception ex) { ex.printStackTrace(); } } catch (NullPointerException ex) { JOptionPane.showMessageDialog(this, "No file selected.\nPlease select a java file.", "Error", JOptionPane.WARNING_MESSAGE); } }); submitPanel.add(submit); JPanel clarificationsPanel = new JPanel(null); clarificationsPanel.setPreferredSize(new Dimension(500, 500)); cList = new JList<>(); cList.setBounds(12, 12, 476, 200); cList.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)), BorderFactory.createEmptyBorder(8, 8, 8, 8))); cList.setBackground(new Color(254, 254, 255)); clarificationsPanel.add(cList); JButton viewC = new JButton("View"); viewC.setBounds(12, 224, 232, 25); viewC.addActionListener(e -> { if (cList.getSelectedIndex() != -1) { int id = Integer.parseInt(cList.getSelectedValue().split("\\.")[0]); clarificationDatas.stream().filter(data -> data.getId() == id).forEach( data -> new ClarificationDisplay(data.getProblem(), data.getText(), data.getResponse())); } }); clarificationsPanel.add(viewC); JButton refreshC = new JButton("Refresh"); refreshC.setBounds(256, 224, 232, 25); refreshC.addActionListener(e -> updateCList(true)); clarificationsPanel.add(refreshC); JSeparator separator2 = new JSeparator(); separator2.setBounds(12, 261, 476, 2); separator2.setForeground(new Color(122, 138, 152)); clarificationsPanel.add(separator2); JLabel problemChooserLabelC = new JLabel("Problem:"); problemChooserLabelC.setBounds(12, 273, 74, 25); clarificationsPanel.add(problemChooserLabelC); JComboBox problemsC = new JComboBox<>(listOfProblems); problemsC.setBounds(96, 273, 393, 25); clarificationsPanel.add(problemsC); JTextArea textAreaC = new JTextArea(); textAreaC.setLineWrap(true); textAreaC.setWrapStyleWord(true); textAreaC.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)), BorderFactory.createEmptyBorder(8, 8, 8, 8))); textAreaC.setBackground(new Color(254, 254, 255)); JScrollPane areaScrollPane = new JScrollPane(textAreaC); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setBounds(12, 312, 477, 134); clarificationsPanel.add(areaScrollPane); JButton submitC = new JButton("Submit Clarification"); submitC.setBounds(170, 458, 160, 30); submitC.addActionListener(e -> { if (textAreaC.getText().length() > 2048) { JOptionPane.showMessageDialog(this, "Clarification body is too long.\nMaximum of 2048 characters allowed.", "Error", JOptionPane.WARNING_MESSAGE); } else if (textAreaC.getText().length() < 20) { JOptionPane.showMessageDialog(this, "Clarification body is too short.\nClarifications must be at least 20 characters, but no more than 2048.", "Error", JOptionPane.WARNING_MESSAGE); } else { Connection conn = null; PreparedStatement stmt = null; try { Class.forName(JDBC_DRIVER); conn = DriverManager.getConnection(Main.Configuration.get("jdbc_mysql_address"), Main.Configuration.get("mysql_user"), Main.Configuration.get("mysql_pass")); String sql = "INSERT INTO clarifications (team, problem, text) VALUES (?, ?, ?)"; stmt = conn.prepareStatement(sql); stmt.setInt(1, Integer.parseInt(String.valueOf(Main.accountID))); stmt.setString(2, String.valueOf(problemsC.getSelectedItem())); stmt.setString(3, String.valueOf(textAreaC.getText())); textAreaC.setText(""); stmt.executeUpdate(); stmt.close(); conn.close(); updateCList(false); } catch (Exception ex) { ex.printStackTrace(); } finally { try { if (stmt != null) { stmt.close(); } } catch (Exception ex2) { ex2.printStackTrace(); } try { if (conn != null) { conn.close(); } } catch (Exception ex2) { ex2.printStackTrace(); } } } }); clarificationsPanel.add(submitC); pane.addTab("Submit", submitPanel); pane.addTab("Clarifications", clarificationsPanel); Timer timer = new Timer(); TimerTask updateTask = new TimerTask() { @Override public void run() { updateCList(false); } }; timer.schedule(updateTask, 10000, 10000); updateCList(false); this.pack(); this.setLocationRelativeTo(null); this.setVisible(true); }
From source file:GenAppStoreSales.java
/** * Creates a new demo instance.//www . j a va 2 s. c om * * @param title the frame title. */ public GenAppStoreSales(String title, ArrayList<String> cLabels, ArrayList<ArrayList<Integer>> cUnits) { super(title); JPanel chartPanel = createDemoPanel(title, cLabels, cUnits); chartPanel.setPreferredSize(new java.awt.Dimension(widthChart, heightChart)); setContentPane(chartPanel); }
From source file:ngat.opsgui.xcomp.SeeingPanel2.java
private JPanel makeChartPanel() { tac = new TimeAxisChart("Seeing"); tac.setTimeLabel("Time [UTC]"); tac.setYLabel("Seeing [asec]"); tac.setShowGridLines(true);// www .j a v a 2s. co m tac.setTimeAxisRange(6 * 3600 * 1000L); tac.setYAxisStart(0.0); tac.setYAxisEnd(3.0); tac.setChartBackgroundColor(jPanel5.getBackground()); tac.addRangeBackground(0.0, 0.8, new Color(192, 248, 193)); tac.addRangeBackground(0.8, 1.3, new Color(248, 233, 192)); tac.addRangeBackground(1.3, 2.0, new Color(248, 198, 192)); tac.addRangeBackground(2.0, 3.0, new Color(192, 236, 248)); try { tac.createPlot("RAW_STD", "Standards Raw", TimeAxisChart.SHAPE_TRIANGLE, 0, Color.magenta, false, true); } catch (Exception e) { e.printStackTrace(); } try { tac.createPlot("CORR_STD", "Standards Corrected", TimeAxisChart.SHAPE_RECTANGLE, 0, Color.orange, false, true); } catch (Exception e) { e.printStackTrace(); } try { tac.createPlot("RAW_SCI", "Science Raw", TimeAxisChart.SHAPE_TRIANGLE, 0, Color.blue, false, true); } catch (Exception e) { e.printStackTrace(); } try { tac.createPlot("CORR_SCI", "Science Corrected", TimeAxisChart.SHAPE_RECTANGLE, 0, Color.green, false, true); } catch (Exception e) { e.printStackTrace(); } try { tac.createPlot("PRED", "Prediction", TimeAxisChart.SHAPE_NONE, 0, Color.red, true, true); } catch (Exception e) { e.printStackTrace(); } JPanel cp = tac.createChartPanel(); cp.setLayout(new BorderLayout()); cp.setPreferredSize(new Dimension(550, 320)); return cp; }
From source file:charts.Chart.java
public static void PlotMeanParallelCoordinates(String title, String x_axis_label, String y_axis_label, float[][] Md, int classes, int[] features, Vector featurestitles, Vector datatitles) { JFrame chartwindow = new JFrame(title); JFreeChart jfreechart = ChartFactory.createLineChart(title, x_axis_label, y_axis_label, null, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.white); categoryplot.setRangeGridlinePaint(Color.black); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); int lines = Md.length; int columns = Md[0].length; LineAndShapeRenderer[] lineandshaperenderer = new LineAndShapeRenderer[classes]; //lineandshaperenderer[0] = new LineAndShapeRenderer();//(LineAndShapeRenderer) categoryplot.getRenderer(); //lineandshaperenderer[0].setShapesVisible(true); //lineandshaperenderer[0].setDrawOutlines(true); //lineandshaperenderer[0].setUseFillPaint(true); //lineandshaperenderer[0].setFillPaint(Color.white); for (int i = 0; i < lineandshaperenderer.length; i++) { lineandshaperenderer[i] = new LineAndShapeRenderer(); lineandshaperenderer[i].setShapesVisible(true); lineandshaperenderer[i].setDrawOutlines(true); lineandshaperenderer[i].setUseFillPaint(true); lineandshaperenderer[i].setFillPaint(Color.white); lineandshaperenderer[i].setBaseStroke(new BasicStroke(2.0f)); }/*from w ww . java 2 s.c om*/ double[][][] valuesperclasse = new double[columns][classes][2]; /* a primeira coluna acumula a soma dos valores, e a segunda coluna conta o numero de vezes que recebeu um valor, para gerar a media aritmetica dos valores de cada atributo para cada uma das classes.*/ for (int i = 0; i < lines; i++) { int classe = ((int) Md[i][columns - 1]); int j = 0; while (j < features.length) { valuesperclasse[features[j]][classe][0] += Md[i][features[j]]; valuesperclasse[features[j]][classe][1]++; j++; } } for (int i = 0; i < classes; i++) { DefaultKeyedValues2DDataset dataset = new DefaultKeyedValues2DDataset(); double meanvaluej = 0; for (int j = 0; j < features.length; j++) { meanvaluej = valuesperclasse[features[j]][i][0] / valuesperclasse[features[j]][i][1]; String strclasse = String.valueOf(i); //especifico Marie-Anne /* if (i == 0) { strclasse = "thi1"; lineandshaperenderer[i].setSeriesPaint(0, Color.RED); Shape s0 = new Rectangle2D.Float(-3f, -3f, 6f, 6f); lineandshaperenderer[i].setSeriesShape(0, s0); } else if (i == 1) { strclasse = "controle"; lineandshaperenderer[i].setSeriesPaint(0, Color.PINK); Shape s1 = new Ellipse2D.Float(-3f, -3f, 6f, 6f); lineandshaperenderer[i].setSeriesShape(0, s1); } else if (i == 2) { strclasse = "fotossntese"; lineandshaperenderer[i].setSeriesPaint(0, Color.GREEN); int[] x = {-3, 0, 3}; int[] y = {-3, 3, -3}; int n = 3; Shape s2 = new Polygon(x, y, n); lineandshaperenderer[i].setSeriesShape(0, s2); } else if (i == 3) { strclasse = "respirao"; int[] x = {-3, 0, 3}; int[] y = {3, -3, 3}; int n = 3; Shape s3 = new Polygon(x, y, n); lineandshaperenderer[i].setSeriesShape(0, s3); lineandshaperenderer[i].setSeriesPaint(0, Color.BLUE); } else if (i == 4) { strclasse = "sntese de tiamina"; lineandshaperenderer[i].setSeriesPaint(0, Color.BLACK); Shape s4 = new Rectangle2D.Float(-1f, -3f, 1f, 6f); lineandshaperenderer[i].setSeriesShape(0, s4); } else if (i == 5) { strclasse = "gliclise"; int[] x = {-3, 0, 3, 0}; int[] y = {0, -3, 0, 3}; int n = 4; Shape s5 = new Polygon(x, y, n); lineandshaperenderer[i].setSeriesPaint(0, Color.ORANGE); lineandshaperenderer[i].setSeriesShape(0, s5); } else if (i == 6) { strclasse = "AT4G34200"; int[] x = {-3, 0, 3, 0}; int[] y = {0, -3, 0, 3}; int n = 4; Shape s5 = new Polygon(x, y, n); lineandshaperenderer[i].setSeriesPaint(0, Color.MAGENTA); lineandshaperenderer[i].setSeriesShape(0, s5); } else if (i == 7) { strclasse = "AT2G36530"; int[] x = {-3, 0, 3, 0}; int[] y = {0, -3, 0, 3}; int n = 4; Shape s5 = new Polygon(x, y, n); lineandshaperenderer[i].setSeriesPaint(0, Color.CYAN); lineandshaperenderer[i].setSeriesShape(0, s5); } */ if (featurestitles != null) { if (datatitles != null) { dataset.addValue(meanvaluej, strclasse, (String) featurestitles.get(features[j] + 1)); //datasets[i].addValue(Mo[lineindex[i]][c], label, (String) featurestitles.get(c + 1)); } else { dataset.addValue(meanvaluej, strclasse, (String) featurestitles.get(features[j])); //datasets[i].addValue(Mo[lineindex[i]][c], label, (String) featurestitles.get(c)); } } else { dataset.addValue(meanvaluej, strclasse, String.valueOf(features[j])); //dataset.addValue(meanvaluej, String.valueOf(i), String.valueOf(features[j])); } //dataset.addValue(meanvaluej, String.valueOf(i), String.valueOf(features[j])); } categoryplot.setDataset(i, dataset); categoryplot.setRenderer(i, lineandshaperenderer[i]); } JPanel jpanel = new ChartPanel(jfreechart); jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight)); chartwindow.setContentPane(jpanel); chartwindow.pack(); RefineryUtilities.centerFrameOnScreen(chartwindow); chartwindow.setVisible(true); }
From source file:com.wet.wired.jsr.player.JPlayer.java
private JPanel createSliderLayout() { slider.setEnabled(false);//from w w w . ja v a2 s .c o m JPanel sliderPanel = new JPanel(); sliderPanel.setPreferredSize(close.getSize()); // use default size of // button GridBagLayout gbl = new GridBagLayout(); sliderPanel.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(2, 2, 2, 2); gbc.gridx = 0; gbc.gridy = 0; gbc.gridheight = 1; gbc.weightx = 1.0; gbl.setConstraints(slider, gbc); sliderPanel.add(slider); return sliderPanel; }
From source file:de.kletterfreak98.xmass.ui.BMIChart.java
public BMIChart(String title, TimeSeries values) { super(title); setIconImage(//from w w w . j a va 2 s.co m new ImageIcon(getClass().getClassLoader().getResource("de/kletterfreak98/xmass/resources/fav.png")) .getImage()); // create a title... final String chartTitle = strings.getString("bmicourse"); final XYDataset dataset = new TimeSeriesCollection(values); final JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, strings.getString("date"), strings.getString("bmi"), dataset, false, true, false); final XYPlot plot = chart.getXYPlot(); plot.setDataset(1, new TimeSeriesCollection(values)); plot.mapDatasetToRangeAxis(1, 1); final XYItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setShapesFilled(true); } final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.black); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); plot.setRenderer(1, renderer2); final DateAxis axis = (DateAxis) plot.getDomainAxis(); SimpleDateFormat sdf; if (Main.settings.getLang().equals(Locale.GERMANY)) { sdf = new SimpleDateFormat("dd.MM.yyyy"); } else { sdf = new SimpleDateFormat("MM/dd/yyyy"); } axis.setDateFormatOverride(sdf); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); JPanel panel = new JPanel(); JButton close = new JButton(strings.getString("close")); close.setPreferredSize(new Dimension(close.getWidth(), 30)); close.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); panel.setLayout(new BorderLayout()); panel.add(chartPanel, BorderLayout.CENTER); panel.add(close, BorderLayout.SOUTH); panel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(panel); setUndecorated(true); }
From source file:events.ListSelectionDemo.java
public ListSelectionDemo() { super(new BorderLayout()); String[] listData = { "one", "two", "three", "four", "five", "six", "seven" }; String[] columnNames = { "French", "Spanish", "Italian" }; list = new JList(listData); listSelectionModel = list.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); JScrollPane listPane = new JScrollPane(list); JPanel controlPane = new JPanel(); String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" }; final JComboBox comboBox = new JComboBox(modes); comboBox.setSelectedIndex(2);/* w w w. ja v a 2 s .co m*/ comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newMode = (String) comboBox.getSelectedItem(); if (newMode.equals("SINGLE_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } else { listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } output.append("----------" + "Mode: " + newMode + "----------" + newline); } }); controlPane.add(new JLabel("Selection mode:")); controlPane.add(comboBox); //Build output area. output = new JTextArea(1, 10); output.setEditable(false); JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); //Do the layout. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS)); JPanel listContainer = new JPanel(new GridLayout(1, 1)); listContainer.setBorder(BorderFactory.createTitledBorder("List")); listContainer.add(listPane); topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); topHalf.add(listContainer); //topHalf.add(tableContainer); topHalf.setMinimumSize(new Dimension(100, 50)); topHalf.setPreferredSize(new Dimension(100, 110)); splitPane.add(topHalf); JPanel bottomHalf = new JPanel(new BorderLayout()); bottomHalf.add(controlPane, BorderLayout.PAGE_START); bottomHalf.add(outputPane, BorderLayout.CENTER); //XXX: next line needed if bottomHalf is a scroll pane: //bottomHalf.setMinimumSize(new Dimension(400, 50)); bottomHalf.setPreferredSize(new Dimension(450, 135)); splitPane.add(bottomHalf); }
From source file:de.kletterfreak98.xmass.ui.WeightChart.java
public WeightChart(String title, TimeSeries values) { super(title); setIconImage(// w ww. j a v a 2 s . c o m new ImageIcon(getClass().getClassLoader().getResource("de/kletterfreak98/xmass/resources/fav.png")) .getImage()); final String chartTitle = strings.getString("weightcourse"); final XYDataset dataset = new TimeSeriesCollection(values); final JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, strings.getString("date"), strings.getString("weightinkg"), dataset, false, true, false); final XYPlot plot = chart.getXYPlot(); plot.setDataset(1, new TimeSeriesCollection(values)); plot.mapDatasetToRangeAxis(1, 1); final XYItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setShapesFilled(true); } final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.black); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); plot.setRenderer(1, renderer2); final DateAxis axis = (DateAxis) plot.getDomainAxis(); SimpleDateFormat sdf; if (Main.settings.getLang().equals(Locale.GERMANY)) { sdf = new SimpleDateFormat("dd.MM.yyyy"); axis.setDateFormatOverride(sdf); } else { sdf = new SimpleDateFormat("MM/dd/yyyy"); axis.setDateFormatOverride(sdf); } final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); JPanel panel = new JPanel(); JButton close = new JButton(strings.getString("close")); close.setPreferredSize(new Dimension(close.getWidth(), 30)); close.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); panel.setLayout(new BorderLayout()); panel.add(chartPanel, BorderLayout.CENTER); panel.add(close, BorderLayout.SOUTH); panel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(panel); setUndecorated(true); }