 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Tux Guest
|
Posted: Sun Nov 14, 2004 3:04 pm Post subject: Picture in a JFrame? |
|
|
i want to make "welcome screen" for my application, with a few buttons and a
jpg picture in a background.
How to put that background picture in a JFrame ?
|
|
| Back to top |
|
 |
Andrew Thompson Guest
|
Posted: Sun Nov 14, 2004 3:39 pm Post subject: Re: Picture in a JFrame? |
|
|
On Sun, 14 Nov 2004 16:04:34 +0100, Tux wrote:
| Quote: | i want to make "welcome screen" ..
|
A 'splash screen'?
| Quote: | ..for my application, with a few buttons ..
|
Though splash screens usually have no buttons or
other focusable elements. They simply show an image
either for a predetermined time, or until the main GUI
is ready to be displayed.
| Quote: | ...and a jpg picture in a background.
|
JLabels can display an image.
| Quote: | How to put that background picture in a JFrame ?
|
If you are actually speaking of a splash screen, you would
do it slightly differently to what you described.
Is this a splash screen? What is the nature of the buttons
and other elements you want to add to it - what do they do?
--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
|
|
| Back to top |
|
 |
Tux Guest
|
Posted: Mon Nov 15, 2004 5:36 pm Post subject: Re: Picture in a JFrame? |
|
|
Andrew Thompson wrote:
| Quote: | On Sun, 14 Nov 2004 16:04:34 +0100, Tux wrote:
i want to make "welcome screen" ..
A 'splash screen'?
..for my application, with a few buttons ..
Though splash screens usually have no buttons or
other focusable elements. They simply show an image
either for a predetermined time, or until the main GUI
is ready to be displayed.
...and a jpg picture in a background.
JLabels can display an image.
How to put that background picture in a JFrame ?
If you are actually speaking of a splash screen, you would
do it slightly differently to what you described.
Is this a splash screen? What is the nature of the buttons
and other elements you want to add to it - what do they do?
|
Actually I need main menu with a buttons:
- New file
- Open file
- Exit
but little prettier than grey background JPanel, so I think that some
texture (jpg for example) in background will be just fine.
I already put pictures on a buttons.
|
|
| Back to top |
|
 |
Daniel Guest
|
Posted: Mon Nov 15, 2004 7:14 pm Post subject: Re: Picture in a JFrame? |
|
|
<SNIP>
| Quote: | Actually I need main menu with a buttons:
- New file
- Open file
- Exit
but little prettier than grey background JPanel, so I think that some
texture (jpg for example) in background will be just fine.
I already put pictures on a buttons.
|
to put a jpeg in there are a few ways to do, one easy way is to make a
JLabel with that has you image and nothing else like this:
JLabel title = new JLabel(new
ImageIcon("C:\pathl\to\image\title.jpg"));
and then you just add this label to your JPanel in the normal way.
To add a menu you would have to do something along these lines:
JMenuBar mb = new JMenuBar();
JMenu fmenu = new JMenu(" File ");
JMenuItem fnew = new JMenuItem("New filet");
JMenuItem fopen = new JMenuItem("Open file");
JMenuItem fexit = new JMenuItem("exit");
and then in your constructor (or whereever you find it fit) you need
to do this
myframe.setJMenuBar(mb); // on the frame you want the menu on.
// add the menu items
mb.add(fmenu);
fmenu.add(fnew);
fmenu.add(fopen);
fmenu.addSeparator(); /* if you want a line between your options,
looks nice but it not needed */
fmenu.add(fexit);
there you go. take a look at the examples given in the swing tuturial
as they are generally good.
/daniel
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|