Results 1 to 4 of 4
  1. #1
    Mr U is offline Member
    Join Date
    Sep 2012
    Posts
    11
    Rep Power
    0

    Default Adding a Background image?

    Hey, I'm trying to add in a background image and I'm unsure on how to do
    My code starts out like this if more info is needed let me know. Thanks!
    Java Code:
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Random;
    import javax.swing.*;
    
    
    public class App extends JApplet
    
    
    
    {
    	String Val;
    	String[] brand = { "Arc Keyboard","Arc Mouse"};
    	JLabel label = new JLabel("Select a brand");
    	JButton button = new JButton("Generate");
    	JComboBox brands = new JComboBox(brand);
    	JPanel panel = new JPanel();
    	JTextField box = new JTextField("           " + Val);
    	public void init()
    	
    	{
    		JFrame window = new JFrame();		
    		setSize(200, 100);
    		BuildPanel();
    		add(panel);
     
    	}

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Adding a Background image?

    Moved from New to Java.

    Go through this Tutorial Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    Why does your class extend JApplet and create a JFrame? Are you creating an Applet or a desktop application? Do you know the difference?

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

  3. #3
    Mr U is offline Member
    Join Date
    Sep 2012
    Posts
    11
    Rep Power
    0

    Default Re: Adding a Background image?

    Quote Originally Posted by DarrylBurke View Post
    Moved from New to Java.

    Go through this Tutorial Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    Why does your class extend JApplet and create a JFrame? Are you creating an Applet or a desktop application? Do you know the difference?

    db
    This is an applet, It will be going up on a website.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Adding a Background image?

    Quote Originally Posted by Mr U View Post
    This is an applet, It will be going up on a website.
    Then you'll likely want to delete the line where you create a new JFrame. It's unnecessary and may be a little misleading.

Similar Threads

  1. use image for background
    By tony_stark in forum AWT / Swing
    Replies: 1
    Last Post: 05-31-2011, 09:20 PM
  2. Adding image in background
    By nayanjyoti in forum New To Java
    Replies: 1
    Last Post: 04-26-2011, 12:47 PM
  3. Adding JButton to JFrame with background
    By bzknight in forum AWT / Swing
    Replies: 1
    Last Post: 01-19-2011, 07:55 PM
  4. adding background image to jtabbedpane
    By Gloomy in forum AWT / Swing
    Replies: 1
    Last Post: 08-09-2010, 03:17 PM
  5. Image as background
    By Java.child in forum AWT / Swing
    Replies: 2
    Last Post: 10-03-2008, 12:37 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
  •