Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / June 2005

Tip: Looking for answers? Try searching our database.

button on image

Thread view: 
gbruno - 08 Jun 2005 08:26 GMT
How do I put 5 buttons on top of an image?

If I try  JBuilders XYConstraints I can only put a limit of 2 buttons
on top of an image... there is evidently a scarce suply of
XYconstraints

If I set button constraints to Rectangles the image is greyed out to
the bottom right of the lowest button.  Aint that sad.

Over in the Sun forum, in 2004,
[http://forum.java.sun.com/thread.jspa?forumID=5&threadID=494487
]a fellow asked a similar question, got a detailed program (which
doesnt compile) but which if it could run, would  put the image in a
North panle and the buttons in an East panel.

This precisely does NOT answer the question.

Evidently the java gods  never envisioned buttons ON TOP of the image.
.. Or is there a way???
Thomas Weidenfeller - 08 Jun 2005 08:57 GMT
> How do I put 5 buttons on top of an image?

Mixing graphics with Components is not really a good idea in Java
(equivalent to Q8.6 of the FAQ). Consider another approach, like drawing
 some kind of buttons with the 2D API and handling your own mouse events.

If you really want buttons, then start with learning the layout
managers. You are apparently missing the basics: Getting buttons on a
JPanel where you want them. Getting a background image is the second,
not the first step, and you already fail the first one.

> If I set button constraints to Rectangles the image is greyed out to
> the bottom right of the lowest button.  Aint that sad.

No, you mixed up the painting. Please spend some time and make yourself
familiar with the Swing architecture and the AWT/Swing painting model,
particularly the handling of transparency. Sun's TSC articles about this
subjects are a good start.

> Over in the Sun forum, in 2004,
> [http://forum.java.sun.com/thread.jspa?forumID=5&threadID=494487
[quoted text clipped - 3 lines]
>
> This precisely does NOT answer the question.

Well, then you might want to work on your asking style. Do you think it
is easy to make sense of your sentence like:

> Because the image takes time to load up when it loads up the image
loads on top of the buttons rather than being below.

> Evidently the java gods  never envisioned buttons ON TOP of the image.
>  .. Or is there a way???

It is a piece of cake - *if you know the basics*

/Thomas

Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq

Michael Rauscher - 08 Jun 2005 10:06 GMT
gbruno schrieb:
> How do I put 5 buttons on top of an image?

Not at all.

[...]

> Evidently the java gods  never envisioned buttons ON TOP of the image.

Evidently you never envisioned to start learning the basics - SCNR.

>  .. Or is there a way???

What you want (or what I think you want) is a panel that is able to
display an image in the background:

class IconPanel extends JPanel {
    private Icon icon;

    public void setIcon( Icon icon ) {
        this.icon = icon;
        repaint();
    }

    public void paintComponent( Graphics g ) {
        super.paintComponent(g);

        if ( icon != null )
            icon.paintIcon( this, g, 0, 0 );
    }
}

Bye
Michael
gbruno - 09 Jun 2005 02:35 GMT
Yes, IconPanel does look like the solution.
Thanks for prompt replies, I can handle the abuse if it means such
prompt replies.  (Ask in the afternoon in Sydney, get the answer in the
next morning,)

btw its  conflicting to get abused by 2 respondents who offer mutually
exclusive solutions.    One lot of abuse must be right up itself.
gbruno - 09 Jun 2005 03:38 GMT
yes IconPanel works.
Although I'm from Wellington, and spent yers drinking in the Gluepot in
Ponsonby Road, I promise not to throw the phone at you.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.