Note that there are some explanatory texts on larger screens.

plurals
  1. POForce fixed size JScrollPane in DesignGridLayout
    primarykey
    data
    text
    <p>I want to display JTextArea with 2 visible row and 30 visible column.</p> <p>package testing;</p> <pre><code>import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.JComboBox; import javax.swing.JDesktopPane; import javax.swing.JFrame; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSeparator; import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.JTextField; import net.java.dev.designgridlayout.DesignGridLayout; /** * * @author Denni */ public class TestWindow extends JFrame { public TestWindow() { this.setPreferredSize(new Dimension(700, 600)); this.setDefaultCloseOperation(EXIT_ON_CLOSE); JDesktopPane desktopPane = new JDesktopPane(); this.getContentPane().add(desktopPane); ModifyFrame modifyFrame = new ModifyFrame(); modifyFrame.pack(); modifyFrame.setVisible(true); desktopPane.add(modifyFrame); this.pack(); } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new TestWindow().setVisible(true); } }); } class ModifyFrame extends JInternalFrame { private JTabbedPane tabPane; private JPanel panel; private JComboBox jcb; private JTextArea jta; private JTextField jtf1; private JTextField jtf2; private JTextField jtf3; public ModifyFrame() { super("Testting", true, true, true); initComponents(); } private void initComponents() { this.setPreferredSize(new Dimension(600,450)); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); tabPane = new JTabbedPane(); this.getContentPane().add(BorderLayout.CENTER, tabPane); panel = new JPanel(); jta = new JTextArea(2, 30); Dimension d = jta.getPreferredSize(); jcb = new JComboBox(); jtf1 = new JTextField(); jtf2 = new JTextField(); jtf3 = new JTextField(); JScrollPane tmp = new JScrollPane(); tmp.setPreferredSize(d); tmp.setSize(d); tmp.setMaximumSize(d); tmp.getViewport().add(jta); DesignGridLayout layout = new DesignGridLayout(panel); layout.disableSmartVerticalResize(); layout.row().grid().empty().grid(new JLabel("Testing")).add(new JSeparator()); layout.row().grid(new JLabel("jtf1")).add(jtf1).grid(new JLabel("jta")).add(tmp); layout.row().grid(new JLabel("jtf2")).add(jtf2).grid().spanRow(); layout.row().grid(new JLabel("jtf3")).add(jtf3).grid(new JLabel("jcb")).add(jcb); this.getContentPane().add(tabPane); tabPane.add("Tab ", panel); } } } </code></pre> <p>With those codes, I can't make my jta viewed with 2 row and 30 column size. The JScrollPane always resize itself to more than 10rows and 50column size. But if I don't put the jta into JScrollPane, it can view with exact 2 row and 30 column size!</p> <p>How to force the JScrollPane to obey the size?</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