Refreshing JLIst

I'm having a bit of trouble refreshing JList
I have a file that stores an arraylist of objects. What happens when the program starts up is the arraylist is deserialized, converted to an array, and then displayed in the JList. I also have 3 other classes which are accessed via buttons, and those 3 deserialize the arraylist, modify it, and save it back to the file. One class adds an object, one edits(replaces) and object, and one deletes. How do I get my JList to update after a change is made to the file?

You update the model of the JList.

Similar Messages

  • Using an embedded driver instead of client, and refreshing JList

    I am finishing up a simple database interface program that I need to do in order to graduate. There are a couple issues I need to address.
    1. This program is meant to be on one computer with one connection to a database. Currently, when I build the program and run the .jar file, it will not work unless I have manually started the server in Netbeans. Once the server is on, it works like a champ. But since I have to send this to my professor it must work without him doing any additional setup. For this I figured I could use the embeddedDriver, but unfortantely I cant get that to work.
    In netbeans I can right click on the main database icon and select "New Connection" and i have the option of choosing the embedded driver yet when i put the database name in and the user and password it gives me the
    error: "Unable to add connection. Cannot establish a connection to jdbc:derby:MaxxTrax using org.apache.derby.jdbc.EmbeddedDriver (Database 'MaxxTrax' not found).
    Why is it that I can use the client driver without a problem yet not the embedded one? And if I cant use the embedded one, how can I set up the client driver so it will automatically start the server (does the end user need to have the server installed or will the clean and build do that)?
    2. Using the netbeans gui builder, i created a jList that I bound to my database's name query. I then have multiple textFields that i bound to whatever jList selection there is and tell it to update with the specified data. My problem is, that I cannot get the jList to "refresh". Right now when I add somebody to the database it visually writes over another persons record, but doesn't actually delete record. So if i could just figure out how to make it look at the database again I could do it automatically after entering in a new record. I've tried nameList.validate(), updateUI() and even tried to copy the ide generated code that actually binds the data but no go.
    Once I get these two little things taken care of I am done!! Please help, its greatly appreciated.

    I'm not getting much help out there.....anyone??
    I need to make the database seem invisible to the end user application.
    When I try to use an embedded driver I keep getting errors. In netbeans, I can see the "Java DB(Embedded)" link under drivers, and when I hit connect using.. I input all the correct data and it gives me the following error:
    Error: Unable to add connection. Cannot establish a connection to jdbc:derby:MaxxTrax using org.apache.derby.jdbc.EmbeddedDriver (Database 'MaxxTrax' not found).
    Under the Database setting the pointer for the java db installation and database location are correct. Why can't I connect using the embedded driver, cause using that would make my life so much easier for a single application.

  • How to dynamicly add a component to a panel

    when I click a button, I want to add a component to a panel, how can I do ?
    I try to do this:
    public void actionPerformed(ActionEvent e)
    contentPane.add(label,"north");
    contentPane.repaint;
    but there is no effect. Could u help me?

    Could you tell me why the repaint method doesn't work?repaint() does some low level validation and its more often suits for refreshing JList,TextFields etc etc...
    JPanel is somehow a more weighted component compared to JLabel,JTextFields etc,etc and hence it needs some heavy refreshing and these heavy refreshing can be obtained by doLayout() and validate() and some times both.
    when I add a component into another component, how can I get the new performace of the updated component?Is there a universal way? Pls put ur question more clearly.

  • RemoveAllElements function throws Exception

    Hi ,
    Have got a strange pbm
    I have to implement a JList component in my application. I have used DefaultList Model with it.
    But when I call ,list.clearSelection() or any other function to empty the list, application throughs Array Index out of bound exception.
    I m waiting for Ur sugesstions...
    Thanks for the advicers...
    Sapna

    Inorder to refresh the list contents try following code:
    DefaultListModel dlm = new DefaultListModel();
    JList jlist = new JList(dlm);
    //processing...
    //CODE FOR REFRESHING JLIST
    //if elements are present in List, remove them.
    if (dlm.size() > 0)
      dlm.removeAllElements();
    //add all elements in model one by one.
    for(int i = 0; i < al.size(); i++)
      dlm.addElement(al.get(i));
    if (dlm.size() > 0)
       if(!jlist.isSelectionEmpty()) jlist.clearSelection();
      //now if the defaultlistmodel has got any elements then select first
      //element
      jlist.setSelectedIndex(0);
    }Manish.

  • Clearing a bound JList after a refresh

    Hey guys, I'm fairly new to NetBeans and data binding in general so I'm having a bit of a hard time here. I'm working on a fairly basic database application (not modified too much from the template) and I've got a JList bound to the selected table value as such: ${selectedElement.vcr}. The problem is that when I refresh (and presumably there is no selected element) the JList is still displaying whatever it was displaying from before the refresh. I'm kind of running into a wall when I try to get the list model so that I can clear it, any suggestions?

    I do. Are you using the Develoepr Exchange of NI Developer Zone or soemthing else? Attachments are stripped from comp.lang.labview using Google. The same thing probably happens with a news reader. I'll reattach in case there's something wierd going on.
    Attachments:
    clear.vi ‏27 KB

  • JList - Adding Data & Refreshing

    Hi
    I have two JLists in JDialog. First JList is get populated with some items. I selected some items in the first list and click on ">>" button the selected items has to add to the second list and remove from first list.
    First time getting selected items using the method (getSelectedValues()) and assigning to second list. working fine. Again selected some more items from the first list and trying to assing to second list the items first assigned were vanished and the new items comes into picture. I want to preserve the existing list and add new items to the list.
    Code
    Vector listData = list1.getSelectedValues();
    list2.setListData(listData);
    Thanks
    Hari Babu Popuri

    I am trying to attain similar events as listed in the original post (move selected multiple items from one jList to another). I have searched through hundreds of posts and a few list tutorials. I tried the code listed here, but am getting an error on it.
    on the line:
    Vector listData = list1.getSelectedValues();
    My compiler doesn't like that I'm trying to put Object[] into a Vector. I've tried casting it to a vector and a couple other things, but I'm just lost right now.

  • Refreshing a jList

    Hi all friends!
    Well I have a jList where I display the users that are registered to the system; on the left I have some buttons that add some criteria to the search for users (eg. their role in the company). Now the problem is that if I get a list (eg. all usersI) and then I click for eg. ONLY ADMIN I see admins under all user...practically I can't clean up the List before I display the new result of the search...
    Is it possible to do that?
    Thanks!

    JList.setModel(...). Read the API for more information.

  • Problem in refreshing the combo box on selection of an item in another comb

    I have a situation where values to be displayed in 2nd combo box depends on the selection of an item from the 1st combo box.
    Problem observed:
    The 2nd combo box is not getting refreshed if the selected item from the 1st combo box has mapping to more than 10 items.
    for ex:
    A - AA, AB, AC, AD, AE, AF
    B - BA, BB, BC, BD, BE, BF, BG, BH, BI, BJ, BK, BL, BM, BN, BO, BP
    C - CA, CB, CC
    D - DA, DB, DC, DD
    1st combo box list:
    A
    B
    C
    D
    2nd combo box list:
    If the value selected from the first combo box is A, C, or D then 2nd combo box refreshes with repective values. But when the value selected is B, then 2nd combo box is not getting refreshed with respective values.
    Combo Model for 1st combo box:
    public class proCLMLossTypeComboModel implements javax.swing.ComboBoxModel
    package nz.co.towerinsurance.quantum.claims.pro;
    import javax.swing.*;
    import java.util.*;
    import CoreProduct.mbsoPRDLossCauseTypeList;
    import javax.swing.event.*;
    public class proCLMLossTypeComboModel implements javax.swing.ComboBoxModel
    Vector vector = null;
    mbsoPRDLossCauseTypeList mbsoPRDLossCauseTypeListInst0 = null;
    public void setData(Vector vector)
    this.vector = vector;
    public int getSize()
    if(vector != null)
    return this.vector.size();     
    else
    return 0;
    public void addListDataListener(ListDataListener l)
    public void removeListDataListener(ListDataListener l)
    public Object getElementAt(int index)
    return this.vector.elementAt(index);     
    public Object getSelectedItem()
    return this.mbsoPRDLossCauseTypeListInst0;     
    public void setSelectedItem(Object anItem)
    mbsoPRDLossCauseTypeList mbsoPRDLossCauseTypeListInst1 = (mbsoPRDLossCauseTypeList)anItem;
    this.mbsoPRDLossCauseTypeListInst0 = mbsoPRDLossCauseTypeListInst1;
    public Vector getData()
    return this.vector;     
    Combo Model for 2nd combo box:
    package nz.co.towerinsurance.quantum.claims.pro;
    import javax.swing.*;
    import java.util.*;
    import CoreProduct.mbsoPRDCauseTypeList;
    import javax.swing.event.*;
    public class proCLMCauseTypeComboModel implements javax.swing.ComboBoxModel
    Vector vector = null;
    mbsoPRDCauseTypeList mbsoPRDCauseTypeListInst0 = null;
    public void setData(Vector vector)
    this.vector = vector;
    public int getSize()
    if(vector != null)
    return this.vector.size();     
    else
    return 0;
    public void addListDataListener(ListDataListener l)
    public void removeListDataListener(ListDataListener l)
    public Object getElementAt(int index)
    return this.vector.elementAt(index);     
    public Object getSelectedItem()
    return this.mbsoPRDCauseTypeListInst0;     
    public void setSelectedItem(Object anItem)
    mbsoPRDCauseTypeList mbsoPRDCauseTypeListInst1 = (mbsoPRDCauseTypeList)anItem;
    this.mbsoPRDCauseTypeListInst0 = mbsoPRDCauseTypeListInst1;
    public Vector getData()
    return this.vector;     
    The Panel inside which these combo boxes are used:
    package nz.co.towerinsurance.quantum.claims.pro;
    import nz.co.towerinsurance.quantum.logger.MessageLogger;
    import nz.co.towerinsurance.quantum.claims.vmo.*;
    import nz.co.towerinsurance.quantum.utility.uhoUTLDialogueContext;
    import nz.co.towerinsurance.quantum.utility.uhoUTLModelHolder;
    import nz.co.towerinsurance.quantum.utility.uhoUTLInteraction;
    import nz.co.towerinsurance.quantum.utility.uhoUTLNotesContext;
    import nz.co.towerinsurance.quantum.utility.uhoUTLPrivacyContext;
    import nz.co.towerinsurance.quantum.utility.uhoUTLProcessImpContext;
    import nz.co.towerinsurance.quantum.help.*;
    import nz.co.towerinsurance.quantum.document.*;
    import nz.co.towerinsurance.quantum.task.*;
    import nz.co.towerinsurance.quantum.qtm.*;
    import nz.co.towerinsurance.quantum.claims.uhoCLMClientModel;
    import nz.co.towerinsurance.quantum.claims.utility.*;
    import MCType.*;
    import Claim.*;
    import Client.*;
    import Policy.*;
    import CoreProduct.*;
    import Security.*;
    import MCUtil.*;
    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.border.*;
    import javax.swing.ButtonGroup.*;
    import java.text.*;
    public class proSummaryPanel extends proCLMPanelBase implements proCLMRefreshInterface, proCLMDeclineReasonInterface
    private static final MessageLogger msgLogger=MessageLogger.getLogger("claims.pro.proSummaryPanel");
    uhoCLMClientModel uhoCLMClientModelInst0 = null;
    Vector VectorInst0 = new Vector();
    JRadioButton jRdBtnSummaryPM = new JRadioButton();
    JRadioButton jRdBtnSummaryAM = new JRadioButton();
    ButtonGroup ButtonGroupInst0 = new ButtonGroup();
    JButton jBtnSummarySearch = new JButton();
    JLabel jLblSummaryCompanyName = new JLabel();
    JLabel jLblSummaryCauseType = new JLabel();
    JTextField jTxtFldSummaryAmountSaved = new JTextField();
    JTextField jTxtFldSummaryDateNotified = new JTextField();
    JTextField jTxtFldSummary = new JTextField();
    JTextField jTxtFldSummarySuburb = new JTextField();
    JLabel jLblSummaryCatCode = new JLabel();
    JLabel jLblSummaryLossDesc = new JLabel();
    JLabel jLblSummaryDateNotified = new JLabel();
    JLabel jLblSummaryCity = new JLabel();
    JLabel jLblSummaryTime = new JLabel();
    JLabel jLblSummaryDeclineReason = new JLabel();
    JCheckBox jChkBxNcbLost = new JCheckBox();
    JCheckBox jChkBxLegal = new JCheckBox();
    JCheckBox jChkBxNoBlameBonus = new JCheckBox();
    JLabel jLblSummaryPostCode = new JLabel();
    JTextField jTxtFldSummaryStreetName = new JTextField();
    JTextField jTxtFldSummaryLossDate = new JTextField();
    JTextField jTxtFldSummaryCity = new JTextField();
    JTextField jTxtFldSummaryTime = new JTextField();
    JLabel jLblSummaryLossType = new JLabel();
    JTextField jTxtFldSummaryPhone = new JTextField();
    JTextField jTxtFldSummaryCompanyName = new JTextField();
    JLabel jLblSummarySuburb = new JLabel();
    JTextArea jTxtArLossDescription = new JTextArea();
    JScrollPane jScrPnSummaryLossDesc = new JScrollPane(jTxtArLossDescription);
    JTextField jTxtFldSummaryDeclineReason = new JTextField();
    JPanel jPanel2 = new JPanel();
    JPanel jPanel1 = this;
    JLabel jLblSummaryPhone = new JLabel();
    JTextField jTxtFldSummaryPostCode = new JTextField();
    JLabel jLblSummaryAmountSaved = new JLabel();
    JPanel jPnlSummaryCoy = new JPanel();
    JLabel jLblSummaryStreetName = new JLabel();
    Vector lossTypeVec = new Vector();
    JComboBox jCmbBxSummaryLossType = new JComboBox(lossTypeVec);
    proCLMLossTypeComboModel lossTypeComboModel = new proCLMLossTypeComboModel();
    Vector causeTypeVec = new Vector();
    JComboBox jCmbBxSummaryCauseType = new JComboBox();
    proCLMCauseTypeComboModel causeTypeComboModel = new proCLMCauseTypeComboModel();
    Vector CatCodeVec = new Vector();
    JComboBox jCmbBxSummaryCatCode = new JComboBox();
    proCLMCatCodeComboModel catCodeComboModel = new proCLMCatCodeComboModel();
    JLabel jLblSummaryLossDate = new JLabel();
    JButton jBtnSave = new JButton();
    JButton jBtnCancel = new JButton();
    Border border1;
    TitledBorder titledBorder1;
    Border border2;
    Border border3;
    TitledBorder titledBorder2;
    Border border4;
    TitledBorder titledBorder3;
    GridBagLayout gridBagLayout1 = new GridBagLayout();
    GridBagLayout gridBagLayout2 = new GridBagLayout();
    Border border5;
    TitledBorder titledBorder4;
    GridBagLayout gridBagLayout3 = new GridBagLayout();
    GridBagLayout gridBagLayout4 = new GridBagLayout();
    Component component1;
    Component component2;
    * @parameter uhoUTLInteraction ,mbsoSEMPrivilege
    * @return
    public proSummaryPanel(proQTMBase parent, uhoUTLInteraction inter,mbsoSEMPrivilege services)
    super(parent,inter,services);
    try {
    jbInit();
    catch(Exception e) {
    e.printStackTrace();
    * Component initialization
    * @parameter
    * @return void
    private void jbInit() throws Exception
    component1 = Box.createHorizontalStrut(8);
    component2 = Box.createHorizontalStrut(8);
    jCmbBxSummaryLossType.setMinimumSize(new Dimension(225, 25));
    // set the combo models
    jCmbBxSummaryLossType.setModel(lossTypeComboModel);
    jCmbBxSummaryCauseType.setModel(causeTypeComboModel);
    jCmbBxSummaryCatCode.setModel(catCodeComboModel);
    // renderer for the loss type combo
         jCmbBxSummaryLossType.setRenderer(new DefaultListCellRenderer()
         public Component getListCellRendererComponent(JList list, Object value,
         int index, boolean isSelected, boolean cellHasFocus)
         mbsoPRDLossCauseTypeList mbsoPRDLossTypeListObj = (mbsoPRDLossCauseTypeList) value;
         String v = (mbsoPRDLossTypeListObj == null) ? null:mbsoPRDLossTypeListObj.GetLossTypeName().toString();
         return super.getListCellRendererComponent(list,v,index,isSelected,cellHasFocus);
         // key selection manager for loss type combo
         jCmbBxSummaryLossType.setKeySelectionManager(new javax.swing.JComboBox.KeySelectionManager()
         public int selectionForKey(char aKey,ComboBoxModel aModel)
         try
         Vector vector = lossTypeComboModel.getData();
         // prepare a character array witht the first letter of loss types in lower case
         char[] characterArray = new char[vector.size()];
         for(int i=0;i<vector.size();i++)
         mbsoPRDLossCauseTypeList mbsoPRDLossCauseTypeListInst0 = (mbsoPRDLossCauseTypeList)vector.elementAt(i);
         char charac = mbsoPRDLossCauseTypeListInst0.GetLossTypeName().toString().toLowerCase().charAt(0);     
         characterArray[i] = charac;
         Character char1 = new Character(aKey);
         int index = 0;
         if(char1.isUpperCase(aKey))
         char char2 = char1.toLowerCase(aKey);
         index = java.util.Arrays.binarySearch(characterArray,char2);
         else
         index = java.util.Arrays.binarySearch(characterArray,aKey);
         if(index > 0)
         jCmbBxSummaryLossType.setSelectedIndex(index);
         else
         jCmbBxSummaryLossType.setSelectedIndex(0);
         jCmbBxSummaryLossType.repaint();
         if(index > 0)
         return index;
         else
         return 0;
         catch(Exception e1)
         msgLogger.fatal("Exception     : proSumamryPanel     : loss type combo key sel mgr : "+e1.getMessage());
         return 0;
         // renderer for cause type combo
         jCmbBxSummaryCauseType.setRenderer(new DefaultListCellRenderer() {
         public Component getListCellRendererComponent(JList list, Object value,
         int index, boolean isSelected, boolean cellHasFocus)
         mbsoPRDCauseTypeList mbsoPRDCauseTypeListObj = (mbsoPRDCauseTypeList) value;
         String v = (mbsoPRDCauseTypeListObj == null) ? null:mbsoPRDCauseTypeListObj.GetCauseTypeName().toString();
         return super.getListCellRendererComponent(list,v,index,isSelected,cellHasFocus);
         // key selection manager for loss type combo
         jCmbBxSummaryCauseType.setKeySelectionManager(new javax.swing.JComboBox.KeySelectionManager()
         public int selectionForKey(char aKey,ComboBoxModel aModel)
         try
         Vector vector = causeTypeComboModel.getData();
         // prepare a character array witht the first letter of loss types in lower case
         char[] characterArray = new char[vector.size()];
         for(int i=0;i<vector.size();i++)
         mbsoPRDCauseTypeList mbsoPRDCauseTypeListInst0 = (mbsoPRDCauseTypeList)vector.elementAt(i);
         char charac = mbsoPRDCauseTypeListInst0.GetCauseTypeName().toString().toLowerCase().charAt(0);     
         characterArray[i] = charac;
         Character char1 = new Character(aKey);
         int index = 0;
         if(char1.isUpperCase(aKey))
         char char2 = char1.toLowerCase(aKey);
         index = java.util.Arrays.binarySearch(characterArray,char2);
         else
         index = java.util.Arrays.binarySearch(characterArray,aKey);
         if(index > 0)
         jCmbBxSummaryCauseType.setSelectedIndex(index);
         else
         jCmbBxSummaryCauseType.setSelectedIndex(0);
         jCmbBxSummaryCauseType.repaint();
         if(index > 0)
         return index;
         else
         return 0;
         catch(Exception e1)
         msgLogger.fatal("Exception     : proSumamryPanel     : cause type combo key sel mgr : "+e1.getMessage());
         return 0;
    jBtnSummarySearch.setBorder(BorderFactory.createRaisedBevelBorder());
    jBtnSummarySearch.setMaximumSize(new Dimension(119, 23));
    jBtnSummarySearch.setPreferredSize(new Dimension(65, 23));
    jBtnSummarySearch.setMnemonic(KeyEvent.VK_E); // 20/12
    jBtnSummarySearch.setText("Search");
    this.setLayout(gridBagLayout4);
    ButtonGroupInst0.add(jRdBtnSummaryPM);
    ButtonGroupInst0.add(jRdBtnSummaryAM);
    border1 = BorderFactory.createEtchedBorder(Color.white,new Color(142, 142, 142));
    titledBorder1 = new TitledBorder(border1,"Where Is It Now?");
    border2 = BorderFactory.createEtchedBorder(Color.white,new Color(142, 142, 142));
    border3 = BorderFactory.createEtchedBorder(Color.white,new Color(142, 142, 142));
    titledBorder2 = new TitledBorder(border3,"Where Is It Now?");
    border4 = BorderFactory.createEtchedBorder(Color.white,new Color(142, 142, 142));
    titledBorder3 = new TitledBorder(border4,"Summary");
    border5 = BorderFactory.createEtchedBorder(Color.white,new Color(142, 142, 142));
    titledBorder4 = new TitledBorder(border5,"Location of Vehicle/Boat");
    jScrPnSummaryLossDesc.setToolTipText("");
    jScrPnSummaryLossDesc.setFont(new java.awt.Font("SansSerif", 0, 12));
    jScrPnSummaryLossDesc.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    jLblSummarySuburb.setText("Suburb");
    jLblSummarySuburb.setForeground(Color.black);
    jLblSummarySuburb.setPreferredSize(new Dimension(100, 17));
    jLblSummarySuburb.setFont(new java.awt.Font("SansSerif", 1, 12));
    jTxtFldSummaryCompanyName.setFont(new java.awt.Font("SansSerif", 0, 12));
    jTxtFldSummaryCompanyName.setBorder(BorderFactory.createLoweredBevelBorder());
    jTxtFldSummaryCompanyName.setMinimumSize(new Dimension(100, 20));
    jTxtFldSummaryCompanyName.setPreferredSize(new Dimension(100, 20));
    jTxtFldSummaryPhone.setToolTipText("");
    jTxtFldSummaryPhone.setBorder(BorderFactory.createLoweredBevelBorder());
    jTxtFldSummaryPhone.setMinimumSize(new Dimension(100, 20));
    jTxtFldSummaryPhone.setPreferredSize(new Dimension(100, 20));
    jTxtFldSummaryPhone.setFont(new java.awt.Font("SansSerif", 0, 12));
    jLblSummaryLossType.setText("Loss Type");
    jLblSummaryLossType.setForeground(Color.black);
    jLblSummaryLossType.setPreferredSize(new Dimension(102, 17));
    jLblSummaryLossType.setFont(new java.awt.Font("SansSerif", 1, 12));
    jTxtFldSummaryTime.setBorder(BorderFactory.createLoweredBevelBorder());
    jTxtFldSummaryTime.setMinimumSize(new Dimension(100, 20));
    jTxtFldSummaryTime.setPreferredSize(new Dimension(100, 20));
    jTxtFldSummaryTime.setFont(new java.awt.Font("SansSerif", 0, 12));
    jTxtFldSummaryCity.setFont(new java.awt.Font("SansSerif", 0, 12));
    jTxtFldSummaryCity.setBorder(BorderFactory.createLoweredBevelBorder());
    jTxtFldSummaryCity.setMinimumSize(new Dimension(100, 20));
    jTxtFldSummaryCity.setPreferredSize(new Dimension(100, 20));
    jTxtFldSummaryLossDate.setBackground(Color.cyan);
    jTxtFldSummaryLossDate.setBorder(BorderFactory.createLoweredBevelBorder());
    jTxtFldSummaryLossDate.setMinimumSize(new Dimension(100, 20));
    jTxtFldSummaryLossDate.setPreferredSize(new Dimension(100, 20));
    jTxtFldSummaryLossDate.setFont(new java.awt.Font("SansSerif", 0, 12));
    jBtnSave.setToolTipText("");
    jBtnSave.setBorder(BorderFactory.createRaisedBevelBorder());
    jBtnSave.setMnemonic('S');
    jBtnSave.setText("Save");
    jBtnSave.setPreferredSize(new Dimension(100,23)); // 30/07
    jBtnSummarySearch.addActionListener(new java.awt.event.ActionListener(){
    public void actionPerformed(ActionEvent e) {
    jBtnSummarySearch_actionPerformed(e);
    //the listener for losstype combobox
    jCmbBxSummaryLossType.addItemListener(new java.awt.event.ItemListener() {
    public void itemStateChanged(ItemEvent e) {
    jCmbBxSummaryLossType_itemStateChanged(e);
    //Actioin listener for Save button
    jBtnSave.addActionListener(new java.awt.event.ActionListener()
    public void actionPerformed(ActionEvent e)
    jBtnSave_actionPerformed(e);
    //Actioin listener for Cancel button
    jTxtFldSummaryStreetName.setFont(new java.awt.Font("SansSerif", 0, 12));
    jTxtFldSummaryStreetName.setBorder(BorderFactory.createLoweredBevelBorder());
    jTxtFldSummaryStreetName.setMinimumSize(new Dimension(100, 20));
    jTxtFldSummaryStreetName.setPreferredSize(new Dimension(100, 20));
    jLblSummaryPostCode.setText("Post Code");
    jLblSummaryPostCode.setForeground(Color.black);
    jLblSummaryPostCode.setPreferredSize(new Dimension(100, 17));
    jLblSummaryPostCode.setFont(new java.awt.Font("SansSerif", 1, 12));
    jChkBxNcbLost.setFont(new java.awt.Font("SansSerif", 1, 12));
    jChkBxNcbLost.setPreferredSize(new Dimension(130, 17));
    jChkBxNcbLost.setText("NCB Lost");
    jLblSummaryDeclineReason.setText("Decline Reason");
    jLblSummaryDeclineReason.setForeground(Color.black);
    jLblSummaryDeclineReason.setPreferredSize(new Dimension(102, 17));
    jLblSummaryDeclineReason.setFont(new java.awt.Font("SansSerif", 1, 12));
    jLblSummaryTime.setText("Time");
    jLblSummaryTime.setForeground(Color.black);
    jLblSummaryTime.setPreferredSize(new Dimension(35, 17));
    jLblSummaryTime.setFont(new java.awt.Font("SansSerif", 1, 12));
    jLblSummaryCity.setText("Town/City");
    jLblSummaryCity.setForeground(Color.black);
    jLblSummaryCity.setPreferredSize(new Dimension(100, 17));
    jLblSummaryCity.setFont(new java.awt.Font("SansSerif", 1, 12));
    jLblSummaryDateNotified.setText("Date Notified");
    jLblSummaryDateNotified.setForeground(Color.black);
    jLblSummaryDateNotified.setPreferredSize(new Dimension(102, 17));
    jLblSummaryDateNotified.setFont(new java.awt.Font("SansSerif", 1, 12));
    jLblSummaryLossDesc.setText("Loss Description");
    jLblSummaryLossDesc.setForeground(Color.black);
    jLblSummaryLossDesc.setPreferredSize(new Dimension(102, 17));
    jLblSummaryLossDesc.setFont(new java.awt.Font("SansSerif", 1, 12));
    jLblSummaryCatCode.setText("Catastrophe Code");
    jLblSummaryCatCode.setForeground(Color.black);
    jLblSummaryCatCode.setFont(new java.awt.Font("SansSerif", 1, 12));
    jTxtFldSummarySuburb.setFont(new java.awt.Font("SansSerif", 0, 12));
    jTxtFldSummarySuburb.setBorder(BorderFactory.createLoweredBevelBorder());
    jTxtFldSummarySuburb.setMinimumSize(new Dimension(100, 20));
    jTxtFldSummarySuburb.setPreferredSize(new Dimension(100, 20));
    jTxtFldSummaryAmountSaved.setFont(new java.awt.Font("SansSerif", 0, 12));
    jTxtFldSummaryAmountSaved.setBorder(BorderFactory.createLoweredBevelBorder());
    jTxtFldSummaryAmountSaved.setMinimumSize(new Dimension(100, 20));
    jTxtFldSummaryAmountSaved.setPreferredSize(new Dimension(100, 20));
    jTxtFldSummaryDateNotified.setFont(new java.awt.Font("SansSerif", 0, 12));
    jTxtFldSummaryDateNotified.setBorder(BorderFactory.createLoweredBevelBorder());
    jTxtFldSummaryDateNotified.setMinimumSize(new Dimension(100, 20));
    jTxtFldSummaryDateNotified.setPreferredSize(new Dimension(100, 20));
    jLblSummaryCauseType.setText("Cause Type");
    jLblSummaryCauseType.setForeground(Color.black);
    jLblSummaryCauseType.setPreferredSize(new Dimension(102, 17));
    jLblSummaryCauseType.setFont(new java.awt.Font("SansSerif", 1, 12));
    jLblSummaryCompanyName.setText("Company Name");
    jLblSummaryCompanyName.setForeground(Color.black);
    jLblSummaryCompanyName.setPreferredSize(new Dimension(100, 17));
    jLblSummaryCompanyName.setFont(new java.awt.Font("SansSerif", 1, 12));
    jCmbBxSummaryCatCode.setFont(new java.awt.Font("SansSerif", 0, 12));
    jCmbBxSummaryCatCode.setMinimumSize(new Dimension(225, 25));  // on 21/11
    jCmbBxSummaryCatCode.setPreferredSize(new Dimension(126, 25));
    jRdBtnSummaryPM.setFont(new java.awt.Font("SansSerif", 1, 12));
    jRdBtnSummaryPM.setPreferredSize(new Dimension(40, 17));
    jRdBtnSummaryPM.setText("pm");
    jTxtFldSummaryDeclineReason.setFont(new java.awt.Font("SansSerif", 0, 12));
    jTxtFldSummaryDeclineReason.setBorder(BorderFactory.createLoweredBevelBorder());
    jTxtFldSummaryDeclineReason.setMinimumSize(new Dimension(225, 20));
    jTxtFldSummaryDeclineReason.setPreferredSize(new Dimension(225, 20));
    jChkBxLegal.setPreferredSize(new Dimension(130, 17));
    jChkBxLegal.setText("Legal");
    jChkBxLegal.setActionCommand("jChkBxLegal");
    jChkBxLegal.setFont(new java.awt.Font("SansSerif", 1, 12));
    jPanel2.setBorder(BorderFactory.createEtchedBorder());
    jPanel2.setLayout(gridBagLayout1);
    jPanel1.setLayout(gridBagLayout3);
    jLblSummaryPhone.setFont(new java.awt.Font("SansSerif", 1, 12));
    jLblSummaryPhone.setForeground(Color.black);
    jLblSummaryPhone.setPreferredSize(new Dimension(100, 17));
    jLblSummaryPhone.setText("Phone");
    jRdBtnSummaryAM.setPreferredSize(new Dimension(40, 17));
    jRdBtnSummaryAM.setText("am");
    jRdBtnSummaryAM.setFont(new java.awt.Font("SansSerif", 1, 12));
    jRdBtnSummaryAM.setSelected(true); // 20/12
    jTxtFldSummaryPostCode.setBorder(BorderFactory.createLoweredBevelBorder());
    jTxtFldSummaryPostCode.setMinimumSize(new Dimension(100, 20));
    jTxtFldSummaryPostCode.setPreferredSize(new Dimension(100, 20));
    jTxtFldSummaryPostCode.setFont(new java.awt.Font("SansSerif", 0, 12));
    jLblSummaryAmountSaved.setText("Amount Saved");
    jLblSummaryAmountSaved.setForeground(Color.black);
    jLblSummaryAmountSaved.setPreferredSize(new Dimension(102, 17));
    jLblSummaryAmountSaved.setFont(new java.awt.Font("SansSerif", 1, 12));
    jPnlSummaryCoy.setFont(new java.awt.Font("SansSerif", 1, 12));
    jPnlSummaryCoy.setBorder(titledBorder4);
    jPnlSummaryCoy.setLayout(gridBagLayout2);
    jLblSummaryStreetName.setFont(new java.awt.Font("SansSerif", 1, 12));
    jLblSummaryStreetName.setForeground(Color.black);
    jLblSummaryStreetName.setPreferredSize(new Dimension(100, 17));
    jLblSummaryStreetName.setText("Street Name");
    jCmbBxSummaryLossType.setBackground(Color.cyan);
    jCmbBxSummaryLossType.setFont(new java.awt.Font("SansSerif", 0, 12));
    jCmbBxSummaryLossType.setPreferredSize(new Dimension(225, 26));
    jCmbBxSummaryCauseType.setBackground(Color.cyan);
    jCmbBxSummaryCauseType.setFont(new java.awt.Font("SansSerif", 0, 12));
    jCmbBxSummaryCauseType.setPreferredSize(new Dimension(225, 26));
    jLblSummaryLossDate.setText("Loss Date");
    jLblSummaryLossDate.setForeground(Color.black);
    jLblSummaryLossDate.setPreferredSize(new Dimension(102, 17));
    jLblSummaryLossDate.setFont(new java.awt.Font("SansSerif", 1, 12));
    jTxtArLossDescription.setLineWrap(true);
    jTxtArLossDescription.setWrapStyleWord(true);
    jTxtArLossDescription.setBackground(Color.cyan);
    jTxtArLossDescription.setFont(new java.awt.Font("SansSerif", 0, 12));
    jTxtArLossDescription.setBounds(new Rectangle(124, 39, 394, 46));
    jChkBxNoBlameBonus.setPreferredSize(new Dimension(130, 17));
    jChkBxNoBlameBonus.setText("No Blame Bonus ");
    jChkBxNoBlameBonus.setFont(new java.awt.Font("SansSerif", 1, 12));
    jPanel1.setBorder(titledBorder3);
    jPanel1.setBounds(new Rectangle(23, 11, 810, 436));
    jPanel1.add(jLblSummaryCatCode, new GridBagConstraints(0, 6, 1, 1, 0.1, 0.05
    ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jScrPnSummaryLossDesc, new GridBagConstraints(1, 1, 6, 1, 0.9, 0.15
    ,GridBagConstraints.SOUTHWEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    jScrPnSummaryLossDesc.getViewport().add(jTxtArLossDescription, null);
    jPanel1.add(jRdBtnSummaryPM, new GridBagConstraints(5, 0, 1, 1, 0.1, 0.05
    ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jTxtFldSummaryDeclineReason, new GridBagConstraints(1, 8, 2, 1, 0.1, 0.1
    ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jLblSummaryLossDesc, new GridBagConstraints(0, 1, 1, 1, 0.1, 0.5
    ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jLblSummaryLossType, new GridBagConstraints(0, 3, 1, 1, 0.1, 0.05
    ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jLblSummaryCauseType, new GridBagConstraints(0, 4, 1, 1, 0.1, 0.05
    ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jLblSummaryDeclineReason, new GridBagConstraints(0, 8, 1, 1, 0.1, 0.05
    ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jLblSummaryLossDate, new GridBagConstraints(0, 0, 1, 1, 0.1, 0.05
    ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jTxtFldSummaryTime, new GridBagConstraints(3, 0, 1, 1, 0.1, 0.05
    ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jLblSummaryTime, new GridBagConstraints(3, 0, 1, 1, 0.1, 0.05
    ,GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 107, 7));
    jPanel1.add(jRdBtnSummaryAM, new GridBagConstraints(4, 0, 1, 1, 0.1, 0.05
    ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jCmbBxSummaryCauseType, new GridBagConstraints(1, 4, 2, 1, 0.1, 0.05
    ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jTxtFldSummaryLossDate, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.05
    ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jTxtFldSummaryDateNotified, new GridBagConstraints(1, 7, 1, 1, 0.1, 0.05
    ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jPanel2, new GridBagConstraints(0, 9, 6, 1, 1.0, 0.1
    ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jChkBxNoBlameBonus, new GridBagConstraints(3, 0, 1, 1, 0.1, 0.0
    ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jChkBxLegal, new GridBagConstraints(4, 0, 1, 1, 0.1, 0.0
    ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jBtnSave, new GridBagConstraints(5, 0, 1, 1, 0.1, 0.0
    ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(jChkBxNcbLost, new GridBagConstraints(2, 0, 1, 1, 0.1, 0.0
    ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(component1, new GridBagConstraints(1, 0, 1, 1, 0.35, 0.0
    ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPanel2.add(component2, new GridBagConstraints(5, 0, 1, 1, 0.35, 0.0
    ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jCmbBxSummaryLossType, new GridBagConstraints(1, 3, 2, 1, 0.1, 0.05
    ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jCmbBxSummaryCatCode, new GridBagConstraints(1, 6, 2, 1, 0.1, 0.05
    ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jPnlSummaryCoy, new GridBagConstraints(2, 3, 4, 6, 1.0, 0.0
    ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    jPnlSummaryCoy.add(jLblSummaryPhone, new GridBagConstraints(0, 6, 1, 1, 0.5, 0.16
    ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPnlSummaryCoy.add(jLblSummarySuburb, new GridBagConstraints(0, 3, 1, 1, 0.5, 0.16
    ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPnlSummaryCoy.add(jTxtFldSummaryStreetName, new GridBagConstraints(1, 2, 1, 1, 0.5, 0.16
    ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPnlSummaryCoy.add(jTxtFldSummaryCity, new GridBagConstraints(1, 4, 1, 1, 0.5, 0.16
    ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPnlSummaryCoy.add(jTxtFldSummaryPostCode, new GridBagConstraints(1, 5, 1, 1, 0.5, 0.16
    ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPnlSummaryCoy.add(jTxtFldSummarySuburb, new GridBagConstraints(1, 3, 1, 1, 0.5, 0.16
    ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPnlSummaryCoy.add(jLblSummaryPostCode, new GridBagConstraints(0, 5, 1, 1, 0.5, 0.16
    ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPnlSummaryCoy.add(jTxtFldSummaryPhone, new GridBagConstraints(1, 6, 1, 1, 0.5, 0.16
    ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPnlSummaryCoy.add(jTxtFldSummaryCompanyName, new GridBagConstraints(1, 0, 1, 1, 0.5, 0.16
    ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPnlSummaryCoy.add(jLblSummaryCompanyName, new GridBagConstraints(0, 0, 1, 1, 0.5, 0.16
    ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPnlSummaryCoy.add(jLblSummaryStreetName, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.16
    ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPnlSummaryCoy.add(jLblSummaryCity, new GridBagConstraints(0, 4, 1, 1, 0.5, 0.16
    ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jLblSummaryDateNotified, new GridBagConstraints(0, 7, 1, 1, 0.1, 0.05
    ,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    jPanel1.add(jBtnSummarySearch, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0
    ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    jTxtFldSummaryLossDate.grabFocus();
    jTxtFldSummaryLossDate.setNextFocusableComponent(jTxtFldSummaryTime);
    jTxtFldSummaryTime.setNextFocusableComponent(jRdBtnSummaryAM);
    jRdBtnSummaryAM.setNextFocusableComponent(jRdBtnSummaryPM);
    jRdBtnSummaryPM.setNextFocusableComponent(jTxtArLossDescription);
    jTxtArLossDescription.setNextFocusableComponent(jCmbBxSummaryLossType);
    jCmbBxSummaryLossType.setNextFocusableComponent(jCmbBxSummaryCauseType);
    jCmbBxSummaryCauseType.setNextFocusableComponent(jBtnSummarySearch);
    jBtnSummarySearch.setNextFocusableComponent(jCmbBxSummaryCatCode);
    jCmbBxSummaryCatCode.setNextFocusableComponent(jTxtFldSummaryDateNotified);
    jTxtFldSummaryDateNotified.setNextFocusableComponent(jTxtFldSummaryDeclineReason);
    jTxtFldSummaryDeclineReason.setNextFocusableComponent(jTxtFldSummaryCompanyName);
    jTxtFldSummaryCompanyName.setNextFocusableComponent(jTxtFldSummaryStreetName);
    jTxtFldSummaryStreetName.setNextFocusableComponent(jTxtFldSummarySuburb);
    jTxtFldSummarySuburb.setNextFocusableComponent(jTxtFldSummaryCity);
    jTxtFldSummaryCity.setNextFocusableComponent(jTxtFldSummaryPostCode);
    jTxtFldSummaryPostCode.setNextFocusableComponent(jTxtFldSummaryPhone);
    jTxtFldSummaryPhone.setNextFocusableComponent(jChkBxNcbLost);
    jChkBxNcbLost.setNextFocusableComponent(jChkBxNoBlameBonus);
    jChkBxNoBlameBonus.setNextFocusableComponent(jChkBxLegal);
    jChkBxLegal.setNextFocusableComponent(jBtnSave);
    jBtnSave.setNextFocusabl                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     &nbs

    the very simple strategy to do is to call removeAllItems() method for the 2nd combox box and then insert the contents. this is because the validate() method is not repeatedly called and so the contents are not updated immediately.

  • JTree - changed content, refresh

    Hello,
    I have a problem in my program I can`t solve...
    basically I am using drop-down menu with different drives (c:, d:, etc.). Don`t ask me why I don`t use the JTree to display all the drives, I simply need to display each drive separately.
    when I select the drive, JTree pops up with the content of the drive.
    Problem comes in, when the JTree is already displayed and I go into my drop-down menu to select a different drive.... Everything seems to work fine in background.... The tree gets build up, I just somehow cannot update (or refresh) the screen....
    did anyone experienced similar problem?
    thank you
    Otakar

    No, I am not using TreeModel.. Let me post the code... I am using 3 different files:
    MainModule.java
    DetectDrives.java
    FileSystem.java
    I think You might wanna see the ChoiceListener in MainModule
    thank you for you time
    MainModule.java
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.DefaultMutableTreeNode;
    import java.awt.*;
    import java.awt.event.*;
    public class MainModule{
         private JFrame aFrame;         // BASE frame
         private JPanel driveListPane;
         private JList  driveList;
         // MENU Bar Components
         private JMenuBar aMenuBar;
         private JMenu fileMenu, editMenu, viewMenu, settingsMenu, helpMenu;
         private JMenuItem newMenuItem, openMenuItem, saveMenuItem,                // FILE menu Items
                                           saveAsMenuItem, exitMenuItem,                     //
                                           selectDriveMenuItem, selectOutputMenuItem;        // SETTINGS menu Items
          // ComboBox
         private JComboBox aComboBox;
          // Buttons
         private JButton selectDriveButton, printButton;
         // Listeners
         private PrintButtonListener prtListener;
         private ChoiceListener choiceListener;
         // Labels
         private JLabel sourceLabel, label1, label2;
         private int listRows;
         public static String drive;
         private DetectDrives dd;
         private FileSystem fs;
         private int ct;
         /*============ CONSTRUCTOR ===========================================================\
         |
         public MainModule(){
             ct = 0;
              // create a MAIN WINDOW (Frame)
              drive = new String("C:\\");
              aFrame = new JFrame("Otax Drive Printer 0.99b");
              aFrame.setSize(800, 600);
              aFrame.setLocation(100, 50);
              aFrame.getContentPane().setLayout(null);
              aFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              // create the categories in a menu bar
              aMenuBar = new JMenuBar();
              fileMenu = new JMenu("File");
              editMenu = new JMenu("Edit");
              viewMenu = new JMenu("View");
              settingsMenu = new JMenu("Settings");
              helpMenu = new JMenu("Help");
              // create menu items for FILE menu
              newMenuItem = new JMenuItem("New", 'N');
              openMenuItem = new JMenuItem( "Open", 'O');
              saveMenuItem = new JMenuItem( "Save", 'S' );
                     saveAsMenuItem = new JMenuItem( "Save As", 'A');
                     exitMenuItem = new JMenuItem("Exit", 'E');
              // create menu items for SETTINGS menu
                     selectDriveMenuItem = new JMenuItem("Select Drive", 'D');
                     selectOutputMenuItem = new JMenuItem("Select Output", 'O');
              // detect drives mounted to system and put them into JComboBox
              dd = new DetectDrives();
              aComboBox = new JComboBox(dd.detectCdDrives());
              aComboBox.setBounds(100, 5, 180, 20);
              //create labels
              sourceLabel = new JLabel("Select Source:");
              sourceLabel.setBounds(6, 4, 90, 20);
                     label1 = new JLabel("Current Drive: ");
              label1.setBounds(2, 500, 90, 20);
              label2 = new JLabel();
              label2.setBounds(85, 500, 50, 20);
              //create buttons
              printButton = new JButton("Print");
              printButton.setBounds(2, 50, 101, 16);
                     //create Accelerators for FILE MenuItems
                     newMenuItem.setAccelerator(KeyStroke.getKeyStroke(
                   KeyEvent.VK_N, InputEvent.CTRL_MASK, false));
              saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(
                   KeyEvent.VK_S, InputEvent.CTRL_MASK, false));
              //create the action listeners (listener definitions bellow)
              prtListener = new PrintButtonListener();
              choiceListener = new ChoiceListener();
              //connect the action listeners with menu items
              printButton.addActionListener(prtListener);
              aComboBox.addActionListener(choiceListener);
         // LISTENERS Definitions start HERE ====================================
         public class PrintButtonListener implements ActionListener{
              public void actionPerformed(ActionEvent e){
                   System.out.println("print action performed: " + drive);
         public class ChoiceListener implements ActionListener{
             public void actionPerformed( ActionEvent e)
                  ct++;
                  System.out.println(ct + " event started");
               String drive = new String(aComboBox.getSelectedItem().toString().substring(0,2));
               label2.setText(drive);
               fs = new FileSystem(drive + "//");
               fs.sortFiles();
               fs.addNodes(drive);
               DefaultMutableTreeNode top = fs.getNodes();
               JTree tree = new JTree(top);
               tree.setBounds(10, 30, 500, 450);
                  aFrame.getContentPane().add(tree);
               aFrame.repaint();
         public void addComponents(){
              aMenuBar.add(fileMenu);        // create menu
              aMenuBar.add(editMenu);
              aMenuBar.add(settingsMenu);
              aMenuBar.add(helpMenu);
              fileMenu.add(newMenuItem);     //add items to the FILE menu
              fileMenu.add(openMenuItem);
              fileMenu.addSeparator();
              fileMenu.add(saveMenuItem);
                     fileMenu.add(saveAsMenuItem);
                     fileMenu.addSeparator();
                     fileMenu.add(exitMenuItem);
              settingsMenu.add(selectDriveMenuItem);
              settingsMenu.add(selectOutputMenuItem);
              aFrame.setJMenuBar(aMenuBar);
              aFrame.getContentPane().add(aComboBox);
              aFrame.getContentPane().add(sourceLabel);
              aFrame.getContentPane().add(label1);
              aFrame.getContentPane().add(label2);
              aFrame.setVisible(true);
         public static void main(String [] args){
              MainModule m1 = new MainModule();
              m1.addComponents();
    DetectDrives.java
    import java.io.*;
    import java.util.Vector;
    import javax.swing.filechooser.*;
    public class DetectDrives{
         private FileSystemView fsv;
         private File[] roots;
         private Vector drives;
         /*======== CONSTRUCTOR =====================================================================\
         |Purpose: To INITIALIZE the object                                                          |
         |Variables: (FileSystemView) fsv - creates the Object containing info about current system  |
         |           (File[]) roots - array used to store all drives currently mounted to system     |
         |           (Vector) drives - vector used for storage of selected info about drives         |
           \==========================================================================================*/
         public DetectDrives(){
              drives = new Vector(0,1); // *Create empty Vector(0) with expansion capacity (1)
              //--- Get a FileSystemView object for the current system
             fsv = FileSystemView.getFileSystemView();
            //--- Get an array of File objects describing the 'roots' attached to the system
              roots = File.listRoots();
         /*SD1)==== Method detectCdDrives() ========================================================\
         |Purpose: To SCAN the system for any drives mounted and add DRIVE LETTER and DRIVE NAME    |
         |         to a Vector. It Also CHECKS if drive CONTAINS any DATA or if it`s EMPTY.         |
         |Variables: (int) i - a loop iterator                                                      |
         |           (String) cdInfo - temporary storage for drive information during drive check   |
         |           (Vector) drives - storage for driveletter and drive name for all drives        |
         |                             This Vector is returned upon function call                   |
         public Vector detectCdDrives(){
              String cdInfo;
              //SCAN system and RETRIEVE drives
              for(int i = 0; i < roots.length; i++){
                   if((fsv.getSystemDisplayName(roots)).equals("")) //--FIND OUT if any DATA on DRIVE
                        cdInfo = fsv.getSystemTypeDescription(roots[i]) + " ";
                   else
                   cdInfo = fsv.getSystemDisplayName(roots[i]);
                   drives.addElement(roots[i].getPath() + " " + cdInfo.substring(0, cdInfo.length()-5));
              return drives;
    FileSystem.java
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.tree.*;
    import javax.swing.tree.DefaultMutableTreeNode;
    import java.io.File;
    import java.io.*;
    import java.util.Vector;
    public class FileSystem{
         private String driveLetter;
         private Vector root;
         private Vector dirs;
         private Vector files;
         private File dir;
         private File [] allFiles;
         private DefaultMutableTreeNode top;
         /*================= File System Constructor ================================\
         |Purpose: To initialize the conject and to accept drive letter selected in  |
         |         main module                                                       |
         public FileSystem(String dl){
              driveLetter = dl;
        /*================= Method: sortFiles() ====================================\
         |Purpose: To sort content of selected drive, directories (alphabetically),  |
         |         followed by files (alphabeticaly)                                 |
         public void sortFiles(){
              dir = new File (driveLetter);
              allFiles = dir.listFiles();
              root  = new Vector(2,1);
              dirs  = new Vector(0,1);
             files = new Vector(0,1);
             //---- Separate Directories and Files into 2 different vectors
             for(int i = 0; i < allFiles.length; i++){
                   if(allFiles.isDirectory())
                   dirs.add(allFiles[i]);
                   else
                   files.add(allFiles[i]);
              //---- Add elements from dirs and files Vectors into root vector
              for(int i = 0; i < dirs.size(); i++){
                   root.add(dirs.elementAt(i));
              for(int i = 0; i < files.size(); i++){
                   root.add(files.elementAt(i));
    /*================= Method: addNodes() =====================================\
         |Purpose: to build the file structure which will be used to create the tree |
         |Variables: drive = used to accept the drive letter representing the root |
         | top = primary (root) node in the structure) |
    | root = vector of all files in the drive |
         public void addNodes(String drive){
              top = new DefaultMutableTreeNode(drive);
              DefaultMutableTreeNode node = null;
              for(int i = 0; i < root.size(); i++){
                   node = new DefaultMutableTreeNode(root.elementAt(i));
                   top.add(node);
    /*================= Method: getNodes() =====================================\
         |Purpose: To return variable top, which holds the files structure and will |
         | be used to build the tree |
    public DefaultMutableTreeNode getNodes(){
              return top;

  • Why won't my JList update?

    My JList is first dimensioned to an array with 100 elements in it but then in a function i set it to null and then I set it to a different array with a smaller amount of elements. Then i call repaint() to refresh the pane but it still doesn't change anything. The JList on my pane still shows the items in the old array. How do i fix this?

    you need to reset the listModel
    search the swing forum for
    listModel DefaultListModel
    and you'll find plenty of working examples

  • Model in my JList not reflecting the new value I added to it?

    uness I create a new model object and modify it then my code does not work as I want. Adding new data to the exitsting model causes the JList to display blank when I refresh the screen. I have created my own implementation of an editable Model.
    When my action performed creates a new instance of the model everything works fine but is this how it should work?
    //In my GUI I have a JList initialized with the model ....
    private EditableListModel model = new EditableListModel();
    model.add("one");
    model.add("two");
    model.add("three");
    colsToDisplayJList.setModel( model );
    I have a button with the following action performed
        private void addActionPerformed(java.awt.event.ActionEvent evt) {                                   
            //model = new EditableListModel();
            model.add("four");
            colsToDisplayJList.setModel( model );
    //EditableModel implementation
    import java.util.*;
    import javax.swing.AbstractListModel;
    public class EditableListModel extends AbstractListModel
        private Vector items = new Vector();
        public Object getElementAt(int key)
            return items.get( key );
        public int getSize()
            return items.size();
        public void add( String item )
            items.add( item );
        public void remove( String key )
            Iterator iter =  items.iterator();
            int index = 0;
            while( iter.hasNext() )
                String item = (String)iter.next();
                if( item.equalsIgnoreCase( key ) )
                    items.remove( index );
                    break;
                index ++;
    }

    That other post looks different, though - the OP is now manipulating the model.The OPs statement of the problem was:
    Adding new data to the exitsting model causes the JList to display blank when I refresh the screen.
    The suggestion in the other posting was to change the model not the array and the tutorial has a working example of this.
    The OPs question was:
    When my action performed creates a new instance of the model everything works fine but is this how it should work?
    The answer to this is no, you don't need to change the model, just update the model.
    So if the OP read the other posting and read the tutorial they should have an answer to their problem.
    As you suggested there is no need to create a custom model. The example in the tutorial uses the default list model, if the OP read the tutorial they would know that.

  • Rather Specific JList Conundrum

    Hi Guys,
    I've come to a bit of a brick wall on the project I'm working on, but as my problem is so specific no amount of Googling is helping me.
    Essentially my coursework is to make a twitter client using the Twitter4JAPI, the part I'm stuggling with is showing the home feed. I want it to show the Icon, with the User and Status next to it which I'm doing using my own custom cell renderer. Now it works fine, but the program takes ages to load as it pulls all the avatars off the web, swapping to and from that tab takes ages (for the same reason), and scrolling the list is so mind blowingly slow, as every tick it refreshes all the images (from the web).
    Any suggestions how to stop this?
    Here is my custom cell renderer code:
    public Component getListCellRendererComponent(JList list, Object value,
                   int index, boolean isSelected, boolean cellHasFocus) {
              input = value.toString();
              final String splitArray[] = input.split("`");
              Image avatar = null;
              try {
                   final URL avatarURL = new URL(splitArray[0]);
                   avatar = ImageIO.read(avatarURL);
              } catch (final IOException e) {
                   JOptionPane.showMessageDialog(null,
                             "Error retriving some users avatars",
                             "Image download error", JOptionPane.ERROR_MESSAGE);
              usersAvatar.setIcon(new ImageIcon(avatar));
              tweet.setText(splitArray[2]);
              userName.setText(" " + splitArray[1] + "    ");
              return mainPanel;
         }I cut out all the layout junk.
    And the input for the list is in the form avatarurl`username`tweet, which is then split and stored in the split array.
    I've had a bash at threading it based on [Improve Application Performance With SwingWorker in Java SE 6|http://java.sun.com/developer/technicalArticles/javase/swingworker/] but it meant that the avatars were all identical.
    Do I need to thread the entire list creation section instead of just the image retrival.
    All help greatly appreciated.
    For your reference --->

    I can safely say you answered my question.
    The 2 classes I added were:
    User Class import javax.swing.ImageIcon;
    public class UserClass {
         String userName;
         ImageIcon userAvatar;
         public UserClass(String user, ImageIcon avatar) {
              userName = user;
              userAvatar = avatar;
         public String getUserName() {
              return userName;
         public ImageIcon getUserAvatar() {
              return userAvatar;
    }and UserDB
    import java.awt.Image;
    import java.io.IOException;
    import java.net.URL;
    import java.util.ArrayList;
    import javax.imageio.ImageIO;
    import javax.swing.ImageIcon;
    public class UserDB {
         private ArrayList<UserClass> users;
         public UserDB(){
              users = new ArrayList<UserClass>();
         public ImageIcon getAvatar(String username){
              ImageIcon avatar = null;
              for (int i = 0; i < users.size(); i++) {
                   String beingChecked = users.get(i).getUserName();
                   if (username.equals(beingChecked)) {
                        avatar = users.get(i).getUserAvatar();
              return avatar;
         public String getUserName(int index){
              return users.get(index).getUserName();
         public int getTotalUsers() {
              return users.size();
         public void addUser(String userName, URL profileImageURL){
              Image avatar = null;
              try {
                   final URL avatarURL = profileImageURL;
                   avatar = ImageIO.read(avatarURL);
              } catch (final IOException e) {
              ImageIcon avatarIcon = new ImageIcon(avatar);
              UserClass tooAdd = new UserClass(userName, avatarIcon);
              users.add(tooAdd);
         public boolean isEmpty(){
              return users.isEmpty();
    }So now the first time it encounters a unique user for the first time it add's it too the database.
    Honestly that's an approach i would never have thought of in a million years!
    Thanks a bunch

  • Make JList Recalculate Component Widths and Heights

    I have created a subclass of JList in which every item in the list has an associated icon and the text for the item is displayed underneath the icon. The JList is given the HORIZONTAL_WRAP layout orientation by default. I have an option to show the icon and the text or just the icon. When I change this property, I have the JList refresh itself to redraw the JLabels at their new preferred sizes. Currently I do it like this:
              setVisibleRowCount(getVisibleRowCount()+1);
              setVisibleRowCount(getVisibleRowCount()-1);I'm hoping there's a better way. The repaint() method makes the text appear or disappear, but does not adjust the size of the list items until the window is resized. I tried invalidate(), revalidate(), and validate(), but they had no effect whatsoever. I tried using updateUI(), which works the first time, but generates an exception if used more than once:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at javax.swing.plaf.basic.BasicListUI$Handler.isNavigationKey(BasicListUI.java:2060)
            at javax.swing.plaf.basic.BasicListUI$Handler.keyTyped(BasicListUI.java:1986)
            at java.awt.AWTEventMulticaster.keyTyped(AWTEventMulticaster.java:182)
            at java.awt.Component.processKeyEvent(Component.java:5509)
            at javax.swing.JComponent.processKeyEvent(JComponent.java:2713)
            at java.awt.Component.processEvent(Component.java:5331)
            at java.awt.Container.processEvent(Container.java:2010)
            at java.awt.Component.dispatchEventImpl(Component.java:4021)
            at java.awt.Container.dispatchEventImpl(Container.java:2068)
            at java.awt.Component.dispatchEvent(Component.java:3869)
            at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1810)
            at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:672)
            at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:920)
            at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:798)
            at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:636)
            at java.awt.Component.dispatchEventImpl(Component.java:3907)
            at java.awt.Container.dispatchEventImpl(Container.java:2068)
            at java.awt.Window.dispatchEventImpl(Window.java:1774)
            at java.awt.Component.dispatchEvent(Component.java:3869)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

    What kind of ListModel are you using? I ask because if it's a subclass of AbstractListModel then you just call the fireContentsChanged method for the entire list.

  • Custom Cell Renderer / Video garbage on "refresh"

    I have created a custom Cell Renderer for my JTable. When the application in which this JTable is displayed, is moved into the background and then brought back "front", The application does not redraw itself completely.
    I am able to see the information contained in the JTable but none of the surrounding components. When I do a mouse click on any of the background of the surrounding panel, nothing happens.
    In order to get the entire Panel/View/all visible components to refresh themselves, I have to click on aother component (example would be switching to a different panel of the tabbed pane.)
    This only happens when I have a JTable with this particular Renderer showing. Any other panel or JTable not using this Renderer refreshes completely.
    Here is my Cell Renderer most of which I borrowed extensively from info posted in these forums:
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.io.*;
    * This is a much lighter version of the multiline renderer.  It does need to have newline
    * characters at the points where the next line should occur.
    public class CTAuditTableCellRenderer extends JList implements TableCellRenderer {
        public CTAuditTableCellRenderer() {
            setOpaque(true);
            ListCellRenderer renderer = getCellRenderer();
            ((JLabel)renderer).setHorizontalAlignment(JLabel.CENTER);
            setCellRenderer(renderer);
        *   getTableCellRendererComponent() is the only method that must be over-ridden.
        *   @param table the JTable holding cell we wish to render
        *   @param value the object which we wish to put into the cell
        *   @param isSelected boolean to allow selected cell to appear as such
        *   @param hasFocus boolean to alert as to the cell having focus
        *   @param row row of the JTable in which cell resides
        *   @param column column of the JTable in which the cell resides.
        *   @return Component the image of the value object.  Not a true object but an
        *   image of the object.
        public Component getTableCellRendererComponent(JTable table, Object value,
                                    boolean isSelected, boolean hasFocus, int row, int column) {
            if (isSelected) {
                setForeground(table.getSelectionForeground());
                setBackground(table.getSelectionBackground());
            } else {
                setForeground(table.getForeground());
                setBackground(table.getBackground());
            setFont(table.getFont());
            if (hasFocus) {
                setBorder( UIManager.getBorder("Table.focusCellHighlightBorder") );
                if (table.isCellEditable(row, column)) {
                    setForeground( UIManager.getColor("Table.focusCellForeground") );
                    setBackground( UIManager.getColor("Table.focusCellBackground") );
            } else {
                setBorder(new EmptyBorder(1, 2, 1, 2));
            String str = (value == null) ? "" : value.toString();
            BufferedReader br = new BufferedReader(new StringReader(str));
            String line;
            Vector v = new Vector();
            try {
                while ((line = br.readLine()) != null) {
                    v.addElement(line);
            } catch (IOException ex) { ex.printStackTrace(); }
            setListData(v);
            if(v.size() > 1){
                table.setRowHeight(row, (table.getRowHeight()+ 3)* v.size());
            return this;
    }Thank you in advance for your constructive, insightful, and applicable replies.
    Jerry

    Here is an entire example that shows the situation of the Frame (in this case) not updating/refreshing all of it's components when regaining focus.
    To simulate the problem, simply move "something"/another window over the sample frame and then move it off. In my case the scrollbar and the headers do not reappear until I have selected a row and scrolled the table.
    Here is the example code:
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.border.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MultiLineCellExample extends JFrame {
      MultiLineCellExample() {
        super( "Multi-Line Cell Example" );
        DefaultTableModel dm = new DefaultTableModel() {
          public Class getColumnClass(int columnIndex) {
            return String.class;
        dm.setDataVector(new Object[][]{{"aa aa aa aa aa\naa aa aa aa aa\naa aa aa aa aa","b","c"},
                                        {"A","B","C\nC"},{"x","y","z"}},
                         new Object[]{"1","2","3"});
        JTable table = new JTable( dm );
        table.setDefaultRenderer(String.class, new MultiLineCellRenderer());
        JScrollPane scroll = new JScrollPane( table );
        getContentPane().add( scroll );
        setSize( 400, 130 );
        setVisible(true);
      public static void main(String[] args) {
        MultiLineCellExample frame = new MultiLineCellExample();
        frame.addWindowListener( new WindowAdapter() {
          public void windowClosing( WindowEvent e ) {
            System.exit(0);
    }And here is the Renderer code:
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.io.*;
    public class MultiLineCellRenderer extends JList implements TableCellRenderer {
        public MultiLineCellRenderer() {
            setOpaque(true);
            ListCellRenderer renderer = getCellRenderer();
            ((JLabel)renderer).setHorizontalAlignment(JLabel.CENTER);
            setCellRenderer(renderer);
        public Component getTableCellRendererComponent(JTable table, Object value,
                                    boolean isSelected, boolean hasFocus, int row, int column) {
            if (isSelected) {
                setForeground(table.getSelectionForeground());
                setBackground(table.getSelectionBackground());
            } else {
                setForeground(table.getForeground());
                setBackground(table.getBackground());
            setFont(table.getFont());
            if (hasFocus) {
                setBorder( UIManager.getBorder("Table.focusCellHighlightBorder") );
                if (table.isCellEditable(row, column)) {
                    setForeground( UIManager.getColor("Table.focusCellForeground") );
                    setBackground( UIManager.getColor("Table.focusCellBackground") );
            } else {
                setBorder(new EmptyBorder(0, 0, 0, 0));
            String str = (value == null) ? "" : value.toString();
            BufferedReader br = new BufferedReader(new StringReader(str));
            String line;
            Vector v = new Vector();
            try {
                while ((line = br.readLine()) != null) {
                    v.addElement(line);
            } catch (IOException ex) { ex.printStackTrace(); }
            setListData(v);
            if(v.size() > 1){
                table.setRowHeight(row, (table.getRowHeight()+2)* v.size());
            return this;
    }Please, this is a very annoying problem and I would appreciate help in solving.
    Jerry

  • Refresh/reload Swing components???

    Hi all,
    I am having a problem with using a Swing frame ... I am calling a command line program on the click of a button in the frame. But as soon as the button is clicked, the swing frame is paused .. the button stays pressed as long as the program ends. My requirement is ... all those messages which are printed on the console should be printed on a Swing component (like a JLabel or JList). I have no problem doing that... but everything is visible only after the program ends... till then the swing frame remains static. Is there any way out??? Can we reload or refresh the JFrame?
    thaanx in advance

    jif1=new JInternalFrame("JIF Title",false,false,false,false);
                        Container c=jif1.getContentPane();
              c.setLayout(new BorderLayout());
                        listModel = new DefaultListModel();
                        listModel.addElement("First entry");
                                  JPanel jp=new JPanel();
                                  index=0;
                                  list = new JList(listModel);
                                  list.setVisibleRowCount(9);
                                  Font displayFont = new Font("Arial",Font.PLAIN,11);
                             list.setFont(displayFont);
                                  JScrollPane listScrollPane = new JScrollPane(jp);
                                  listScrollPane.getViewport().setView(list);
                                  list.setVisible(true);
                                  c.add(jp, BorderLayout.PAGE_END);
                                  jif1.setVisible(true);
                             jif1.setOpaque(true);
                                  jdp.add(jif1);
                                  jp.add(listScrollPane);
                                  repaint();
                                  jp.setVisible(true);
                                  try
                                            jif1.setSelected(true);
                                       } catch (java.beans.PropertyVetoException e) {}
                                  Process proc = Runtime.getRuntime().exec(command);
                                  InputStream stderr = proc.getErrorStream();
                                  InputStreamReader isr = new InputStreamReader(stderr);
                                  BufferedReader br = new BufferedReader(isr);
                                  String line = null;
                                  System.out.println("<DETAILS>");
                             while((line = br.readLine())!=null)
                                       final String con=line;
                                       final int ind=index;
                                  System.out.println(con);
    listModel.addElement(con);
                                       list.ensureIndexIsVisible(ind);
                                       index++;
                                  repaint();
                                  invalidate();
                                  validate();
                                  repaint();
                                  System.out.println("</DETAILS>");
                                  int exitVal = proc.waitFor();
                                  System.out.println("Value = " + exitVal);
                                  if(fil.exists()) System.out.println("File Created");                                                       pb.setString("Creating output file ... ");
                                  pb.setIndeterminate(true);
    ..... this internal frame should be popped up on the click of a button. but.. as soon as the button is clicked, the JFrame is frozen (... paused..) and there is no motion,... even the clicked button remains in the "clicked" state.Its only after the whole process is completed... that the internal frame becomes visible. As you can watch from the code posted above, in the while loop... I'm trying to display the status message both on the concole as well as on the list box. the console messages are displayed correctly.... but as the JFrame is not refreshed.... I'm not able to see the Internal frame as well as the list box atteched to it. please help me out.
    thanx in advance.....

Maybe you are looking for

  • My profile was 'fixed' and I am trying to return to functionality

    I had a bug on my laptop and the system experts removed my profile. That got rid of all of my workspace information. I had a backup, so I started copying everything back. I am close to getting things back, but this isn't horeshoes! I currently get th

  • Playing itunes movies from macbook to Projector over HDMI

    Hi, I'd like to play moves that are in my itunes library over an HDMI connection to a projector. I think that I will need to buy a Thunderbolt to HDMI adapter. Is there anything else that I need to know about settings for this?.. do I have to allocat

  • Help! Moved a project from laptop to desktop files are missing

    hi, sorry I am a premiere elements 7 newbie. I started my project on my laptop but unfortunately it hadn´t enough space and was not aible to work with the data flow. i bought a desktop and made the mistake that I only copied the "premiere elements pr

  • Using a string variable to create an object

    Hi, I just have a quick question. It is probably very simple but I can not seem to find an asnwer anywhere. I have a class called Receive, from this class I derrive 12 difference other classes. I also have a hashtable with a bunch of Object objects.

  • Burning to disc MUVO

    Windows XP Home. I have Creative Nomad software installed. I have successfully installed several albums on my hard dri've using Creative Nomad software. I would like to take a few of these albums and burn them to a CD? Instructions keep telling me to