Results 1 to 1 of 1
  1. #1
    Manfizy's Avatar
    Manfizy is offline Senior Member
    Join Date
    Nov 2008
    Location
    Germany
    Posts
    193
    Rep Power
    7

    Post How to use Jpanel

    Hi pple,
    how can i add components to a jpanel that i already created in netbeans?
    I created a simple graph and i want the grph to display on the jpanel. How do i make it appear?
    here is my code
    Java Code:
    public class XYGraph extends javax.swing.JFrame {
    
      
    public XYGraph() {
    final XYSeries series = new XYSeries("Xenon Poisoning");
    series.add(0, 400.2);
    series.add(1.0, 294.1);
    series.add(2.0,350.0);
    series.add(5,20);
    final XYSeriesCollection dataset = new XYSeriesCollection(series);
    
    JFreeChart chart = null;
    
    chart  = ChartFactory.createXYLineChart("Xenon Concentration and Poisoning",
            "Time(Hrs)", "Power Level(%)",(XYSeriesCollection) dataset, PlotOrientation.VERTICAL, true, true, false);
    
    // create and display a frame...
    ChartPanel CP = new ChartPanel(chart);
        
        /** Creates new form XYGraph */
        
            initComponents();
            jPanel1.add(CP);
            jPanel1.validate();
        }
    
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        @SuppressWarnings("unchecked")
    
        /**
        * @param args the command line arguments
        */
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new XYGraph().setVisible(true);
                }
            });
        }
    
        // Variables declaration - do not modify
        private javax.swing.JPanel jPanel1;
        // End of variables declaration
    
    }
    your response will be highly appreciated
    thanks
    Last edited by Manfizy; 02-19-2009 at 02:10 PM.

Similar Threads

  1. .add to a JPanel
    By harrier in forum NetBeans
    Replies: 11
    Last Post: 07-13-2010, 11:24 AM
  2. JPanel won't update
    By ibanez270dx in forum New To Java
    Replies: 3
    Last Post: 01-06-2009, 09:59 PM
  3. refresh JPanel
    By olesja in forum AWT / Swing
    Replies: 1
    Last Post: 04-16-2008, 04:58 PM
  4. Genarate JPanel
    By Bill in forum AWT / Swing
    Replies: 6
    Last Post: 03-24-2008, 08:38 PM
  5. Problem with JPanel
    By ibanez270dx in forum New To Java
    Replies: 2
    Last Post: 11-09-2007, 06:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •