-4

これを希望どおりに表示することはできません.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);
4

1 に答える 1

1

複合コンテナ/レイアウトを使用する必要があります

3つのコンテナから始めます。親コンテナ、JScrollPane/JTableのようなものJPanel

  • 親コンテナーのレイアウトを に設定しBorderLayoutます。JScrollPane位置に/JTableを追加し CENTERます...add(scrollPane, BorderLayout.CENTER);
  • 新しいものを作成し、そのJPanelレイアウトをに設定しますGridLayout(0, 1)
  • このパネルにボタンを追加します
  • このパネルをEAST親コンテナの位置に追加...add(buttonPanel, BorderLayout.EAST)
于 2013-02-27T05:20:53.427 に答える