Note that there are some explanatory texts on larger screens.

plurals
  1. POJTextArea Getting Cut Off in Swing
    primarykey
    data
    text
    <p>I'm writing a program that takes in some equations from the user. I want each constant to be entered in a <code>JTextField</code>, with each separated by a <code>JTextArea</code> (saying +x0, +x1, etc.). However, I can't quite get the formatting to work, and I'm not sure why. Here's the relevant code:</p> <pre><code>JTextField[][] dataTextFields = new JTextField[a+1][b+1]; JTextArea[][] dataLabels = new JTextArea[a][b+1]; for (int i = 0; i &lt; a+1; i++) { for (int j = 0; j &lt; b+1; j++) { dataTextFields[i][j] = new JTextField(10); dataTextFields[i][j].setLocation(5+70*i, 10+30*j); dataTextFields[i][j].setSize(40,35); dataEntryPanel.add(dataTextFields[i][j]); if (i &lt; a) { String build = "x" + Integer.toString(i) + "+"; dataLabels[i][j] = new JTextArea(build); dataLabels[i][j].setBackground(dataEntryPanel.getBackground()); dataLabels[i][j].setBounds(45+70*i,20+30*j,29,30); dataEntryPanel.add(dataLabels[i][j]); } } } </code></pre> <p>This creates <code>JTextFields</code> with <code>JTextAreas</code> 0f "+xi" in between them. However, when I run the applet, it looks like this:</p> <p><img src="https://i.stack.imgur.com/DnD7W.png" alt="enter image description here"></p> <p>I can click on the labels and bring them to the foreground, it seems, resulting in this:</p> <p><img src="https://i.stack.imgur.com/IF1E8.png" alt="enter image description here"></p> <p>I'd like for the labels to be visible without any effort from the user, obviously. Does JTextArea have some attribute that can be changed to bring this to the foreground? I'd really prefer not to add any more UI elements (panels, containers, etc). Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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