Group: http://groups.google.com/group/jpassion_java/topics
- JFrame_AddJPanelToJFrame_JPanel_paint [1 Update]
- JFrame_AddJPanelToJFrame_JPanel_paint" sample application in Swing, Java Programming course [1 Update]
- "paint" method [1 Update]
Haichien Nguyen <haich...@gmail.com> Apr 24 01:52PM -0700
Hi there
I just want to ask about "JFrame_AddJPanelToJFrame_**JPanel_paint" sample
application in Swing, Java Programming course. There is method "paint" in
this project, which never be called anywhere in the project, but it still
being executed. I don't understand that. Please explain for me.
Best regards
Haichien Nguyen <haich...@gmail.com> Apr 24 05:41PM -0700
Hi there
I just want to ask about "JFrame_AddJPanelToJFrame_**JPanel_paint" sample
application in Swing, Java Programming course. There is method "paint" in
this project, which never be called anywhere in the project, but it still
being executed. I don't understand that. Please explain for me.
--
Best regards,
Haichien Nguyen <haich...@gmail.com> Apr 24 09:54PM -0700
Hi All
Please look at the code below and tell me why "paint" method run without
being callled? For your reference it is sample 1.3 "
JFrame_AddJPanelToJFrame_JPanel_paint " in Swing - Java programming
Thank you
=============
package mypackage;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Main extends JPanel {
Main() {
setBackground(Color.black);
}
public void paint(Graphics g) {
g.setColor(new Color(0,255,0)); //green
g.setFont(new Font("Helvetica",Font.PLAIN,16));
g.drawString("Hello GUI World!", 30, 100);
g.setColor(new Color(1.0f,0,0)); //red
g.fillRect(30, 100, 150, 10);
}
/* need to place Panel in Frame or other Window */
public static void main(String args[]) {
JFrame jFrame = new JFrame("Testing Graphics Panel");
Main gp = new Main(); // It is JPanel
jFrame.add(gp);
jFrame.setSize(600, 300);
jFrame.setVisible(true);
}
}
You received this message because you are subscribed to the Google Group jpassion_java.
--
You can post via email.
To unsubscribe from this group, send an empty message.
For more options, visit this group.
You received this message because you are subscribed to the Google Groups "JPassion.com: Java Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpassion_jav...@googlegroups.com.
Visit this group at http://groups.google.com/group/jpassion_java?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.