Button text resizing
843806Aug 26 2009 — edited Aug 26 2009Hello, [Administrator: I'm new here, so excuse me if I've misplaced this message]
My question is the following: I have this vertical JPanel containing four buttons in a column style, embedded in a JFrame likewise. The buttons have text and an image (both set with setText & setIcon JButton methods). The layout of the JPanel is TableLayout.
The matter arises when resizing the JFrame on runtime (Maximizing or resizing via mouse action). The JFrame's size increases/reduces, so does the JPanel and the four buttons within, which is all right, however the buttons' text and icon do not resize along with the buttons. What I want to know is if there is a relationship between button size and its text font size so that when the button is resized (In this case the entire JFrame) the button text font resizes in proportion as well.
The only thing I figured out is to override the Jbutton class for these four buttons and rewrite the paintComponent method. There, depending on the size of the button in a specific moment I could set the text font size and icon size in proportion (doing a bit of maths). Anyways, I do not know whether this is a nice solution or I am turning it into a shoddy work.
I would like to know your opinions before throwing myself into freaking coding.
Thanks a lot!.