Re: jfreechart and jpanel
That's not enough information to offer any targeted advice. Maybe you need to understand how layout managers work; go through this Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI With JFC/Swing)
db
1 Attachment(s)
Re: jfreechart and jpanel
hi db
plz see the screen shot below:
Attachment 3434
the green area is the jpanel. iam using the matisse builder(netbeans platform) to develop the gui.
i have a pie chart created using jfreechart
i need to display the chart inside the panel.
after creating the piechart , i did the following
ChartPanel piechart=new ChartPanel(chart); //chart is the piechart with required values
jpanel.add(piechart);
but after executing,i dont see the chart but only the panel
Re: jfreechart and jpanel
So, have you gone through the layout tutorial?
db
Re: jfreechart and jpanel
db,
i went through the tutorial specifically, swings with the netbeans part...
i came across these codes:
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setBorder(someBorder);
contentPane.add(someComponent, BorderLayout.CENTER);
contentPane.add(anotherComponent, BorderLayout.PAGE_END);
topLevelContainer.setContentPane(contentPane);
The following question may be absurd for you but i cant get hold of it:
the topLevelContainer is either jFrame/jDialog/jApplet, but with refernce to the above pic(attached in my previous reply),which is the toplevelcontainer? with reference to which object iam supposed to use setContentpane() menthod?
please once again remember iam using netbeans platform.
Re: jfreechart and jpanel
If you find the visual designer too difficult to use (no shame in that, it's an advanced tool, not meant for beginners, regardless of what Oracle would have you believe) it's not difficult to learn to write Swing code by hand. You'll find ample guidance in the other sections of the tutorial I gqave you a link for.
db
Re: jfreechart and jpanel
db,
i found a way around it. i just copied the generated code for another component and refactored it to match my chart component.
here is the code: i have commented out the changed code.....
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(99, 99, 99)
.addComponent(jButton1)// .addComponent(chart)
.addContainerGap(146, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(69, 69, 69)
.addComponent(jButton1)//.addComponent(chart)
.addContainerGap(113, Short.MAX_VALUE))
);
Re: jfreechart and jpanel
Look around the forum FAQs and discover how to post code so that it retains its formatting.
db