Is there a way I can define my own font and color schemes for Text1 AND Text2 text within the setBorder method. New to java and cannot find it in the SUN tutorials.
My code
//Create Positions Table
JPanel SpreadPanel = new JPanel();
SpreadPanel.setBorder(BorderFactory.createTitledBorder(" Text 1 Text 2"));
Regards Simon
setBorder(BorderFactory.createTitledBorder(null, "text", TitledBorder.CENTER, TitledBorder.BOTTOM, new Font("times new roman",Font.PLAIN,12), Color.yellow));
the first parameter null or another border (for compound borders) 2nd param text that you're displaying 3rd and 4th param justification and location of the text from param 2
4th param and 5th param are the two to set font and color
If you want a different font and color for each of the strings (e.g. Text1
and Text2
) in the same TitledBorder
, you may be need to extend AbstractBorder
and override paintBorder()
. The existing implementation only has one font and one color for a single title.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With