Results 1 to 8 of 8
Like Tree1Likes
  • 1 Post By KevinWorkman

Thread: Background and tabbed pane

  1. #1
    heman is offline Member
    Join Date
    Aug 2012
    Posts
    39
    Rep Power
    0

    Default Background and tabbed pane

    hello everyone,

    I am making a simple program in Swing.
    I wish to use buttons and combobox in frame,with a custom background image.
    The problem is that,either the "image" is showed up or the "buttons and combobox".
    PLease help me out,so that buttons and combobox are shown on custom image.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: Background and tabbed pane

    I recommend putting together an SSCCE that shows us exactly what the problem is, in as few lines as possible.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    heman is offline Member
    Join Date
    Aug 2012
    Posts
    39
    Rep Power
    0

    Default Re: Background and tabbed pane

    Here is my code:

    I wish to substitute the green Color of frame by a image.What should i do for it.The textfield should also be visible.



    Java Code:
    import javax.swing.*;import java.awt.*;
    class Back extends JFrame
    {
    	public Back(String s)
    	{
    		super(s);
    		setSize(400,400);
    		setLayout(null);
    
    
    		JTextField tf=new JTextField(20);
    		tf.setBounds(30,30,80,30);
    		add(tf);
    
    
    		getContentPane().setBackground(Color.green);
    
    
    	setVisible(true);
    	}
    
    
    	public static void main(String arg[])
    	{
    		new Back("image test");
    	}	
    
    
    }

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: Background and tabbed pane

    If I were you, I'd extend JPanel and override paintComponent() and draw your background image in there. Then just add whatever else you want to the JPanel.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    heman is offline Member
    Join Date
    Aug 2012
    Posts
    39
    Rep Power
    0

    Default Re: Background and tabbed pane

    I am new to java,could you please write a line of code to make me understand.
    thanks for reply

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,839
    Rep Power
    8

    Default Re: Background and tabbed pane

    DarrylBurke likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    heman is offline Member
    Join Date
    Aug 2012
    Posts
    39
    Rep Power
    0

    Default Re: Background and tabbed pane

    thanks for the link,i will go through it and get back again.

  8. #8
    heman is offline Member
    Join Date
    Aug 2012
    Posts
    39
    Rep Power
    0

    Default Re: Background and tabbed pane

    Quote Originally Posted by KevinWorkman View Post
    If I were you, I'd extend JPanel and override paintComponent() and draw your background image in there. Then just add whatever else you want to the JPanel.
    Thanks to you, my problem is solved..

Similar Threads

  1. Controls on a tabbed pane
    By taman in forum New To Java
    Replies: 2
    Last Post: 03-03-2012, 01:52 AM
  2. Tabbed pane problem
    By franco in forum NetBeans
    Replies: 5
    Last Post: 10-23-2011, 08:38 PM
  3. Tabbed pane
    By sonal12 in forum AWT / Swing
    Replies: 13
    Last Post: 09-15-2010, 12:22 AM
  4. tabbed Pane .
    By programmer_007 in forum AWT / Swing
    Replies: 2
    Last Post: 09-03-2009, 08:52 PM
  5. JTree and Tabbed Pane
    By paluee in forum AWT / Swing
    Replies: 1
    Last Post: 03-30-2009, 06:03 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
  •