List of usage examples for javax.swing JFrame setContentPane
@BeanProperty(bound = false, hidden = true, description = "The client area of the frame where child components are normally inserted.") public void setContentPane(Container contentPane)
contentPane
property. From source file:turtlekit.viewer.PopulationCharter.java
@Override public void setupFrame(JFrame frame) { final ChartPanel chartPanel = ChartsUtil.createChartPanel(dataset, "Population", null, null); chartPanel.setPreferredSize(new java.awt.Dimension(550, 250)); frame.setContentPane(chartPanel); frame.setLocation(50, 0);//from ww w. j av a2 s . c o m }
From source file:org.ujmp.jfreechart.AbstractChartPanel.java
public synchronized void export(FileFormat fileFormat, File file) { JFrame frame = null; if (isVisible()) { frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setContentPane(this); frame.setSize(800, 600);/*w w w .j av a 2s . c om*/ frame.setVisible(true); try { redraw(); repaint(); } catch (Exception e) { } } if (FileFormat.JPG.equals(fileFormat)) { try { ExportJPEG.save(file, this); } catch (Exception e) { } } else if (FileFormat.PDF.equals(fileFormat)) { try { ExportPDF.save(file, this); } catch (Exception e) { } } else { throw new RuntimeException("FileFormat not yet supported: " + fileFormat); } if (frame != null) { frame.setVisible(false); frame = null; } }
From source file:com.freedomotic.plugins.devices.harvester_chart.HarvesterChart.java
@ListenEventsOn(channel = "app.event.sensor.object.behavior.clicked") public void onObjectClicked(EventTemplate event) { List<String> behavior_list = new ArrayList<String>(); System.out.println("received event " + event.toString()); ObjectReceiveClick clickEvent = (ObjectReceiveClick) event; //PRINT EVENT CONTENT WITH System.out.println(clickEvent.getPayload().toString()); String objectName = clickEvent.getProperty("object.name"); String protocol = clickEvent.getProperty("object.protocol"); String address = clickEvent.getProperty("object.address"); try {/* ww w . j a va 2 s .c om*/ Statement stat = connection.createStatement(); System.out.println("Protocol=" + protocol + ",Address=" + address); //for (EnvObjectLogic object : EnvObjectPersistence.getObjectByProtocol("wifi_id")){ //EnvObjectLogic object = EnvObjectPersistence.getObjectByName(objectName); for (EnvObjectLogic object : EnvObjectPersistence.getObjectByAddress(protocol, address)) { for (BehaviorLogic behavior : object.getBehaviors()) { System.out.println(behavior.getName()); } } //String query = "select date,value from events where protocol='"+clickEvent.getProperty("object.protocol")+"' and behavior='power' ORDER BY ID DESC LIMIT 1000;"; String query = "select date,value from events where object='" + objectName + "' and behavior='power' ORDER BY ID DESC LIMIT 1000;"; System.out.println(query); //String query = "select datetime(date, 'unixepoch', 'localtime') as TIME,value from events where protocol='remote_receiver' and behavior='button'"; ResultSet rs = stat.executeQuery(query); //JFreeChart chart = ChartFactory.createLineChart("Test", "Id", "Score", dataset, PlotOrientation.VERTICAL, true, true, false); //System.out.println("Wilson Kong Debug:"+rs.getLong("date")); final TimeSeries series = new TimeSeries("Data1", Millisecond.class); while (rs.next()) { Date resultdate = new Date(rs.getLong("date") * 1000); Millisecond ms_read = new Millisecond(resultdate); series.addOrUpdate(ms_read, rs.getDouble("value")); //series.add((Millisecond)rs.getLong("date"),(double)rs.getLong("value")); } XYDataset xyDataset = new TimeSeriesCollection(series); JFreeChart chart = ChartFactory.createTimeSeriesChart("Chart", "TIME", "VALVE", xyDataset, true, // legend true, // tooltips false // urls ); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(800, 500)); JFrame f = new JFrame("Chart"); f.setContentPane(chartPanel); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.pack(); f.setVisible(true); //if (...) { //MyFrame myFrame = new MyFrame(); //bindGuiToPlugin(myFrame); //showGui(); //triggers the showing of your frame. Before it calls onShowGui() //} } catch (SQLException ex) { Logger.getLogger(HarvesterChart.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage()); System.out.println("Wilson Kong Error: " + ex.toString()); //ex.printStackTrace(); stop(); } }
From source file:c.depthchart.ViewerPanel.java
private void initChart() // create the dataset, chart, panel, and window { // create an empty data set series = new XYSeries("Depth Counts Histogram"); for (int i = 0; i <= CHART_MAX_DEPTH; i++) series.add(i, 0); // depth with a zero count XYSeriesCollection dataset = new XYSeriesCollection(series); // put the data into a chart JFreeChart chart = ChartFactory.createXYBarChart("Depth Histogram", "Depth (mm)", false, "Depth Count", dataset, PlotOrientation.VERTICAL, false, true, false); // legend, tooltips, urls // modify the chart axes XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); // x-axis domainAxis.setVerticalTickLabels(true); domainAxis.setRange(0, CHART_MAX_DEPTH); domainAxis.setTickUnit(new NumberTickUnit(100)); ValueAxis rangeAxis = plot.getRangeAxis(); // y-axis rangeAxis.setRange(0, 15000); // a bit of a guess // add the chart to a panel ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(1000, 500)); // add the panel to a window JFrame chartFrame = new JFrame("Depth Histogram"); chartFrame.setContentPane(chartPanel); chartFrame.pack();//from w w w . jav a2 s. co m chartFrame.setVisible(true); }
From source file:gui.accessories.BattleSimFx.java
@Override public void start() { SwingUtilities.invokeLater(new Runnable() { @Override/*from w w w. j a v a2 s .c o m*/ public void run() { JFrame frame = new JFrame("Swing JTable"); frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JApplet applet = new BattleSimFx(); applet.init(); frame.setContentPane(applet.getContentPane()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); // applet.start(); } }); }
From source file:org.geotools.renderer.chart.GeometryRendererTest.java
void showChart(XYPlot plot) throws Exception { JFreeChart chart = new JFreeChart(plot); chart.setAntiAlias(true);//from w w w. jav a 2s . c o m ChartPanel panel = new ChartPanel(chart, true); final String headless = System.getProperty("java.awt.headless", "false"); if (!headless.equalsIgnoreCase("true") && TestData.isInteractiveTest()) { try { JFrame frame = new JFrame(getName()); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { e.getWindow().dispose(); } }); frame.setContentPane(panel); frame.setSize(new Dimension(500, 500)); frame.setVisible(true); Thread.sleep(5000); frame.dispose(); } catch (HeadlessException exception) { // The test is running on a machine without X11 display. Ignore. return; } } }
From source file:turtlekit.murmuration.SpeedChecker.java
@Override public void setupFrame(JFrame frame) { XYSeriesCollection dataset = new XYSeriesCollection(); final ChartPanel chartPanel = ChartsUtil.createChartPanel(dataset, "Moyenne", null, null); chartPanel.setPreferredSize(new java.awt.Dimension(550, 250)); speed = new XYSeries("Speed"); dataset.addSeries(speed);/*from w w w. j a va2 s. co m*/ frame.setContentPane(chartPanel); frame.setLocation(50, 0); // XYSeries s = dataset.getSeries("Total"); }
From source file:edu.uara.tableeditor.TableFigure.java
/** * view chart in a new frame//www .ja v a 2s.co m */ public void chartPreview() { java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { JFrame chartFrame = new JFrame(title); JFreeChart ch = chart.getChart(); ChartPanel chartPanel = new ChartPanel(ch); chartPanel.setPreferredSize(new Dimension(500, 300)); chartFrame.setContentPane(chartPanel); chartFrame.pack(); RefineryUtilities.centerFrameOnScreen(chartFrame); chartFrame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); chartFrame.setVisible(true); chartFrame.setAlwaysOnTop(true); } }); }
From source file:turtlekit.murmuration.HeadingChecker.java
@Override public void setupFrame(JFrame frame) { XYSeriesCollection dataset = new XYSeriesCollection(); final ChartPanel chartPanel = ChartsUtil.createChartPanel(dataset, "Average heading", null, null); chartPanel.setPreferredSize(new java.awt.Dimension(550, 250)); heading = new XYSeries("Average heading"); dataset.addSeries(heading);/*w w w . ja v a2 s . c om*/ frame.setContentPane(chartPanel); frame.setLocation(50, 0); // XYSeries s = dataset.getSeries("Total"); }
From source file:Main.java
public void init() { JFrame frame = new JFrame(); dataDisplayer.setEditable(false);/*from w w w . j a v a 2s .co m*/ caret = new MyCaret(); dataDisplayer.setCaret(caret); dataDisplayer.add(new JButton()); dataDisplayer.setContentType("text/html"); JScrollPane jsp = new JScrollPane(dataDisplayer); dataDisplayer.setText("<a href=''>Change Text</a>new word"); this.dataDisplayer.addHyperlinkListener(this); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(jsp); frame.pack(); frame.setVisible(true); }