Reputation: 1727
I am trying to create JButton such as there must be a number painted on the top and right corner of JButton.
For example, in case of notification buttons there is a message in the button, how is that possible? Can the help be taken of paint method to draw the label?
Upvotes: 4
Views: 301
Reputation: 205775
Also consider implementing Icon
to decorate the button; ColorIcon
is a simple example. You can use the color to signify buttons that are likely to need attention, and you can use drawString()
specify a number.
Upvotes: 1
Reputation: 19167
JButton
and any JComponent
extend Container
class, so you should be able to add elements into JButton
as if it were a simple panel. So in your case you can add a JLabel with your text into a button.
Upvotes: 2
Reputation: 109815
there are three ways, by using
JButtton (all JComponents) is container too, there is easy and possible use standard LayoutManagers (only JFrame == BorderLayout
and JPanel == FlowLayout
have got implemented LayoutManager in API
directly), then basically everything is possible
Upvotes: 3