Buggy JTabbed Pane, Scroll? Constraints?

I don't know if this is a bug, limitation, or if I'm not implementing it properly, but I am having a problem with scroll panes in a tabbed frame.
Here's the scoop.
I have a JFrame which has a has a JTabbedPane north and a JPanel (which contains a couple components) down south.
The tabbed pane has 4 tabs/panes. Only the first two are relevant right now because I haven't made it to the last two.
Tab 1 has a JPanel with a gridlayout (2 cols, 3 rows). The components display fine until I populate tab 2 with my 25 rows of stats. Once that happens, the JFrame (the container/content pane, not the physical window) size stretches itself to about 600px tall.
Tab 2 contains a JPanel with a gridlayout (2 cols, 25 rows). As described above, this many rows causes every pane in the tabbed pane set to take on this size, causing undesirable spacing. Not only that, you have to resize the window to display it all.
My solution was to use a JScrollPane to contain the JPanel with all the rows, and then add the JScrollPane to the tab. This just doesn't work. The result was just a border around the JPanel, no scroll.
Can someone give me some ideas on how to use a JScrollPane as the component in the tab 2?
Also, how do I control the size of JPanels in the the tabbed panes so they do not change based on the size of another pane?
Thanks So Much!!!
Here is my constructor code (irrelvant logic not included):
public CbStats() {
//create main frame
JFrame frame = new JFrame("VSN1 Callback Stats");
frame.setSize(400,200);
//main container
Container content = frame.getContentPane();
//tabbed pane goes north
JTabbedPane tabs = new JTabbedPane();
//flow panel goes south
JPanel southPanel = new JPanel();
southPanel.setLayout(new FlowLayout());
//add status and manual refresh
JLabel status = new JLabel("Refresh Rate: 2 mins ");
southPanel.add(status);
JButton manRefresh = new JButton("Manual Refresh");
southPanel.add(manRefresh);
//create 4 panels, 1 for each tab
JPanel panSummary = new JPanel();
JPanel panPerf = new JPanel();
JPanel panNotes = new JPanel();
JPanel panJump = new JPanel();
//add stuff to panel 1
panSummary.setLayout(new GridLayout(5,2));
panSummary.add(new JLabel(" Open Tickets:"));
panSummary.add(openTix);
panSummary.add(new JLabel(" Assigned Tickets:"));
panSummary.add(assignedTix);
panSummary.add(new JLabel(" Closed Tickets:"));
panSummary.add(closedTix);
//add stuff to panel 2
//panPerf.setLayout(new FlowLayout());
panUsers.setLayout(new GridLayout(25,4));
for(int i=0;i<ulAr.length;i++) {
ulAr[i] = new JLabel();
panUsers.add(ulAr);
panPerf.add(panUsers);
//add panels to tabs
tabs.add(panSummary, "Summary");
tabs.add(panPerf, "Performance");
tabs.add(panNotes, "Notes");
tabs.add(panJump, "Jump To...");
//add tabbed pane to main frame
content.add(tabs, BorderLayout.NORTH);
content.add(southPanel, BorderLayout.SOUTH);
//make visible
frame.setVisible(true);

You have to specify real panel's size.
panel.setPrefferedSize(...);
JScrollPane will ask the panel and if the size of panel is bigger than the size of scrollpane scrollbars appear.
And of course you have to specify size of scroll.
hope this helps.
Stas

Similar Messages

  • X JPanels in a JTabbed pane.

    I'm wondering if anyone can help.
    I have an application consisting of a JTabbed pane, within this there should be 'x' JPanels. Each JPanel has 3 RadioButtons and 5 Text fields. I need to be able to refer to each radio button and text field as RB0 - RBx and TF0 - TFx.
    It is obviously easy enough to do this for just 3 or even 20 (despite a lot of coding), however, my problem is getting a variable number (x) of Panels with respective variable numbers of TF and radio buttons.
    Simply I need to produce an array of panels, radiobuttons and textfields....
    anyone anyideas?

    another way of looking at it is to think how can I make 5 of exactly the same panel (just with different names) in the same tabbed frame in just one bit of code that is called 5 times - or x in this case.

  • 2nd time posting: Flashing JTabbed Pane?

    I'm trying to use a JTabbed Pane wherein tabs are created dynamically from the server. In order to alert the the user of the client software that a new tab has been created, I would like the top of the tab to flash or blink with a different color. any ideas how to do this? I really do want to avoid doing stuff like writing my own component etc.
    Tia,
    carlos

    You can use:
    tabPane.setBackgroundAt(i, Color.red);to set the background of tab number "i" to red, and
    you can use:tabPane.setBackgroundAt(i, tabPane.getComponentAt(i).getBackground());to set the background of tab number "i" back to its original color. If you do these in a loop with a delay, then you have a flashing tab.
    You can also change the font color if you want by using tabPane.setForeground(...) instead of setBackground(...)

  • Focus event with JTabbed pane

    How do I set FocusListener to fire with I select a specific tab in a JTabbed pane? If I put the FocusListener on the Tabben pane it fires rquardless of which tab I select and if I try to use an if statement to single out a specific tab nothing happens.

    If you are interested in listening to when a tab is selected you can use a ChangeListener:
    JTabbedPane tab = ...
    tab.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            // get the selected tab-index:
            int index = ((JTabbedPane)e.getSource()).getSelectedIndex();
    });Btw, Swing related posts should be posted in the Swing forum.

  • Icon in the JTABBED PANE

    hello...
    How can I put an Icon into the JTABBED PANE?
    So every TAB will have its own Icon?
    I believe JBuilder 4.0 do that.
    Thank you.

    Read http://java.sun.com/docs/books/tutorial/uiswing/components/tabbedpane.html
    tabbedPane.addTab("Title", image, panel, "Tooltip");

  • JCombobox on a jtabbed pane, AND Choice on jtabbed pane problems

    I have a Choice on a jtabbed pane, on a panel that isn't showing when the jtabbed pane is made visible. The Choice on the hidden pane is "bleeding" through to the first tabbed panel. help!
    If I click on the second tabbed panel (where the Choice is), and then click on the first tabbed panel, the Choice becomes hidden like it is supposed to.
    AND, I have a JComboBox on a JTabbedPane, it works for the most part, but when you click on it, the scrollbox underneath it doesn't appear! Instead, a grey box appears below it. Help!

    I was having similar problems when I was working with JFrames, Anything not covered by a piece of GUI would show other parts of my program (like the progress bar or buttons and stuff).
    Anyway, it went away when I used the setBackground() method. My guess is that using this forces the container to be opaque or something. Anyway, it worked for me, maybe it will work for you also.
    Steve

  • Transparent JTabbed Pane

    Is there a way to make a JTabbed Pane transparent, include the tabs?

    What do you mean? A JTabbedPane simply displays the currently selected component. In order for the whole thing to be transparent, the components contained in the JTabbedPane also need to be transparent.

  • Jtabbed pane is listening to the keyboard, how do i stop?

    hello
    this is probobly a simple Swing problem. i have a j3d canvas inside a tabbed pane with other info on other panes. i need the keyboard to listen on the canvas so i can move around the j3d world, but the left and right are being detected by the jtabbed pane, but i didnt add any listen to those. how can i stop this behavior from occuring? its very annoying.
    i appreciate any help you can lend..

    The reason it is responding to keyboard events is becuase it has the focus. Request focus on the component in the tab, and the tabbed pane should stop responding. If that doesn't work, try this:
    JTabbedPane tabbed = new JTabbedPane();
    KeyStroke[] keys = tabbed.getRegisteredKeyStrokes();
    for (int i=0; i<keys.length; i++) {
    int code = keys.getKeyCode();
    if (code == KeyEvent.VK_LEFT || code == KeyEvent.VK_RIGHT) {
    tabbed.unregisterKeyboardAction(keys[i]);

  • Jtabbed pane problem + flags printout

    Hi,
    I am having difficulty displaying a JTabbedPane which is contained by a dialog. When I display the Dialog for the first time the Tabbed displays perfectly - anytime after that it disappears.
    I found this really strange so I put in some printout statements for the JTabbed pane here's what I got
    When it displays the prinout for the JTabbed pane is ............................
    extCellTabbedPane
    rnh.adj.cellhandovermgt.gui.refactor.ExtCellTabbedPane[,0,0,0x0,invalid,layout=javax.swi
    ng.plaf.basic.BasicTabbedPaneUI$TabbedPaneLayout,alignmentX=null,alignmentY=null
    ,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,haveRegistered=false,t
    abPlacement=TOP]
    When it does n't display the prinout for the JTabbedPane is
    rnh.adjcellhandovermgt.gui.refactor.ExtCellTabbedPane[,0,67,193x45,inv
    alid,layout=javax.swing.plaf.basic.BasicTabbedPaneUI$TabbedPaneLayout,alignmentX
    =null,alignmentY=null,border=,flags=16,maximumSize=,minimumSize=,preferredSize=,
    haveRegistered=false,tabPlacement=TOP]
    What I am interested in is the meaning of the parameter flags. In one case it is 0 and in one case it is 16? What does this parameter mean? Where I can get some information on this as I think this will tell me what is happening to the JTabbedPane.
    Thank you in Advance
    Alex

    The flags item reflect the flags value in JComponent
    class. It represents several status
    of the component:
    REQUEST_FOCUS_DISABLE
    IS_DOUBLE_BUFFERED
    ANCESTOR_USING_BUFFER
    IS_PAINTING_TITLE
    HAS_FOCUS
    IS_OPAQUE
    As my understand about your problem, this may be no
    help for you to locate the error
    As the message you post, you might use a third
    implementation of JTabbedPane, so the
    problem might be in the implementation. I
    have used JTabbedPane often with no error
    like you say :)
    Hope this Helps!Thanks for your help here - I would like more information if possible i.e. a numerical mapping for each property - do you know where I could get this. I don't really understand what you mean about the Third implementation. Do you mean simply extend the JTabbedPane? Thisis what I do but I don't really know what part to change to stop it disappearing. Thanks once again. Anymore help would be greatly appreciated.

  • JTabbed pane customize title on selection

    Hi all
    i want to change the title font when a tab is selected.I add a ChangeListener to my JTabbed pane to intercept tab selection and to change font via html.
    I have some proble ex:
    if i click on tab4, it correctly change font but the tab2 take the title of the tab1 and so on.
    This is the code
              ChangeListener changeListener = new ChangeListener()
                   public void stateChanged(ChangeEvent changeEvent)
                        JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.
                             getSource();
                        int index = sourceTabbedPane.getSelectedIndex();
                        for (int i = 0; i < sourceTabbedPane.getTabCount(); i++)
                             if (i == index)
                                  sourceTabbedPane.setTitleAt(i,
                                       "<html><b>" + sourceTabbedPane.getTitleAt(i) + "</html>");
                             else
                                  String desc  = sourceTabbedPane.
                                       getTitleAt(i).replaceAll("<html>", "").
                                       replaceAll("<b>", "").replaceAll("</html>", "");
                                  sourceTabbedPane.setTitleAt(i, desc);
                        System.out.println("***********************");
                        for (int i = 0; i < sourceTabbedPane.getTabCount(); i++)
                             System.out.println(sourceTabbedPane.getTitleAt(i));
              };The last system.out show me the correct tirtle, only the selected with html but on screen i see some mixed title.Where i'm wrong?

    I hope can you help me:
    public static void main(String[] arg)
            JTabbedPane jTabbedPane = new JTabbedPane();
         jTabbedPane.addTab("Tab1", new JPanel());
         jTabbedPane.addTab("Tab2", new JPanel());
         jTabbedPane.addTab("Tab3", new JPanel());
         jTabbedPane.addTab("Tab4", new JPanel());
         jTabbedPane.addTab("Tab5", new JPanel());
         jTabbedPane.addTab("Tab6", new JPanel());
         jTabbedPane.addTab("Tab7", new JPanel());
         jTabbedPane.addTab("Tab8", new JPanel());
         ChangeListener changeListener = new ChangeListener()
            public void stateChanged(ChangeEvent changeEvent)
              JTabbedPane sourceTabbedPane = (JTabbedPane) changeEvent.
              getSource();
              int index = sourceTabbedPane.getSelectedIndex();
              for (int i = 0; i < sourceTabbedPane.getTabCount(); i++)
                      if (i == index)
                           sourceTabbedPane.setTitleAt(i,
                        "<html><b>" + sourceTabbedPane.getTitleAt(i) + "</html>");
                   else
                        String desc = sourceTabbedPane.getTitleAt(i).replaceAll(
                        "<html>", "").
                        replaceAll("<b>", "").replaceAll("</html>", "");
                   sourceTabbedPane.setTitleAt(i, desc);
              System.out.println("***********************");
              for (int i = 0; i < sourceTabbedPane.getTabCount(); i++)
                   System.out.println(sourceTabbedPane.getTitleAt(i));
         jTabbedPane.addChangeListener(changeListener);
         JDialog dialog = new JDialog(new JFrame(),true);
         dialog.getContentPane().add(jTabbedPane);
         dialog.setPreferredSize(new Dimension(300,300));
         dialog.setSize(new Dimension(300,300));
         dialog.setVisible(true);
    }

  • JTabbed pane row shifting

    Hi,
    I would like to ask one question - In a JTabbed pane which has WRAP_TAB_LAYOUT , the tabs will be shown in more than one rows when number of tabs is more -When I click a tab in upper row, that row will come down - Is there any way to override this default behaviorur - that is the tabs should reamai in same position when I click
    Message was edited by:
    anikuts
    Message was edited by:
    anikuts

    If you force a particular L&F you can do this. For example, if you force the basic L&F you can create a subclass of BasicTabbedPaneUI which uses a subclass of BasicTabbedPaneUI.TabbedPaneLayout which overrides calculateTabRects.

  • Lightroom 4.0 & Wacom Bamboo (Pan/Scroll Function)

    Hi guys,
    just updated to LR 4.0. Unfortunately I can't use the pan/scroll function of my Wacom Bamboo Pen & Touch anymore. I set my »back button« of the pen to »right click« and my »front button« to »pan/scroll«. So if I press the front button I can scroll and pan through the windows (browser, finder, etc.). In LR 3.6 I could use the pan/scroll in each module - especially in Library - Grid View, Navigation and Menus I always used it to scroll through. Since LR 4.0 I can't - if I click the pan/scroll button LR always zooms in or goes into Loupe View (from Grid View). It's like hitting the space bar or left click. I don't know why. I deinstalled and reinstalled LR already. I checked my Bamboo driver as well. I went through LR's preferences, but like in LR 3 there's no way to change keys (like in PS). It drives me nuts!
    I'm using Mac OSX 10.6.8 with LR 4.0 and Wacom Bamboo Pen & Touch.
    Thank You!
    //edit
    Cool. Solved it! Just reinstalled the driver and LR again. Don't know what happened or what's different now, but it works ...
    Message was edited by: CeremonyGod

    The same problem here. However, like somebody mentioned scrolling up and down helps. Also, What I did, I set up the scroll speed to the minimum. That gives you much more control in Premiere Pro, but when you go to web to check something, better have mouse near your tablet, cause scrolling web on minimum is freakin' slow. A good solution for that is to have turned on the touch option and scroll with 2 fingers. The pen scroll and the tuch scroll can have separate speeds.
    BTW. ADOBE FOR GOD'S SAKE! FIX IT PLEASE. IT DRIVES ME NUTS!!!!!!!!!!!
    And now I'm angry again... all because of you Adobe!

  • Panning/scrolling movieclip, needs to stop and start on rollover/rollout

    Hello, I just started a new flash developer job, but I am relatively new to Actionscript itself (seems dumb, I know).
    The deal is that we have a movieclip with a jpg in it that we need to scroll left to right based on the mouse's position. This seems fairly straightforward, but there will also be FLV's (flvPlayback) and other various buttons to click on during the panning.
    What I need is a way for the MC to stop panning upon rolling over one of the pre-determined buttons.
    I inherited the code below and get what it is doing, but I have no idea how to make it stop panning when I need it to, and then "onRollOut" make it start panning again.
    bg_mc.onEnterFrame = function() {
       if (hitTest(_root._xmouse, _root._ymouse, true)) {
           mover();
       } else {
           delete panoramic_mc.onEnterFrame;
    function mover() {
       panoramic_mc.onEnterFrame = function() {
           if (_xmouse<movieMiddle) {
               if (panoramic_mc._x > movieWidth) {
                   //trace("Move panoramic 1 back");
                   panoramic_mc._x = (panoramic2_mc._x - panoramicWidth);
               if (panoramic2_mc._x > movieWidth) {
                   //trace("Move panoramic 2 back");
                   panoramic2_mc._x = (panoramic_mc._x  -panoramicWidth);
               inc = Math.abs(_xmouse - movieMiddle)*speed;
               panoramic_mc._x += inc;
               if(panoramic_mc._x > panoramic2_mc._x){
                   panoramic2_mc._x = panoramic_mc._x - panoramicWidth;
               }else{
                   panoramic2_mc._x = panoramic_mc._x + panoramicWidth;
           } else {
               if (panoramic_mc._x < (0 - panoramicWidth)) {
                   //trace("Move panoramic 1 ahead");
                   panoramic_mc._x = (panoramic2_mc._x + panoramicWidth);
               if (panoramic2_mc._x<(0 - panoramicWidth)) {
                   //trace("Move panoramic 1 ahead");
                   panoramic2_mc._x = (panoramic_mc._x + panoramicWidth);
               inc = Math.abs(_xmouse - movieMiddle)*speed;
               panoramic_mc._x -= inc;
               if(panoramic_mc._x > panoramic2_mc._x){
                   panoramic2_mc._x = panoramic_mc._x - panoramicWidth;
               }else{
                   panoramic2_mc._x = panoramic_mc._x + panoramicWidth;

    when you want the panning to be active call activate():
    function activate(){
    bg_mc.onEnterFrame = function() {
       if (hitTest(_root._xmouse, _root._ymouse, true)) {
           panoramicF()
    //when you want it to be inactive call deactivate():
    function deactivate(){
    delete bg_mc.onEnterFrame;
      function panoramicF() {
           if (_xmouse<movieMiddle) {
               if (panoramic_mc._x > movieWidth) {
                   //trace("Move panoramic 1 back");
                   panoramic_mc._x = (panoramic2_mc._x - panoramicWidth);
               if (panoramic2_mc._x > movieWidth) {
                   //trace("Move panoramic 2 back");
                   panoramic2_mc._x = (panoramic_mc._x  -panoramicWidth);
               inc = Math.abs(_xmouse - movieMiddle)*speed;
               panoramic_mc._x += inc;
               if(panoramic_mc._x > panoramic2_mc._x){
                   panoramic2_mc._x = panoramic_mc._x - panoramicWidth;
               }else{
                   panoramic2_mc._x = panoramic_mc._x + panoramicWidth;
           } else {
               if (panoramic_mc._x < (0 - panoramicWidth)) {
                   //trace("Move panoramic 1 ahead");
                   panoramic_mc._x = (panoramic2_mc._x + panoramicWidth);
               if (panoramic2_mc._x<(0 - panoramicWidth)) {
                   //trace("Move panoramic 1 ahead");
                   panoramic2_mc._x = (panoramic_mc._x + panoramicWidth);
               inc = Math.abs(_xmouse - movieMiddle)*speed;
               panoramic_mc._x -= inc;
               if(panoramic_mc._x > panoramic2_mc._x){
                   panoramic2_mc._x = panoramic_mc._x - panoramicWidth;
               }else{
                   panoramic2_mc._x = panoramic_mc._x + panoramicWidth;

  • How to make Navigation and Topic panes scroll independently?

    Can anyone suggest how to make the default Multiscreen HTML layout navigation and topic panes to scroll independently, to accomidate a long index or TOC? Currently, scrolling toward the end of the index, for example, causes the topic pane to scroll also. Selecting an index entry scrolls the topic to the location of the appropriate content, but also scroll the index, taking the selected entry out of view. I would like independent scrolling of nav pane and topic panes.
    I'm using RoboHelp HTML 10, FrameMaker 11, TCS4.
    Thanks you.

    Your post has been moved to the Multiscreen forum. That does not change the link.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • Images with JTabbed Pane

    the panels that i am using in JtabbedPane load images in background at run time when i seperately run them images are loaded but when the panels are used in tabed pane images are not visible

    I have overriden the function . what i am using for my panels is the Image panel which is derived from panel class and i create an instance of that image panel on my panel that is to be added on jtabbed control but it is not showing

Maybe you are looking for

  • Release date of IE 11 'Enterprise Mode' (EmIE)?

    I read announcements (e.g. http://www.zdnet.com/internet-explorer-11-to-get-new-enterprise-mode-7000025842/)  that IE 11 shall be equipped with a so-called 'Enterprise Mode' (EMIE) as a new feature. EMIE will allow businesses to specify which sites s

  • Need to reset Nano sometimes to get audio out from iPod connector

    When I connect the Nano (and 5G also), to one of my 3 docks, I sometimes have to do a reset to get line out audio out of the iPod connector. Anyone else see this behavior?

  • How to retreive tomcat parameters in a servlet

    Hi guys&girls, I need to get username and password used to connect to a jsp application from a servlet. Is it possible? The application uses the standard j_security_check configuration on Tomcat (with the tomcat-users.xml file, containing users) I ha

  • "send" could not load in 64-bit mode

    Hi, I just updated to Mac OS X Lion and everytime I open iTunes (v.10.4) I get this annoying pop-up. How can I get rid of this? The only plug-in installed in /Library/iTunes/iTunes Plug-ins is "Quartz Composer Visualizer". Should I delete this one? T

  • SRM 5.00 web Maximum number of sessions reached

    hello it seems a problem very simple anyway i don't know how to resolve it. the error "Maximum number of sessions reached" occurs in the ITS of SRM 5.00 using the web. It happens on all transactionsn anyway it works properly in abap gui but not in we