| Author |
Vertical gray patch in my JFrame?
|
Roshni Singhania
Ranch Hand
Joined: Mar 11, 2007
Posts: 78
|
|
Hi, I've learned Java, but that was two years ago... Now I'm back to it and I've reached Swing components. I have a small problem here. I wrote some programs, which are working fine, except for one vertical gray patch at the right side of the frame/panel. I think it's something probably really small, but I can't figure it out since I'm touching Swing after two years. Can someone please point out to what I'm doing wrong. It's just a small code to display a circle. The circle is displayed, but there's this path next to it. I'm not understanding what it is... it seems like a part of the frame or panel. Please help me solve the problem, I'll really appreciate it! Here's the code - import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Face { JFrame frame1 = new JFrame("Smile Please!"); void go() { FacePanel face1 = new FacePanel(); frame1.getContentPane().add(face1); frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame1.setSize(500, 500); frame1.setVisible(true); } public static void main(String[] str) { new Face().go(); } class FacePanel extends JPanel { public void paintComponent(Graphics g) { g.setColor(Color.WHITE); g.fillRect(0, 0, this.getHeight(), this.getWidth()); g.setColor(Color.BLACK); g.drawOval(50, 50, 450, 450); } } }
|
 |
Nathan Pruett
Bartender
Joined: Oct 18, 2000
Posts: 4121
|
|
The method is : Graphics.fillRect(x0, y0, x1, y1) You have : It should be :
|
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
|
 |
Roshni Singhania
Ranch Hand
Joined: Mar 11, 2007
Posts: 78
|
|
Oh dear!I knew I was making some silly mistake in that code! Thank you so much for pointing it out. Thanks a ton! Have a nice day.
|
 |
 |
|
|
subject: Vertical gray patch in my JFrame?
|
|
|