Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating a class JPanel inside of a JSplitPane

Status
Not open for further replies.

bnye

Programmer
May 10, 2002
5
US
Hello All,

I have a JFrame that contains a JSplitPane. In that JSplitPane I have a new class that extends JPanel ("SortedPortfolioPanel") in the leftComponent and a new class that extends JPanel ("FilterMarketPanel") in the rightComponent. In JPanel "FilterMarketPanel" I have a button that needs to send an updated ArrayList to JPanel "SortedPortfolioPanel" where that JPanel will be redrawn based on the new Info. This doesn't seem to work. The classes are initially correct, but they don't have the ability to update each other. The JTree is not being redrawn. If someone could point me in the right direction I would appreciate it. All of my bussiness logic is isolated so I can completely change my UI around if need be. In order to keep this short, only the code of the "SortedPortfolioPanel " JPanel is as follows:

Code:
public class SortedPortfolioPanel extends JPanel{

private static Portfolio tempPortfolioToSort;
private static Portfolio portfolioToSort;

public SortedPortfolioPanel(Portfolio newPortfolioToSort) {

tempPortfolioToSort = newPortfolioToSort;
createSortedPortfolioPanel(tempPortfolioToSort);
}
public void createSortedPortfolioPanel(Portfolio newPortfolioToSort) {

portfolioToSort = newPortfolioToSort;

this.setBackground(SystemColor.window);
System.out.println(portfolioToSort.getPortfolioName());

DefaultMutableTreeNode portfolioTreeRoot = new DefaultMutableTreeNode(newPortfolioToSort.getPortfolioName());

for(int x = 0; x < 19; x++) {
Stock stockForTree = new Stock();
ArrayList arrayListForTree = new ArrayList();
arrayListForTree = portfolioToSort.getStockPortfolio();
stockForTree = (Stock)arrayListForTree.get(x);
portfolioTreeRoot.add(new DefaultMutableTreeNode(stockForTree.getTicker()));
}

DefaultTreeModel portfolioTreeModel = new DefaultTreeModel(portfolioTreeRoot);
JTree portfolioTree = new JTree(portfolioTreeModel);

this.add(portfolioTree);
this.repaint();
}
}

Thanks,
bnye
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top