Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package LoggerGUI; import java.util.HashSet; import javax.swing.JFrame; import javax.swing.SwingUtilities; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.xy.DefaultXYDataset; import org.jfree.data.xy.XYDataset; import java.awt.BorderLayout; import java.awt.Color; import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.BorderFactory; import javax.swing.JPanel; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.DateAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.CombinedDomainXYPlot; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.time.Millisecond; import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStream; import gnu.io.CommPortIdentifier; import gnu.io.SerialPort; import gnu.io.SerialPortEvent; import gnu.io.SerialPortEventListener; import java.awt.Container; import java.awt.Dimension; import java.util.Enumeration; import java.io.*; public class MainFrame extends JFrame { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { /*JFrame frame = new JFrame("Charts"); frame.setSize(700, 400); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); */ DataLogger demo = new DataLogger("DemoUI", 51); Container contentPane = demo.getContentPane(); demo.pack(); demo.setVisible(true); demo.setSize(100, 100); demo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); demo.setVisible(true); XYDataset ds = createDataset(); JFreeChart chart = ChartFactory.createXYLineChart("Test Chart", "x", "y", ds, PlotOrientation.HORIZONTAL, true, true, false); ChartPanel cp = new ChartPanel(chart); //cp.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); //contentPane.add(cp, BorderLayout.EAST); //cp.setSize(100,100); //RefineryUtilities.centerFrameOnScreen(demo); demo.pack(); } }); } private static XYDataset createDataset() { DefaultXYDataset ds = new DefaultXYDataset(); double[][] data = { { 0.1, 0.2, 0.3 }, { 1, 2, 3 } }; ds.addSeries("series1", data); return ds; } private javax.swing.JButton TargetButton; }