1 Replies - 10617 Views - Last Post: 05 August 2011 - 11:30 AM Rate Topic: -----

#1 dolphins087  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 28-June 11

GUI Login Screen

Posted 05 August 2011 - 11:23 AM

Hi guys I am trying to create a login page in java, but the formatting is messed up. I am not sure what I should do.

Thanks in advance

package def;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

public class virtual  implements ActionListener {
	JFrame economy;
	JPanel virtuPanel;
	int width = 30;
	int height = 30;
	JButton proceed;
	JLabel nombre, pass, confPass;
	 JTextField name;
	 JTextField password; 
	 JTextField confirmPass;  
	
	public virtual(){
	economy = new JFrame("ECONOMY SIMULATOR");
	economy.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	  virtuPanel = new JPanel(new GridLayout(height , width));
	  formatIt();
	  economy.getRootPane().setDefaultButton(proceed);
	  economy.getContentPane().add(virtuPanel, BorderLayout.CENTER);
	  economy.pack();     // ... having just added the panel to the window ...
      economy.setVisible(true); 
	}
	public void formatIt() {
		
		nombre = new JLabel("Name:", SwingConstants.LEFT);
		
		pass = new JLabel("Password:", SwingConstants.LEFT);
		
		confPass = new JLabel("Confirm Password:", SwingConstants.LEFT);
		
		proceed = new JButton("Proceed to Bank Setup"); 
	
		proceed.addActionListener(this);      
	    
		virtuPanel.add(nombre);
		name = new JTextField(40);
		nombre.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
	    virtuPanel.add(pass);
	    password = new JTextField(15);
	    pass.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 
	    virtuPanel.add(confPass);
	    confPass.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
	    confirmPass = new JTextField(15);
	    virtuPanel.add(proceed);
	    confPass.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
	    virtuPanel.add(name);
	    virtuPanel.add(password);
	    virtuPanel.add(confirmPass);
	  
	     
	}
	 public void actionPerformed(ActionEvent event) {  
	       String tempName = nombre.getText();
	       String tempPass =  pass.getText();
	       String tempconfirmPass =  confPass.getText();
	 }
	       private static void createAndShowGUI() {
	           JFrame.setDefaultLookAndFeelDecorated(true);
	           virtual econ = new virtual();   	     
	 }
	       
	       public static void main(String[] args) {
	           javax.swing.SwingUtilities.invokeLater(new Runnable() {
	               public void run() {
	                   createAndShowGUI();
	               }
	           });
	       }
}


This post has been edited by macosxnerd101: 06 August 2011 - 05:26 PM
Reason for edit:: Please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: GUI Login Screen

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: GUI Login Screen

Posted 05 August 2011 - 11:30 AM

http://www.dreaminco...snippet4460.htm
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1