problem with multiple internal frames for drawing different graphs
- From: gbgkille69@xxxxxxxx
- Date: 31 Oct 2005 06:55:38 -0800
Hello,
I want to use the same code to draw graphs just with different input so
I have the following code:
showgraph sg1 = new showgraph("AAAA",tp,x[n], y[n]);
showgraph sg2 = new showgraph("BBBBB",tp,x[n+1], y[n+1]);
public showgraph(String text, JPanel tp, int x, int y)
{
JPanel pan = new graphpanel(text);
setClosable(true);
setPreferredSize(new
java.awt.Dimension(globals.smallFrameX,globals.smallFrameY));
pan.setBackground(new java.awt.Color(255, 255, 255));
pan.setForeground(new java.awt.Color(51, 51, 51));
getContentPane().add(pan, java.awt.BorderLayout.CENTER);
pack();
this.setVisible(true);
tp.add(this, new org.netbeans.lib.awtextra.AbsoluteConstraints(x,
y, globals.smallFrameX, globals.smallFrameY ) );
this.setTitle(title);
this.setLocation(x,y);
this.toFront();
}
public class graphpanel extends JPanel{
public static String data;
public graphpanel(String str)
{
int xpan = this.getWidth();
int ypan = this.getHeight();
System.out.println(xpan +" - "+ypan);
data=str;
}//graphpanel
public void paintComponent(Graphics g)
{
super.paintComponent(g);
int xpan1 = this.getWidth();
int ypan1 = this.getHeight();
System.out.println(xpan1 +" - "+ypan1);
g.drawString( data, 10, 10 );
}
Now when I run the code it will produce 2 windows (internal frames as
expected) but both will have the same content "AAAA". What did I do
wrong.
Furthermore, Iäd like to have as much time consuming code in the
graphpanel method instead of the paintComponent method, but it seems
that the witdh and height (xpan and ypan) isn't known in the moment
when graphpanel is called. I guess it is due to the fact that the
pack() in showgraph is called afterwords.
How can I resolve this issues?
.
- Prev by Date: Re: SteppedComboBox problem
- Next by Date: weird applet-display problem..
- Previous by thread: Re: Yo solo se que no se nada, pero ahora si, 7J51
- Next by thread: Re: problem with multiple internal frames for drawing different graphs
- Index(es):
Relevant Pages
|