Switching panels in diffrent states

Hi all,
I have a lot of panels which I'm switch between them using card layout.
My problem is that the switching between the panels isn't constant and it is depent of the application current state.
For example:
STATE1: Screen1 (next -->) Screen2 (next -->)Screen3 (next -->) Screen1
STATE2: Screen1 (next -->) Screen2 (next -->) Screen3 (next -->) Screen2
STATE3: Screen2 -(next -->) Screen1 (next -->) Screen3 (next -->) Screen1
Each STATE is the user choise from the main-menu and and the Screens are the panels which displayed using the CardLayout and (next -->) represent the order they displayed
and so on...
At the moment i'm using a lot of if-else but this is not a good technigue when adding new panels and states.
Does any one can give me advise how to make this simplier ?
Thank,
hanoch

Use a 2D array to store the screen switch info.
String[][] switchBoard = new String[stateNum][stepNum];
// ToDo: Initialize the array here ...
switchBoard[2][3] = "Screen 3";
// Flip screen
yourCardLayout.show(yourPanel, switchBoard[state][step]);

Similar Messages

  • Switch panel lights on all the time after keyboard replacement

    I replaced the keyboard on my DV6000, now the keyboard works fine....but the blue lights on the switch panel are on all the time whether the machine is powered up or not.  I re-connected everything per the service manual instructions, and have now triple checked my work....help!
    Just as an FYI, I have 2 DV6000's, and just today replaced the trackpad on the other one, and now have the same issue with that one!!!!!
    What gives?
    Thanks in advance for the assistance.
    John

    Seriously?  No one has experienced this issue?
    Anyone from HP out there care to help me out?

  • Switching Panels and good swing practice..Swi

    Hi all,
    I have a GUI in which one of the panels needs to change, based on what "mode" the program is currently in.
    I've written code to do this but am wondering if it is good practice and if there are any easier ways you can suggest.
    In particular, the use of validate/+revalidate+ and repaint. And also how I can use pack, because last time I tried it didn't work that well.
    Thanks,
    KrimsonEagl
    public class SwitchingPanels extends JFrame implements ActionListener {
         private JDesktopPane desktopPane;
         private JPanel buttonPanel;
         private JPanel buttonPanelMain;
         private JPanel currentPanel = new JPanel();
         private enum Mode {
              MODE1, MODE2, MODE3
         private Mode mode = Mode.MODE1;
         private Map<Mode, JPanel> buttonMap;
         public SwitchingPanels() {
              // Set up GUI.
              super("Switching Panels");
              setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
              setSize(1024, 768);
              desktopPane = new JDesktopPane();
              add(desktopPane, BorderLayout.CENTER);
              buttonPanel = new JPanel();
              buttonPanel.setBorder(BorderFactory.createEtchedBorder());
              BoxLayout layout = new BoxLayout(buttonPanel, BoxLayout.Y_AXIS);
              buttonPanel.setLayout(layout);
              buttonPanelMain = new JPanel();
              ButtonGroup buttons = new ButtonGroup();
              addToggleButton(buttonPanelMain, buttons, "Mode1");
              addToggleButton(buttonPanelMain, buttons, "Mode2");
              addToggleButton(buttonPanelMain, buttons, "Mode3");
              addButton(buttonPanelMain, "Quit");
              createButtonPanels();
              buttonPanel.add(buttonPanelMain);
              buttonPanel.add(new JSeparator(SwingConstants.HORIZONTAL));
              add(buttonPanel, BorderLayout.NORTH);
              setLocation(50, 50);
              setVisible(true);
              refreshButtons();
         private void createButtonPanels() {
              buttonMap = new HashMap<Mode, JPanel>();
              JPanel mode1Panel = new JPanel();
              addButton(mode1Panel, "1.1");
              addButton(mode1Panel, "1.2");
              buttonMap.put(Mode.MODE1, mode1Panel);
              JPanel mode2Panel = new JPanel();
              addButton(mode2Panel, "2.1");
              addButton(mode2Panel, "2.2");
              buttonMap.put(Mode.MODE2, mode2Panel);
              JPanel mode3Panel = new JPanel();
              addButton(mode3Panel, "3.1");
              addButton(mode3Panel, "3.2");
              buttonMap.put(Mode.MODE3, mode3Panel);
         private void refreshButtons() {
              buttonPanel.remove(currentPanel);
              currentPanel = buttonMap.get(mode);
              buttonPanel.add(currentPanel);
              buttonPanel.validate();
              buttonPanel.repaint();
         private JToggleButton addToggleButton(JPanel panel, ButtonGroup group,
                   String name) {
              JToggleButton button = new JToggleButton(name);
              button.addActionListener(this);
              group.add(button);
              panel.add(button);
              return button;
         public void actionPerformed(ActionEvent e) {
              String cmd = e.getActionCommand();
              if (cmd.equals("Mode1")) {
                   mode = Mode.MODE1;
                   refreshButtons();
              } else if (cmd.equals("Mode2")) {
                   mode = Mode.MODE2;
                   refreshButtons();
              } else if (cmd.equals("Mode3")) {
                   mode = Mode.MODE3;
                   refreshButtons();
    }

    Look up the CardLayout as it is probably your best option here.
    Best of luck!

  • A tool-switching panel disappears, when a dialog is displayed.

    We are currently developing the plug-in of Adobe Illustrator CS6.
    Our CS6 Plug-in displays a modal dialog in tool selection.
    Modal dialog appears when I change tools, and the tool-switching panel disappears.
    I do not want to display a modal dialog on changing tool.
    In the case of CS5, such a thing does not occur.
    Do you have any solution?

    After a bunch of grumbling, head-scratching, research, and experimentation, I identified a solution that works for us.
    The consistent condition for users with this problem was that they had Acrobat (any version, near as we can tell) installed.  The browser used the Acrobat print dialog to print .pdf, and that dialog is the one that doesn't work.  Those who had only Adobe Reader were OK, since its print dialog worked.
    The fix is to make the browser use Reader to process pdfs rather than Acrobat, and the Reader print dialog works great.
    In the cases where no Reader was installed (only Acrobat), we installed it, and the Reader install reconfigured the browser to use the Reader with pdfs, instead of Acrobat.  The Reader install also makes itself the default application for all the standard pdf file types.  We initially thought, where both Reader and Acrobat were already installed, we could just re-associate the files with Reader and that would also correct the browser behavior.  But the browser explicitly associates an application with a file type, and does not rely on the computer associations to make that determination.
    Unfortunately, we weren't able to figure out how to manually change that for IE 10 or 11.  Probably a registry hack for that, but we're not terribly interested in going there.  So, if the computer already had both Acrobat and Reader installed, we just removed and reinstalled Reader.  Presto, browser uses Reader and printing is fixed.
    Of course, the down side is that after a Reader install, double-clicking a pdf file will bring up Reader, not Acrobat.  We told Acrobat users to run Acrobat first and use File/Open, or to right-click the file and use Open with.  If they want to play around with the file associations themselves, well, that's up to them.
    TSN, thanks for the response.

  • Switching panels in AWT

    Hi, having a problem with switching 2 panels within a frame. Am using the following code within the frame file:
    removeAll();
    recPlay = new RecPlayPanel(tvacs);
    recPlay.start();
    add(recPlay);
    this.repaint();
    When this code is exectuted the first panel is removed but the second is not displayed, yet if you resize the frame it suddenly appears. Does anybody know why this happens. NOTE: this must be done using AWT components only as is to run on JEODE runtime. Thanks in advance, Alan

    You should probably call validate() since that'll set the size of the panel according to your layout policy.
    Hope this helps.

  • Switch statesment in  return statement

    Hello, how do i effectively use a switch statement in a method that returns a string, below is my understanding but this implementation will not compile
    public String toString(int format){
         return switch(format){
                             case 0: System.out.print(year+" "+month+" "+day);
                                       break;
                             case 1: System.out.print(month+" "+day+" "+year);
                                       break;
                             case 3: System.out.print(day+" "+month+" "+year);
                   default: System.out.print("that is not a valid format");

    If you are new to Java I suggest using the New to Java forum in future.
    The problem also appears to be that you haven't used any of the constructs correctly.
    BTW: Why is there no format #2
    public String toString(int format){
        switch(format) {
              case 0: return year+" "+month+" "+day;
              case 1: return month+" "+day+" "+year;
              case 3: return day+" "+month+" "+year;
              default: throw new IllegalArgumentException("that is not a valid format");
    }There are allot of ways you could do this better but it requirements more advanced programming.

  • Switch case in select statement

    I have got the following message, while executing the SQL Query.  Appreciate any help pointing what is wrong...
    Msg 156, Level 15, State 1, Line 2
    Incorrect syntax near the keyword 'CASE'.
    SELECT TOP 1 UP.DATAID, UP.START_TIME, datediff(day, UP.START_TIME, getutcdate()) as DayGap
    CASE DayGap
        WHEN 0
            THEN 'SAME DAY'
        WHEN > 0
            THEN 'new record'
        ELSE 'other'
    END as FinalRe
    FROM MTP.USERPROGRESS as UP
    where UP.MDATAID = 575 AND UP.LSTATUS = 2
    tried the following also, but no luck
    SELECT TOP 1 DATAID, START_TIME,  datediff(day, START_TIME, getutcdate() as DayGap
    SWITCH((datediff(day, START_TIME, getutcdate()) = 0)'ITSZERO', (datediff(day, START_TIME, getutcdate()) > 0)'GT1', TRUE, 'n')
    FROM MTP.USERPROGRESS
    where MDATAID = 575 AND LSTATUS = 2

    SELECT TOP 1 UP.DATAID, UP.START_TIME, datediff(day, UP.START_TIME, getutcdate()) as DayGap,
    CASE when DayGap =0
                THEN 'SAME DAY'
        WHEN DayGap > 0
            THEN 'new record'
        ELSE 'other'
    END as FinalRe 
    FROM MTP.USERPROGRESS as UP
    where UP.MDATAID = 575 AND UP.LSTATUS = 2
    -Prashanth

  • Display on front panel of what state vi is in

        I would like to find away to light an LED when the vi is in a state indicating on the fron panel what point it is in, any ideas.
    Attachments:
    timedBackbone.vi ‏77 KB

    Well, a single LED alone will not show you what state it is in. It has only two states (On/Off), but your state machine has many.
    You have a few possibilities:
    Just create an indicator on the enum wire in the loop. It will give ou the state in clear text.
    Create an indicator for any particular state, repeat if needed. (for example, the LED in the image wil light if state is in "exhaust four".
    Create a 12 element boolean array each corresponding to one state and turn them on as a function of state (using replace array subset)
    The image below show a few possibilities. (And please try to wire left to right for clarity).
    Message Edited by altenbach on 07-13-2006 03:45 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    States.png ‏7 KB

  • How to switch to the United States store

    How can I switch back to the United States App Store? My phone is current in the brazilian store.

    Settings > iTunes & App Stores > Apple ID: > View Apple ID > Country/Region...change here.

  • Silver Shuffle - Switch Panel Area Is White And Not Green As Apple Adverts

    Hi everyone
    Just got the New Silver iPod Shuffle.
    Have a question about the top of the ipod - where the switch is, the colour is White and not Green as shown in the Apple store Pictures. Any idea?
    I wouldn't like to think its a fake. Reason asking is I have already had to send one back as it looked liked it had been tampered with - had loads of scratches on the back and the cable was missing.
    Look forward to hearing feedback on your purchases.
    Best regards and thanks C :0)

    I Feel a Plonk
    Thanks for that

  • Getting ORA- 4031 when switching db_cache_advice to ready stat

    i m getting memory allocation error while switching from off to ready...tell me what should i do to make it on.

    Check out http://metalink.oracle.com and search with "ORA-04031 DB_CACHE_ADVICE". Several useful documents are found.
    MHE

  • Switching Panels

    I am not experienced in developing java application and am working on a product management system in java.
    My initial design is to create a JFrame as the parent container and load different forms and reports in the parent container once a time.
    Each form/report would be a class which extends JPanel and will be instantiated and added to the parent JFrame. They should be called by each other to be loaded and showed in the parent JFrame.
    My questions are:
    1/. Should I use CardLayout and add ALL the forms at the very beginning? That does not sound good as the application might grow big to have many forms and reports.
    2/. Becasue the GUI components (buttons etc) are added in separate form/report from separate classes, how to call from one form/report class to load another in the parent JFrame?
    3/. Any other ways to do the task and what is the common practice?
    Thanks!

    i have asked the 1st question previously.
    someone replied that using cardlayout is not viable.
    he did not give me alternative.
    one way is to serialize jpanel forms and invoke them when u need.
    if there is another alternative u come across then pls post
    i also need this answer.
    thanks and regards,
    z_idane

  • Panel Switching

    I am having trouble switching panels.
    http://www.elovitz.net/help.zip
    Please reference myJFrame.java where the panelSwitch method is defined, welcomePanel where the method is called, and testPanel what should be displayed after.
    The panel switch method works, but after the panels are switched the screen remains blank...until I resize the window. I've tried every combination of repaint, revalidate, and validate that I could think of. I appreciate any insight in this matter.
    Thanks!

    >
    I've looked into a card layout and would prefer not to use it...>Why not? Is it perhaps that a CardLayout is the simplest and most well designed layout for this, and you want to do it the most complex and poorly designed way?
    >
    A zip file does usually imply a lot of code...but this one is only a few lines, just in different files :)>So take the advice in the SSCCE, demote most classes to 'default' and include them in the single source file - that can then be the 'few lines' you can post to the forum (between code tags, please).

  • How to animate panel's borderAlpha between states?

    Hi there,
    I have two states where a panel starts small in one state, then grows larger in the next state.
    I want to have the borderAlpha property of the panel change between states as well. The first state I want the borderAlpha to be ".04", the other state it needs to be "1".
    I've looked around and I can't find a way to define the borderAlpha between the two states.
    When I use this code in the state's properties I keep getting an error: ("panelURL" is the id of the panel)
    <mx:SetProperty target="{panelURL}" name="borderAlpha" value="1.0"/>

    Hi, have you taken a look at transitions between states?
    for example:
       <mx:transitions>
          <mx:Transition id="toOver" fromState="*" toState="over">
             <ds:AnimateColor target="{this}" property="backgroundColor"
                isStyle="true" toValue="0xff9600" duration="300" />
          </mx:Transition>
          <mx:Transition id="toUp" fromState="*" toState="up">
             <ds:AnimateColor target="{this}" property="backgroundColor"
                isStyle="true" toValue="0x1e83b8" duration="300" />
          </mx:Transition>
          <mx:Transition id="toDown" fromState="*" toState="down">
             <ds:AnimateColor target="{this}" property="backgroundColor"
                isStyle="true" toValue="0xff9600" duration="300" />
          </mx:Transition>
       </mx:transitions>
    (taken from a blog)
    hope it helps

  • HtmlText is scrunched when switching states.

    I am using Flex 3 and have a state that adds text controls with htmlText.
    When I switch between the default state and the state that has the text, the htmlText is scrunched for a bit and then renders okay.
    Any way around this?

    I fixed it by using a single Text control, and lots of <br> and <b> in the htmlText.
    I couldn't catch it in a screen shot becuse it is so fast, but I understand your point.

Maybe you are looking for

  • Tooooooo much to comprehend. Please help. I have a very simple question !!

    Hi All Gurus, I have been to almost all sites that google could throw at me, also scanned a lot of books, but thats just added to confusion. Thus, resorting to the root of all, the oracle forum. Please review the task & suggest a solution, even a goo

  • IPad Airplay Issue - iOS 8

    I work for a K-12 school district.  Teachers often use airplay and the app AirServer on our macs to mirror their iPad on their mac.  This has worked great, until iOS 8.  On iPads with iOS 8+, when you click on the airplay button in Control Center, th

  • Show in finder not working in Safari 5.1.3

    I was wondering whether anyone else had this trouble. After combo update to 10.7.3, in Safari 5.1.3 the "show in finder" magnifying glass will not open my downloads folder to show downloaded files.That is, if I have invoked "Show Downloads" from the

  • SD Card read only [Solved]

    Hi, Do not think its an Arch related problem but I have an SD Card which will only mount read-only mount: block device /dev/sdh2 is write-protected, mounting read-only mount: wrong fs type, bad option, bad superblock on /dev/sdh2, missing codepage or

  • Nested XML Feed

    Hello, I use Oracle 11g R2 SOE.... I have two main tables COMMERCIALS_PROPERTIES (com_id number PK , com_size number, project_id number, com_type number) COM_PHOTOS (ID number PK , com_id number FK, content blob, mimetype varchar2) Please, note the f