Note that there are some explanatory texts on larger screens.

plurals
  1. POAutomatic resizing (JTextArea and JTabbedPane) instead of fixed layout
    primarykey
    data
    text
    <p>I make my first baby steps in Java and Swing GUI. My plan is to make a little GUI with an JTextArea to fill in some text and two tabbed JPanels. But the problem is, when I fill in some text in the JTextArea and click the tab "Includes" (or the other tab "Functions"), it resizes the tabmenu (It should have a fixed 50:50 view).</p> <p>Here are some pictures for a better understanding:</p> <p><img src="https://i.stack.imgur.com/t5pIh.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/1xfHn.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/VdNRl.png" alt="enter image description here"></p> <p>Here is the Java code:</p> <pre><code>import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTabbedPane; import javax.swing.JTextArea; public class Editor extends JFrame { private static final long serialVersionUID = 1L; public static void main(String[] args) { Editor editor = new Editor(); } private JTextArea guiEdit = new JTextArea(); private JScrollPane utilScrollbar = new JScrollPane(guiEdit); private JTabbedPane guiOverviewTabPanel = new JTabbedPane(); private JPanel guiOverviewTabIncludes = new JPanel(); private JPanel guiOverviewTabFunctions = new JPanel(); public Editor() { // Set layout GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridbag); // Add the textfield c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 0; c.gridheight = 1; c.weightx = 1.0; c.weighty = 1.0; c.anchor = GridBagConstraints.WEST; add(utilScrollbar, c); // Add tabs to the JTabbedPane guiOverviewTabPanel.add("Includes", guiOverviewTabIncludes); guiOverviewTabPanel.add("Functions", guiOverviewTabFunctions); // Add the JTabbedPane c.fill = GridBagConstraints.BOTH; c.gridx = 1; c.gridy = 0; c.gridheight = 1; c.weightx = 1.0; c.weighty = 1.0; c.anchor = GridBagConstraints.EAST; add(guiOverviewTabPanel, c); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH); this.setMinimumSize(new Dimension(800, 400)); setVisible(true); } } </code></pre> <p>Does anyone know a way/solution to fix this perspective. The real ratio ist 5:2 (5 parts JTextArea and 2 parts JTabbedPane - this is just for a better understanding, so I can't use a GridLayout</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.
    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