473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to create pages in swing??

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.  
Sep 27 '09 #1
3 1518
r035198x
13,262 8TB
Google and read about CardLayout.
Sep 28 '09 #2
If i had got help from google then why would i ask here????
Oct 1 '09 #3
r035198x
13,262 8TB
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.
Oct 1 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Scott Khan | last post by:
We have a Java Swing position. Need consultants ASAP. Position : Java Swing XML / SOAP - FX / Brokerage Requirements : Swing - JTrees / Jtables. other swing classes. etc. Java/ J2EE. JDK...
5
by: Chris | last post by:
Having been traumatised many years ago when using MFC/C++ to develop front-end code, I've religiously avoided GUI work since and stuck to back-end / server-side projects. So I'm a bit of a novice...
6
by: Joseph | last post by:
hi 1) i plan on having an awt canvas component (to draw graphs) on a JFrame with other swing components..will this be okay? i've read that swing and awt aren't compatible.. 2)Also, if i...
3
by: bergel | last post by:
Hello, Does anyone already have some experience in mixing AWT and Swing? Is it conceptually doable? Does the design of Swing prevent interaction between an AWT and a Swing widget? Regards,...
3
by: Sherrod Faulks | last post by:
I'm using Jython and in the python script I do: from javax import swing result = javax.swing.JOptionPane.showInputDialog(wC, cmd,"Prompt from " + client.serverName, JOptionPane.PLAIN_MESSAGE) ...
1
by: Nandan | last post by:
hello, can I ask a jython question here? when I use the jython interpreter I have no problem with the statement: from java import lang from javax import swing but when I put this in a...
2
by: asj | last post by:
I have to honestly say I was flabbergasted by this report. Obviously, I have no problems asserting that Java is #1 in the enterprise (JEE), or in the mobile space (JME), and I do know it's made...
3
by: Nuwang | last post by:
Hai, I'm using a swing to connect database with swing application... 1. How this swing connect with access database... 2. Important thing is how change Button size and Font size Still I...
1
by: Akino877 | last post by:
Hello, I have a question regarding Java and Swing programming I wonder if I could ask the forum for some help. I have a JPanel that has a couple of radio buttons and an "OK/Next" button on it. ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.