我只是不能让它以我想要的方式出现,我已经筋疲力尽了尝试gridlayout,gridbaglayout,borderlayout等......
我需要帮助
这是我到目前为止所做的事情
panneauEst = new JPanel(new BorderLayout());
zoneTexte = new JTextArea("LIVRES", 45, 50);
scroller= new JScrollPane(zoneTexte);
scroller.setPreferredSize(new Dimension(600, 580));
scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
EcouteurBoutons btnEcouteur = new EcouteurBoutons();
btnTrierCote = new JButton("Trier par cote");
btnTrierCote.addActionListener(btnEcouteur);
btnTrierTitre = new JButton("Trier par titre");
btnRechercheCote = new JButton("Rechercher par cote");
btnRechercheTitre = new JButton("Rechercher par titre");
btnFusion = new JButton("Fusion");
btnQuitter = new JButton("Quitter");
panneauEst.add(scroller);
//http://stackoverflow.com/questions/15104630/java-swing-gridlayout-issue
this.setLayout(new GridLayout(6, 2));
this.add(panneauEst);
this.add(btnTrierCote);
this.add(btnTrierTitre);
this.add(btnRechercheCote);
this.add(btnRechercheTitre);
this.add(btnFusion);
this.add(btnQuitter);
答案 0 :(得分:1)
您需要使用复合容器/布局
从3个容器开始。父容器,JScrollPane
/ JTable
和类似JPanel
BorderLayout
。添加
JScrollPane
/ JTable
CENTER
位于add(scrollPane, BorderLayout.CENTER);
位置JPanel
GridLayout(0, 1)
并将其布局设置为EAST
add(buttonPanel, BorderLayout.EAST)
位置... {{1}}