|
|
|
|
![]() ![]() |
Dec 18 2005, 07:57 PM
Post
#1
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 407 Joined: 13-December 04 Member No.: 2,696 |
I am using a frame a triple times, I mean, i want to use the same JFrame to display 3 different setup's of components in a sequencial way. First i as for to select drives, second i display a progressreport, last, user select a certificatedirectory. I am using getContentPane().removeAll() and then i add the new components but this doesn't show. The frame reamins blank after the first removeAll(). Is there some trick.??? Code follows...
CODE class ScanForCertificateStore extends JFrame { FindCertificates fc; ScanForCertificateStore sfcs=this; DefaultListModel lmRoot = new DefaultListModel(); JList lbRoot = new JList(lmRoot); JScrollPane spRoot = new JScrollPane(lbRoot); JButton bStartScan = new JButton("Start Scan of Selected "); File[] Roots; public ScanForCertificateStore (FindCertificates fc) { this.fc = fc; final Container p = getContentPane(); setSize(200,200); setLocation(100,100); p.setLayout(new BorderLayout()); p.add(spRoot,BorderLayout.CENTER); File f = new File("\\"); Roots = f.listRoots(); for(int i=0;i<Roots.length;i++){ lmRoot.addElement(Roots[i].getAbsolutePath()); } p.add(bStartScan,BorderLayout.SOUTH); bStartScan.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // dfeine new layout JPanel aPanel = new JPanel(new BorderLayout()), bPanel = new JPanel(new BorderLayout()); final DefaultListModel lmFound = new DefaultListModel(); JList lbFound = new JList(lmFound); JButton bAbort = new JButton("Abort Scanning Computer"), bSelect = new JButton("Select a Certificate Store"); final JTextArea taReport = new JTextArea(""); JScrollPane spFound = new JScrollPane(lbFound), spReport = new JScrollPane(taReport); aPanel.add(spReport,BorderLayout.CENTER); aPanel.add(bAbort,BorderLayout.SOUTH); bPanel.add(spFound,BorderLayout.CENTER); bPanel.add(bSelect,BorderLayout.SOUTH); p.removeAll(); // fisrt removeAll() (second isn't there jet.. p.add(aPanel,BorderLayout.NORTH); // These componets don't show up on tyhe frame... p.add(bPanel,BorderLayout.SOUTH); // ArrayList a = new ArrayList(); for(int i=0;i<lmRoot.size();i++) { if(lbRoot.getSelectionModel().isSelectedIndex(i)) { a.add(Roots[i]); } } Object[] o = a.toArray(); //File[] ff= (File[]) a.toArray(); ScanComputer sc = new ScanComputer(o, sfcs.fc.tfStore.getText()); sc.addReporter(new Report() { public void action(String msg) { taReport.append(msg); taReport.setCaretPosition(taReport.getText().length()); repaint(); } }); sc.addStore(new Report () { public void action(String msg) { lmFound.addElement(msg); repaint(); } }); sc.addFinish(new Report() { public void action (String msg) { } }); sc.start(); } }); } } |
|
|
|
Dec 23 2005, 10:30 PM
Post
#2
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 629 Joined: 26-February 05 Member No.: 3,995 |
I had a problem like that recently. I'm not sure if it's the exact same thing, but try adding this line after you add all the components:
CODE p.updateUI(); Basically it tells the frame that something has changed, and to display the change, so the stuff should show up. |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 6th September 2008 - 05:07 PM |