Reputation: 81
I want to achieve a effect that i can add JComponents to a given component's (maybe a JLable)border,like picture below
I try to solve it by custom a border,and the dot is draw as a image but not a component.Before works
But this time I want to turn the dot as an JComponent which can be attached to border.So,How could I achieve this?
Upvotes: 0
Views: 87
Reputation: 324118
Check out Component Border.
It allows you to create a Border that contains a component. You can control the location of the component within the Border and it will manage all the insets of the border.
Upvotes: 1
Reputation: 6307
It looks like you didn't have much luck with your other question, so I suggest that this time you make a special container to manage this.
Here is an example image (not to scale):
First make a jPanel
to store and manage everything. Then you can add a jLabel
in the middle, and then add your custom jComponent
inside the container in the border space.
Then just make sure everything is the right size and sits in the right position and has the correct icons, and then it will look exactly the way you want like shown in your drawing.
Edit: Note that you don't actually need to add a border to the jPanel
, the image is just showing where the jComponent
might sit. You will probably want to set the jPanel
background to be transparent.
Upvotes: 1