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:org.jfree.chart.demo.TimeSeriesDemo13.java
/** * Creates a new demo instance.// ww w . j a v a 2s . c o m * * @param title the frame title. */ public TimeSeriesDemo13(final String title) { super(title); final XYDataset dataset1 = createDataset(26); final JFreeChart chart1 = createChart(dataset1); final ChartPanel chartPanel1 = new ChartPanel(chart1); final XYDataset dataset2 = createDataset(1); final JFreeChart chart2 = createChart(dataset2); final ChartPanel chartPanel2 = new ChartPanel(chart2); final JTabbedPane tabs = new JTabbedPane(); tabs.add("Chart 1", chartPanel1); tabs.add("Chart 2", chartPanel2); final JPanel content = new JPanel(new BorderLayout()); content.setPreferredSize(new java.awt.Dimension(500, 270)); content.add(tabs); setContentPane(content); }
From source file:org.jfree.chart.demo.selection.SelectionDemo5Category.java
public SelectionDemo5Category(String title) { super(title); JPanel chartPanel = createDemoPanel(); chartPanel.setPreferredSize(new Dimension(500, 270)); JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); split.add(chartPanel);//from w ww. j a v a 2 s . c o m this.model = new DefaultTableModel(new String[] { "row:", "column:", "value:" }, 0); this.table = new JTable(this.model); TableColumnModel tcm = this.table.getColumnModel(); JPanel p = new JPanel(new BorderLayout()); JScrollPane scroller = new JScrollPane(this.table); p.add(scroller); p.setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Selected Items: "), new EmptyBorder(4, 4, 4, 4))); split.add(p); setContentPane(split); }
From source file:wef.articulab.view.ui.BNXYPlot.java
/** * Creates a new demo instance./*www.ja va2s.c om*/ * * @param title the frame title. */ public BNXYPlot(String title, String[] series) { super(title); this.series = series; JPanel chartPanel = createPanel(); chartPanel.setPreferredSize(new java.awt.Dimension(1100, 1000)); setContentPane(chartPanel); thresholds = new ArrayList<>(); activations = new ArrayList<>(); }
From source file:gui.images.CodebookVectorProfilePanel.java
/** * Sets the data to be shown./*ww w . j a v a 2s. co m*/ * * @param occurrenceProfile Double array that is the neighbor occurrence * profile of this visual word. * @param codebookIndex Integer that is the index of this visual word. * @param classColors Color[] of class colors. * @param classNames String[] of class names. */ public void setResults(double[] occurrenceProfile, int codebookIndex, Color[] classColors, String[] classNames) { int numClasses = Math.min(classNames.length, occurrenceProfile.length); this.codebookIndex = codebookIndex; this.occurrenceProfile = occurrenceProfile; DefaultPieDataset pieData = new DefaultPieDataset(); for (int cIndex = 0; cIndex < numClasses; cIndex++) { pieData.setValue(classNames[cIndex], occurrenceProfile[cIndex]); } JFreeChart chart = ChartFactory.createPieChart3D("codebook vect " + codebookIndex, pieData, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); PieRenderer prend = new PieRenderer(classColors); prend.setColor(plot, pieData); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(140, 140)); chartPanel.setVisible(true); chartPanel.revalidate(); chartPanel.repaint(); JPanel jp = new JPanel(); jp.setPreferredSize(new Dimension(140, 140)); jp.setMinimumSize(new Dimension(140, 140)); jp.setMaximumSize(new Dimension(140, 140)); jp.setSize(new Dimension(140, 140)); jp.setLayout(new FlowLayout()); jp.add(chartPanel); jp.setVisible(true); jp.validate(); jp.repaint(); JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setUndecorated(true); frame.getContentPane().add(jp); frame.pack(); BufferedImage bi = new BufferedImage(jp.getWidth(), jp.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = bi.createGraphics(); jp.print(graphics); graphics.dispose(); frame.dispose(); imPanel.removeAll(); imPanel.setImage(bi); imPanel.setVisible(true); imPanel.revalidate(); imPanel.repaint(); }
From source file:org.jfree.chart.demo.TimeSeriesDemo11.java
/** * A demonstration application showing how to... * * @param title the frame title.//from w w w . j a v a 2 s.co m */ public TimeSeriesDemo11(final String title) { super(title); final JPanel panel = new JPanel(new GridLayout(2, 2)); panel.setPreferredSize(new java.awt.Dimension(800, 600)); final Day today = new Day(); final XYDataset dataset = createDataset("Series 1", 100.0, today, 365); final JFreeChart chart1 = createChart("Chart 1 : 1 Year", dataset); final ChartPanel chartPanel1 = new ChartPanel(chart1); panel.add(chartPanel1); final JFreeChart chart2 = createChart("Chart 2 : 6 Months", dataset); final SerialDate t = today.getSerialDate(); final SerialDate t6m = SerialDate.addMonths(-6, t); final Day sixMonthsAgo = new Day(t6m); final DateAxis axis2 = (DateAxis) chart2.getXYPlot().getDomainAxis(); axis2.setRange(sixMonthsAgo.getStart(), today.getEnd()); final ChartPanel chartPanel2 = new ChartPanel(chart2); panel.add(chartPanel2); final JFreeChart chart3 = createChart("Chart 3 : 3 Months", dataset); final SerialDate t3m = SerialDate.addMonths(-3, t); final Day threeMonthsAgo = new Day(t3m); final DateAxis axis3 = (DateAxis) chart3.getXYPlot().getDomainAxis(); axis3.setRange(threeMonthsAgo.getStart(), today.getEnd()); final ChartPanel chartPanel3 = new ChartPanel(chart3); panel.add(chartPanel3); final JFreeChart chart4 = createChart("Chart 4 : 1 Month", dataset); final SerialDate t1m = SerialDate.addMonths(-1, t); final Day oneMonthsAgo = new Day(t1m); final DateAxis axis4 = (DateAxis) chart4.getXYPlot().getDomainAxis(); axis4.setRange(oneMonthsAgo.getStart(), today.getEnd()); final ChartPanel chartPanel4 = new ChartPanel(chart4); panel.add(chartPanel4); setContentPane(panel); }
From source file:ChartUsingJava.CombinedXYPlotDemo1.java
/** * Constructs a new demonstration application. * * @param title the frame title.//from www .jav a 2s . c o m */ public CombinedXYPlotDemo1(String title) { super(title); JPanel panel = createDemoPanel(); panel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(panel); }
From source file:es.bsc.autonomic.powermodeller.graphics.TotalPowerVsPredictionDecomposed.java
public TotalPowerVsPredictionDecomposed(DataSet dataset) { super(NAME);/* www .j a v a2 s. com*/ jFreeChartDataSets = dataSetToJFreeChartDefaultCategoryDataset(dataset); // pActualDS = createActualPowerDataset(dataset); // pPredictedDS = createPredictedPowerDataset(dataset); JPanel jpanel = createPanel(); jpanel.setPreferredSize(new Dimension(500, 270)); //jpanel.setPreferredSize(jpanel.getMaximumSize()); setContentPane(jpanel); }
From source file:Main.java
Main(String title) { super(title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel jp = new JPanel(); Vector v = new Vector(); v.add("A");//from ww w .j a v a2 s . c o m v.add("B"); v.add("C"); jcb = new JComboBox(v); jcb.setEditable(true); jcb.getActionMap().put("selectNext", new DownAction()); jp.setPreferredSize(new Dimension(200, 35)); jp.add(jcb); getContentPane().add(jp); pack(); setVisible(true); }
From source file:MainClass.java
MainClass(String title) { super(title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel jp = new JPanel(); Vector v = new Vector(); v.add("A");//from w ww.ja v a 2 s. com v.add("B"); v.add("C"); jcb = new JComboBox(v); jcb.setEditable(true); jcb.getActionMap().put("selectNext", new DownAction()); jp.setPreferredSize(new Dimension(200, 35)); jp.add(jcb); getContentPane().add(jp); pack(); setVisible(true); }
From source file:GCWrapper.java
/** * Creates and lays out components in the container. See the comments below * for an organizational overview by panel. */// w ww . j a va 2s . c o m private void initComponents(Container c) { c.setLayout(new BorderLayout()); // Graphics Config JPanel gcPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); c.add(gcPanel, BorderLayout.NORTH); gcSelection.setPreferredSize(new Dimension(400, 30)); gcPanel.add(gcSelection); // Capabilities JPanel capsPanel = new JPanel(new BorderLayout()); c.add(capsPanel, BorderLayout.CENTER); // Image Capabilities JPanel imageCapsPanel = new JPanel(new GridLayout(2, 1)); capsPanel.add(imageCapsPanel, BorderLayout.NORTH); imageCapsPanel.setBorder(BorderFactory.createTitledBorder("Image Capabilities")); imageAccelerated.setEnabled(false); imageCapsPanel.add(imageAccelerated); imageTrueVolatile.setEnabled(false); imageCapsPanel.add(imageTrueVolatile); // Buffer Capabilities JPanel bufferCapsPanel = new JPanel(new BorderLayout()); capsPanel.add(bufferCapsPanel, BorderLayout.CENTER); bufferCapsPanel.setBorder(BorderFactory.createTitledBorder("Buffer Capabilities")); // Buffer Access JPanel bufferAccessCapsPanel = new JPanel(new GridLayout(3, 1)); bufferAccessCapsPanel.setPreferredSize(new Dimension(300, 88)); bufferCapsPanel.add(bufferAccessCapsPanel, BorderLayout.NORTH); // Flipping JPanel flippingPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); bufferAccessCapsPanel.add(flippingPanel); flippingPanel.add(flipping); flipping.setEnabled(false); flippingPanel.add(flippingMethod); // Full-screen JPanel fsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); bufferAccessCapsPanel.add(fsPanel); JPanel indentPanel = new JPanel(); indentPanel.setPreferredSize(new Dimension(30, 30)); fsPanel.add(indentPanel); fsPanel.add(fullScreen); fullScreen.setEnabled(false); // Multi-buffering JPanel mbPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); bufferAccessCapsPanel.add(mbPanel); indentPanel = new JPanel(); indentPanel.setPreferredSize(new Dimension(30, 30)); mbPanel.add(indentPanel); mbPanel.add(multiBuffer); multiBuffer.setEnabled(false); // Front and Back Buffer Capabilities JPanel buffersPanel = new JPanel(new GridLayout(1, 2)); bufferCapsPanel.add(buffersPanel, BorderLayout.CENTER); // Front Buffer JPanel fbPanel = new JPanel(new GridLayout(2, 1)); fbPanel.setBorder(BorderFactory.createTitledBorder("Front Buffer")); buffersPanel.add(fbPanel); fbPanel.add(fbAccelerated); fbAccelerated.setEnabled(false); fbPanel.add(fbTrueVolatile); fbTrueVolatile.setEnabled(false); // Back Buffer JPanel bbPanel = new JPanel(new GridLayout(2, 1)); bbPanel.setPreferredSize(new Dimension(250, 80)); bbPanel.setBorder(BorderFactory.createTitledBorder("Back and Intermediate Buffers")); buffersPanel.add(bbPanel); bbPanel.add(bbAccelerated); bbAccelerated.setEnabled(false); bbPanel.add(bbTrueVolatile); bbTrueVolatile.setEnabled(false); }