A
ahd292
Hi everyone.
I want to paint some bars with "fillrect()" in JPanel. my JPanel
component, call it panel, is inside JFrame. it means:
---JFrame
-------JPanel
In fact I want to draw bars with method "drawbar" that i create it in
my Main class that extended JFrame and have panel inside itself. i
call drawbar metohd from othe class, for example ChartGenerator.
this is my pseudo code:
Class Main extends JFrame{
JPanel panel;
//other fields
drawbar(){
//paint bars in panel with fillrect method
}
void main(){
ChartGeneratirCG = new ChartGenrator(this);
}
}
class ChartGenerator{
Main m;
public ChartGenerator(Main m){
this.m = m;
}
makechart(){
//produce chart details
this.m.drawbar();
}
}
Does I need reconstruct this class structure or this is correct.
please help me with explain how to use graphics and painting in Swing
component specially if one Comp is inside other one.
I want to paint some bars with "fillrect()" in JPanel. my JPanel
component, call it panel, is inside JFrame. it means:
---JFrame
-------JPanel
In fact I want to draw bars with method "drawbar" that i create it in
my Main class that extended JFrame and have panel inside itself. i
call drawbar metohd from othe class, for example ChartGenerator.
this is my pseudo code:
Class Main extends JFrame{
JPanel panel;
//other fields
drawbar(){
//paint bars in panel with fillrect method
}
void main(){
ChartGeneratirCG = new ChartGenrator(this);
}
}
class ChartGenerator{
Main m;
public ChartGenerator(Main m){
this.m = m;
}
makechart(){
//produce chart details
this.m.drawbar();
}
}
Does I need reconstruct this class structure or this is correct.
please help me with explain how to use graphics and painting in Swing
component specially if one Comp is inside other one.