I am trying to put a two-line piece of text in JButton; eg.
+----------+ | READER | | STOP | +----------+
But I had trouble concentrating on the button. Go to the property editor for JButton and enter <html><center>READER<br>STOP for the text property. This causes the two words to be centered relative to each other, but together they still appear offset to the right side of the button’s face, as in:
+----------+ | READER| | STOP | +----------+
There are also horizontal and vertical alignment and text position properties that I set for CENTER, but this does not have any effect that I can see.
EDIT: here is an illustration of how it is presented when I completely omit <center> , in case someone confuses my description that "READER and STOP are left-justified with respect to each other, on the button":
+----------+ | READER| | STOP | +----------+
EDIT: here is the code generated by NetBeans:
readerStopButton_.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.light")); readerStopButton_.setFont(new java.awt.Font("Geneva", 0, 12)); // NOI18N readerStopButton_.setText("<html><center>READER<br>STOP</center></html>\n"); readerStopButton_.setToolTipText("<html><b>Stop</b> button is currently inactive. "); readerStopButton_.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); readerStopButton_.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { readerStopButton_ActionPerformed(evt); } }); operationButtons_.add(readerStopButton_);
EDIT: Here's a screen capture of how the button looks at me. I don’t know much about layouts, so it’s quite possible that I am omitting some important information. But basically, I let NetBeans do all the work except for the provision of HTML text.
EDIT: Set a replacement screenshot showing all buttons. Note that those that do not use HTML (single-word) are correctly aligned, and those that use HTML are confused.

source share