Frage

I currently have a JDialog (class that implements JDialog and is constructed like a jframe), and has 3 swing buttons placed on it. Currently I have it set, undecorated = true, to hide the outer frame. Is there any way to use my image to replace the default square frame?

This is what I aim for :

http://i.stack.imgur.com/6w9kh.jpg

The blue square with shadow is the pre made image.

Regards

War es hilfreich?

Lösung

The blue square with shadow is the pre made image.

Well, the best way would be to set the background of the panel and then add a ShadowBorder to the panel. This will provide you with far more flexibility in the future as you can create many panels with different colors and reuse the same ShadowBorder instead of having to create an Image every time. I don't have an example of a ShadowBorder, but you might find one if you search the web.

Is there any way to use my image to replace the default square frame?

But if you really want to use your premade Image, then you can just:

  1. create a JLabel and add your Image to the label as an Icon
  2. add the label to the dialog
  3. set the layout manager of the label
  4. add your components to the label.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top