Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The basic problem is that a <code>TitledBorder</code> will not expand a component to the point where it will be big enough to display the entire text. Instead it will just truncate the text.</p> <p>The solution is to ensure the components are big enough for the text to display. I have shown this here by expanding the size of the text field, and by adding a 'full length' label in placed of the 'shortened' title.</p> <p><img src="https://i.stack.imgur.com/NQCia.png" alt="Test Size Of Gui"></p> <pre><code>import java.awt.*; import javax.swing.*; import javax.swing.border.*; class TestSizeOfGui { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JTextField account = new JTextField(10); JPanel accountPanel = new JPanel(new GridLayout()); accountPanel.add(account); accountPanel.setBorder(new TitledBorder("Account")); String[] firstDigitList = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; JLabel firstDigitListLabel = new JLabel("Leading Digit Change"); JPanel firstDigitListPanel = new JPanel(new BorderLayout(4,2)); firstDigitListPanel.add(firstDigitListLabel, BorderLayout.WEST); JComboBox firstDigitCombo = new JComboBox(firstDigitList); firstDigitListPanel.add(firstDigitCombo); firstDigitCombo.setSelectedIndex(0); firstDigitListPanel.setBorder(new TitledBorder("LDC")); JPanel panel = new JPanel(); panel.add(accountPanel); panel.add(firstDigitListPanel); int result = JOptionPane.showConfirmDialog( null, panel, "Please Enter Values", JOptionPane.OK_CANCEL_OPTION); } }); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload