-
GUI Issue
Hi friends, i have an issue , I want to make JButton that will grow a circle. I have JButton in the frame using BorderLayout on the WEST side of the frame i want to link up the two so that when the JButton is clicked the circle will grow or become bigger. I have thought and reached max. Am a newbie
Code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GrowCircle extends JPanel {
int x = 225;
int y = 200;
JFrame frame;
public static void main(String[] args) {
GrowCircle g = new GrowCircle();
g.setUpScreen();
}
public void setUpScreen() {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
CircleDrawPanel drawPanel = new CircleDrawPanel();
frame.getContentPane().add(drawPanel);
frame.setVisible(true);
frame.setSize(500, 500);
JButton east = new JButton("Click me to grow the circle");
frame.getContentPane().add(BorderLayout.EAST, east);
}
class CircleDrawPanel extends JPanel {
public void paintComponent(Graphics g) {
g.setColor(Color.blue);
g.fillOval(x, y, 50, 50);
}
}
}
-
Re: GUI Issue
You didn't bother to return to the last thread you started before asking this near-identical question here. Nor did you return to the cross post you started on JavaRanch. --edit: see my remarks in the thread linked in the next paragraph.
I'm closing this thread. If you have anything to add, add it on your earlier thread: http://www.java-forums.org/new-java/...s-50-50-a.html
db