I am having a problem with setting JButtons so the are not opaque to i can
see the image behind them.

I also have a JTextfield and here it is working, I dont know what i am doing wrong,

I'm creating a gui for the mainmenu of my game.

here is the code for my JText field, works perfect, I can see stuff through it.

T1 = new JTextField ("Enter Player-name Here");
        T1.setToolTipText ("Enter Player-name Here");
        T1.setFont (new Font ("Arial", Font.PLAIN, 18));
        T1.setBorder (compoundmain);
        T1.setOpaque (false);
        T1.setBounds (400, 220, 200, 30);
        infoPane.add (T1);

Here is the code to my Jbuttons, but i just see the plain originel gray behind the text,
but i should see the image behind the JButton

B1 = new JButton ("Play");
        B1.setFont (new Font ("Arial", Font.BOLD, 18));
        B1.setBorder (compoundmain);
        B1.setOpaque (false);
        B1.setBounds (400, 170, 200, 30);
        B1.addActionListener (this);
        infoPane.add (B1);

        B2 = new JButton ("Quit");
        B2.setFont (new Font ("Arial", Font.BOLD, 18));
        B2.setBorder (compoundmain);
        B2.setOpaque (false);
        B2.setBounds (400, 270, 200, 30);
        B2.addActionListener (this);
        infoPane.add (B2);

What am i doing wrong, everthing works perfect, action listener works perfect, just the set.Opague is not working?...

I've just figured somthing out, if you click on the Jbutton, move your mouse away from it, then it becomes clear, or not opaque, whatever you want to call it, but as soon as you release the click, it reverts back to original state... with the default gray behind text

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.