Results 1 to 2 of 2

Thread: GUI Issue

  1. #1
    Nakinsige is offline Member
    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0

    Default 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
    Java 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);
    
    		}
      
    	}
    	
    	
    
    }
    Last edited by DarrylBurke; 02-22-2012 at 10:13 AM. Reason: Fixed the code tag

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default 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: Increase Oval size by 2 every time the program is run. For the coordinates 50,50

    db
    Last edited by DarrylBurke; 02-22-2012 at 02:54 PM.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Regular Expression issue and setName() method issue
    By geforce in forum New To Java
    Replies: 2
    Last Post: 01-30-2012, 03:33 AM
  2. How do I fix this issue?
    By m4mm4l in forum New To Java
    Replies: 8
    Last Post: 11-17-2011, 03:49 AM
  3. Same issue as before....
    By hayden06f4i in forum New To Java
    Replies: 4
    Last Post: 11-08-2010, 01:49 AM
  4. nio issue
    By mawandiadeepak in forum Networking
    Replies: 2
    Last Post: 03-17-2010, 05:23 AM
  5. Issue
    By chaitu444 in forum New To Java
    Replies: 2
    Last Post: 11-06-2007, 07:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •