Switching a panel to another panel in the same frame.Is there a better way?

    public void actionPerformed(ActionEvent e) {
        if (e.getSource() instanceof toolButton){
            westPanel.remove(optionPanel);
            westPanel.setVisible(false);
            toolButton tb = (toolButton)e.getSource();
            optionPanel = tb.getPanel();
            westPanel.add(optionPanel);
            westPanel.setVisible(true);
    }This code above is what I used to execute when one of several JButtons is being pressed.
In this program, one of the JPanel will be automatically switched to another JPanel when you press the respective JButtons.
Here are my questions:
1. Right now, I use westPanel.setVisible(false) and then change some stuff and then invoke westPanel.setVisible(true) to make it visible again. Although this works, I have a feeling that this is not quite right. I feel that there should be some better way to do this, switching the panel and request the program to redraw the replacing JPanel. Is there a better way for this?
2. Most of the time, the JPanel changes the size according to the components on it. I have tried several LayoutManager, but it seems that those components have more priority. Is there a way to completely fix the JPanel so that they stay the same size?

Look into using a Card Layout rather than manually swapping the panels: http://java.sun.com/docs/books/tutorial/uiswing/layout/card.html

Similar Messages

  • Adding items to the sidebar automatically - is there a better way?

    I'm working on a way to automatically add a user's network home to the sidebar when they log in.
    Currently, I've removed the local home from the sidebar in the user template, and the following runs at every login to check whether it is there and add if not:
    (ignore the http link in line 2, forum doesn't like my code)
    name="$(whoami)"
    if [[ "$(defaults read com.apple.sidebarlists)" =~ "$name" ]]
    then echo "true"
    else
    open /Volumes/MacHomes/$(whoami)
    osascript -e 'tell application "System Events" to keystroke "t" using command down'
    osascript -e 'tell application "System Events" to keystroke "w" using command down'
    Which does the job, but I don't like the way that it has to open the folder in the GUI and can therefore be interrupted by an ill-timed click of the mouse. If possible, I'd prefer to run this without any visible element to the user. I'm also bothered by echoing a string that doesn't seem to go anywhere - to verify a condition and invoke else if necessary.
    Can anyone offer any suggestions on how to improve this?
    thanks
    Chris
    Message was edited by: Christopher Mills2

    Tony,
    Yes, but no!
    The client's need is for an AFP based, per user, private storage area without using the functionality provided by OD but retaining the ability to manage with MCX - so it's a network home in all but name. Life is too short to waste my time explaining the politics... I will write it up and stick it on t'web when the project is done.
    Essentially I have a collection of shell scripts that run at log in on the client. This part comprises a fairly minor piece that I would like to be a little more reliable and less intrusive to users in operation.
    Chris

  • How to merge the Panel with another Panel to One Panel?

    As Title!!

    i will give it a shot. by no means do i say it is correct being a beginner myself
    Panel aPanel = new Panel();
    Panel anotherPanel = new Panel();
    Panel mythirdPanel = new Panel();
    aPanel.add(anotherPanel);
    aPanel.add(myThirdPanel);
    this should create one panel called aPanel with two panels inside - another Panel first, followed by mythirdPanel second. This should be in FlowLayout pattern as that is default unless specified.
    That is my guess and my shot.
    8)

  • Two sliding panels/w tabs widgets on the same page?

    I would like to use two of the same widget (Sliding Panels/w
    tabs) on the same page.
    How can I get two instances to function independently and not
    break each other....?
    I edited the sp_withTabs.js file by duplicating the first
    section below copying it, modifying it, and then pasting it below
    as the second section:
    // Turn the slidingPanel region into a real sliding panel
    widget.
    Spry.$$("#slidingPanel").addClassName("SlidingPanels");
    Spry.$$("#slidingPanel >
    div").addClassName("SlidingPanelsContentGroup");
    Spry.$$("#slidingPanel .SlidingPanelsContentGroup >
    div").addClassName("SlidingPanelsContent");
    sp2 = new Spry.Widget.SlidingPanels('slidingPanel');
    // Turn the slidingPanel2 region into a real sliding panel
    widget.
    Spry.$$("#slidingPanel2").addClassName("SlidingPanels");
    Spry.$$("#slidingPanel2 >
    div").addClassName("SlidingPanelsContentGroup");
    Spry.$$("#slidingPanel2 .SlidingPanelsContentGroup >
    div").addClassName("SlidingPanelsContent");
    sp2 = new Spry.Widget.SlidingPanels('slidingPanel2');
    This actually gets the second instance to function properly,
    but now the first instance is "frozen".

    Chapman, i know its been a while
    but where on the JS file is the part you changed?
    I cant find that in mine
    check out my page:
    http://www.pupr.edu/department/industrial/students.asp
    Im trying to do that same thing, but a sliding panel inside another one.
    The one inside isnt being recognized as a slliding panel, im thinking its the same problem you were having.
    If you need me to copy the .js file let me know!
    This is working with the Spry Sliding Panels Widget

  • Add a panel on another panel

    I am working on a program and need to put one panel into another panel . I have been successful at adding the panel
    however when i do this i cannot set the size of the 2nd panel. The first panel on the frame is just fine
    i have tried adding the panel to the first panels constructor this works the panel shows up but i am unable
    to set the size of the panel which is the problem.
    I tried calling this.setSize in the second panels constructor to solve this problem no luck there
    i have also tried adding the 2nd panel to the frame but this produces the same problem as stated above
    im really stumped any help woul be appreciated
    here is some code i have
    This is the frames class with the first panel added
    public ICUFrame () {
            super("ICU");
            canvas= new ICUPanel();
            add(canvas, BorderLayout.CENTER);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setSize(1000,1000);
            setVisible(true);
        } this is the panel on the frame
    only the constructor is required here as the rest is just code for drawing etc...
    public class ICUPanel extends JPanel {
        DiaDisplay d ;
        SysDisplay s;
        public ICUPanel(){
            super();
            setBackground(Color.BLACK);
            ICUMonitoring monitor = new ICUMonitoring();
            Thread rep = new Thread(new Repainter());
            d = new DiaDisplay(220,20,40,200);
            s = new SysDisplay(420,220,40,200);
            rep.start();
        }// end of constructor
    }this is the 2nd panel i am trying to add to the 1st panel
    public class ECGPanel extends JPanel {
        ecgDisplay e;
         public ECGPanel(){
         super();
         setBackground(Color.white);
         e = new ecgDisplay();
        }// end of constructor
    }

    xiaolixx wrote:
    I am working on a program and need to put one panel into another panel . I have been successful at adding the panel
    however when i do this i cannot set the size of the 2nd panel. The first panel on the frame is just fine
    i have tried.. What happened to your shift key? Please apply it once at the start of every sentence, rather than those rare occasions you 'feel like it'. Adding an upper case letter to each sentence makes it easier for people to quickly scan the text, looking for ways to help. You would not want to make it harder for someone to help, would you?
    ..adding the panel to the first panels constructor this works the panel shows up but i am unable
    to set the size of the panel which is the problem.
    I tried calling this.setSize in the second panels constructor to solve this problem no luck there
    i have also tried adding the 2nd panel to the frame but this produces the same problem as stated above
    im really stumped any help woul be appreciated
    here is some code i haveAlso known as 'uncompilable code snippets'. For better help sooner, post an SSCCE . But first, go through the tutorial to which Darryl linked.

  • Center a panel in another panel

    Good day:
    I am trying to center align (horizontal & vertical centering) a panel in another panel.
    How would I go about doing this?
    I have tried a few different layout managers, but they have not produced the results I am looking for.
    The parent panel is fixed sized, but the child panel is dynamic.
    Please help!!

    Thank you for your post, I greatly appreciate it. However, I tried both of those methods, and my child JPanel is always being placed in the upper left corner of the parent JPanel.
    Here is some code showing my initialization of the JPanel, and the adding of the child JPanel:
    Creating the parent JPanel:
            imagePreview = new JPanel();
            imagePreview.setBackground(Color.white);
            imagePreview.setBorder(new LineBorder(Color.black,1,true));
            getContentPane().add(imagePreview);Adding the child JPanel
    void displayThumbnail()
                  wallpaperChanger.imagePreview.removeAll();
                  wallpaperChanger.imagePreview.add(new viewer(THUMB_LOCATION));
                  wallpaperChanger.imagePreview.repaint();
             }If it helps, the viewer class:
    class viewer extends JPanel
         private Image image;
         public viewer(String fileName)
              Toolkit toolkit = Toolkit.getDefaultToolkit();
              image = toolkit.createImage(fileName);
              MediaTracker mediaTracker = new MediaTracker(this);
              mediaTracker.addImage(image, 0);
              try
                   mediaTracker.waitForID(0);
              catch (InterruptedException ie)
                   System.err.println(ie);
              setSize(image.getWidth(null), image.getHeight(null));
              //show();
         public void paint(Graphics graphics)
              graphics.drawImage(image, 0, 0, null);
    }

  • How can I using tpcall from one service to another service in the same server

    When I using tpforward between two services in one server, it's working ok. However,
    when I using tpcall from one service to another service, it's failed?
    anybody can tell me why?
    thanks
    george

    "george" <[email protected]> wrote:
    >
    When I using tpforward between two services in one server, it's working
    ok. However,
    when I using tpcall from one service to another service, it's failed?
    anybody can tell me why?Basically, tpcall:ing another service in the same server is a no-no, unless you
    a) are running a multi-threaded server (requires TUXEDO 7 or newer + compilation
    options) or
    b) use tpacall() instead of tpcall() and specify the flag TPNOREPLY. This is probably
    not what you want to accomplish, though.
    The reason is that TUXEDO servers by default (and always in versions before 7)
    are single-threaded. If service A and B both reside in server X, server X will
    be busy taking care of the call to A. If A makes a call to B, the call will be
    put on the queue to X, but X will not look at the queue until it is done with
    A, which won't happen until B returns... deadlock!
    You can play tricks with starting multiple instances of X, but in the end you
    will always face a risk (something lika a race-condition) for a dead-lock.
    Solution: Move service B to another server (usually quite easy) OR switch to multi-threading,
    if that's possible. Just make sure all code your service calls is MT-safe as well...
    thanks
    georgeHope this helps you,
    /Per

  • How can I copy an audio effect from a clip and paste it to another clip in the same timiline...With FCPro 7 it was all so fast........

    how can I copy an audio effect from a clip and paste it to another clip in the same timiline...With FCPro 7 it was all so fast........

    Tom Wolsky wrote:
    The advantage goes to FCP7 if you allow that it can copy and paste filters, audio and video, transformations, and other attributes separately.
    You can do that in FCPX too, as all the things you cited are listed separately in the inspector.
    Here's a little gotcha. Let's say you've color corrected a few clips and you've applied an effect to one and want to paste it the other clips. You switch off color correction and copy the clip. You select the other clips and paste effects. What do you think happens? The effect is applied, but the color correction is applied as well, only it's switched off as it was in the first clip, so all the color correction on the other clips is lost. Fun, eh?
    I'll try to replicate your gotcha - but no, that doesn't sound like fun at all!

  • I tried to download a movie on my iPod touch but due to limited space, it did not download.  Then, I checked my credit card online, and I found the money was already taken.  How will I get it to download on another device with the same account?

    I tried to download a movie on my iPod touch but due to limited space, it did not download.  Then, I checked my credit card online, and I found the money was already taken.  How will I get it to download on another device with the same account? Also, I was wondering why they took my money even when it did not finish downloading let alone get downloaded?

    Welcome to the Apple Community.
    You can re-download content purchased from the iTunes store (availability varies depending on location) using the purchased option from the Quick Links section in the top right corner of the iTunes homepage in your iTunes application on your computer.
    You can re-download content purchased from the iTunes store (availability varies depending on location) using the purchased option which is revealed in the iTunes app on your iOS device by tapping the more button at the bottom of the screen.

  • Load another sound in the same sound object

    Hi,
    I am loading a sound like this:
    public var smallSound:Sound = new Sound();
    public var trans1:SoundTransform = new SoundTransform(1, 0);
    public var channel:SoundChannel = new SoundChannel();
    smallSound.load(new URLRequest("firsttrack.mp3"));
    channel=smallSound.play(0,1,trans1);
    When an event occurs (button click actually) I would like to stop playing the first sound and playing another sound in the same object. So I try doing this:
    smallSound.load(new URLRequest("secondtrack.mp3"));
    channel=smallSound.play(0,1,trans1);
    but it does not work. The first sound keeps playing. I havent understood something probably.. Can someone help me ??

    ok, i solved my problem. It works like:
    channel.stop();
    smallSound = new Sound;
    smallSound.load(new URLRequest("secondtrack.mp3"));
    channel = new SoundChannel;
    channel=smallSound.play(0,1,trans1);

  • Radio group in classic report based on another column on the same row.

    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    Application Express 4.1.0.00.32
    How can I have a radio group column based on an LOV utilizing another column on the same row of the report?
    For example: what if I had a survey application and depending on the likert scale that was assigned to the question there would be different possible answer choices:
    Question 1 on row 1 of the report: The class instructor was friendly?
    Likert scale choice is Agreement.
    Choices on Radio Group: Strongly Agree, Agree, Undecided, Strongly Disagree
    Question 2 on row 2 of the report: The class offered good materials?
    Likert scale choice is Quality.
    Choices on Radio Group: Excellent, Below Average, Average, Above Average, Excellent
    The radio group can change per row depending on the Likert scale assigned to the question which is assigned to a different column on the row.
    Can LOV utilize the column? :
    SELECT scale_text
    FROM scale_choices
    WHERE scale_category_choice_id = 2 <<= this would be the Likert scale identifier
    ORDER
    BY display_order

    Here is the answer:
    APEX_ITEM.SELECT_LIST_FROM_QUERY(
    p_idx IN NUMBER,
    p_value IN VARCHAR2 DEFAULT NULL,
    p_query IN VARCHAR2,
    p_attributes IN VARCHAR2 DEFAULT NULL,
    p_show_null IN VARCHAR2 DEFAULT 'YES',
    p_null_value IN VARCHAR2 DEFAULT '%NULL%',
    p_null_text IN VARCHAR2 DEFAULT '%',
    p_item_id IN VARCHAR2 DEFAULT NULL,
    p_item_label IN VARCHAR2 DEFAULT NULL,
    p_show_extra IN VARCHAR2 DEFAULT 'YES')
    RETURN VARCHAR2;

  • How do I move Contacts & Calendar from one User to another User on the same Macbook Pro?

    How do I move Contacts & Calendar from one User to another User on the same Macbook Pro? OSX 10.9.5

    is this second library in a different account on the computer?
    Look at Home Sharing.
    iTunes: How to share music and video - http://support.apple.com/kb/HT2688 - about Music Sharing and Home Sharing
    Home Sharing Support page - http://www.apple.com/support/homesharing/
    iTunes: Setting up Home Sharing on your computer - http://support.apple.com/kb/HT4620
    iTunes Home Sharing now works between users on same computer - https://discussions.apple.com/thread/3865597

  • Mountain Lion: Copying mailbox from one user to another user on the same mac

    When I bought the mac I had only one email address.  Since then I have accumulated 3 more addresses. I created another User on the same MAC to seperate the personal emails from the 3 new email addresses, that I use for business. 
    There are some mailboxes from the 1st account that has business information in them that I want to move to the 2nd User account (with the 3 e-mail addresses).  I though that I could save them in the dropbox and then save them into the 2nd User accounts like I did with the documents and spreadsheets, but this does not work.  
    I really need to separate the Family Personal email information from the Busines Information and I do not want to just send lots and lots of emails to the accounts to get them there. 
    I am not using Cloud at the moment because it created some syncing issues.  Because the 1st User Account and email account is synced with an iPad and iPhone that my wife uses with an Apple ID.  The 2nd User (and 3 mail addresses) are synced with my iPhone and a separate Apple ID.  We have separate ID's because she did not want my personal & business contacts seeping into the family email accounts
    I know that this is long, but I wanted to provide as much information as possible, so that I can resolve this.
    Thanks in Advance

    I spent quite a few hours after this was posted trying to figure it out and I did.
    Select Mailbox > Export Mailbox.  This asks you a location to export the mailboxes to.  It just uploads the exported mailboxes into Dropbox. 
    Then change the User that I want to import the mailboxes into. Select Import and select the location of where you placed the folder in Dropbox. This then imports the mailbox into a folder called Import. You then drag and drop the copied mailboxes from the Import folder to the folder in the structure you have.  If you decide to delete the folders from the import folder list, do this.  You can also delete the copied folders from Dropbox if you wish.
    Took a while, but I got there and I'm happy now....

  • How can i copy my itunes library to another computer in the same household?

    How can I copy my itunes library to another computer in the same houehold?

    If you just want to share the iTunes library with other computers in your house: http://support.apple.com/kb/ht3819
    If you want to move the iTunes library:
    For Windows: http://support.apple.com/kb/ht1364
    For Mac: http://support.apple.com/kb/ht1449

  • For some reason osx mountain lion has disappeared from my purchases and now when i want to install mountain lion on another mac with the same apple id it wants to charge me for the program even though i have already purchased it. what do i do?

    for some reason osx mountain lion has disappeared from my purchases and now when i want to install mountain lion on another mac with the same apple id it wants to charge me for the program even though i have already purchased it. what do i do?

    Open the Mac App Store on the other Mac and in the Quick Links sign into your account. See if the Mountain Lion purchase is among hidden apps in the iCloud area of your account info.

Maybe you are looking for

  • How to add columns in field-symbol

    Dear All,               Have made a report for HR - ZHR_CTC by using logical database and field-symbol. Report is working fine, but now have to add columns e.g business area text, positions text etc. Have added columns in field-symbol.But not able to

  • RV320 SSL VPN web service unable to connect port 56000 56001...

    I have recently installed a RV320 dual WAN small business router in order to use the SSL VPN functionality to allow secure access to our intranet pages which are hosted on a server inside our network. I have the latest firmware installed on the route

  • Using multiple iPhone remotes with Apple TV

    Hi Anyone knows how to use two iPhones 4  as remotes with one same Apple TV device ? I am using iTunes 10.5.0.142 on my computer. Home sharing is turned on and I can access my iTunes library with both iPhones. Home sharing on Apple TV is turned on. E

  • How to create a partition using Boot camp assistant 4.0.1 ?

    Hi, i would like to "Partition" my drive and not "Install" windows 7 like the assistant asks me... I wanted to increase the size of my bootcamp partition. So i used winclone to save it and now to restore it i need a NTFS partition that is normally cr

  • Auto rotation when editing in iPhoto

    When I go from organize to editing mode in iPhoto the photos automatically turn anti clockwise through 90 degrees, I can't find any help which explains this problem, please help. Flat Panel PowerPC G4   Mac OS X (10.4.8)