Connecting Tech Pros Worldwide Help | Site Map

how to create pages in swing??

Newbie
 
Join Date: Sep 2009
Posts: 2
#1: Sep 27 '09
i want to design a GUI such that when i click a button (eg. next), i get a new look ie. having different no. of buttons at different place( just like a next or back buttons in website)...

Expand|Select|Wrap|Line Numbers
  1. import javax.swing.*;
  2. public class authenticate extends JFrame
  3. {
  4. JButton Blogin;
  5. private JPanel mainPanel = new JPanel()
  6.     {
  7.         //@Override
  8.         protected void paintComponent(Graphics g)
  9.         {
  10.  
  11.           super.paintComponent(g);
  12.  
  13.           if (img != null)
  14.           {
  15.  
  16.             int width = mainPanel.getWidth();
  17.             int height = mainPanel.getHeight();
  18.             // and do the drawing here:
  19.             g.drawImage(img,0,0, width, height, mainPanel);
  20.           }
  21.         }
  22.       };
  23. public authenticate() throws Exception
  24.     {
  25. setContentPane(mainPanel);
  26.  
  27.         Container con=getContentPane();
  28.         con.setLayout(null);
  29. Blogin = new JButton("Login");
  30.         con.add(Blogin);                            //Blogin Button
  31.         Blogin.setBounds(800,100,80,30);
  32.         Blogin.addActionListener(this);
  33.  
  34. }
  35.     public static void main(String[] argv) throws Exception
  36.     {
  37.  
  38.         authenticate frame= new authenticate();
  39.         frame.setVisible(true);
  40.         frame.setSize(1024,768);
  41.         frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
  42.  
  43.     }
  44. }
  45.  
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Sep 28 '09

re: how to create pages in swing??


Google and read about CardLayout.
Newbie
 
Join Date: Sep 2009
Posts: 2
#3: Oct 1 '09

re: how to create pages in swing??


If i had got help from google then why would i ask here????
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#4: Oct 1 '09

re: how to create pages in swing??


There is no need for me or anyone to reproduce a tutorial on CardLayout here. Sun already wrote it a long time ago and it's available through google. Read it and then ask a more specific question.
Reply