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;

Similar Messages

  • TabNavigator Tab content refresh

    Hi,
    I have a TabNavigator with let's say two Tabs - TabA and TabB along with its contents. Both tab contents read and change xml on which their both contents depends. If i click TabA, then on TabB in which content i modify xml and then return to TabA which also depends on that xml but change won't be reflected like TabA content is not refreshed :/ So i am not sure how to handle that, how can i accomplish that Tab content refreshes every time i click on Tab?
    Thanks,
    Best regards

    Hi,
    I have a TabNavigator with let's say two Tabs - TabA and TabB along with its contents. Both tab contents read and change xml on which their both contents depends. If i click TabA, then on TabB in which content i modify xml and then return to TabA which also depends on that xml but change won't be reflected like TabA content is not refreshed :/ So i am not sure how to handle that, how can i accomplish that Tab content refreshes every time i click on Tab?
    Thanks,
    Best regards

  • News order in News Iviews changes upon refresh

    Hi guys,
    I've recently installed SP12 into my EP7 and I notice that the order (last created/modified should appear at the top) of my news in the news iview changes upon refreshing the iview.
    I've checked in the Content Management and see that the news which are displayed in the iview are also modified by me (which I've only displayed) within the same timestamp.
    Does anyone experience the same?

    Ok I found out a solution by changing the layout set (collection renderer), so that the news are sorted via "created" and not "modified".
    If there are anyone who have the same issue, let me know and I will be glad to help.
    Ray

  • How Can I change my refresh rate to 75hz for on LCD using 91.47 drivers?

    HI,
    I use a 19" LCD and have always changed my refresh rate to 75hz to avoid ghosting in games like fifa 06 (60hz causes a nasty ghost on my 8ms panel).  I have been using the 81.98 drivers and could create an override to use 75.   The new driver will allow me to change the refresh rate to 75, but will not let me use it - I get the message "The custom resolution cannot be added".   I have coolbits2 installed.  Is there a registry setting that I can add to allow me to change the refresh rate?  If not, I'll just go back to the 81.98.  I am also using the DVI connection.
    Thank you,
    * This is on my Sli PC in my sig. *

    I know that on my particular LCD monitor, if I go above the recommended rates, then the screen will just go black and won't let me see anything.  Usually it displays a message telling me that it cannot display.  I think it especially does this with the DVI connection.
    You may have tried it allready, but just make sure that in your display properties you have unchecked the option to only display resolutions allowed by the monitor.
    You may also want to try and see if it will let you do it with a VGA connection instead of the DVI.
    Otherwise, you just may have to go back to the earlier driver.

  • Changing content in an array

    can someone help me with changing content in an array. The index will be specified by the user entering the index number.
    eg
    Enter the item number to Change
    1
    Then I need to replace the data in this index with new data.
    I am very new to java so I am sorry if this seems like a stupid questions. Your help is much appreciated.
    thanks

    public void modifyIt(String[] myArray){
      System.out.println("Which index?");
        int index = readResponse() //read in response somehow
      System.out.println("Whats the new data?");
      String data = readResponse() // read in response
      myArray[index] = data;
    }

  • How to change content-type in receiver mail adapter

    Hi,
    I have receiver mail adapter for sending XML file as attachment in the mail. My partner expects to receive mail with content-type: text/xml, but XI sends Content-Type: application/xml. Please advise how I can change content-type to text/xml.
    Thank you
    Lev

    hi,
    try MessageTransformBean
    Transform.ContentType
    http://help.sap.com/saphelp_nw04/helpdata/en/57/0b2c4142aef623e10000000a155106/content.htm
    also shown in my blog:
    /people/michal.krawczyk2/blog/2005/11/23/xi-html-e-mails-from-the-receiver-mail-adapter
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a>

  • Change content-disposition in email attachment

    I am using apex_mail (in Apex 4.1) to send emails with an attachment.
    v_mail_id := apex_mail.send(
             p_to  => '[email protected]'
             ...etc...
    apex_mail.add_attachment( p_mail_id    => v_mail_id
                             ,p_attachment => v_image
                             ,p_filename   => 'signature.jpg'
                             ,p_mime_type  => 'image/jpeg');
    Apex creates this as an attachment:
    Content-Disposition: attachment;
    I would like to change it to inline:
    Content-Disposition: inline;
    so I can reference it in my email body with <img src="cid:signature.jpg"/>. Well... I hope it is going to be shown inline anyway if I change Content-Disposition.
    Currently (with Content-Disposition: attachment;) it works for Outlook, but, for instance, not in Gmail in the browser. Gmail shows the image separately as an attachment.
    Is there a way to change the content-disposition with Apex?
    I know it is possible to do it with utl_mail, but this is currently not installed in our databases. I need to involve our DBA to set this up, and I don't know if he is willing to do that.

    Hi Joel,
    I thought so. I will put this in the Apex feature request database.
    Ino
    BTW, for other people it might be interesting to know that there is another option I tried that doesn't work in many situations either. You can put this in the email body:
    <img src="data:image/jpeg;base64,'||v_image_base64||'"/>
    where v_image_base64 is the base64 encoded jpg image.
    From my experiments the inline attachment with a cid reference seems to work best.

  • How to change Content-Transfer-Encoding for mail sending

    Hello Experts,
    I need to send some documents through mail which i am doing with the help of cl_output_service=>document_output method. Mail is been send succesfully.
    But in the payload content which got from Exchange server:
       X-Mailer: SAP Web Application Server 7.10
       Content-Type: text/plain;
        charset="us-ascii"
       Content-Transfer-Encoding: quoted-printable
    Can any one help me, how i can change Content-Transfer-Encoding field to some other format which is not  'quoted-printable'.
    Thanks & Regards,
    Dheeraj

    Do you documents contain an XML Declaration like this at the top?
    <?xml version="1.0" encoding="ISO-8859-2"?>
    If not, then they need to. The XML 1.0 specification says that if an XML declaration is not present, the processor must default to assume its in UTF-8 encoding.

  • How to change content type from Document set to Item

    While creating content type I've selected Item as a parent but after created I can see its showing Document Set as a parent content type. Now can anyone please suggest if possible I can change the parent content type from Document Set to Item.

    Hi,
    From your description, I know you want to change content type’s parent after creating it.
    There is no OOB method to change content type’s parent after you create it. If current content type has not been used, you could delete it and recreate it with your desired base type. Here are similar cases:
    http://sharepoint.stackexchange.com/questions/16131/change-base-content-type-of-content-type
    https://social.technet.microsoft.com/Forums/sharepoint/en-US/b976f17e-99b5-42bb-bc82-8d4123a625cf/change-the-parent-of-a-content-type.
    This article may help you understand the relationship of Content type inheritance:
    https://support.office.com/en-au/article/Create-and-edit-content-types-3d5d45af-608d-4183-8d51-073095fe0312#__toc239159103.
    Best Regards
    Vincent Han
    TechNet Community Support

  • How to change contents of PDF

    Hello,
    I want to know is there any way by which i can change content of pdf.
    please tell me

    thanks..
    I have done that. using iText it is helpfull.
    Still there is a bit of problem.
    When I open the file adobe pdf is unable to open the file .
    where are foxyplayer can view it correctly with edited content so please can you
    show me possible changes to do so.

  • Loosing changed contents when used FM REUSE_ALV_GRID_DISPLAY

    Hi,
    I have used FM REUSE_ALV_GRID_DISPLAY in my program as below.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = g_repid
          i_callback_pf_status_set = c_pf
          i_callback_user_command  = 'USER_COMMAND'
          is_layout                = ist_layout      "I_CALLBACK_TOP_OF_PAGE = C_TOP
          it_fieldcat              = ist_fieldcat
        TABLES
          t_outtab                 = ist_outtab.
    and kept one column editable by setting EDIT = 'X' and INPUT = 'X' for one column in ist_fieldcat.
    Now if user changes contents of a cell in this editable column and clicks on any toolbar button, then changed contetns are not received in USER_COMMAND routine.
    But if user changes the contents of a cell in this editable column and then double-clicks anywhere inside the ALV grid, then changed contents are received in USER_COMMAND routine.
    I dont want to loose the changed contents of ALV grid, can anybody help in this.
    Thanks in advance.
    Regards,
    Dhiraj

    In your USER_COMMAND form check the SY-UCOMM  for button which you have pressed may be you have used '&IC1'  (for double click)
    provide your Form USER_COMMAND code here.
    Kanagaraja L

  • Unable to change content types for pptx, xslx and docx files

    I'm running into an issue where I cannot change the content type of any xml-based Office documents. Here's what I've done:
    1 - Create a custom content (A) type based off the Document content type
    2 - Enable the custom content type in a document library
    3 - Add a document or select an existing document and edit the content type to the custom content type
    4 - The custom content type will save for documents such as .ppt, .doc, etc. The custom content type will now save for .docx, .pptx or .xlsx files. The properties window will save without displaying any errors but the content type will not change
    I ran several tests including creating another custom content type (B) based off of the Document content type. I proved that:
    The custom content type (B) can be saved to .docx, .pptx or .xlsx files IF no additional columns are added to the custom content type
    As soon as I add a column to the custom content type the aforementioned documents cannot be saved as that custom content type 
    Documents created through the File option in a document library also fail to change content type to the custom content type when saved. Most of my files are .docx, .pptx, or .xlsx files, and this issue poses a significant roadblock in our SharePoint roll-out.
    I appreciate any advise you can provide.

    Hi,
    According to your post, my understanding is that the custom content type could not save with .docx, pptx and xlsx files when with a additional column.
    I tested with your issue as the steps below, the custom content type worked well.
    Create a custom column Doc1
    Create a custom content type Doc1, the parent content type from chose the Document Content Types, Parent Content Type chose Document.
    Add the custom Doc1 to the custom content type Doc1.
    Add the custom content type into the library LIbA.
    Upload the files with .docx, .pptx and .xlsx files into the library with the custom content type, they all save well with the custom content type.
    I also create other content type with other Parent Content Type, they all worked.
    Did the issue occur in other library? You can create a new library then use the custom content type to check whether it works.
    You can also use the other browsers to check whether it works, such as Chrome, Firefox.
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • How to change content of DataGrid cell on mouse over

    I am trying to change content of a datagrid cell when the mouse is over it. Changing the dataProvider does not provide immediate feedback because update is performed by renderer. I am trying to directly update content of a cell onMouseOver and restore it onMouseOut.
    I am thinking of leaving the column empty and insert content onMouseOver, cleanup onMouseOut. Alternative, may be I can populate the column and mask out all but the cell the mouse is over.
    Any suggestion on how this may be done?
    Thanks!

    I would override updateDisplayList, call isItemHighlighted and set the content of the cell accordingly
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui

  • How to change Content canvas size during run time?

    Hi All,
    I am using oracle 10g web forms and opening in Separate Frame. When I re-size the MID window, I want to change Content canvas size to window size. Is it possible to change content canvas size at run time? Even after using following statement it is not working.
    set_canvas_property('content_can', WIDTH, 200 );
    set_canvas_property('content_can', HEIGHT, 100 );
    Please help me.
    Regrads

    Francois,
    Yes, I have used messages, when get the current values (after setting new values) it shows right one but on the screen it is not accurate because
    it is going beyond the window size and it adding scroll bars. I am using window W&H minus some numbers. When I look at the help it says size in characters. How to set the Content canvas size in characters?
    Is it possible to change the Content Canvas size in Run time? Please help me.
    Regards.

  • Changing default refresh time for the UWL.

    Hello,
    I am trying to change the Default refresh time for the UWL(workflow inbox) for all the users before they personalize or save the refresh time, Would changing the refresh time in the .xml file work or is there any other way to do it? Thanks,
    Aniketh R.

    We have had all sorts of issues with this as well. I have been unable to find a solution that works as of yet. From my own debugging it seems as if RP is trying to parse the pasted text as logo's, fields etc.... I am looking at potentially using a script w/ set interval to "clean" the clipboard data but this isn't a perfect solution for numerous reasons.
    What is happening to your letters when the users paste? Our letters actually become unusable after a plugin save. So I am actually very interested in the answer to this question!

Maybe you are looking for

  • I have ver 10.5.8 with 4Gb of memory, can I upgrade to snow leopard?

    I have a Mac Pro running version 10.5.8 with 4Gb of memory, can I upgrade to snow leopard?  My info is: Processor 2x2.8 Ghz Intel Memory 4GB but when I saw the upgrade for Snow Leopard it said something about needing 5GB? I'm not the best with tech s

  • NWDS 7 does not compile JSPs

    I have recently downloaded NWDS tool that comes with the NW04s trial version (NWDS version 7). When I create portal components (par files), NWDS does not compile the java files.  It creates a par file even with errors in Java. Is this a new "feature"

  • Dimp88

    Pics in organizer window not automatically opening in editor window when "Full Edit" is selected

  • How do I stop getting "MEET MOZILLA FIRE FOX" for the startup screen?

    As well, most, but not all, of my bookmarks have lost their icons. Showing a blank square where they used to proceed the text.

  • Airprt not finding networks

    i have a macbrook less than a year old.  the AirPort is not locating my network or other networkks in the neighborhood.  When it does, I get a network with Safari even though its connected. Any ideas?