Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't change size of block in BorderLayout
    primarykey
    data
    text
    <p>I created simple app with Border Layout and added into it two buttons and JTable. I use JSplitPane between button2 and JTable. I would like redefine default size of block where is situated button1. How can I to solve this task?</p> <p>Here is my code:</p> <pre><code>package test; import java.awt.BorderLayout; import java.awt.Dimension; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTable; import javax.swing.SwingUtilities; public class Sample { public Sample() { JFrame app = new JFrame("Sample"); app.setSize(new Dimension(800,600)); JPanel panel = new JPanel(); app.add(panel); BorderLayout borderlayout = new BorderLayout(); panel.setLayout(borderlayout); JButton but1 = new JButton("1"); JButton but2 = new JButton("2"); but2.setMinimumSize(new Dimension(250,0)); String[] colNames = {"Name","Number","Scores"}; Object[][] data = { { "Mark",11,12}, {"Tommy",23,34}, {"John",34,45} }; JTable table = new JTable(data, colNames); JScrollPane scrollpane = new JScrollPane(table); JSplitPane jsplitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,but2,scrollpane); panel.add(but1,BorderLayout.NORTH); panel.add(jsplitpane,BorderLayout.CENTER); app.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new Sample(); } }); } } </code></pre> <p><img src="https://i.stack.imgur.com/4xQu2.jpg" alt="enter image description here"></p>
    singulars
    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