Problem to draw rectangle in Card LayOut.

This is my code..i can't display the rectangle in card lay out...pls help me!
JPanel cards;
final static String WELCOME = "Welcome Screen";
public void addComponentToPane(Container pane) {
JPanel comboBoxPane = new JPanel();
     comboBoxPane.setSize(500,500);
String comboBoxItems[] = { WELCOME};
JComboBox cb = new JComboBox(comboBoxItems);
cb.setEditable(false);
cb.addItemListener(this);
comboBoxPane.add(cb);
//inside this is the paintComponent() method..
     AirAsiaFirstClass first = new AirAsiaFirstClass();
JPanel card1 = new JPanel();
     JLabel label = new JLabel("WELCOME TO AIR ASIA.");
     card1.add(label);
card1.add(first);
     card1.setSize(500,500);
card1.setVisible(true);
cards = new JPanel(new CardLayout());
cards.add(card1, WELCOME);
pane.add(comboBoxPane, BorderLayout.PAGE_START);
pane.add(cards, BorderLayout.CENTER);
public void itemStateChanged(ItemEvent evt) {
CardLayout cl = (CardLayout)(cards.getLayout());
cl.show(cards, (String)evt.getItem());
private static void createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Air Asia");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     frame.setSize(500,500);
CardLayoutDemo demo = new CardLayoutDemo();
demo.addComponentToPane(frame.getContentPane());
frame.setVisible(true);
}

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CLD implements ItemListener {
    JPanel cards;
    final static String WELCOME = "Welcome Screen";
    public void addComponentToPane(Container pane) {
        JPanel comboBoxPane = new JPanel();
//        comboBoxPane.setSize(500,500);
        String comboBoxItems[] = { WELCOME };
        JComboBox cb = new JComboBox(comboBoxItems);
        cb.setEditable(false);
        cb.addItemListener(this);
        comboBoxPane.add(cb);
        //inside this is the paintComponent() method..
        AAFC first = new AAFC();
        JPanel card1 = new JPanel();  // default FlowLayout
        JLabel label = new JLabel("WELCOME TO AIR ASIA.");
        card1.add(label);
        card1.add(first);
        // these next two lines have no affect
        // JPanel responds to "setPreferredSize" better than "setSize"
        // "setSize" works better for top-level containers like JFrame
//        card1.setSize(500,500);
//        card1.setVisible(true);
        cards = new JPanel(new CardLayout());
        cards.add(card1, WELCOME);
        pane.add(comboBoxPane, BorderLayout.PAGE_START);
        pane.add(cards, BorderLayout.CENTER);
    public void itemStateChanged(ItemEvent evt) {
        CardLayout cl = (CardLayout)(cards.getLayout());
        cl.show(cards, (String)evt.getItem());
    private static void createAndShowGUI() {
        JFrame.setDefaultLookAndFeelDecorated(true);
        JFrame frame = new JFrame("Air Asia");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(500,500);
        CLD demo = new CLD();
        demo.addComponentToPane(frame.getContentPane());
        frame.setVisible(true);
    public static void main(String[] args) {
        createAndShowGUI();
class AAFC extends JPanel {
    int width = 150;
    int height = 55;
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        int w = getWidth();
        int h = getHeight();
        g2.setPaint(Color.red);
        g2.drawRect(10, 10, w-20, h-20);
     * tells parent container what size this needs for display
     * without this and with no child components this JPanel
     * will report a size of either 0,0 or the default 10,10 to
     * its parent container.
    public Dimension getPreferredSize() {
        return new Dimension(width, height);
}

Similar Messages

  • Card layout pb(URGENT)

    Wrote a Java application about pollen and I want to display an HTML file in the very begining. then when I click on it I go to another page in which I select some family types etc...
    then click on next and get the results. from the results page I can click on previous and I'm supposed to go back to the page where I can select family types. I used a card layout.
    here's the program :
    editor where I put the html file
    selection is the page where i can select families
    result is the results page...
    this is not the full program, just a small part...
    principal = new JPanel();
    principal.setLayout(card);
    selection = new JPanel();
    principal.add(selection, "1");
    card.show(principal, "1");
    page = new JPanel();
    page.setLayout(card);
    editor = new JEditorPane();
    editor.setEditable(false);
    page1 = new JPanel();
    page1.setLayout(new BorderLayout());
    page1.add(principal, "Center");
    page.add("1", editor);
    page.add("2", page1);
    card.show(page, "1");
    //if I clich on the html page, go to the search page
    editor.addMouseListener(new MouseAdapter()
    public void mouseClicked(MouseEvent evt)
    System.out.println("click");
    card.show(page, "2");
    getContentPane().add(page, "Center");
    //button bChercher is a button put in the south of page1
    bChercher.addActionListener(new java.awt.event.ActionListener()
    public void actionPerformed(ActionEvent e)
    System.out.println("click");
    //principal.add(selection, "1");
    card.show(principal, "1");
    bChercher.setEnabled(false);
    bInit.setEnabled(true);
    bResult.setEnabled(true);
    repaint();
    the problem is, whenever I click on the button bChercher, it sends me back to editor and not selection... it does work though id I add selection again in principal, but it's too slow...
    thanx!

    Sorry... stupid question... :o)

  • Draw rectangle with rmi

    Dear friends
    I do I draw a simple square in rmi?
    thanks

    RuiAranhaJava wrote:
    ejp...posting an interface doesn't help and I don't want no one to do my work...
    The simple question is to draw a rectangle or circle in a frame...but one of the problems is that draw (Graphics g) is abstract and must be implemented in a abstract class (I can't even declare the function).
    what I really need is a small example to understand how to do this... I really want to understand...
    Thankssounds like you would be better off posting in the AWT or "new to java" forums. you are currently posting in the RMI forums which is for questions related to remote communication, not questions related to drawing rectangles. once you figure out how to draw a rectangle, if you still need some sort of remote communication help, i'd recommend reading some RMI tutorials. then, if you have a specific question related to remote communication in java, come back here and ask it.

  • Hiding a form card layout

    Hey folks i have the code below, its an example that i have been messing around with.
    I have a on the first card button 2 which has an action listener on, it simply opens another formwhich it does correct but i want the form with the card layout on it to be hidden.
    As you can see from my code i have triediy numerous ways with no luck, hope i'm in the right forum and this shouldnt be in event handling
    Any ideas welcomed
    Ambrose
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    public class Tab_Demo implements ActionListener
         final static String ROUTER1 = "Router One";
         final static String ROUTER2 = "Router Two";
         final static String ROUTER3 = "Router Three";
         final static String ROUTER4 = "Router Four";
         final static String ROUTER5 = "Router Five";
         final static String ROUTER6 = "Router Six";
         private     JTable          table1;
         private     JTable          table2;
         private     JTable          table3;
         private     JTable          table4;
         private     JTable          table5;
               public JFrame frame;
         private Button b1 = new Button("Add");
         public void addComponentToPane(Container pane)
              JTabbedPane tabbedPane = new JTabbedPane(); //Create the "cards".           
              JPanel card1 = new JPanel()
         //Make the panel wider than it really needs, so //the window's wide enough for the tabs to stay //in one row.
         public Dimension getPreferredSize()
              Dimension size = super.getPreferredSize();
              size.width += 100;
              size.height += 600;
              return size;
              JButton button2 = new JButton("Button 2");
           button2.addActionListener(this);
           button2.setActionCommand("button2");
            card1.add(button2);
              card1.add(b1);
              card1.add(new JButton("But3"));
              card1.add(new JTextField("f",20));
              JPanel card2 = new JPanel();
              card2.add(new JButton("buttonDays"));
              // Create columns names
              String columnNames[] = { "IP Address ", "Address", "Private User", };
              // Create some data
              String dataValues[][] =
                   { "IP1", "Dublin 1 Ireland", "Yes" },
                   { "1P2", "Dublin 1 Ireland", "Yes" },
                   { "IP3", "Dublin 1 Ireland", "Yes" },
                   { "IP4", "Dublin 1 Ireland", "Yes" },
                   { "IP5", "Dublin 1 Ireland", "Yes" }
              // Create a new table instance
              table2 = new JTable( dataValues, columnNames );
              card2.add(new JScrollPane(table2));
              JPanel card3 = new JPanel();
              JPanel card4 = new JPanel();
              JPanel card5 = new JPanel();
              JPanel card6 = new JPanel();
              tabbedPane.addTab(ROUTER1, card1);
              tabbedPane.addTab(ROUTER2, card2);
              tabbedPane.addTab(ROUTER3, card3);
              tabbedPane.addTab(ROUTER4, card4);
              tabbedPane.addTab(ROUTER5, card5);
              tabbedPane.addTab(ROUTER6, card6);
              pane.add(tabbedPane, BorderLayout.CENTER);
              b1.addActionListener(this);
              public void actionPerformed( ActionEvent e)
              if (e.getActionCommand().equals("button2"))
                   Main_Menu fr = new Main_Menu("User Main Menu");
                   //Test.setDefaultLookAndFeelDecorated(true);
                   fr.show();
                   //this.hide();
                   //frame.setVisible(false);
              /** * Create the GUI and show it. For thread safety, *
              *this method should be invoked from the * event-dispatching thread. */
         private static void createAndShowGUI()
              //Make sure we have nice window decorations.
              //JFrame.setDefaultLookAndFeelDecorated(true);
              //Create and set up the window.
              JFrame frame = new JFrame("TabDemo");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              //Create and set up the content pane.
              Tab_Demo demo = new Tab_Demo();
              demo.addComponentToPane(frame.getContentPane());
              //Display the window.
              frame.pack();
              frame.setVisible(true);
         public static void main(String[] args)
              //Schedule a job for the event-dispatching thread:
              //creating and showing this application's GUI.
              javax.swing.SwingUtilities.invokeLater(new Runnable()
         public void run()
         createAndShowGUI();
    }

    HIDE_WINDOW does not hide a window that is associated to the main canvas of a form, same goes for HIDE_VIEW. And what do you mean by open_form?

  • Hiding a form using card layout

    Hey folks i have the code below, its an example that i have been messing around with.
    I ahve a on the first card button 2 which has an action listener on, it simply opens another formwhich it does correct but i want the form with the card layout on it to be hidden.
    As you can see from my code i have triediy numerous ways with no luck, hope i'm in the right forum and this shouldnt be in event handling
    Any ideas welcomed
    Ambrose
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    public class Tab_Demo implements ActionListener
         final static String ROUTER1 = "Router One";
         final static String ROUTER2 = "Router Two";
         final static String ROUTER3 = "Router Three";
         final static String ROUTER4 = "Router Four";
         final static String ROUTER5 = "Router Five";
         final static String ROUTER6 = "Router Six";
         private     JTable          table1;
         private     JTable          table2;
         private     JTable          table3;
         private     JTable          table4;
         private     JTable          table5;
               public JFrame frame;
         private Button b1 = new Button("Add");
         public void addComponentToPane(Container pane)
              JTabbedPane tabbedPane = new JTabbedPane(); //Create the "cards".           
              JPanel card1 = new JPanel()
         //Make the panel wider than it really needs, so //the window's wide enough for the tabs to stay //in one row.
         public Dimension getPreferredSize()
              Dimension size = super.getPreferredSize();
              size.width += 100;
              size.height += 600;
              return size;
              JButton button2 = new JButton("Button 2");
           button2.addActionListener(this);
           button2.setActionCommand("button2");
            card1.add(button2);
              card1.add(b1);
              card1.add(new JButton("But3"));
              card1.add(new JTextField("f",20));
              JPanel card2 = new JPanel();
              card2.add(new JButton("buttonDays"));
              // Create columns names
              String columnNames[] = { "IP Address ", "Address", "Private User", };
              // Create some data
              String dataValues[][] =
                   { "IP1", "Dublin 1 Ireland", "Yes" },
                   { "1P2", "Dublin 1 Ireland", "Yes" },
                   { "IP3", "Dublin 1 Ireland", "Yes" },
                   { "IP4", "Dublin 1 Ireland", "Yes" },
                   { "IP5", "Dublin 1 Ireland", "Yes" }
              // Create a new table instance
              table2 = new JTable( dataValues, columnNames );
              card2.add(new JScrollPane(table2));
              JPanel card3 = new JPanel();
              JPanel card4 = new JPanel();
              JPanel card5 = new JPanel();
              JPanel card6 = new JPanel();
              tabbedPane.addTab(ROUTER1, card1);
              tabbedPane.addTab(ROUTER2, card2);
              tabbedPane.addTab(ROUTER3, card3);
              tabbedPane.addTab(ROUTER4, card4);
              tabbedPane.addTab(ROUTER5, card5);
              tabbedPane.addTab(ROUTER6, card6);
              pane.add(tabbedPane, BorderLayout.CENTER);
              b1.addActionListener(this);
              public void actionPerformed( ActionEvent e)
              if (e.getActionCommand().equals("button2"))
                   Main_Menu fr = new Main_Menu("User Main Menu");
                   //Test.setDefaultLookAndFeelDecorated(true);
                   fr.show();
                   //this.hide();
                   //frame.setVisible(false);
              /** * Create the GUI and show it. For thread safety, *
              *this method should be invoked from the * event-dispatching thread. */
         private static void createAndShowGUI()
              //Make sure we have nice window decorations.
              //JFrame.setDefaultLookAndFeelDecorated(true);
              //Create and set up the window.
              JFrame frame = new JFrame("TabDemo");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              //Create and set up the content pane.
              Tab_Demo demo = new Tab_Demo();
              demo.addComponentToPane(frame.getContentPane());
              //Display the window.
              frame.pack();
              frame.setVisible(true);
         public static void main(String[] args)
              //Schedule a job for the event-dispatching thread:
              //creating and showing this application's GUI.
              javax.swing.SwingUtilities.invokeLater(new Runnable()
         public void run()
         createAndShowGUI();
    }

    HIDE_WINDOW does not hide a window that is associated to the main canvas of a form, same goes for HIDE_VIEW. And what do you mean by open_form?

  • Problems to reconize the sim card after upgrade itunes, what should I do???

    Problems to reconize the sim card after upgrade itunes, what should I do???

    Get a SIM card from the carrier to whom the phone is legitimately locked.

  • Facing problem in placing portlets in Web Layout

    I am facing problem in placing portlets on Web layout page-
    1. I am getting some space between the regions. I want that my portlet should join adjacent only not even a single pixel gap should be there.
    2. In Web Layout, First region is the left most and after that subsequent region comes right to first region and one after other. But my second and third region's portlet are coming adjacent instead of third region's portlet coming under second region's portlet
    Please help...............

    The first issue is a bug/feature that has been changed in 3.0.8 (9iAS MR1) due out this week. In previous releases we added spacing arbitrarily. Now, you can define the spacing in the region properties.
    I don't understand issue number 2. Can you clarify the problem?

  • Facing problem in placing portlet on Web Layout

    I am facing problem in placing portlets on Web layout page-
    1. I am getting some space between the regions. I want that my portlet should join adjacent only not even a single pixel gap should be there.
    2. In Web Layout, First region is the left most and after that subsequent region comes right to first region and one after other. But my second and third region's portlet are coming adjacent instead of third region's portlet coming under second region's portlet
    Please help...............

    The first issue is a bug/feature that has been changed in 3.0.8 (9iAS MR1) due out this week. In previous releases we added spacing arbitrarily. Now, you can define the spacing in the region properties.
    I don't understand issue number 2. Can you clarify the problem?

  • Draw rectangle in plot

    How can i draw rectangle in graph
    with Component works++?

    Annotations were introduced to the C++/ActiveX graph in Measurement Studio 6.0. This is the best way to draw a rectangle.
    Details:
    CNiAnnotation:hape is a property of type CNiShape. CNiShape::Type is an enumeration, one value of which is CNiShape::Rectangle. Use CNiShape::XCoordinates and CNiShape::YCoordinates to specify the location and size of the rectangle. Use CNiAnnotation::CoordinateType to specify whether the coordinates of the rectangle are in axis units or in pixels relative to plot area or screen area.
    If you cannot upgrade to Measurement Studio 6.0, you could consider using 2 cursors as a workaround.
    David Rohacek
    National Instruments

  • Hello guys,My first time in community.my problem is that my SIM card was working ok and from today at the left of the screen up shows that is searching for the sim.I contacted the carrier and the SIM card shows that is working.Any suggestions?

    Hello guys,My first time in community.my problem is that my SIM card was working ok and from today at the left of the screen up shows that is searching for the sim.I contacted the carrier and the SIM card shows that is working.Any suggestions?

    Hey NicolasZen,
    Thanks for the question and welcome to the Apple Support Communities. I understand that you are experiencing issues with “No Service” or “Searching” on your iPhone. The following resource provides some great troubleshooting steps that you may wish to try:
    iPhone: Troubleshooting No Service
    http://support.apple.com/kb/TS4429
    Your iPhone may have one of these symptoms:
    - iPhone displays "No Service" or "Searching" in an area of good coverage
    - iPhone doesn't regain service when returning to an area of coverage
    Resolution
    If you encounter either of the above symptoms on your iPhone, follow these steps to attempt to resolve the issue. Test after each step.
    1. Toggle airplane mode: Tap Settings > Enable Airplane Mode, wait five seconds, then turn off airplane mode.
    2. Turn iPhone off and then on again.
    3. Remove the SIM card and verify that it's a valid, carrier-manufactured SIM. Also verify that it isn't damaged, worn, or modified. Then reinsert it.
    4. Check for a carrier-settings update. Connect to a Wi-Fi network. Then tap Settings > General > About. If an update is available, iOS will ask you if you want to install it. If Wi-Fi isn't available, connect your device to iTunes.
    5. Update your iPhone to the latest version of iOS.
    6. Reset network settings by tapping Settings > General > Reset > Reset Network Settings. This will reset all network settings, including Bluetooth pairing records, Wi-Fi passwords, VPN, and APN settings.
    7. Restore the iPhone.
    Thanks,
    Matt M.

  • Card layout trouble

    I cannot figure out why when I run the program it shows the second card, and will not change when I click on the buttons that should change the card.
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.*;
    import java.util.*;
    public class Payroll extends JFrame
        // Card Layout to hold panels of GUI
        private CardLayout cardLayout = new CardLayout();
        // panels for various parts of GUI
        private JPanel homePanel = new JPanel();
        private static JPanel filePanel = new JPanel();
        private JPanel processedPanel = new JPanel();
        private JPanel journalPanel = new JPanel();
        private JPanel checkPanel = new JPanel();
        private JPanel stubPanel = new JPanel();
        // contentPane will hold other panels via cardLayout
        private JPanel contentPane;
        //row panels that will be used in various other panels
        private JPanel firstRow = new JPanel();
        private JPanel secondRow = new JPanel();
        private JPanel thirdRow = new JPanel();
        private JPanel fourthRow = new JPanel();
        private JPanel fifthRow = new JPanel();
        //create other data
        private int fileReturnValue;
        private JFileChooser fc = new JFileChooser();
        private File file;
        public Payroll()
            super("Widget Incorporated Payroll");
            contentPane = (JPanel)getContentPane(); // get contentpane
            contentPane.setLayout(cardLayout);  //set its layout to cardlayout
            //create the panels as cards
            homePanel = createHomePanel();
            filePanel = createFilePanel();
            /*processedPanel = createProcessedPanel();
            journalPanel = createJournalPanel();
            checkPanel = createCheckPanel();
            stubPanel = createStubPanel();*/
            contentPane.add(homePanel,"home");
            contentPane.add(filePanel,"file");
            /*contentPane.add(processedPanel);
            contentPane.add(journalPanel);
            contentPane.add(checkPanel);
            contentPane.add(stubPanel);*/
            cardLayout.show(contentPane, "home");
        private JPanel createHomePanel()
            //Create the layout for this panel
            JPanel homePanel = new JPanel(new GridLayout(4,1));
            FlowLayout rowSetup = new FlowLayout(FlowLayout.CENTER);
                firstRow.setLayout(rowSetup);
                secondRow.setLayout(rowSetup);
                thirdRow.setLayout(rowSetup);
            //Create components for this panel
            JLabel hoursWorkedLabel = new JLabel("Default hours worked:");
            JTextField hoursWorkedField = new JTextField("40",2);   
            JButton processButton = new JButton ("Process payroll for all non-terminated employees");  
            JButton closeButton = new JButton ("End Program");
            //Clear all rows
            firstRow.removeAll();
            secondRow.removeAll();
            thirdRow.removeAll();
            fourthRow.removeAll();
            fifthRow.removeAll();
            //Add the components to rows
            firstRow.add(hoursWorkedLabel);
            firstRow.add(hoursWorkedField);
            secondRow.add(processButton);
            thirdRow.add(closeButton);
            //Add the rows to this panel
            homePanel.add(firstRow);
            homePanel.add(secondRow);
            homePanel.add(thirdRow);
            //Add action listeners to the buttons
            processButton.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    //creates next part of GUI
                    cardLayout.show(contentPane,"file");
            processButton.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    //Verfies user wants to close program
                    int answer = JOptionPane.showConfirmDialog(null,"Are you sure you want to end the program","Exit",JOptionPane.YES_NO_OPTION);
                    if (answer == JOptionPane.YES_OPTION)
                    System.exit(0);
            return homePanel;
        private JPanel createFilePanel()
            //Create the layout for this panel
            JPanel filePanel = new JPanel(new GridLayout(3,1));
            FlowLayout rowSetup = new FlowLayout(FlowLayout.CENTER);
                firstRow.setLayout(rowSetup);
                secondRow.setLayout(rowSetup);
                thirdRow.setLayout(rowSetup);
            //Create components for this panel
            JLabel chooseFileLabel = new JLabel("Select the payroll file");
            final JTextField fileChooseField = new JTextField(25);
            JButton fileChooseButton = new JButton("Find");
            JButton fileOKButton = new JButton("Process");
            JButton fileBackButton = new JButton ("Back");
            //Clear all rows
            firstRow.removeAll();
            secondRow.removeAll();
            thirdRow.removeAll();
            fourthRow.removeAll();
            fifthRow.removeAll();
            //Add the components to rows
            firstRow.add(chooseFileLabel);
            secondRow.add(fileChooseField);
            secondRow.add(fileChooseButton);
            thirdRow.add(fileBackButton);
            thirdRow.add(fileOKButton);
            //Add the rows to this panel
            homePanel.add(firstRow);
            homePanel.add(secondRow);
            homePanel.add(thirdRow);
            //Add action listeners to the buttons
            fileChooseButton.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    //Goes back to previous part of GUI
                    chooseFile(fileChooseField);
            fileBackButton.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    //Goes back to previous part of GUI
                    cardLayout.show(contentPane,"home");
            return filePanel;
        private void chooseFile(JTextField field)
            fileReturnValue = fc.showOpenDialog(filePanel);
            if (fileReturnValue == JFileChooser.APPROVE_OPTION)
                file = fc.getSelectedFile();
            field.setText(file.toString());
        public static void main(String[] args)
            java.awt.EventQueue.invokeLater(new Runnable()
                public void run()
                    Payroll frame = new Payroll();
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);           
        }

    I used an example from Encephtalophathic as a guide
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SimpleCardLO1 extends JFrame
        // first create a CardLayout object
        private CardLayout cardlayout = new CardLayout();
        // contentPane will hold the next two panels via CardLayout
        private JPanel contentPane;
        private JPanel firstPanel;
        private JPanel nextPanel;
        public SimpleCardLO1()
            super("Simple Card Layout");
            contentPane = (JPanel)getContentPane(); // get contentpane
            contentPane.setPreferredSize(new Dimension(160, 80));
            contentPane.setLayout(cardlayout); //set its layout to cardlayout
            // create the two panels held in contentPane as cards
            firstPanel = createFirstPanel();
            nextPanel = createProcessPanel();
            // and add them.  The String helps to recognize which panel is which
            contentPane.add(firstPanel, "First");
            contentPane.add(nextPanel, "Next");
        private JPanel createFirstPanel()
            JPanel firstPanel = new JPanel(new GridLayout(0, 1, 20, 20));
            JPanel buttonPanel = new JPanel();
            JButton nextButton = new JButton("Process");
            buttonPanel.add(nextButton);
            firstPanel.add(buttonPanel);
            nextButton.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    // to get the next panel, simply call cardlayout's next method
                    // also pass a reference the component that is using the cardlayout as its manager
                    cardlayout.next(contentPane);
            return firstPanel;
        private JPanel createProcessPanel()
            JPanel processPanel = new JPanel(new GridLayout(0, 1, 20, 20));
            JPanel buttonPanel = new JPanel();
            JButton backButton = new JButton("Back");
            buttonPanel.add(backButton);
            processPanel.add(buttonPanel);
            backButton.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    // to get the previous panel, call the previous method
                    cardlayout.previous(contentPane);
            return processPanel;
        // code to call this program in a thread-safe way
        public static void main(String[] args)
            java.awt.EventQueue.invokeLater(new Runnable()
                public void run()
                    SimpleCardLO1 frame = new SimpleCardLO1();
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);            }
    }The example works and mine doesn't and I just can't find the difference
    Edited by: tim.raptorrunner on Jan 17, 2008 8:54 PM
    As far as I can tell it decided to randomly work.

  • Control of drawing rectangle (links, cropping, etc.)

    For some reason, I don't have precise control over drawing rectangles (for adding links or cropping) to PDF documents in Acrobat 9.0 Pro. I used to!
    I can still create these boxes, but they are much more rigid control-wise, almost like a "snapping" feature is activated. If links are close together on the PDF, it's hard to make them so they don't overlap.
    Does this make sense? Advice?

    Under View make sure Snap to grid is turned off.

  • I had a big problem i scrape the gift card hard and i cant see the code what should i do??, i had a big problem i scrape the gift card hard and i cant see the code what should i do??

    i have a problem i scrape the gift card hard and i cant see the code what should i do??

    iTunes Store: Invalid, inactive, or illegible codes

  • IPhoto card layout

    I have iPhoto ver 9.4.3. I am trying to create a flat card but iphoto only alows me to use 4 different card layouts.
    Is there a way to modify the "standard" layouts or create new card layouts other than what iPhoto allows?

    Do you have iWork?  With Pages it's easy to create a collage of photos of any size you want. Just drag the photos from iPhoto onto the Pages layout, resize and place where you want Like this 20 x 30 poster with 96 photos:
    The demo version of OmniGraffle will let you create a layout with 10 photos on it.

  • OTL: Time Card Layout Notification

    Hi all,
    I have 2 questions:
    1. How do I find out which Time Card Layout Notification we are using AND if that particular layout has been customized? Please answer both parts.
    2. How do I find out if a particular work flow has been customized? in this case its HXCEMP.
    Thank you all.
    OB

    OB,
    Check through the Preferences form to find the layout preference attached to a person.
    If your OTL implementer was wise enough, he would have given a new name to the modified layout. Otherwise use the fndload command to download the layout ldt file and compare with the original ones.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • RSTPTEST , RFC ping failed RFC error text: timeout during allocate / CPIC-C

    Hi all, I was transporting the request in my landscape last week and all of sudden transports in acceptance system is not working and I am getting a error message as Could not start transport control program tp Message no. TP608 Diagnosis There was a

  • How can I take out all my HealthVault data?

    As titled, how can I take out all my HealthVault data?

  • Hooking up my mixer??????

    what would be the best way to hook up a mixer with normal av connections to my G5 IMAC. What is the product and where do i buy it????? If you have the answers call 914-850-0882.

  • MXF OP1a export problems  - URGENT

    i am using the adobe cs5 mxf op1a settings to export my projects for tv stations. at the tv stations, there are installed avid media compser and harris broadcast playout. the problem is this - when the exported mxf project is imported in either the a

  • Where does a PL/SQL block run? PGA or SGA?

    Hi all, 11g I'm not familiar with the oracle memory structure, if I have a simple pl/sql block as below DECLARE   v1 number; BEGIN   v1:=100;   DBMS_OUTPUT.PUT_LINE(v1); END;in my mind, even though it's a small block, when i execute it, it would also