Re: help with image display gui
- From: Ian Wilson <scobloke2@xxxxxxxxxxxxx>
- Date: Mon, 24 Jul 2006 11:00:09 +0100
ben.jenson@xxxxxxxxx wrote:
hi wondered if anyone can help i want to create a dummy gui which looks
like a media player eg transition window buttons etc and have created
them as jpeg can someone help me in understanding how to inport them
into jframes etc and place there positions on the grid,
can gridbag place static images.is there any tutorials to do?
I wouldn't repost the same request like this, you posted an identical request just before the weekend. I'd wait a bit longer then consider how to reformulate my request if it didn't seem to have what it takes to get any response.
I Googled for "Java drawImage".
You can position graphics without using a GridBagLayout to layout individual components each containing an image.
Image image = getToolkit().getImage(getClass().getResource("widget.jpg"));
public void paint(Graphics g) {
g.drawImage(image, 10, 30, this);
// ... draw other images at various coordinates
}
(I haven't tried the above, so I'd read the Javadocs carefully rather than blindly trying this example. I recall you need to take care when overriding paint() in this way but, since I've never done it, I don't recall the details)
Personally I don't see what doing this in Java buys you, If you really want to draw a GUI using JPEGs you might as well mock up the whole thing in photoshop.
I mock up GUIs by contructing them in Java with JButtons, JPanels, Layout Managers, etc. Just without implementing any actions. You can "skin" components with images but I've never tried that.
myButton.setIcon(defaultIcon)
myButton.setPressedIcon(pressedIcon)
http://javaalmanac.com/egs/javax.swing/button_SetIcon.html
.
- References:
- help with image display gui
- From: ben . jenson
- help with image display gui
- Prev by Date: Swing without AWT?
- Next by Date: Re: Dynamically adding components
- Previous by thread: help with image display gui
- Next by thread: Swing without AWT?
- Index(es):