How to move text to bottom of JButton
icons, java, jbutton, layout, swing
Solution
button.setVerticalAlignment(SwingConstants.BOTTOM) will move everything (text + icon) to the bottom of the button.
If you want spacing between the text and the icon, you can use button.setIconTextGap(int distance)
Problem
I have a JButton created using the following code. ``` JButton button = new JButton ( "Document",appletRec.getIcon()) ; button.addActionListener ( this ) ; button.setOpaque ( true ) ; //changed false from true. button.setFocusPainted ( true ) ; //changed false from true. button.actAsLink ( true ) ; button.setHighlightForeground ( Color.blue ) ; button.setVerticalTextPosition ( SwingConstants.BOTTOM ) ; button.setVerticalAlignment ( SwingConstants.TOP ) ; button.setHorizontalTextPosition ( SwingConstants.CENTER ) ; ``` But my button is appearing like this I want to move the text to the bottom of the button. Any suggestion highly appreciated.