Adding Jtree to Panel

Hi all,
I have a JTree in a scrollpane rendered with checkbox on each node. I
When I try adding to JFrame its displaying with scrollbar as expected. like this
frame.setContentPane(scrollPane); //working fineBut When I try adding to panel and try to display that its not working
JPanel panel = new JPanel();
panel.add(scrollPane);
frame.setContentPane(panel); // displaying tree without scrollbarsthanks,
sur

scrollPane.setPreferredSize(new Dimension(x,y));where x,y can be the width/height of the frame

Similar Messages

  • Suggestion: Adding a "Pages Panel" in Edge Reflow, similar to Adobe Fireworks

    Hello Adobe Team:
    I realize ER is mostly to set up fluid layout prototypes, which so far I'm loving this software.  Especially the feature of your align panel. 
    But, I have a suggestion that I would love to see implemented in the near future. 
    Allowing for more than one File to be opened in ER
    Adding a "Pages Panel" similar to the Fireworks pages panel
    Master Page
    Pages

    Thanks for the suggestion!  I filed a Feature Request in our public github at: https://github.com/edge-reflow/issues/issues/38
    If you have a free github account, feel free to add additional feature requests there.  Posting them here is fine, too!

  • Adding JTree nodes from worker threads

    I'm trying to add a large number of nodes (> 1700) to a JTree, and I'm looking for a way to do this while allowing the user to continue working in the meantime.
    The nodes are retrieved from a database, which may be geographically distant and therefore possibly slow to access. I would like to have the process of processing the result-set and creating the Nodes run separately.
    I have considered processing the result-set in a separate Thread and creating the Nodes before then returning to the EDT to add them to the tree. This would cause the GUI to pause when adding the Nodes to the tree, but does at least separate the DB access out of the EDT.
    I would prefer to update the tree node by node as the result-set is processed, but I'm not sure whether this would incur too much overhead.
    I would appreciate any advice.

    I'm not sure overhead is the problemimport java.awt.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.util.Random;
    public class Test extends JFrame implements Runnable {
      JTree jt = new JTree();
      DefaultTreeModel dtm = (DefaultTreeModel)jt.getModel();
      public Test() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        new Thread(this).start();
        setSize(500, 500);
        setVisible(true);
      public void run() {
        Random r = new Random();
        DefaultMutableTreeNode root = (DefaultMutableTreeNode)dtm.getRoot();
        for (int i=0; i<1700; i++) {
          DefaultMutableTreeNode item = (DefaultMutableTreeNode)root.getChildAt(r.nextInt(root.getChildCount()));
          while (r.nextInt(5)>0 && item.getChildCount()>0) {
            item = (DefaultMutableTreeNode)item.getChildAt(r.nextInt(item.getChildCount()));
          item.add(new DefaultMutableTreeNode("Node-"+i));
          dtm.nodeStructureChanged(item);
          try { Thread.sleep(500); } catch (Exception e) {}
      public static void main(String[] args) { new Test(); }
    }

  • Panel class not adding to main panel...

    I have a panel class that has a borderlayout which is to be nested in another panel with a borderlayout. I'm not sure what I'm doing wrong. Here is my code for the problematic classes:
    1st: Panel that needs to be added:
    public class SizePanel extends JFrame
         private JPanel sizePanel;
         private JPanel selectedSizePanel;
         private JList sizeList;
         private JScrollPane scrollPane;
         private JTextField selectedSize;
         private JLabel sizeLbl;
         private String[] sizes = {"Starter", "Standard", "Better", "Best" };
         public SizePanel()
              setLayout(new BorderLayout());
              buildSizePanel();
              buildSelectedSizePanel();
              add(sizePanel, BorderLayout.CENTER);
              add(selectedSizePanel, BorderLayout.SOUTH);
              pack();
              setVisible(false);
         private void buildSizePanel()
              sizePanel = new JPanel();
              sizeList = new JList(sizes);          
              sizeList.setSelectionMode(
                        ListSelectionModel.SINGLE_SELECTION);          
              sizeList.addListSelectionListener(
                        new ListListener());     
              sizeList.setVisibleRowCount(4);     
              scrollPane = new JScrollPane(sizeList);     
              sizePanel.add(scrollPane);
         private void buildSelectedSizePanel()
              selectedSizePanel = new JPanel();          
              sizeLbl = new JLabel("Price: ");     
              selectedSize = new JTextField(9);     
              selectedSize.setEditable(false);     
              selectedSizePanel.add(sizeLbl);
              selectedSizePanel.add(selectedSize);
         private class ListListener implements ListSelectionListener
              public void valueChanged(ListSelectionEvent e)
                   String selection = (String) sizeList.getSelectedValue();
                   selectedSize.setText(selection);
    }2nd: My code for adding it to the main panel:
    public HouseCalcGUI() {
            setTitle("McKeown's Real Estate Program");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setLayout(new BorderLayout());
            greetingPnl = new GreetingPanel();
            featuresPnl = new FeaturesPanel();
            sizePnl = new SizePanel();
            stylePnl = new StylePanel();
            buildButtonPanel();
            add(greetingPnl, BorderLayout.NORTH);
            add(stylePnl, BorderLayout.EAST);
            add(featuresPnl, BorderLayout.CENTER);
            add(sizePnl, BorderLayout.WEST);
            add(buttonPanel, BorderLayout.SOUTH);
            pack();
            setVisible(true);
        }

    Hey, guess what I just did...? BANGED MY HEAD AGAINST THE WALL. Your ingeniousness is in the form of my stupidity. Thank you though. Here are your dukes...What I did was take some sample program from my text to make my program.

  • Adding mouselistener on Panel and Canvas

    Hi,
    I m building an application in which I m making a frame, adding a panel on it and then adding a Canvas on the panel. On this Canvas my Native C code is drawing an Image. This image is very small with respect to the size of the frame.
    The size of the Panel and the Canvas is made equal to the size of Image drawn.
    Now I want a mouseclick event on this image.
    Now the problem is that when I add mouselistener to the Panel I don't get any event.
    And when I add mouselistener to the Canvas I get the event but I get the event on the whole frame even if I set the canvas size equal to the drawn image size. I only want the mouse event only if mouse is clicked on the image.
    Can anyone tell the mistake or suggest any other way of doing this ?

    Hi,
    I m building an application in which I m making a frame, adding a panel on it and then adding a Canvas on the panel. On this Canvas my Native C code is drawing an Image. This image is very small with respect to the size of the frame.
    The size of the Panel and the Canvas is made equal to the size of Image drawn.
    Now I want a mouseclick event on this image.
    Now the problem is that when I add mouselistener to the Panel I don't get any event.
    And when I add mouselistener to the Canvas I get the event but I get the event on the whole frame even if I set the canvas size equal to the drawn image size. I only want the mouse event only if mouse is clicked on the image.
    Can anyone tell the mistake or suggest any other way of doing this ?

  • Hp 4315: some hp updates cause a new hp fax# to be added to control panel.

    I now have six (6) hp faxes listed in control panel. Which ones should I delete?

    Did you check the "Device Settings" in the 8600 printer properties.
    Please mark the post that solves your issue as "Accept as Solution".
    If my answer was helpful click the “Thumbs Up" on the left to say “Thanks”!
    I am not a HP employee.

  • MS JView  & adding Canvas to Panel

    Hi,
    I want to animate the opening of my Dialogs by a dotted line starting from one edge of the main frame and finally leading to the dialog. I've put the code into the setVisible method of the Dialog. It adds small canvases to the main frame's panel, one by one with a break of 5 ms and after reaching the position of the dialog it shows up the dialog. It works fine on Sun jdks, but it does not show the canvases on MS JView until the dialog is visible. That means, it runs the code, I can hear the ticks, but it does not refresh the frame's panel until the dialog is visible. It doesn't matter if it is a modal dialog or not.
    Has anymone any clue how to make it work on JView?
    Here's the Dialog.setVisible code (just the basics):
    public void setVisible(boolean visible) {
         if (visible) {
              for (int i = 0; i < 20; i++) {
                   Panel dot = new Panel();
                   dot.setBackground(Color.black);
                   dot.setBounds(20 * i, 20 * i, 2, 2);
                   frame.getPanel().add(dot, 0); // frame is a reference to my main frame
                   try {
                        Thread.sleep(5);
                   } catch (InterruptedException ex) { }
              super.setVisible(visible);
    }Thanks
    Mani

    Hi Noah,
    I tried almost everything I can imagine before posting here. I'm going mad about that. It seems that jview doesn't want to add the component until the dispatcher thread gets unblocked again. Here's what I tried:
    dot.getPeer().show();
    frame.dispatchEvent(new ContainerEvent(this, ContainerEvent.ComponentAdded, ...));and many more things. Finally, I created a new Thread inside of the set visible method, which created the dots and called super.setVisible(). That works, but if you need a modal dialog like for example a message box for confirmation, it won't wait for the response (since it is a new thread). So, that can't be my solution.
    By the way, you can try the applet under http://www.jq-consulting.de/pages/psm.html
    Thanks, but no Duke Dollars, unfortunately.
    Mani

  • Adding image to panel gives an error

    any ideas whatz wrong with this
    Panel p = new Panel();
    Graphics g = getGraphics();
    g.drawImage(splashImage, 0,0, p);
    add(p,BorderLayout.CENTER );
    the error i get is
    "AWT-Windows" (TID:0x14bda60, sys_thread_t:0x56a0cb8, state:R, native ID:0x540) prio=5
    at sun.awt.windows.WToolkit.eventLoop(Native Method)
    at sun.awt.windows.WToolkit.run(WToolkit.java:130)
    at java.lang.Thread.run(Thread.java:479)
    "SunToolkit.PostEventQueue-0" (TID:0x14bde28, sys_thread_t:0x569f970, state:CW, native ID:0
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:417)
    at sun.awt.PostEventQueue.run(SunToolkit.java:406)
    "AWT-EventQueue-0" (TID:0x14be1f0, sys_thread_t:0x5673818, state:CW, native ID:0x270) prio=
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:417)
    at java.awt.EventQueue.getNextEvent(EventQueue.java:216)
    at java.awt.EventDispatchThread.pumpOneEventForComponent(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEventsForComponent(EventDispatchThread.java:89)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:84)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:76)
    "SymcJIT-LazyCompilation-0" (TID:0x14ae228, sys_thread_t:0x4a1cf90, state:CW, native ID:0x4
    at SymantecJITCompilationThread.DoCompileMethod(Native Method)
    at SymantecJITCompilationThread.run(JITcompilationthread.java, Compiled Code)
    "SymcJIT-LazyCompilation-PA" (TID:0x14ae1f0, sys_thread_t:0x4a1b9e8, state:CW, native ID:0x
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:417)
    at SymantecJITCompilationThread.run(JITcompilationthread.java, Compiled Code)
    "Finalizer" (TID:0x14a9590, sys_thread_t:0x4964e10, state:CW, native ID:0x4dc) prio=8
    at java.lang.Object.wait(Native Method)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:105)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:120)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:167)
    "Reference Handler" (TID:0x14a9338, sys_thread_t:0x4961460, state:CW, native ID:0x598) prio
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:417)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:107)
    "Signal dispatcher" (TID:0x14a9370, sys_thread_t:0x4960130, state:R, native ID:0x55c) prio=
    "main" (TID:0x14a9420, sys_thread_t:0x2f2888, state:CW, native ID:0x528) prio=5
    Monitor Cache Dump:
    sun.awt.PostEventQueue@14BDE28/153CBC0: <unowned>
    Waiting to be notified:
    "SunToolkit.PostEventQueue-0" (0x569f970)
    java.lang.ref.Reference$Lock@14A9348/14DEB30: <unowned>
    Waiting to be notified:
    "Reference Handler" (0x4961460)
    java.awt.EventQueue@14BE108/153C848: <unowned>
    Waiting to be notified:
    "AWT-EventQueue-0" (0x5673818)
    SymantecJITCompilationThread@14AE228/1505068: <unowned>
    Waiting to be notified:
    "SymcJIT-LazyCompilation-PA" (0x4a1b9e8)
    java.lang.ref.ReferenceQueue$Lock@14A92F0/14DEEB8: <unowned>
    Waiting to be notified:
    "Finalizer" (0x4964e10)
    Registered Monitor Dump:
    SymcJIT Method Monitor: <unowned>
    SymcJIT Lazy Queue Lock: <unowned>
    Waiting to be notified:
    "SymcJIT-LazyCompilation-0" (0x4a1cf90)
    SymcJIT Method Monitor: <unowned>
    SymcJIT Method List Monitor: <unowned>
    SymcJIT Lock: <unowned>
    utf8 hash table: <unowned>
    JNI pinning lock: <unowned>
    JNI global reference lock: <unowned>
    BinClass lock: <unowned>
    Class linking lock: <unowned>
    System class loader lock: <unowned>
    Code rewrite lock: <unowned>
    Heap lock: <unowned>
    Monitor cache lock: owner "Signal dispatcher" (0x4960130) 1 entry
    Thread queue lock: owner "Signal dispatcher" (0x4960130) 1 entry
    Waiting to be notified:
    "main" (0x2f2888)
    Monitor registry: owner "Signal dispatcher" (0x4960130) 1 entry

    Following is the code i am using
    i create an instance of this class in another class.
    when i run this class, i get to see only a blank window but no image on that...
    any ideas!!
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.*;
    class SplashWindow extends Window
         Label l;
         Label l2;
         Label l3;
         Label l4;
         SplashWindow(Frame parent)
                   super(parent);
                   Dimension screenDim = Toolkit.getDefaultToolkit().getScreenSize();
                   Rectangle winDim = getBounds();     
                   setSize(300,200);
                   setLayout(new BorderLayout());
                   //l = new Label(" Solutions Demo");
                   //l.setFont(new Font("",1,20));
                   Image splashImage = Toolkit.getDefaultToolkit().getImage("spalsh.jpg");
                   //add(l, BorderLayout.WEST);     /* Center the window */     
                   JLabel label = new JLabel(new ImageIcon(splashImage));
                   add(label, BorderLayout.CENTER);     
                   setLocation((screenDim.width - winDim.width) / 2,     (screenDim.height - winDim.height) / 2);     
                   setBackground(Color.gray);     
                   setVisible(true);
                   try
                        Thread.sleep(4000);
                        dispose();
                   catch (InterruptedException ie)

  • Adding image on panel

    My applet is in 5 panel and I would like to add an image to my South panel. How can I do this?

    Try this,
    class p1 extends Panel
    Image image;
    public canpan(Image img)
    image = img;
    public void paint (Graphics g)
    if (image == null)
    return;
    g.drawImage(image, 0, 0, this);
    }

  • Error when adding textField to panel

    Hi, I am trying to learn some about swings and my first test code is like this:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Frename implements ActionListener{
         JButton btn_Aceptar;
         JButton btn_Cancelar;
         JButton btn_Ruta;
         JTextField txt_Nombre;
         JTextField txt_Ruta;
         JFrame frm_Frame;
         JPanel pnl_Panel;
        public static void main(String[] args) {
             //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    CrearMostrarGUI();
         private static void CrearMostrarGUI() {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            Frename frename = new Frename();
        public Frename(){
             frm_Frame = new JFrame("Renombrador de Archivos");
             frm_Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frm_Frame.setSize(new Dimension(200,200));
             pnl_Panel = new JPanel(new GridLayout(2,3));
             AgregarComponentes();
             frm_Frame.getContentPane().add(pnl_Panel, BorderLayout.CENTER);
             frm_Frame.pack();
             frm_Frame.setVisible(true);
        public void AgregarComponentes(){
             txt_Ruta = new JTextField();
             txt_Ruta = new JTextField();
             txt_Ruta.enable(false);
             btn_Aceptar = new JButton("Iniciar");
             btn_Cancelar = new JButton("Salir");
             btn_Ruta = new JButton("Ruta");
             btn_Aceptar.addActionListener(this);
             btn_Cancelar.addActionListener(this);
             btn_Ruta.addActionListener(this);
             pnl_Panel.add(btn_Ruta);
             //THIS TWO FOLLOWING LINES PRODUCE ERRORS
             //pnl_Panel.add(txt_Ruta);
             //pnl_Panel.add(txt_Nombre);                  
             pnl_Panel.add(btn_Aceptar);
             pnl_Panel.add(btn_Cancelar);
        public void actionPerformed(ActionEvent e){     
               *THINGS THAT MUST BE DONE
               *WHEN ACTION IS PERFORMED
    }if I leave the lines that add the textfield to the panel as a comment the program runs good, otherwise the following erros are displayed:
    --------------------Configuration: <Default>--------------------
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at java.awt.Container.addImpl(Container.java:1031)
    at java.awt.Container.add(Container.java:352)
    at Frename.AgregarComponentes(Frename.java:65)
    at Frename.<init>(Frename.java:43)
    at Frename.CrearMostrarGUI(Frename.java:35)
    at Frename.access$000(Frename.java:13)
    at Frename$1.run(Frename.java:27)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    Process completed.
    Please help me understand whats going on with this....
    The other question I have is why does the buildouput screen shows this:
    --------------------Configuration: <Default>--------------------
    Note: D:\Fred\Java Projects\Frename.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Process completed.

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Projekt2 implements ActionListener{
         JButton btn_Aceptar;
         JButton btn_Cancelar;
         JButton btn_Ruta;
         JTextField txt_Nombre;
         JTextField txt_Ruta;
         JFrame frm_Frame;
         JPanel pnl_Panel;
        public static void main(String[] args) {
             //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    CrearMostrarGUI();
         private static void CrearMostrarGUI() {
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            Projekt2 Projekt2 = new Projekt2();
        public Projekt2(){
             frm_Frame = new JFrame("Renombrador de Archivos");
             frm_Frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frm_Frame.setSize(new Dimension(200,200));
             pnl_Panel = new JPanel(new GridLayout(2,3));
             AgregarComponentes();
             frm_Frame.getContentPane().add(pnl_Panel, BorderLayout.CENTER);
             frm_Frame.pack();
             frm_Frame.setVisible(true);
        public void AgregarComponentes(){
             txt_Ruta = new JTextField();
             txt_Nombre = new JTextField(); //I found your error here!!!
             txt_Ruta.enable(false);
             btn_Aceptar = new JButton("Iniciar");
             btn_Cancelar = new JButton("Salir");
             btn_Ruta = new JButton("Ruta");
             btn_Aceptar.addActionListener(this);
             btn_Cancelar.addActionListener(this);
             btn_Ruta.addActionListener(this);
             pnl_Panel.add(btn_Ruta);
             //THIS TWO FOLLOWING LINES PRODUCE ERRORS
             pnl_Panel.add(txt_Ruta);
             pnl_Panel.add(txt_Nombre);                  
             pnl_Panel.add(btn_Aceptar);
             pnl_Panel.add(btn_Cancelar);
        public void actionPerformed(ActionEvent e){     
               *THINGS THAT MUST BE DONE
               *WHEN ACTION IS PERFORMED
    }

  • Changing/Adding to Filter panel?

    Hello!
    I have question about posibility to add Color Mode from Metadata to Filter panel because i'm in a need to be able to easy separate and see what colormode have images. Like for poligraphy images supposed to be in CMYK and to see which images are still in RGB and so and on.
    So is that possible or not? In CS3 or CS5?
    P.S. acctually i don't understand why Metadata is made so tuneable (can not show what i don't need to know at all) but Filters panel are so weak (or i miss totaly something).
    Thank You!

    I know, my english isn't so good (making sense skill neither)
    I haven't trouble with getting Color Profile but getting Color Mode to filter by, as i start understand it's not posible.
    And it's a big comfort question.
    Like diference
    By profile: 4 sRGB, 1 NikonRGB, 3 ISO Coated, 1 U.S. Web Coated and 7 Untagged. (often CMYK profile aren't save so PROBABLY 80% chance it's CMYK)
    Teoreticly by mode: 7 RGB and 9 CMYK.
    Easy to "see" easy to use.
    But i get it, i'll use that profile and wait for "miracle".

  • Adding "Image menu/panel"

    Hey all,
    I used to work with Photoshop elements but recently upgraded to CS4. To put my problem short, i work with 50~100 pictures at a time. I crop them and add some light, so i need to have them somewhere where i can open them easy right? Well photoshop and its default settings just toss them on upper side which is kind of ok, but id like to add an panel downside where i can scroll down and choose the picture i want to. I tried to get fixed with "Arrange Documents" button and it turned out to be almost what i wanted, but not quite. Here is screenshot which i took to clear things out a bit =>
    http://koti.welho.com/epunavaa/photoshop.png
    (The red squares would be mini-images of the images that i use and there would be 9~10 each line, and you could scroll down for more)
    Thank you

    Hey all,
    I used to work with Photoshop elements but recently upgraded to CS4. To put my problem short, i work with 50~100 pictures at a time. I crop them and add some light, so i need to have them somewhere where i can open them easy right? Well photoshop and its default settings just toss them on upper side which is kind of ok, but id like to add an panel downside where i can scroll down and choose the picture i want to. I tried to get fixed with "Arrange Documents" button and it turned out to be almost what i wanted, but not quite. Here is screenshot which i took to clear things out a bit =>
    http://koti.welho.com/epunavaa/photoshop.png
    (The red squares would be mini-images of the images that i use and there would be 9~10 each line, and you could scroll down for more)
    Thank you

  • Adding JTree to JFrame using SpringLayout

    I have created a JTree with various nodes and leafs. I want to place the JTree in a GUI that uses SpringLayout as the layout manager. What should I use to place the JTree in the JFrame? I assume I put it in a JScrollPane which serves as a container. Then how do I assign a layout manager to JScrollPane and register it with the JFrame? Does this make sense?

    Twupack, my apologies. I was not receiving any responses in the other forum so I decided to take my questions to the beginner form which is probably more suitable given the complexity of my question. I also asked a different question - regarding the same topic. And my login, although different, was not intentional. This forum asked me to enter a different login name so I did. If I really wanted to hide my identity, I think I could have figured out something a little more creative.
    Now, mods, if you could, remove this thread as I am not receiving any useful responses here.

  • Dynamicaly adding components to panel/grid

    I am trying to add components dynamically in panelgrid but it is displaying nothing.in jsp tag is
    <h:panelGrid id = "ExpenseDetail" binding = "#{expenses.component}" />
    tand his is what i am doing in backing bean.
    public HtmlPanelGrid getComponent()
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Application application = facesContext.getApplication();
    component = new HtmlPanelGrid();
    component.getChildren().clear();
    component.setBorder(1);
    component.setColumns(1);
    component.setStyleClass("browsetabletype2");
    component.setWidth("90%");
    UIOutput outText = (UIOutput)application.createComponent("javax.faces.HtmlOutputText");
              outText.setValue("Name");
              outText.setId("Name");
              component.getChildren().add(outText);
    return component;
    }

    What about setter of your binded component ?
    Try this
            private HtmlPanelGrid dynamicPanel = null;
         public HtmlPanelGrid getDynamicPanel {
              if (this.dynamicPanel == null) {
                   // this will happen the first time the HtmlPanelGrid is retrieved
                   this.dynamicPanel = new HtmlPanelGrid();
              try {
                   generatePanel(this.dynamicPanel);
              } catch (Exception e) {
                   e.printStackTrace();
              return dynamicPanel;
         public void setDynamicPanel(HtmlPanelGrid dynamicPanel) {
              try {
                   generatePanel(dynamicPanel);
              } catch (Exception e) {
                   e.printStackTrace();
              this.dynamicPanel = dynamicPanel;
           private void generatePanel(HtmlPanelGrid dynamicPanel){
                    dynamicPanel.getChildren().clear();
              dynamicPanel.setId("dynamicPanel_1");
                    //adding other attributes and children ...
            } I always use this method, and it works. Maybe there is more sophisticated way, but I didn't managed to find it. Hope it helps.
    Martin

  • Adding JTree to JTable cell is not expanding??

    Hi experts
    My problem is that as Tree expands, my table cell should expands accordingly.
    How do I do that??I do n't mind if other cells get expands.
    Please help me...?
    Thanks in advance

    How do I do that no such method is available.can you guide me or give me some code.I need urgently..
    Thank you very much

Maybe you are looking for