List of usage examples for javax.swing JFrame setBackground
@Override public void setBackground(Color bgColor)
From source file:AppPackage.HumidityGraph.java
/** * *//*from www . j a va 2 s . co m*/ public HumidityGraph() { try { JFrame window = new JFrame(); window.setSize(1000, 615); window.setBackground(Color.blue); Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - window.getWidth()) / 2); int y = (int) ((dimension.getHeight() - window.getHeight()) / 2); window.setLocation(x, y); XYSeries series = new XYSeries("Humidity "); XYSeriesCollection dataset = new XYSeriesCollection(series); JFreeChart chart = ChartFactory.createXYLineChart("Humidity against Time", "Time(seconds)", "Humidity(percentage)", dataset); window.add(new ChartPanel(chart), BorderLayout.CENTER); window.setVisible(true); } catch (Exception e) { System.out.print("Chart exception:" + e); } initComponents(); }
From source file:TradeMonitorGui.java
private XYPlot createChartFrame(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Average Stock Price over 1 minute", "Time", "Price in USD", dataset, true, true, false); XYPlot plot = chart.getXYPlot();/*from w w w .j a v a2 s.c om*/ plot.setBackgroundPaint(new Color(245, 245, 245)); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); final JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setTitle("Trade Monitor"); frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLayout(new BorderLayout()); frame.add(new ChartPanel(chart)); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { avgPrices.removeEntryListener(listenerId); } }); frame.setVisible(true); return plot; }
From source file:AppPackage.Temperature.java
public Temperature() { try {/* www . j av a 2 s .c o m*/ JFrame window = new JFrame(); window.setSize(1000, 615); window.setBackground(Color.blue.darker()); double value = 55; Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - window.getWidth()) / 2); int y = (int) ((dimension.getHeight() - window.getHeight()) / 2); window.setLocation(x, y); DefaultValueDataset dataset = new DefaultValueDataset(value); ThermometerPlot thermometerplot = new ThermometerPlot(dataset); thermometerplot.setSubrangePaint(0, Color.green.darker()); thermometerplot.setSubrangePaint(1, Color.orange); thermometerplot.setSubrangePaint(2, Color.red); JFreeChart jfreechart = new JFreeChart("Temperature readings", JFreeChart.DEFAULT_TITLE_FONT, thermometerplot, true); thermometerplot.setInsets(new RectangleInsets(5D, 5D, 5D, 5D)); thermometerplot.setPadding(new RectangleInsets(10D, 10D, 10D, 10D)); thermometerplot.setThermometerStroke(new BasicStroke(2.0F)); thermometerplot.setThermometerPaint(Color.BLUE); thermometerplot.setGap(3); window.add(new ChartPanel(jfreechart), BorderLayout.CENTER); window.setVisible(true); } catch (Exception e) { System.out.print("Chart exception:" + e); } initComponents(); }
From source file:AppPackage.humidity.java
public humidity() { try {//from ww w .j av a2 s.co m JFrame window = new JFrame(); window.setSize(1000, 615); window.setBackground(Color.blue.darker()); double value = 45; Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - window.getWidth()) / 2); int y = (int) ((dimension.getHeight() - window.getHeight()) / 2); window.setLocation(x, y); DefaultValueDataset dataset = new DefaultValueDataset(value); ThermometerPlot thermometerplot = new ThermometerPlot(dataset); thermometerplot.setSubrangePaint(0, Color.green.darker()); thermometerplot.setSubrangePaint(1, Color.orange); thermometerplot.setSubrangePaint(2, Color.red); JFreeChart jfreechart = new JFreeChart("Humidity readings", JFreeChart.DEFAULT_TITLE_FONT, thermometerplot, true); thermometerplot.setInsets(new RectangleInsets(5D, 5D, 5D, 5D)); thermometerplot.setPadding(new RectangleInsets(10D, 10D, 10D, 10D)); thermometerplot.setThermometerStroke(new BasicStroke(2.0F)); thermometerplot.setThermometerPaint(Color.BLUE); thermometerplot.setUnits(0); thermometerplot.setGap(3); window.add(new ChartPanel(jfreechart), BorderLayout.CENTER); window.setVisible(true); } catch (Exception e) { System.out.print("Chart exception:" + e); } initComponents(); }
From source file:support.TradingVolumeGui.java
private CategoryPlot createChartFrame(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("Trading Volume", "Stock", "Volume, USD", dataset, PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.getRenderer().setSeriesPaint(0, Color.BLUE); JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setTitle("Hazelcast Jet Source Builder Sample"); frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLayout(new BorderLayout()); frame.add(new ChartPanel(chart)); frame.setVisible(true);//w w w . j a v a 2 s.c o m frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { hzMap.removeEntryListener(entryListenerId); } }); return plot; }
From source file:support.SystemMonitorGui.java
private XYPlot createChartFrame(XYSeries series) { XYSeriesCollection dataSet = new XYSeriesCollection(); dataSet.addSeries(series);//from w w w . j a v a2 s .c o m JFreeChart chart = ChartFactory.createXYLineChart("Memory Allocation Rate", "Time (ms)", "Allocation Rate (MB/s)", dataSet, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.getRenderer().setSeriesPaint(0, Color.BLUE); JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setTitle("Hazelcast Jet Source Builder Sample"); frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLayout(new BorderLayout()); frame.add(new ChartPanel(chart)); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { hzMap.removeEntryListener(entryListenerId); } }); frame.setVisible(true); return plot; }
From source file:gui.images.CodebookVectorProfilePanel.java
/** * Sets the data to be shown./*from w w w . j a va2s . c o 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:scheduler.benchmarker.manager.CreateCombinedSplineChart.java
private void createSubChart(ChartPanel chart) { JFrame frameGraph = new JFrame(); frameGraph.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frameGraph.setForeground(new Color(76, 76, 76)); frameGraph.setBackground(new Color(246, 244, 242)); Dimension window = Toolkit.getDefaultToolkit().getScreenSize(); if (window.width < 1074 && window.height < 800) frameGraph.setPreferredSize(new Dimension(window.width, window.height)); else//w w w . jav a 2 s . com frameGraph.setPreferredSize(new Dimension(1074, 800)); frameGraph.setLocation((window.width - frameGraph.getPreferredSize().width) / 2, (window.height - frameGraph.getPreferredSize().height) / 2); frameGraph.setResizable(true); frameGraph.add(chart); frameGraph.pack(); frameGraph.setVisible(true); }
From source file:scheduler.benchmarker.manager.CreateSimpleSplineChart.java
private void createSubChart(ChartPanel chart) { JFrame frameGraph = new JFrame();//new JFrame("FINAL RULES ARRANGEMENT"); frameGraph.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frameGraph.setForeground(new Color(76, 76, 76)); frameGraph.setBackground(new Color(246, 244, 242)); Dimension window = Toolkit.getDefaultToolkit().getScreenSize(); if (window.width < 1074 && window.height < 800) frameGraph.setPreferredSize(new Dimension(window.width, window.height)); else/*from w w w.j a v a 2 s . co m*/ frameGraph.setPreferredSize(new Dimension(1074, 800)); frameGraph.setLocation((window.width - frameGraph.getPreferredSize().width) / 2, (window.height - frameGraph.getPreferredSize().height) / 2); frameGraph.setResizable(true); frameGraph.add(chart); frameGraph.pack(); frameGraph.setVisible(true); }
From source file:es.emergya.ui.plugins.admin.aux1.SummaryAction.java
private JFrame createJDialog(final String titulo) { final JFrame d = new JFrame(titulo); d.setResizable(false);/*from ww w . j av a 2s . c o m*/ d.setAlwaysOnTop(true); d.setIconImage(window.getIconImage()); d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); d.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { super.windowClosing(e); if (cambios) { int res = JOptionPane.showConfirmDialog(d, "Existen cambios sin guardar. Seguro que desea cerrar la ventana?", "Cambios sin guardar", JOptionPane.OK_CANCEL_OPTION); if (res != JOptionPane.CANCEL_OPTION) { e.getWindow().dispose(); } } else { e.getWindow().dispose(); } } }); d.setLayout(new BorderLayout(5, 5)); d.setBackground(Color.WHITE); d.getContentPane().setBackground(Color.WHITE); return d; }