JSplitPane: Panel from bottom component comes back in top component

Hi,
In the next program I have added a small Panel (called smallPanel) to a Panel containing what I call a problem. The smallPanel is meant as a place holder for a checkbox that in my program is to be added when needed. So either the smallPanel is added, or a checkbox.
The smalLPanel is added to a panel in the bottomPanel. The bottomPanel is together with a topPanel added to a JSplitPane. What I found out is that if you scroll the bottomPanel downwards, the smallPanel shines through in the topPanel. My question is, is this a bug?
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class JSplitPaneProblem extends Canvas implements ActionListener
    static Color background;
    static String[] csdEngineers = {"jdoe1", "jdoe2", "jdoe3", "jdoe4", "jdoe5", "jdoet", "amacadam"};
    static String[] engineers = {"Choose one", "jdoe1", "jdoe2", "jdoe3", "jdoe4", "jdoe5", "jdoet", "amacadam"};
    static int width;
    static int height;
    static int remainingWidth;
    static int insets;
    static int labelWidth;
    static JScrollPane problemPane;
    static JPanel bottomPanel;
    static Panel smallPanel;
    static final int FAKE_CHECKBOX_SIZE = 10;
    static JSplitPane splitPane;
    static int BIGNUMBER = 100;
    public JSplitPaneProblem(JFrame frame)
        // Get the image to use.
        ImageIcon trafficLight = createImageIcon("any.gif");
        JLabel trafficLightLabel = new JLabel(trafficLight);
        if (trafficLight != null)
            width = trafficLight.getIconWidth();
            height = trafficLight.getIconHeight();
        else
            width = 100;
            height = 300;
        JPanel topPanel = new JPanel();
        JScrollPane trafficLightPane = new JScrollPane (ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER,
                    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        trafficLightPane.setViewportView(topPanel);
        topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.LINE_AXIS));
        for (int i = 0; i < BIGNUMBER; i++)
            trafficLight = createImageIcon("any.gif");
            trafficLightLabel = new JLabel(trafficLight);
            topPanel.add(trafficLightLabel);
        Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
        width = dimension.width;
        trafficLightPane.setPreferredSize(new Dimension(width, height));
        trafficLightPane.setMinimumSize(new Dimension(width, height+10)); // <-- Die doet ut
        height = 36;
        insets = 4; // Number of pixels to left and/or right of a component
        labelWidth = 40;
          frame.setBounds (0, 0, dimension.width, dimension.height);
        // And a new problem pane, to which the problem panel is added
        bottomPanel = new JPanel();
        bottomPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
        JScrollPane problemPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        problemPane.setViewportView(bottomPanel);
        // Set up the JSlitPane
        splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, trafficLightPane, problemPane);
        splitPane.setOneTouchExpandable(true);
        splitPane.resetToPreferredSizes();
        frame.add(splitPane);
     * The screen is divided in two equal sized halves, a left and a right side. Each half is divided into 3 parts.
     * remainingWidth is used to calculate the remaining width inside a half.
    public static JPanel addProblem(String organisation, String problem, int i)
        JPanel panel = new JPanel(); // JPanel has FlowLayout as default layout
        panel.setPreferredSize(new Dimension(width, height));
        // First half, containing serverId, customer name, and problem title
        // serverId
        JTextArea serverId = new JTextArea();
        if (i < 10)
            serverId.setText("9999" + i);
        else
            serverId.setText("999" + i);
        Font usedFont = new Font("SanSerif", Font.PLAIN, 12);
        serverId.setFont(usedFont);
        serverId.setPreferredSize(new Dimension(labelWidth, height));
        serverId.setBackground(background);
        panel.add(serverId);
        // Organisation name. Gets 1/3 of remaining width
        remainingWidth = (width / 2 - (int) serverId.getPreferredSize().getWidth()) / 3 - insets;
        JTextArea organisationArea = new JTextArea(organisation);
        organisationArea.setPreferredSize(new Dimension(remainingWidth, height));
        organisationArea.setAlignmentX(SwingConstants.LEFT);
        organisationArea.setBackground(background);
        organisationArea.setLineWrap(true);
        organisationArea.setWrapStyleWord(true);
        organisationArea.setEditable(false);
        panel.add(organisationArea);
        // Problem title
        JTextArea problemArea = new JTextArea(problem);
        problemArea.setPreferredSize(new Dimension(remainingWidth * 2, height));
        problemArea.setBackground(background);
        problemArea.setLineWrap(true);
        problemArea.setWrapStyleWord(true);
        problemArea.setEditable(false);
        panel.add(problemArea);
        // Second half, containing severity, CSD and Engineer
        // Severity
        JTextArea severity = new JTextArea("WARN");
        severity.setFont(usedFont);
        severity.setBackground(background);
        severity.setPreferredSize(new Dimension(labelWidth, height));
        panel.add(severity);
        // CSD
        JLabel csdField = new JLabel("CSD:");
        csdField.setFont(usedFont);
        JComboBox csdList = new JComboBox(csdEngineers);
        csdList.setFont(usedFont);
        csdList.setSelectedIndex(6);
        //csdList.addActionListener(this);
        panel.add(csdField);
        panel.add(csdList);
// Add "invisible" panel, used instead of checkbox (which is not added in this example)
        smallPanel = new Panel();
        smallPanel.setPreferredSize(new Dimension (FAKE_CHECKBOX_SIZE,
                    FAKE_CHECKBOX_SIZE));
        panel.add(smallPanel);
        // Solver, another ComboBox
        JLabel engineerField = new JLabel("Solver:");
        engineerField.setFont(usedFont);
        JComboBox engineerList = new JComboBox(engineers);
        engineerList.setFont(usedFont);
        engineerList.setSelectedIndex(0);
        //engineerList.addActionListener(this);
        panel.add(engineerField);
        panel.add(engineerList);
        // Empty panel to be added after this panel
        JPanel emptyPanel = new JPanel();
        emptyPanel.setPreferredSize(new Dimension(width, 15));
        return panel;
     * ActionListener
     * @param args
    public void actionPerformed(ActionEvent event)
        System.out.println("Burp");
    private static ImageIcon createImageIcon(String path)
        java.net.URL imgURL = JSplitPaneProblem.class.getResource(path);
        if (imgURL != null)
            return new ImageIcon(imgURL);
        else
            System.err.println("Couldn't find file: " + path);
            return null;
    private static void createAndShowGUI()
         Vector myVector = new Vector();
        // Create and set up the window.
        JFrame frame = new JFrame("JSlitPaneProblem");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        // Set the size of the window so in covers the whole screen
        Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setBounds(0, 0, dimension.width, dimension.height);
        // Create and set up the content pane.
        JSplitPaneProblem newContentPane = new JSplitPaneProblem(frame);       
        // Add panels to vector
        bottomPanel.setPreferredSize(new Dimension(dimension.width, dimension.height - height));
        for (int i = 0; i < BIGNUMBER; i++)
            myVector
                .add(addProblem(
                    "Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch Computer Shop",
                    "expected string or buffer, but that is not everyting, as this problem description is extremely long. And as I am chatty, I add some more length",
                    i));
            myVector.add(addProblem("My Company", "I have no problem", i));
        System.out.println ("adding problems to bottomPanel for the first time");
        for (int j = 0; j < 2 * BIGNUMBER; j++) {
             bottomPanel.add((JPanel)myVector.get(j));
        bottomPanel.removeAll();
        bottomPanel.revalidate();
        System.out.println ("adding problems to bottomPanel for the second time");
        for (int j = 0; j < 2 * BIGNUMBER; j++) {
             bottomPanel.add((JPanel)myVector.get(j));
        frame.setVisible(true);
        frame.pack();
    public static void main(String[] args)
        javax.swing.SwingUtilities.invokeLater(new Runnable()
            public void run()
                createAndShowGUI();
}If you need an image to try out this problem, you can find it here.
Abel
Edited by: Abel on 22-apr-2008 11:41
When you don't see anything in the topPanel, scroll it a bit to the right, and the bottomPanel upwards.

Use a JPanel, not a Panel, so you don't mix heavyweight and lightweight components.

Similar Messages

  • Voltage come back incorrectly Agilent 34970 advanced scan.vi

    Hello,
    I am using an Agilent 34970 wich is connected with serial port to computer and performing voltage measurements  for 16 channel using an Agilent 34902A  16-Channel Multiplexer (2/4-wire) Module
    When using Datalogger voltage reading of the 16 signal are correct
    When using Agilent 34970 advanced scan.vi we can take a voltage reading with the instrument's front panel but it always come back incorrect for the three first channel despite the number of channels tested : (exemple  for 260 V we acquire 272V even the signal is accurate the 13 other signal are correct) 
    we checked the signal manually and they are accurate
    when performing auto delay for Agilent 34970 the measurements  are correct but it take too much time , when putting manual delay the problem is still appearing even a delay of 1s for each channel .
    Is there any solution to reuduce the delay ( about 0.2s for each channel ) and to have correcte Voltage
    Thanks

    Hi Vin_sagem,
    Good afternoon and I hope your well today.
    Is this VI/LabVIEW code your using provide by Agilent or have you writen it yourself using a programmers guide to the instrument?
    If Agilent have written it for you/provide it for their customers I would advise you contact them through your support. Otherwise, I would ask if you could post the trouble example code (Not your whole application) that clearly shows the issue your having. Thus, the community can try to identify any problem areas. 
    I hope this post finds you well, 
    Kind Regards
    James Hillman
    Applications Engineer 2008 to 2009 National Instruments UK & Ireland
    Loughborough University UK - 2006 to 2011
    Remember Kudos those who help!

  • LR bug: Photo not shown when you edit in OnOne Perfect photo and come back to LR

    I have LR 5.5 and OnOne Perfect Photo Suite 8.5 (PPS) installed.
    When I edit the photo in PPS, triggered from LR, then come back to LR, the photo isn't shown, but the original photo shows that another photo is stacked with it.  No matter what I do I can't see the photo unless I either (1) close LR and re-open it or (2) click another folder to load other set of images, then go back to the folder I was in.
    Repro steps:
    Install LR 5.5 and PPS 8.5.
    Select a photo in LR and go to menu bar and click on File, then Plug-in Extras, then click on Perfect Photo Suite 8.
    Edit the photo in PPS, then go to File, then Save.  Exit PPS.
    Go back to LR and you'll see that the original photo you selected shows an overlay showing "2", which indicates it is stacked with another photo.  Click on the overlay to expand the stack,
    Actual result: You only see the original photo, even though you've expanded the group.
    Expected result: I see both photos, the original one and the edited one in PPS.

    I have had the same problem on several occasions and here is what I have found.  Look at your folders in the left-hand pane.  When this has happened to me, the current folder was listed as "Current Import".  You need to change the folder view to the actual folder you are working from and then you will see the additional photos from onOne edits.

  • Satellite U400 wont turn on & when on wont come back from sleep mode

    I have a Satellite U400 and its a year and a few months old.
    In the last little bit it has been acting up, and it started with when the computer goes to sleep and goes to the black blank screen it will not come back from that.
    The only way to do anything is hold in the power key till it turns off and then turning it back on. This brings me to the warning screen I have turned my computer off incorrectly. It has been doings this for a few weeks and started randomly out of the blue.
    Then just today it wouldnt turn on at all, I was pressing the power key and the key itself would light up, and on the bottom right hand side the little lights would light up but wouldnt turn on, I kept pressing it over and over and over again and finally it did turn on. Once on I only used it for a few mins before turning off again and then would do the same thing, I kept pressing the bottom till it turned on. Its been on now and hasnt turned off again.
    Not to log ago I had to reformat my computer due to me forgeting my password and had locked myself out of the computer. About a week after that is when the issues started. I am not all that computer smart, to be honest, I do understand something things, I can follow step by step to do something.
    I really dont want to pay to have it fix I want to just do it myself and soon as its in great shape and never had any issues before.
    Does anyone have any idea what this could be, or why it could be?
    I am thinking about reformatting again as I am worried that didnt work out right the 1st time or something.
    Or if this is something that needs to be repaired does anyone have a clue on the cost of it?
    Thanks ^_^

    hi aev270,
    sounds like a serious problem to me.
    try the following: take out battery, cd-rom, hdd and try again.
    if it starts up without this components - you got lucky!
    this means it probably a software issue (but i dont think so - sorry)
    do you see the toshiba logo / bios messages? no - the you are in trouble.
    this strange behaviour could depend on many things: defektive components like ram or grafics... or (badest thing) the mainboard...
    if you have still warranty on it you should go to a servicepartner having the system checked.

  • Just upgraded to OSX mavericks on macbook pro mid 2011 version. Having a big issue here that whenever my mac comes back from sleep, i.e after I open the lid, the screen flickers and there is an error of Finder not opening properly. Any fix to this?

    Just upgraded to OSX 10.9 mavericks on macbook pro mid 2011 version. Having a big issue here that whenever my mac comes back from sleep, i.e after I open the lid, the screen flickers and there is an error of Finder not opening properly. Any fix to this?

    My daughter has had her Razr for about 9 months now.  About two weeks ago she picked up her phone in the morning on her way to school when she noticed two cracks, both starting at the camera lens. One goes completely to the bottom and the other goes sharply to the side. She has never dropped it and me and my husband went over it with a fine tooth comb. We looked under a magnifying glass and could no find any reason for the glass to crack. Not one ding, scratch or bang. Our daughter really takes good care of her stuff, but we still wanted to make sure before we sent it in for repairs. Well we did and we got a reply from Motorola with a picture of the cracks saying this was customer abuse and that it is not covered under warranty. Even though they did not find any physical damage to back it up. Well I e-mailed them back and told them I did a little research and found pages of people having the same problems. Well I did not hear from them until I received a notice from Fed Ex that they were sending the phone back. NOT FIXED!!! I went to look up why and guess what there is no case open any more for the phone. It has been wiped clean. I put in the RMA # it comes back not found, I put in the ID #, the SN# and all comes back not found. Yet a day earlier all the info was there. I know there is a lot more people like me and all of you, but they just don't want to be bothered so they pay to have it fix, just to have it do it again. Unless they have found the problem and only fixing it on a customer pay only set up. I am furious and will not be recommending this phone to anyone. And to think I was considering this phone for my next up grade! NOT!!!!

  • When I listen to music on my iPhone and pause it, if I come back to it later, the playlist has started over. I have a 4S running on iOS 7.0.4. Is there any way to keep this from happening so that my playlist will start off where I last was?

    When I listen to music on my iPhone and pause it, if I come back to it later, the playlist has started over. I have a 4S running on iOS 7.0.4. Is there any way to keep this from happening so that my playlist will start off where I last was?

    Dear Jody..jone5
    Good for you that can't update your iphone because I did it and my iphone dosen't work for example I can't download any app like Wecaht or Twitter..
    Goodluck
    Atousa

  • HT1222 try to delete emails after about 8 deletions of 37 they all come back even after i edit them from trash folder.

    hi this just started latley i started deleting messages from mail box would delete about 7/8 junk messages then they all come back,even tried deleting 4/5 then going into trash folder and edit all but they all come back to inbox any any answers? did soft reset no luck

    Do a Hard reset - Settings > General > Reset > Reset All Settings

  • When I get an alert from my car sat nav the music on my iphone has a long delay before it comes back on and misses a part of the track why does it do this.

    When I get an alert from my car sat nav the music on my iphone has a long delay before it comes back on and misses a part of the track why does it do this.
    It only seems to do this since an iphone download last year.......its driving me mad !

    See:
    Recovering your iTunes library from your iPod or iOS device: Apple Support Communities
    To copy iTunes purchases to the computer you have to log into (authorize) the account that purchased them and them transfer
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer
    When associating a device with an Apple ID see the following regarding the 90 day limit.

  • I have upgrade ios 6 to ios7 on my iphone 5.  I do NOT like it.  I want to come back to the previosu version.  why is it so complicated.  Why can I not find the instruction strait from apple? This is the worst possible upgrade ever.

    I have upgrade ios 6 to ios7 on my iphone 5.  I do NOT like it at all.   I want to come back to the previous version.  why is it so complicated? Why can I not find the instruction strait from apple? This is the worst possible upgrade ever.  It make me think of when ericsson got sold to Sony....drastic PC change.
    I would like to have simple instruction on how to downgrade.
    It feel like a change that I did not ask for , ok I push the upgrade buttom, but really this is the worst update aver!
    HELP!

    iPhone User Guide (For iOS 7 Software)Sep 20, 2013 - 23 MB

  • I have a 10.2.8 os. I had opened up the AOL logo on the bottom bar. Two aol boxes came up. I can get them to go away for a short time and then they come back. I have not used AOL for 6 years. How can I get the boxes to go away?

    I have a 10.2.8 os on a G4 desktop. A week ago I clicked on the AOL icon in the bottom bar. I have not used AOL for six years. Two aol boxes came up. I can not get the boxes to go away for long. They may go away for 15 minutes and they come back  while I am working. How can I get these  aol boxes to go away?
    I will be upgading to Tiger; 10.4.

    Right click on the AOL icon and select move to trash.

  • I deleted my email account of my iPad buy mistake now I've put it bk on I've only got a few emails come back on not my old ones from before there still in my in box if I going my hotmail account on pc and on my phone, how do I get them bk on my iPad thank

    I deleted my email account of my iPad buy mistake now I've put it bk on I've only got a few emails come back on not my old ones from before there still in my in box if I going my hotmail account on pc and on my phone, how do I get them bk on my iPad thank

    What type of account did you set-up on the iPad, POP, IMAP, the items on your iPad could have downloaded off the server or you will need wait awhile for the message to update to the iPad. 

  • I need to transition my 1st Generation Apple TV from an older instance of iTunes to a new instance of iTunes on my brand new Mac... How do I "switch" from one instance of iTunes to another? How do I get the 5 Digit Code Network to come back on my Screen?

    I need to transition my 1st Generation Apple TV from an older instance of iTunes on my iBook to a new instance of iTunes on my new Mac... How do I get the 5 digit Network code to come back? Is there anyway for 1st Generation Apple TV to be synched to two instances of iTunes or do I have to choose one or the other? I appreciate any advice or suggestions. Thanks!

    The 5 digit code is every time different. That does not matter. Just integrate every device into your network.
    You can connect many computers to Apple TV but syncronisation works exactly with one computer. That's why I use "streaming". But you can sync one computer, then another, and so on. The content on your Apple TV is the content from your computer that has synced last. But you can not mix it.
    The new Apple TV has no syncronisation. Everything is streamed,
    Regards,
    Torsten,
    Germany

  • The share button disappeared from my Facebook add-on just before I upgraded to Firefox 5.0. I thought by upgrading and reinstalling the add-on it might come back, but it didn't. All other FB buttons are there, near as I can tell. Any ideas? I'm using XP3.

    The share button disappeared from my Facebook add-on just before I upgraded to Firefox 5.0. I thought that maybe by upgrading and reinstalling the add-on it might come back, but it didn't. All the other FB buttons are there, near as I can tell. Any ideas? I'm still using XP3.

    Hello,
    I had the same problem with finding this file.
    There's no such file in Mac OS X version of Skype. But there's a directory for your Skype user account in /Users/%current_user_name%/Library/Application Support/Skype/
    try:
    quitting Skype
    renaming old folder
    signing into the Skype

  • When I send a text message from my iPhone response only comes back to my iPhone .  If I send from iPad, response only comes back to iPad. Whichever I used last is where response comes.  Responses are not coming to both anymore!  Please help?

    When I send a text message from my iPhone response only comes back to my iPhone .  If I send from iPad, response only comes back to iPad. Whichever I used last is where response comes.  Responses are not coming to both anymore!

    On both devices when you go to settings>messages>send and recieve how are poeple contacting you on each device?. e.g. email or mobile number.

  • How do I get it so that when I delete a song from my phone it doesn't come back when I sync with iTunes?

    Hi,
    I was wondering if there was a way to deselect a song from my iTunes account automatically when I delete the song from my phone so that I don't have to go through my iTunes account and deselect everything I had deleted before I sync? I'm really big on putting everything I have from several different artists onto my phone and just deleting the songs I don't like as I hear them (very rairly do I actually remember what the song was called let along who the artist was) and often don't have the time/inclnation to go through each song on both my phone and iTunes account to find which ones sould not be checked (seriously who has the time to do this, and even if you do wouldn't you rather spend it doing something else).
    Any help with this would be greatly appreciated!
    Thank you from the girl who just inadvertently synced back over 2,000 songs to her phone.

    BC
    My understanding is that music syncing is a one way process from computer iTunes to your iPhone.  I think what you are asking is to have IOS synching back to an OSX or PC system.  The software doesn't work that way.
    You either have to uncheck the songs to be synced or create a separate playlist for "BC Canada iPhone" and only sync that playlist.
    As well any purchases you made on your iPhone need to be transferred to your iTunes so they can come back to your phone when you re-sync.
    Hope this helps, even though it's not the answer you might have wanted.
    Cheers

Maybe you are looking for

  • New to Apple - Bootcamp Help

    Hello everyone - I'm new to Apple and these forums. I just bought an iMac 21.5" the cheapest version. I have a couple of programs that I use that will only run on Windows. What is the best way to go about that? Bootcamp? Paralells? or something else?

  • How to print in captivate 5 - no widget

    Hi, I've seen various posts about using a widget to print a window/slide  "made from" Captivate 5. As I work in gov and their security policy is restrictive (for good reason I suppose), I can't download this widget. Is there another way I can get a s

  • How can I transfer data from DD & HD 3.5" floppies to my MacBook Pro running Lion?

    I hope this is the correct forum group, and if it's not, I apologize. I didn't find one that was really related to my topic. I was given lots of legacy files (mostly Eudora email messages and other text files from 1995-2000) that I need to access fro

  • MERGE with PL/SQL Record As Source

    I have a very complex process that populates a PL/SQL record. This resulting record is identical to a database table and, once built, corresponds directly to 1 row of contents for the database table. The record that is populated is even declared by b

  • Rendering service by providing material to vendor

    Hi, I need to render service with reference of project for Painting of building , In this case I am providing all the material required for painting and POP to vendor, please suggest me how to create a service PO by specifying the details of material