プログラムのアカウント名を表示する必要があり、JScrollPane 内で JTree を使用して表示したいと考えています。
これが私のコードです:
public void loadAccounts() {
accountsRoot = new DefaultMutableTreeNode("Accounts"); //create root
accountsRoot.add(new DefaultMutableTreeNode("Fred")); //add one element
//for testing
accounts = new JTree(accountsRoot);
accountsPane = new JScrollPane(accounts);
accountsPane.add(accounts); //don't think this is necessary
canvas.add(accountsPane);
accounts.setBounds(0, 0, accountsPane.getWidth(), accountsPane.getHeight());
accountsPane.setBounds(460, 270, 240, 410);
accounts.setVisible(true);
accountsPane.setVisible(true);
}
レイアウトを使用していないため、境界を手動で設定しました。
見せてもらえないみたいです。私は最終的にアカウントをしばらくロードすることになりたいので、JTree はそのためにはかなり簡単だと思います。