java - How do I set the font size of the text on a swing jButton to the maximum size who fits the jButton -
i've got jpanel jbutton, , user can define size of jpanel when launching application using parameters, jbutton sizes according jpanel.
the problem when use fixed font , panel large, font looks small, , vica versa.
so font size should maximum font size fits in button.
not sure, might find size using graphics.getfontmetrics() method inside paintcomponent-method? maybe can use fontmetrics.getstringbounds() methods , test if button contains rectangle (rectangularshape.contains()).
you use binary search algorithm find max font.
make sure take insets account.
Comments
Post a Comment