JLayerPane draws random components from different layers.

Hello,
I am running the latest version of JAVA 1.6 on Mac OS X. I am using JLayerPane and I have three panels where. The problem is that when application starts it draws JTextFields from the third layer, but they don't work. When I go to the last panel (the third) one, I just let's say open my Skype it draws JButton's from the second layer and judging from working effects they do work. Any ideas what's wrong?
David

For more help create a [SSCCE (Short, Self Contained, Compilable and Executable, Example Program)|http://sscce.org], that demonstrates the incorrect behaviour.
Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

Similar Messages

  • How to draw transparent boxes in different layers including Size inside box

    See this apps http://www.pixelwindowapp.com/
    How to do this thing inside photoshop using Shapes or from any other method. see added video on this page to understand.
    In photoshop i want to draw transparent boxes (round corner not necessary) in different layers including Size in pixel like this Adobe air apps http://www.pixelwindowapp.com/ do on desktop
    http://www.pixelwindowapp.com/

    Hi Anvano,
    You don't actually have to draw the live features to be able to access the attributes. You can just call getLiveFeatureAttrs(x, y, tolerance) on your MapViewer instance to get hold of the attributes, you can use this in getToolTipText() of your component to show the attributes in a pop-up. No drawLiveFeatures needed! This way you still have to add a theme twice (once for drawing, once for the attributes) but it only gets drawn once, just in the nice style.
    Ida

  • Referencing repeated components from different AS file

    Hi
    I am having a View SatSetting.mxml and it has repeater
    component which is text field.I am trying to assign the value to it
    from different action script file like below code snippet
    msatView:SATSetting = new SATSetting();
    msatView.taxid_ti[0].text = "Testing";
    where taxid_ti is the id of the textinput inside the
    repeater.
    I am getting null exception at line #2
    I am following the steps in flex doc but still getting this
    error.
    Thanks in advance
    K

    What you need to do is pass a reference for your GUI mainline class to the constructor of your subcomponents and keep a reference to the subcomponents in the mainline. This way the main GUI object can refer to methods in the other objects and they can refer to methods in the GUI.
    eg:
    class GuiMain extends JFrame
        MyMenu menu;
        MyButtons buttons;
        GuiMain()
           menu = new MyMenu(this);
           buttons = new MyButtons(this);
           // the rest of the constructor
        // the rest of the class
        m.buildMenu("File");
    // in separate files
    class MyMenu
        GuiMain parent;
        MyMenu(GuiMain parent)
            this.parent = parent;
            // rest of constructor
        // rest of menu class
        void mnuExit()
           parent.doExit();  // ask parent to shut down
    // other classes

  • Passing events down components in different layers

    Hi,
    Summary: How to pass events to lower level containers
    in a multi layered container system.
    This is the scenario which I have
    2 Small panels (non overlapping)are added to the content pane using
    getContentPane.add(component). Both of them have tool tips associated with them.
    Now I am adding semi transparent pane partially overlapping the above two panes and on the top of it. I achieve it by doing
    getContentPane.add(component, 0 )
    There is no tooltip associated with it.
    When I move the mouse over the non-overlapping areas, i get the tool tip associated with the panel. When I move the mouse over the overlapping area. No tool tip comes. Now I would like to display the tool tip based on the component based below the semi transparent , ofcourse depending on whether the mouse is over the overlapping area.
    Regards,
    Revon

    Here's an idea:transparentPane.addMouseListener(new MouseAdapter(){
       public void mouseEntered(MouseEvent e)
          // depending the components 1 and 2's positioning,
          // in relation to where mouse is over transparentPane,
          // you can determine who to fowaredEvent to
          if(mouseOnTopOfComponent1)
             fowardEvent(component1, e);
          else if(mouseOnTopOfComponent2)
             fowardEvent(component2, e);
    private void forwardEvent(Component c, MouseEvent e)
       c.dispatchEvent(new MouseEvent(c, e.getID(),
                                      e.getWhen(),
                                      e.getModifiers(),
                                      e.getX(), e.getY(),
                                      e.getClickCount(),
                                      e.isPopupTrigger()));
    }

  • Copying the Components from different applications

    Hi, 
                  I have a requirement where components should be copied from 1 application to another application. I cannot use export/import commands as it will overwrite the content in the second application. I want to achieve the similar functionality for which user copies pages/cartridges within application. Is there any way to do it?
    Regards,
    Aashish U S

    I think you can extract contents from both workbench by using emgr_update cmd and merged them locally (xml files) and import the desired content to workbench by using emgr_update cmd.   The challenging part would be merging the two content (XML) files,   depending on how complex your requirements, you might be just manually find/replace or you can write a program to merge them.
    Thanks,
    Meng

  • Grouplayout link size of components from different jpanels

    Hi,
    i have a gui in which i has 5 panels (layed out from top to bottom in one column, using grouplayout).
    now inside each of the panels it looks like this (they use grouplayout as well):
    label 1          component
    labelexample 2     componenthowever, the labels arent always the same size, e.g. the labels in panel 3 are 50% longer than the ones in panel 5
    so all in all it looks like this:
    label 1            component
    labelexample 2      component
    label 1                    component
    labelexample_takesmorespace 2      component
    label 1 component
    label 2 componentI'd really like all the labels be the same size, so that the components all start at the same line. ive tried layout.linksize in the main frame, but this doesnt work, since the jlabels arent in a group in the main frame layout :( ( --> an exception is being thrown)
    is there a way to do this? Any help apprechiated :)
    Edited by: kaori_chan on Jul 21, 2010 7:43 AM

    If the preferred sizes (strictly speaking, preferred widths) of all the "component" components in your layout are the same, it should be fairly trivial using a GridBagLayout with appropriate weightx and fill constraints.
    db

  • Updating Swing components from a different class

    I would like to use the JTextArea component in a JFrame to display fast updating text from my application. My application is very simple. When the app launches the GUI is created then my application engine would start processing and displaying text data into the GUI. After reading about Thread safety when using Swing components I concluded it would not be a good idea for my app engine class to update the JTextArea class directly using methods such as .append(String).
    I would be grateful for any suggestions on how I should approach updating Swing components from different classes.
    Many Thanks in advance Sean

    Hi
    Why don't you just implement a basic callback method?
    To do this the right way you should probably define a simple Interface that has a public method like updateProcessText(String s). Your swing class then implements this interface, basically forcing it to provide the public method you defined (this is no different than implementing ActionListener, which forces you to define actionPerformed). Secondly modify your processing class, so that it take's a class that implements the interface you just created, as one of the arguments in it's constructor. Lastly assign the argument from your construnctor to a private var - this will enable your processing class to have a handle to your swing class and update it as it pleases.
    This might sound very complex, but it's really simple once you've done it once.

  • I have 160gb of music on my Classic, 6th Gen (I think) I've just bought it. Is it possible for it to play my songs in a random order, one or two from different albums?

    I have 160gb of music on my Classic, 6th Gen (I think) I've just bought it. Is it possible for it to play my songs in a random order, one or two from different albums?

    To add to what Stonerock has mentioned, you can either create Playlists in your iTunes Library, containing exactly what you want, and then Sync them to your iPod, or you can use the iPod Classic's On-The-Go feature.
    Reading between the lines, I'm going to assume for now that you want to be able to create your preferred listening list while "out and about" - so not near your iTunes library. (You have posted in iPod Classic, after all.) You can do this with the On-The-Go Playlist.
    Look in the Playlists menu on the iPod. It probably contains the Recently Added, Recently Played and other pre-made Playlists that you see in your iTunes Library. At the bottom of the Playlists list, is the On-The-Go showing 0 Songs. Scroll down to it and press the Select (centre) button. The screen will give you instruction on adding songs to the On-The-Go Playlist.
    Basically, if you press-and-hold the Select (centre) button, while highlighting a song, the song title will blink as it is added to the On-The-Go Playlist. Try it, then go back to Playlists/On-The-Go and notice that it will now say 1 Song. (Note, you cannot add a "now playing" song to the On-The-Go Playlist.) Repeat this for every song you want to have in the list. You can also look in the Albums menu, highlight the album title and press-and-hold that to add the complete album to your On-The-Go Playlists with one press. So if you add the two albums to your On-The-Go Playlist, you can then listen to just those two albums.
    To shuffle the songs, turn on Shuffle on your iPod. Either, go into Settings/Shuffle and press the Select button to toggle between Off/Songs/Albums, or on the Now Playing screen, press the Select button three times to reach the Shuffle option, where you use the scroll wheel to move between Off/Songs/Albums, press the Select button to activate it.
    Having added songs to the On-The-Go Playlist, go into it and notice the list of songs and options to Save Playlist (New Playlist 1) or Clear Playlist. If you use Sync to manage your iPod (and that really is the best way by the way), the next Sync will transfer any unsaved On-The-Go and any New Playlist Xs that you have, back to your iTunes Library. You can even remove any song from the current On-The-Go Playlist by highlighting it (in the On-The-Go, obviously) and press-and-holding the Select button.
    If you need assistance in creating a Playlist in your iTunes Library, please ask.

  • WD My Passport 1TB USB external drive randomly ejects from my iMac and MacBook Pro.  I have tried two separate USB cords.  I have updated the firmware.  I have tried it on my MacBook, two different Macbook Pro's, and my iMac.  All give the

    WD My Passport 1TB USB external drive randomly ejects from my iMac and MacBook Pro.
    The drive is approximately 4 years old.  When the drive is plugged in, I can see the data.  It appears to be working properly.  The only problem is that everyone of my Apple Machines are ejecting it.   Several years ago, this drive connected to Mac machines with no problems.   I have tried two separate USB cords.  I have updated the firmware.  I have tried it on my MacBook, two different Macbook Pro's, and my iMac.  
    All give the same result of random ejection of the drive and the error message of:
    Disk Not Ejected Properly
    Eject "1TB Passport HD" before disconnecting or turning......
    Searching through the web, it seems this is an common/known problem.   Does anyone know the solution?
    Thanks,

    Send Apple feedback. They won't answer, but at least will know there is a problem. If enough people send feedback, it may get the problem solved sooner.
    Feedback

  • Dynamic link confusing two separate AE compositions in PPro from different projects

    I am using CS5 Master Collection for Windows 7 (64 bit) on an HP Pro desktop (Intel core 2 duo, 6Gb RAM). The tower has two hard drives installed (no RAID). CS5 is installed on the original C drive along with the OS, but the working files, footage etc are all on the larger, secondary F drive.
    I am working on a DVD project consisting of several seperate PPro projects. Each project has been colour corrected in AE using dynamic linking. Recently two of my projects suddenly became mixed up, by which I mean the video (not the audio) from one AE composition in one project has taken the place of another in another project. The clip remains the same length, but the link apears to be referencing the wrong clip during playback. Interestingly, there are two clips on the track above the affected clip that fade out and in at either end, during the dissolves between clips, the correct footage plays. It is only when the clip plays by itself that the problem occurs. The next clip also has the same error, though the problem only occurs for half the clip and then suddenly corrects itself. Just to be clear, All clips have been rendered, there are no more than two video tracks on the sequence, and I have tried replacing the composition from the asset menu (in which the clip plays back correctly), but the problem remains in the sequence.
    I hope that descrition is clear enough. My guess is some kind of file path error in the dynamic link, perhaps due to the separate hard drive. But I really wouldn't know. I'm very pressed for time right now and I'd prefer not to go against workflow and re-edit a new composition in AE, I would also like to understand what is going on in case it happens again.
    Any help with ths problem would be appreciated,
    J

    Thanks Colin, I tried what you suggested with both the AE Project that it should be referencing and the AE project it is erroneously referencing but both failed to fix the issue. Its as if a hidden clip were laid over the top of the one I want to play. Frustrating.
    Date: Mon, 24 Oct 2011 19:47:03 -0600
    From: [email protected]
    To: [email protected]
    Subject: Dynamic link confusing two separate AE compositions in PPro from different projects
        Re: Dynamic link confusing two separate AE compositions in PPro from different projects
        created by Colin Brougham in Premiere Pro CS5 & CS5.5 - View the full discussion
    It's not the comps that are the problem; it's the project file names themselves. You can have all the comps in a project named the same thing, and it'll be fine, but naming projects incrementally is an issue. After Effects includes a versioning function (Save and Increment) that will create a new AE project file with a serial number, e.g. AE Project 01, AE Project 02, etc. This is all well and good if you're just working in After Effects, but Dynamic Link gets confused and will usually start looking at the later project file for comps. That will just create a big mess, as you've found. Changing the names of the project files won't help things relink automatically properly, but it can help you fix things. Make all your DL AE comps offline in your Pr projects, and name your AE projects in a manner that is not serial (give them more random names). Select your offline AE comps, and right-click > Link Media, and point to the new AE project. Things should link up correctly then--but if they don't, you'll just have to remove all the AE comps from your Pr project, reimport the comps from the newly-named AE project, and replace them. It's a pain but it'll probably just keep getting worse if you don't.
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/3988711#3988711
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/3988711#3988711. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Premiere Pro CS5 & CS5.5 by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • How can i show images from different folders  in image gallery

    Hi All,
             i have downloaded and executed photo viewer image gallery application.
              in that we r showing images sequentially what we have defined in xml file.
             but i want show images randomly or i want show images from different gallary.
    Can any one help me.
    thanks
    Raghu.

    WaqarLFC7 wrote:
    On Windows:
    Ctrl + click on the songs you want to group - then right click and click get info and it will ask you if you want to get info for multiple items click YES then under album name it whatever you want and them songs will be grouped into 1 album.
    Mac:
    Same procedure but hit SHIFT instead of CTRL.
    Actually, it's right click or ctrl click, same as windows.

  • How to combine data from different input forms outside a nested iView

    Hi,
    i try to combine data from different input forms in a single one.
    Because of space reasons in Flex compiling i already use nested iViews. Within these nested iViews its possible to use the 'combine' function to do this.
    But in the main iView I cant compose these function with other elements. I need to do this because of using these model in Guided Procedures with output parameters. These parameters I only get with a 'endPoint'. Unfortunatly its not possible to combine data from different input forms into the 'endPoint'.
    Is there any solution?
    Thanx
    Mathias

    Hi Scott,
    i tried this already and i also tried to map all parameters in the endpoint by drawing lines from the other forms and assign the 'empty parameters' by a formula.
    And when i create a collable object in GP and assign the VC iView, only the parameters of the parent-form (the form who trigger the event) are shown as output-parameters.
    Maybe any other ideas? I cant believe that such a simple thing is not possible?!?!
    In my opinion, thats a bug, that I'am not able to use the combine-operator in the main VC-iView. Whats your mind?
    greets
    mathias

  • How to pass/share components between different JPanels/Container

    Dear Friends,
    I know here a lot Java Guru, I met a problem below.
    How can I pass components between different JPanels??
    here, ListPanelMain.java is main,
    When I click a tree node in splitPane, I can see all its children on the right splitpane, but I hope they can be seen on another Panel called "ListRightPane.java"
    How to do it??
    Why cannot pass??
    [1]. main Program:
    package swing.com.test.test;
    import javax.swing.JFrame;
    import java.awt.BorderLayout;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JSplitPane;
    import javax.swing.JTextArea;
    import java.io.Serializable;
    import swing.com.test.test.ListPanel;
    import java.awt.GridLayout;
    public class ListPanelMain implements java.io.Serializable{
         private JFrame frame;
         * Launch the application
         * @param args
         public static void main(String args[]) {
              try {
                   ListPanelMain window = new ListPanelMain();
                   window.frame.setVisible(true);
              } catch (Exception e) {
                   e.printStackTrace();
         * Create the application
         public ListPanelMain() {
              initialize();
         * Initialize the contents of the frame
         private void initialize() {
              frame = new JFrame("FileTreePanelMain");
              frame.setBounds(100, 100, 900, 675);
         //     FieTreePanelComm      ftreecomm                = new      FieTreePanelComm();
              ListPanel                ftree                     = new      ListPanel("C:\\");
    //          ListAllFile           ftree                     = new      ListAllFile("C:\\");
         //     FileTreePanelText      fileTreePanelText      = new      FileTreePanelText(ftreecomm);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              final JPanel panel = new JPanel();
              panel.setLayout(new GridLayout(0, 2));
              frame.getContentPane().add(panel, BorderLayout.CENTER);
         //     final JSplitPane splitPane = new JSplitPane();
         //     frame.getContentPane().add(splitPane, BorderLayout.CENTER);
         //     splitPane.setLeftComponent(ftree);
              panel.add(ftree);
              final ListRightPanel listRightPanel = new ListRightPanel(ftree);
              //splitPane.setRightComponent(listRightPanel);
              panel.add(listRightPanel);
         frame.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
         System.exit(0);
         frame.pack();
         frame.setVisible(true);
    [2]. Program 2:
    package swing.com.test.test;
    //File System Tree
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.GridLayout;
    import java.io.File;
    import java.util.Iterator;
    import java.util.Vector;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.JPanel;
    import javax.swing.event.TreeModelEvent;
    import javax.swing.event.TreeModelListener;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.TreeModel;
    import javax.swing.tree.TreePath;
    import java.io.Serializable;
    public class ListPanel extends JPanel implements Serializable{
    protected JTree fileTree;
    private FileSystemModel fileSystemModel;
    private JTextArea ltextArea = new JTextArea();
    protected JTextArea fileDetailsTextArea = new JTextArea();
    private String str = "";
         public String getlTextArea() {
                   //textArea.getText();
                   return str;
         public String setlTextArea(String ta) {
                   ltextArea.setText(ta);
                   str = ta;
                   return str;
    public ListPanel(String directory) {
    //super("JTree FileSystem Viewer");
                   setLayout(new BorderLayout());
                   final JPanel panel = new JPanel();
                   panel.setLayout(new BorderLayout());
              add(panel, BorderLayout.CENTER);
    fileDetailsTextArea.setEditable(false);
    fileSystemModel = new FileSystemModel(new File(directory));
    fileTree = new JTree(fileSystemModel);
    fileTree.setEditable(true);
    fileTree.addTreeSelectionListener(new TreeSelectionListener() {
    public void valueChanged(TreeSelectionEvent event) {
    System.out.println("1. What we save is: getlTextArea() =" + getlTextArea() );
    File file = (File) fileTree.getLastSelectedPathComponent();
    fileDetailsTextArea.setText(getFileDetails(file));
    final ListRightPanel lrp = new ListRightPanel(this);
    lrp.textArea.setText(getFileDetails(file));
    setlTextArea(getFileDetails(file));
    System.out.println("2. What we save is: getlTextArea() =" + getlTextArea() );
              final JSplitPane splitPane = new JSplitPane();
              panel.add(splitPane, BorderLayout.CENTER);
              final JPanel panel_1 = new JPanel();
              splitPane.setLeftComponent(panel_1);
              panel_1.add(new JScrollPane(fileTree));
              final JPanel panel_2 = new JPanel();
              splitPane.setRightComponent(panel_2);
              panel_2.add(new JScrollPane(fileDetailsTextArea));
    setVisible(true);
    private String getFileDetails(File file) {
    if (file == null)
    return "";
    StringBuffer buffer = new StringBuffer();
    if (file.listFiles()!=null){
         for (int i=0; i< file.listFiles().length; i++){
         buffer.append(((file.listFiles())) + "\n");
         System.out.println("List all files");
    return buffer.toString();
    public static void main(String args[]) {
    new ListPanel("c:\\");
    class FileSystemModel implements TreeModel {
    private File root;
    private Vector listeners = new Vector();
    public FileSystemModel(File rootDirectory) {
    root = rootDirectory;
    public Object getRoot() {
    return root;
    public Object getChild(Object parent, int index) {
    File directory = (File) parent;
    String[] children = directory.list();
    return new TreeFile(directory, children[index]);
    public int getChildCount(Object parent) {
    File file = (File) parent;
    if (file.isDirectory()) {
    String[] fileList = file.list();
    if (fileList != null)
    return file.list().length;
    return 0;
    public boolean isLeaf(Object node) {
    File file = (File) node;
    return file.isFile();
    public int getIndexOfChild(Object parent, Object child) {
    File directory = (File) parent;
    File file = (File) child;
    String[] children = directory.list();
    for (int i = 0; i < children.length; i++) {
    if (file.getName().equals(children[i])) {
    return i;
    return -1;
    public void valueForPathChanged(TreePath path, Object value) {
    File oldFile = (File) path.getLastPathComponent();
    String fileParentPath = oldFile.getParent();
    String newFileName = (String) value;
    File targetFile = new File(fileParentPath, newFileName);
    oldFile.renameTo(targetFile);
    File parent = new File(fileParentPath);
    int[] changedChildrenIndices = { getIndexOfChild(parent, targetFile) };
    Object[] changedChildren = { targetFile };
    fireTreeNodesChanged(path.getParentPath(), changedChildrenIndices, changedChildren);
    private void fireTreeNodesChanged(TreePath parentPath, int[] indices, Object[] children) {
    TreeModelEvent event = new TreeModelEvent(this, parentPath, indices, children);
    Iterator iterator = listeners.iterator();
    TreeModelListener listener = null;
    while (iterator.hasNext()) {
    listener = (TreeModelListener) iterator.next();
    listener.treeNodesChanged(event);
    public void addTreeModelListener(TreeModelListener listener) {
    listeners.add(listener);
    public void removeTreeModelListener(TreeModelListener listener) {
    listeners.remove(listener);
    private class TreeFile extends File {
    public TreeFile(File parent, String child) {
    super(parent, child);
    public String toString() {
    return getName();
    [3]. Program 3:
    package swing.com.test.test;
    import java.awt.BorderLayout;
    import java.io.File;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.event.TreeModelEvent;
    import javax.swing.event.TreeModelListener;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.TreeModel;
    import javax.swing.tree.TreePath;
    import java.io.Serializable;
    public class ListRightPanel extends JPanel implements TreeSelectionListener, Serializable{
         protected JTextArea textArea;
    //     protected ListAllFile laf;
    private String str = "";
              public String getlTextArea() {
                        //textArea.getText();
                        return str;
              public String setlTextArea(String ta) {
                        str = ta;
                        return str;
         * Create the panel
         public ListRightPanel(ListPanel laff) {
              super();
              setLayout(new BorderLayout());
              final JPanel panel = new JPanel();
              panel.setLayout(new BorderLayout());
              add(panel, BorderLayout.CENTER);
              textArea = new JTextArea();
    final String st = laff.getlTextArea();
    System.out.println("####################################");
    System.out.println("st=" + st);
         laff.fileTree.addTreeSelectionListener(new TreeSelectionListener() {
         public void valueChanged(TreeSelectionEvent event) {
         //laff.textArea.setText(getFileDetails(file));
              textArea.setText(getlTextArea());
         System.out.println("ListRightPanel Was Invoked from ListPanel!!getlTextArea() =" + getlTextArea() );
         System.out.println("st=" + st);
              panel.add(textArea, BorderLayout.CENTER);
         public void valueChanged(TreeSelectionEvent e){};
    It is runnable program, just compile and run it in Console is ok,
    Regards
    Sunny

    Thnaks, code post again, see
    [1]. package swing.com.test.test;
    import javax.swing.JFrame;
    import java.awt.BorderLayout;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JSplitPane;
    import javax.swing.JTextArea;
    import java.io.Serializable;
    import swing.com.test.test.ListPanel;
    import java.awt.GridLayout;
    public class ListPanelMain implements java.io.Serializable{
         private JFrame frame;
          * Launch the application
          * @param args
         public static void main(String args[]) {
              try {
                   ListPanelMain window = new ListPanelMain();
                   window.frame.setVisible(true);
              } catch (Exception e) {
                   e.printStackTrace();
          * Create the application
         public ListPanelMain() {
              initialize();
          * Initialize the contents of the frame
         private void initialize() {
              frame = new JFrame("FileTreePanelMain");
              frame.setBounds(100, 100, 900, 675);
         //     FieTreePanelComm      ftreecomm                = new       FieTreePanelComm();
              ListPanel                 ftree                     = new      ListPanel("C:\\");
    //          ListAllFile            ftree                     = new      ListAllFile("C:\\");
         //     FileTreePanelText      fileTreePanelText      = new      FileTreePanelText(ftreecomm);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              final JPanel panel = new JPanel();
              panel.setLayout(new GridLayout(0, 2));
              frame.getContentPane().add(panel, BorderLayout.CENTER);
         //     final JSplitPane splitPane = new JSplitPane();
         //     frame.getContentPane().add(splitPane, BorderLayout.CENTER);
         //     splitPane.setLeftComponent(ftree);
              panel.add(ftree);
              final ListRightPanel listRightPanel = new ListRightPanel(ftree);
              //splitPane.setRightComponent(listRightPanel);
              panel.add(listRightPanel);
                frame.addWindowListener(new WindowAdapter() {
                     public void windowClosing(WindowEvent e) {
                         System.exit(0);
                 frame.pack();
                 frame.setVisible(true);
    }[2] Program 2
    package swing.com.test.test;
    //File System Tree
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.GridLayout;
    import java.io.File;
    import java.util.Iterator;
    import java.util.Vector;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.JPanel;
    import javax.swing.event.TreeModelEvent;
    import javax.swing.event.TreeModelListener;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.TreeModel;
    import javax.swing.tree.TreePath;
    import java.io.Serializable;
    public class ListPanel extends JPanel implements Serializable{
      protected JTree fileTree;
      private FileSystemModel fileSystemModel;
      private JTextArea ltextArea = new JTextArea();
      protected JTextArea fileDetailsTextArea = new JTextArea();
      private String str = "";
         public  String getlTextArea()  {
                   //textArea.getText();
                      return str;
         public  String setlTextArea(String ta)  {
                   ltextArea.setText(ta);
                   str = ta;
                      return str;
      public ListPanel(String directory) {
        //super("JTree FileSystem Viewer");
                   setLayout(new BorderLayout());
                   final JPanel panel = new JPanel();
                   panel.setLayout(new BorderLayout());
                  add(panel, BorderLayout.CENTER);
        fileDetailsTextArea.setEditable(false);
        fileSystemModel = new FileSystemModel(new File(directory));
        fileTree = new JTree(fileSystemModel);
        fileTree.setEditable(true);
        fileTree.addTreeSelectionListener(new TreeSelectionListener() {
          public void valueChanged(TreeSelectionEvent event) {
            System.out.println("1. What we save is: getlTextArea() =" + getlTextArea() );
            File file = (File) fileTree.getLastSelectedPathComponent();
            fileDetailsTextArea.setText(getFileDetails(file));
            final ListRightPanel lrp = new ListRightPanel(this);
            lrp.textArea.setText(getFileDetails(file));
            setlTextArea(getFileDetails(file));
            System.out.println("2. What we save is: getlTextArea() =" + getlTextArea() );
              final JSplitPane splitPane = new JSplitPane();
              panel.add(splitPane, BorderLayout.CENTER);
              final JPanel panel_1 = new JPanel();
              splitPane.setLeftComponent(panel_1);
              panel_1.add(new JScrollPane(fileTree));
              final JPanel panel_2 = new JPanel();
              splitPane.setRightComponent(panel_2);
              panel_2.add(new JScrollPane(fileDetailsTextArea));
        setVisible(true);
      private String getFileDetails(File file) {
        if (file == null)
          return "";
        StringBuffer buffer = new StringBuffer();
        if (file.listFiles()!=null){
             for (int i=0; i< file.listFiles().length; i++){
             buffer.append(((file.listFiles())) + "\n");
         System.out.println("List all files");
    return buffer.toString();
    public static void main(String args[]) {
    new ListPanel("c:\\");
    class FileSystemModel implements TreeModel {
    private File root;
    private Vector listeners = new Vector();
    public FileSystemModel(File rootDirectory) {
    root = rootDirectory;
    public Object getRoot() {
    return root;
    public Object getChild(Object parent, int index) {
    File directory = (File) parent;
    String[] children = directory.list();
    return new TreeFile(directory, children[index]);
    public int getChildCount(Object parent) {
    File file = (File) parent;
    if (file.isDirectory()) {
    String[] fileList = file.list();
    if (fileList != null)
    return file.list().length;
    return 0;
    public boolean isLeaf(Object node) {
    File file = (File) node;
    return file.isFile();
    public int getIndexOfChild(Object parent, Object child) {
    File directory = (File) parent;
    File file = (File) child;
    String[] children = directory.list();
    for (int i = 0; i < children.length; i++) {
    if (file.getName().equals(children[i])) {
    return i;
    return -1;
    public void valueForPathChanged(TreePath path, Object value) {
    File oldFile = (File) path.getLastPathComponent();
    String fileParentPath = oldFile.getParent();
    String newFileName = (String) value;
    File targetFile = new File(fileParentPath, newFileName);
    oldFile.renameTo(targetFile);
    File parent = new File(fileParentPath);
    int[] changedChildrenIndices = { getIndexOfChild(parent, targetFile) };
    Object[] changedChildren = { targetFile };
    fireTreeNodesChanged(path.getParentPath(), changedChildrenIndices, changedChildren);
    private void fireTreeNodesChanged(TreePath parentPath, int[] indices, Object[] children) {
    TreeModelEvent event = new TreeModelEvent(this, parentPath, indices, children);
    Iterator iterator = listeners.iterator();
    TreeModelListener listener = null;
    while (iterator.hasNext()) {
    listener = (TreeModelListener) iterator.next();
    listener.treeNodesChanged(event);
    public void addTreeModelListener(TreeModelListener listener) {
    listeners.add(listener);
    public void removeTreeModelListener(TreeModelListener listener) {
    listeners.remove(listener);
    private class TreeFile extends File {
    public TreeFile(File parent, String child) {
    super(parent, child);
    public String toString() {
    return getName();
    [3] Program 3:
    package swing.com.test.test;
    import java.awt.BorderLayout;
    import java.io.File;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.event.TreeModelEvent;
    import javax.swing.event.TreeModelListener;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.TreeModel;
    import javax.swing.tree.TreePath;
    import java.io.Serializable;
    public class ListRightPanel extends JPanel implements TreeSelectionListener, Serializable{
         protected JTextArea textArea;
    //     protected ListAllFile  laf;
        private String str = "";
              public  String getlTextArea()  {
                        //textArea.getText();
                           return str;
              public  String setlTextArea(String ta)  {
                        str = ta;
                           return str;
          * Create the panel
         public ListRightPanel(ListPanel  laff) {
              super();
              setLayout(new BorderLayout());
              final JPanel panel = new JPanel();
              panel.setLayout(new BorderLayout());
              add(panel, BorderLayout.CENTER);
              textArea = new JTextArea();
            final String st = laff.getlTextArea();
            System.out.println("####################################");
            System.out.println("st=" + st);
             laff.fileTree.addTreeSelectionListener(new TreeSelectionListener() {
                 public void valueChanged(TreeSelectionEvent event) {
                   //laff.textArea.setText(getFileDetails(file));
                      textArea.setText(getlTextArea());
                     System.out.println("ListRightPanel Was Invoked from ListPanel!!getlTextArea() =" + getlTextArea() );
                     System.out.println("st=" + st);
              panel.add(textArea, BorderLayout.CENTER);
           public void valueChanged(TreeSelectionEvent e){};
    }You can try this one, thanks again
    sunny

  • Problem removing components from JLayeredPane

    Hi all,
    I have a problem showing and hiding components on a JLayeredPane. It goes Something like this:
    In my application I have a button. When this button is pressed I use getLayeredPane to get the frames layered pane. I then add a JPanel containing a number of labels and buttons onto that layered pane on the Popup layer. The panel displays and funcitons correctly.
    The problem comes when I try to remove the panel from the layered pane. The panel does not dissappear and I am no longer able to click on anything else in the frame!
    If anyone has any ideas how to get around this or what the problem might be I'd be very greatful to hear it. Sample code follows:
          * Called when the button on the frame is pressed:
          * @param e
         public void actionPerformed(ActionEvent e)
                    JLayeredPane mLayredPane = getLayeredPane();
              int x = 0, y = 0;
              Container c = this;
              while (true)
                   c = c.getParent();
                   if (c != null)
                        x += c.getLocation().x;
                        y += c.getLocation().y;
                        if (c instanceof JRootPane)
                             break;
                   else
                        break;
              mPanel.setBounds(x, y, 235, 200);
              mLayredPane.add(mPanel, JLayeredPane.POPUP_LAYER);
    //And when a listener fires from the panel I use
    mLayredPane.remove(mPanel);
    //To remove it from the layered pane and in theory return the
    //app to the state it was before the panel was displayedThanks again...

    The problem is you only removed it within the program, without actually removing it from the display. If that makes any sense, or whether thats your problem at all.
    If you are only using this line.
    mLayredPane.remove(mPanel);
    I think if you tell it to repaint and revalidate it should work, though i have never used LayeredPane.
    mLayredPane.repaint();
    mLayredPane.revalidate();

  • Pops and random glitches from audio output

    Hi,
    I've been experiencing some issues from the audio output. There is a pop sound before and after a single sound is played and stopped. When this happens, the console shows the stack shots enabled/disabled pair of messages. I've seen threads about this messages and the popping sounds, but no solutions really.
    I also get a totally random sound from the speakers (tested different systems) at any given moment. Sometimes browsing the internet, playing a quicktime movie or just doing nothing. I've noticed that it gets really bad when I play chess at chess.com, which uses an interface (not sure what).
    So, this is the thing, I'm a musician and I use my mac for music purposes, so you can imagine how annoying it can be to have pops and glitches on a supposedly state-of-the-art machine

    "Is this a hardware error or am I stuck with this situation? "
    Take your MBP to an Apple Store so that the Geniuses can run diagnostic tests. They will let you know if it's a hardware problem or if you are stuck w/it.

Maybe you are looking for

  • HP t510 Thin Client and USB Printer Redirectiion

    We have HP t510 thin clients connecting to server side XenCenter and running Windows 7 virtual sessions hosted on the server. We are trying to connect a USB lablewriter printer to one of the thin clients. On the t510 device, XEN Connection General Se

  • Is it possible to get a virus or spyware on a iPad ?

    My iPad II seems to have a virus. Notes have disappeared twice. Changes pages for no reason. It it possible t get a virus o spyware? Thank you.

  • How do I download Acrobat Full Version?

    SO here I am, running too much javascript in the rich editor on adobe forums. All I wanted was a frickin download link for Adobe Acrobat. Nope, I have to download the adobe download manager. OK, done. Now I have to install acrobat, but Adobe says I m

  • Can't install Leopard

    When I start my iBook G4(mac os x 10.4.6) I put in the Leopard install disk and it lets me click on the install icon and then asks to restart, but instead of begin install when the system boots it the screen turns grey and idles with spinning rainbow

  • Unable to open audiobooks section

    Hey I'm having a really weird issue with my new 32g iPod Touch. It was working fine, but this afternoon when I tried to open the 'Audiobooks' section (under "more") it wouldn't let me open it - the screen goes black and then goes back to the home scr