Setting different sizes of text for buttons


#1

Hi, I have a screen and I need 3 different sizes of text for the buttons.

Is the only way to do this to create 3 LAFs and apply the appropriate LAF to each button?

thx


#2

getTextButtonFont() gets a reference to the button… where it can get the text size for your TextButton derived Component.

Rail


#3

Hi thx - yes, I was trying to find a solution without having to derive a new class, but looks like I need to do that. thx


#4

The only other option I can think of for you otherwise is to use the TextButton text for the L&F getTextButtonFont() to know which button it is and you can have a switch for the text size… but it’s not a great (or elegant) solution.

Rail


#5

Hi - agreed - already considered and junked that one :). I guess deriving a new class to add a size member isn’t that onerous…


#6

The other option is using the getProperties() method of the Component class, you could set a property called fontSize and read it in your L&F?


#7

hi, nice idea, thx!