This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Vertical gray patch in my JFrame? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Vertical gray patch in my JFrame?" Watch "Vertical gray patch in my JFrame?" New topic
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Vertical gray patch in my JFrame?
 
Similar Threads
paintComponent in JDesktopPane gives unexpected results when dragging
Animation in Java
cannot get the green circle to smear
full-screen gray window problem and event handling problem
painting custom components without extending jcomponent