久しぶりの潜伏者、二度目のポスター (それは絶望的です)
12 個のコンポーネントを並べて表示する必要があるフレームがあります (各コンポーネントが独自の列であるかのように)。最初のコンポーネントは属性名のリストで、2 番目のコンポーネントはデフォルトの属性を示し、次の 10 個はすべてデータベースから取得されます。スクロール バーで最初の 2 つのコンポーネントを効果的に「フリーズ」し (つまり、最初の 2 つのコンポーネントを常に表示する)、スクロール バーで残りのエントリを確認できるようにしたいと考えています。これは、列を固定する Excel に似ています。
テーブルの使用を検討しましたが、問題はコンポーネントが単なるテキストではないことです。画像などもあります。
これが私が使用しているコードの一部です
JPanel info = new JPanel(); // this is the main component (holds the other 12)
info.setLayout(new GridBagLayout()); // GridBag Layoout
info.add(attNames); // add in the attribute names component
info.add(currentCase); // add in the default values
JPanel rets = new JPanel(); // add in the ten retrieved cases
rets.setLayout(new GridLayout(1,10));
for (int i=0;i<maxCases;i++)
{
rets.add(retCase[i]);
}
info.add(rets); // add the return cases to the info component
JScrollPane scrollBar2=new JScrollPane(rets,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); // surround the return cases with a scroll bar
info.add(scrollBar2); // add the scrollbar
//add the info comp to the content pane along with other necessary components
this.getContentPane().add(casesPanel, BorderLayout.NORTH);
this.getContentPane().add(info, BorderLayout.CENTER);
this.getContentPane().add(buttons, BorderLayout.SOUTH);
//finally, add the overall scrollbars and set the size
this.pack();
JScrollPane scrollBar=new JScrollPane(info,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
this.setSize(this.getWidth(), 750);
this.setResizable(true);
this.add(scrollBar);
問題は、返されたケースのスクロール バーが必要とは考えず、大きなスクロール バーを使用する必要があることです。つまり、最初の 2 つのコンポーネントから離れることができます。
どんな助けでも大歓迎です!!
ここに問題があります
乾杯、K