Results 1 to 4 of 4
  1. #1
    such orb is offline Member
    Join Date
    Mar 2012
    Posts
    24
    Rep Power
    0

    Default how to use the Component command

    i am about to start writing a gui game using java swing... i want to use the Component command, but, cannot get it to work.

    here's some code:

    Java Code:
    Component thing1 = GuiTwo.drawpanel();
    System.out.println(thing1);
    			
    thing1.isFocusable();
    thing1.setFocusable(true);
    thing1.setEnabled(true);
    thing1.getBackground();
    
    Rectangle sizeone = thing1.getBounds();
    System.out.println(sizeone);
    			
    thing1.setVisible(true);
    				
    thing1.setBackground(Color.BLUE);
    thing1.validate();
    thing1.repaint();
    some more code:

    Java Code:
    public class GuiTwo extends JPanel {
    
    	public static Component drawpanel() {
    				
    		JPanel panel = new JPanel();
    
    		panel.requestFocusInWindow();
    		
    		panel.getRootPane();
    		
    		Color mycolor = new Color(10,10,10);
    		
    		panel.setBackground(mycolor);
    		
    		Dimension d1 = new Dimension(400, 460);
    		panel.setSize(d1);
    		panel.setLocation(20, 520);
    		panel.setPreferredSize(d1);
    
    		panel.validate();
    		panel.setLayout(null);
    		panel.setVisible(true);
    		panel.setFocusable(true);
    		panel.validate();
    		panel.repaint();
    		
    		panel.revalidate();
    		
    		return panel;
    the code returns the value of the variable sizeone ok. but, that is all that happens. can you help me?

    thanks!

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

    Default Re: how to use the Component command

    Java doesn't have commands, so it's not clear what your question is.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    such orb is offline Member
    Join Date
    Mar 2012
    Posts
    24
    Rep Power
    0

    Default Re: how to use the Component command

    ok, i am trying to get the *funcionality* of Component to work... i guess i need a few pointers.

    thx

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

    Default Re: how to use the Component command

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Calling methods of a component from a different component
    By Mate de Vita in forum AWT / Swing
    Replies: 0
    Last Post: 10-26-2012, 08:15 PM
  2. What's the name of the component that...?
    By balla in forum AWT / Swing
    Replies: 1
    Last Post: 07-06-2011, 03:03 AM
  3. Letting my program command the command prompt
    By Smokey. in forum Threads and Synchronization
    Replies: 4
    Last Post: 03-29-2011, 11:34 PM
  4. Component to use ?
    By pbaudru in forum AWT / Swing
    Replies: 2
    Last Post: 02-17-2010, 09:55 AM
  5. Unable to execute command line command in java
    By LordSM in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 12:23 AM

Posting Permissions

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