Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Second Layout..
kvarnerexpress
post 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();
     }
   });
 }
}
Go to the top of the page
 
+Quote Post
beeseven
post 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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Site Layout For My Friend(9)
  2. Css Layout Generator - *free*(5)
  3. Css And Javascript Combined For Dynamic Layout(9)
  4. Futuristic Web Layout(11)
  5. Layout Size(10)
  6. Ie And Firefox Layout Differences(11)
  7. Unusual Request! Check This Out!(12)
  8. Please Review My New Site Design / Layout / Test In Opera(17)
  9. Web Template Design (request)(1)
  10. Anime Layout Request(2)
  11. [~repost] Anime Layout Request [repost~](1)
  12. Lists, Unordered And Nested(2)
  13. Revamped My Site Layout, Review It?(25)
  14. Help With Css/html Layout(5)
  15. Easy Layout(4)
  1. Why Tables For Layout Is Stupid(10)
  2. Need Help With Layout(3)
  3. Having A Fixed Layout.(8)
  4. New All Black Myspace Layout(11)
  5. Please Review My Layout(7)
  6. I Need Myspace Layout Ideas =/(0)
  7. Centered Div Layout Issues(2)
  8. Nice Clean Php Layout Coding.(7)
  9. What Do You Think About My Layout-image?(2)
  10. Css Layout Help(8)
  11. Mine And Kansuke's Website Layout(5)
  12. Website Layout?(3)
  13. Website/blog Layout (circle Design)(2)


 



- Lo-Fi Version Time is now: 6th September 2008 - 05:07 PM