how do i set background as an image with Jframe? ... and other stuff

Reply

Join Date: Oct 2006
Posts: 116
Reputation: Mr.UNOwen is an unknown quantity at this point 
Solved Threads: 0
Mr.UNOwen Mr.UNOwen is offline Offline
Junior Poster

how do i set background as an image with Jframe? ... and other stuff

 
0
  #1
Mar 11th, 2007
I'm currently creating a program with some buttons and other stuff and I was wondering how do I create a background image with jframe? I don't see any set method for it. Is the there a way to do it?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 376
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: how do i set background as an image with Jframe? ... and other stuff

 
0
  #2
Mar 11th, 2007
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 116
Reputation: Mr.UNOwen is an unknown quantity at this point 
Solved Threads: 0
Mr.UNOwen Mr.UNOwen is offline Offline
Junior Poster

Re: how do i set background as an image with Jframe? ... and other stuff

 
0
  #3
Mar 11th, 2007
Thanks for the help but now I'm pulling my hair out with another thing.... How do I properly position a button (or anything else), and have it at a locked size? Also how do I lock jframe?
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 116
Reputation: Mr.UNOwen is an unknown quantity at this point 
Solved Threads: 0
Mr.UNOwen Mr.UNOwen is offline Offline
Junior Poster

Re: how do i set background as an image with Jframe? ... and other stuff

 
0
  #4
Mar 11th, 2007
ARG!!!!!!!!!!

This is really driving me nuts.

Can some one create a simple JFrame with two buttons(One realy big, one realy small) and have one bottom left and the other upper right and have the JFrame at a size of 800x800. I know how to make the buttons work, so listeners are not needed. I just need to see how to size and position things.

I tried using the Borderlayout with no succss. I tried add(button, BorderLayout.SOUTH) but it still goes north.

Please help me......
Last edited by Mr.UNOwen; Mar 11th, 2007 at 6:00 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 871
Reputation: vinod_javas is an unknown quantity at this point 
Solved Threads: 7
vinod_javas's Avatar
vinod_javas vinod_javas is offline Offline
Practically a Posting Shark

Re: how do i set background as an image with Jframe? ... and other stuff

 
0
  #5
Mar 12th, 2007
Originally Posted by Mr.UNOwen View Post
Thanks for the help but now I'm pulling my hair out with another thing.... How do I properly position a button (or anything else), and have it at a locked size? Also how do I lock jframe?
I have given you simple code to positioning a button ok just look at this one..


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class a extends JFrame
{
// Variables declaration
private JButton jButton1;
private JPanel contentPane;
// End of variables declaration

public a()
{
super();
initializeComponent();
this.setVisible(true);
}


private void initializeComponent()
{
jButton1 = new JButton();
contentPane = (JPanel)this.getContentPane();


jButton1.setBackground(new Color(182, 169, 92));
jButton1.setText("jButton1");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}

});

contentPane.setLayout(null);
addComponent(contentPane, jButton1, 140,107,83,28);

this.setTitle("a - extends JFrame");
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(390, 300));
}

private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}

private void jButton1_actionPerformed(ActionEvent e)
{
System.out.println("\njButton1_actionPerformed(ActionEvent e) called.");

}


` public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch (Exception ex)
{
System.out.println("Failed loading L&F: ");
System.out.println(ex);
}
new a();
}

}
Adios,

Vinod......
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 871
Reputation: vinod_javas is an unknown quantity at this point 
Solved Threads: 7
vinod_javas's Avatar
vinod_javas vinod_javas is offline Offline
Practically a Posting Shark

Re: how do i set background as an image with Jframe? ... and other stuff

 
0
  #6
Mar 12th, 2007
addComponent(contentPane, jButton1, 140,107,83,28);


by changing these four values 140,107,83,28

you can change the position and size of the button
Adios,

Vinod......
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC