applet using CardLayout problem

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 3749 Views - Last Post: 30 June 2011 - 11:17 PM Rate Topic: -----

#1 nashbender  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 21-April 11

applet using CardLayout problem

Posted 24 June 2011 - 02:37 AM

hi guys!

i just developed an applet with uses CardLayout to manage the pages (panels). it involves a login page, then a series of buttons. the buttons will then link to their respective panes. the problem right now, when i click on one of the buttons, a blank page is shown. i have been searching the codes for any mistakes but i couldn't figure it out. could any java guru out there point out what's wrong with my code?

this is my current code:

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JPanel;

public class ButtonView extends JApplet implements ActionListener
	{
	final static String MENU = "Main Menu";
	final static String FILE = "View FileSystem";
	final static String EMP = "Employee Details";
	final static String HELLO = "Hello, Hi";
	
	BorderLayout borderLayout1 = new BorderLayout();
	CardLayout ourLayout;
	JPanel cardPanel;
	JPanel card1;
	JButton file;
	JButton emp;
	JButton hello;

	public void actionPerformed(ActionEvent event)
		{
		if (event.getSource() == file)
		{
			ourLayout.show(cardPanel, FILE);
		}
		else if (event.getSource() == emp)
		{
			ourLayout.show(cardPanel, EMP);
		}
		else 
		{
			ourLayout.show(cardPanel, HELLO);
		}
		
		
		}
		
	public void init()
	{
			//getContentPane().add(jPanel1);
		getContentPane().getPreferredSize();
		getContentPane().setVisible(true);
		cardPanel = new JPanel();
		ourLayout = new CardLayout();
		cardPanel.setLayout(ourLayout);
		
		
		card1 = new JPanel();
		file = new JButton(FILE);
		//file.setActionCommand(FILE);
		file.addActionListener(this);
		card1.add(file);

		emp = new JButton(EMP);
		//emp.setActionCommand(EMP);
		emp.addActionListener(this);
		card1.add(emp);
		
		hello = new JButton(HELLO);
		//hello.setActionCommand(HELLO);
		hello.addActionListener(this);
		card1.add(hello);
		
		FileExplorer card2 = new FileExplorer();
		Employee card3 = new Employee();
		Hello card4 = new Hello();
		
		cardPanel.add(card1, MENU);
		cardPanel.add(card2, FILE);
		cardPanel.add(card3, EMP);
		cardPanel.add(card4, HELLO);

		add(cardPanel, BorderLayout.CENTER);
	}
}
	


this is one of the panel class "Hello" (for testing purposes):

import javax.swing.JLabel;
import javax.swing.JPanel;


public class Hello extends JPanel {
	
	JLabel hi;

	public void init()
	{
		
		hi = new JLabel("Hello World");
		add(hi);
		
		resize(150,25);
	}
	
}



can anybody help me figure out what's wrong? i'd really appreciate the help.

Is This A Good Question/Topic? 0
  • +

Replies To: applet using CardLayout problem

#2 pbl  Icon User is offline

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

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

Re: applet using CardLayout problem

Posted 24 June 2011 - 01:30 PM

The init() method is used to initialize an Applet

However, all other Component are created by a constructor so

	class Hello extends JPanel {
		
		JLabel hi;

		public void init()
		{			
			hi = new JLabel("Hello World");
			add(hi);
		}


Should be raplace by
	class Hello extends JPanel {
		
		JLabel hi;

		public Hello()
		{
			
			hi = new JLabel("Hello World");
			add(hi);
		}



Also get rid of the resize() method it is deprecated
any way it will be ignored, the panel will be automatically resized by the CardLayout manager

Happy coding
Was This Post Helpful? 2
  • +
  • -

#3 nashbender  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 21-April 11

Re: applet using CardLayout problem

Posted 25 June 2011 - 07:19 AM

okay thanks pbl!
Was This Post Helpful? 0
  • +
  • -

#4 nashbender  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 21-April 11

Re: applet using CardLayout problem

Posted 26 June 2011 - 06:29 PM

hmm..okay that problem is solved. but now can anyone tell me how to add a login page before the ButtonView page (the one with the CardLayout manager). i have a login page already (an applet) and i need to know how to link to the ButtonView page when the login button is pressed.

basically i want to know: can a CardLayout button span multiple panels/pages?

many thanks!
Was This Post Helpful? 0
  • +
  • -

#5 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10385
  • View blog
  • Posts: 38,434
  • Joined: 27-December 08

Re: applet using CardLayout problem

Posted 26 June 2011 - 06:52 PM

Sure. Just set your LoginPanel class as the initial Component on the JApplet. Then when the information is correct and submitted, switch the Containers being displayed using the CardLayout.
Was This Post Helpful? 2
  • +
  • -

#6 nashbender  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 21-April 11

Re: applet using CardLayout problem

Posted 27 June 2011 - 12:12 AM

thanks! i tried that..but one thing i don't understand:

the login panel is in a separate class, and i don't know how to switch cards when i clicked the login button. what should i write in the actionPerformed? thanks :)
Was This Post Helpful? 0
  • +
  • -

#7 pbl  Icon User is offline

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

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

Re: applet using CardLayout problem

Posted 27 June 2011 - 05:07 PM

Your class ButtonView is an ActionListener, pass it as parameter to the constructor of your LoginPanel (add a constructor if required) or create a JButton, set your ButtonView as the ActionListenet (and pass it as paremeter to your LoginPanel) that can set it's text, appearance and location. Or have the ActionListener of LoginPanel to create your ButtonView.

There are dozen of possibilities.
Was This Post Helpful? 1
  • +
  • -

#8 nashbender  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 21-April 11

Re: applet using CardLayout problem

Posted 28 June 2011 - 08:32 AM

View Postpbl, on 27 June 2011 - 05:07 PM, said:

Your class ButtonView is an ActionListener, pass it as parameter to the constructor of your LoginPanel (add a constructor if required) or create a JButton, set your ButtonView as the ActionListenet (and pass it as paremeter to your LoginPanel) that can set it's text, appearance and location. Or have the ActionListener of LoginPanel to create your ButtonView.

There are dozen of possibilities.



dear pbl,
i'm afraid i'm still unclear..can you please give me some example codes? if you don't mind..
i'm the kinda person who needs to look at examples to get the idea :)
thanks so much for your help.
Was This Post Helpful? 0
  • +
  • -

#9 pbl  Icon User is offline

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

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

Re: applet using CardLayout problem

Posted 28 June 2011 - 06:14 PM

Post your LoginPanel class
Was This Post Helpful? 1
  • +
  • -

#10 nashbender  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 21-April 11

Re: applet using CardLayout problem

Posted 28 June 2011 - 06:24 PM

this is my Login panel code:

//username : nasya , password : nasya

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;

public class Login extends JPanel {
	public static final String text = "<html><center><b><font size=+3>Central</font></b> <br><b><font size=+3>Manager</font></b></center> </html>";

	JPanel jPanel1 = new JPanel();
	BorderLayout borderLayout1 = new BorderLayout();
	JLabel jLabel1 = new JLabel();
	JPanel jPanel2 = new JPanel();
	GridBagLayout gridBagLayout1 = new GridBagLayout();
	JLabel jLabel2 = new JLabel();
	JLabel jLabel3 = new JLabel();
	JTextField loginTextField = new JTextField(20);
	JPasswordField passwordTextField = new JPasswordField(20);
	JPanel jPanel3 = new JPanel();
	JButton exitButton = new JButton();
	JButton enterButton = new JButton();
	FlowLayout flowLayout1 = new FlowLayout();
	ButtonView button;
	private static String tableName = "users";
	private static Connection conn = null;
	private static Statement stmt = null;
	
	
	private void login(ActionEvent e) {
		try
		{
			Class.forName("org.postgresql.Driver"); 
			//gets a connection
			conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test","postgres","870127");
			stmt = conn.createStatement();
			String login = loginTextField.getText();
			String pass = new String(passwordTextField.getPassword());
			ResultSet results = stmt.executeQuery("select username, password from " + tableName +" where username ='"+login+"'");
			String username = "";
			String password = "";
			
			while(results.next())
			{
				username = results.getString("username");
				password = results.getString("password");
			}
				//validate login and password here. validity will be done by sending login/password to the server
				if (login.equals(username) && pass.equals(password)) {
					System.out.println("login successful");
					button = new ButtonView();
					button.ourLayout.show(button.cardPanel, button.MENU);
				} 	
				else {
					JOptionPane.showMessageDialog(this,"Incorrect login or password","Error",JOptionPane.ERROR_MESSAGE);
					loginTextField.setText("");
					passwordTextField.setText("");
					loginTextField.requestFocusInWindow();
				}
				
			
			results.close();
			stmt.close();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
		
	private void exit(ActionEvent e) {
		setVisible(false);
	}


	public Login()
	{
		resize(500,200);
		//getContentPane().setLocation(400,400);
		//getContentPane().setSize(500, 500);
		setLayout(borderLayout1);
		jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
		jLabel1.setText(text);
		jPanel2.setLayout(gridBagLayout1);
		jLabel2.setText("Password:");
		jLabel3.setText("Login:");
		exitButton.setText("Exit");
		exitButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(ActionEvent e) {
				exit(e);
			}
		});
		
		enterButton.setText("Enter");
		enterButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(ActionEvent e) {
				login(e);
			}
		});
		
		jPanel3.setLayout(flowLayout1);
		flowLayout1.setAlignment(FlowLayout.RIGHT);
		this.add(jPanel1, BorderLayout.CENTER);
		jPanel1.add(jLabel1, BorderLayout.NORTH);
		jPanel1.add(jPanel2, BorderLayout.CENTER);
		jPanel2.add(loginTextField, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0
				,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 11, 0, 0), 0, 0));
		jPanel2.add(jLabel2, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
				,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(11, 0, 0, 0), 0, 0));
		jPanel2.add(passwordTextField, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
				,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(11, 11, 0, 0), 0, 0));
		jPanel2.add(jLabel3, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
				,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
		jPanel1.add(jPanel3, BorderLayout.SOUTH);
		jPanel3.add(enterButton, null);
		jPanel3.add(exitButton, null);
	}
}
 


Was This Post Helpful? 0
  • +
  • -

#11 pbl  Icon User is offline

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

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

Re: applet using CardLayout problem

Posted 28 June 2011 - 08:21 PM

Cheeez there are people who like to complicate their life :)
This could be done if half the number of lines of code... anyhow

In ButtonView:
- rename your init() method myInit()
- write a new init() method that display a new Login() panel
- to the constructor of Login() pass your applet

	public void init() {
		getContentPane().add(new Login(this));
	}
	
	public void myInit()
	{
			//getContentPane().add(jPanel1);
		getContentPane().getPreferredSize();
		getContentPane().setVisible(true);
		cardPanel = new JPanel();
		ourLayout = new CardLayout();



in your Login have an instance variable to save your ButtonView
modify the constructor to receive the ButtonView as parameter
in your method that use to create the ButtonView just call its myInit() method

	FlowLayout flowLayout1 = new FlowLayout();
	
	ButtonView buttonView;
	
	private static String tableName = "users";

....

				if (login.equals(username) && pass.equals(password)) {
					System.out.println("login successful");
//					button = new ButtonView.myInit();
//					button.ourLayout.show(button.cardPanel, button.MENU);
					setVisible(false);
					buttonView.myInit();
				} 	
....

	public Login(ButtonView buttonView)
	{
		super(new BorderLayout());
		
		this.buttonView = buttonView;
		resize(500,200);



Ugly but it should work
Was This Post Helpful? 1
  • +
  • -

#12 nashbender  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 21-April 11

Re: applet using CardLayout problem

Posted 28 June 2011 - 09:18 PM

thank you so much...that was so helpful :)

i amended it but the ButtonView applet didn't wanna show up :(

my current code:
//username : nasya , password : nasya

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;

public class Login extends JPanel {
	public static final String text = "<html><center><b><font size=+3>Central</font></b> <br><b><font size=+3>Manager</font></b></center> </html>";

	 JPanel jPanel1 = new JPanel();
	BorderLayout borderLayout1 = new BorderLayout();
	JLabel jLabel1 = new JLabel();
	JPanel jPanel2 = new JPanel();
	GridBagLayout gridBagLayout1 = new GridBagLayout();
	JLabel jLabel2 = new JLabel();
	JLabel jLabel3 = new JLabel();
	JTextField loginTextField = new JTextField(20);
	JPasswordField passwordTextField = new JPasswordField(20);
	JPanel jPanel3 = new JPanel();
	JButton exitButton = new JButton();
	JButton enterButton = new JButton();
	FlowLayout flowLayout1 = new FlowLayout();
	ButtonView buttonView;
	private static String tableName = "users";
	private static Connection conn = null;
	private static Statement stmt = null;
	
	
	private void login(ActionEvent e) {
		try
		{
			Class.forName("org.postgresql.Driver"); 
			//gets a connection
			conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test","postgres","870127");
			stmt = conn.createStatement();
			String login = loginTextField.getText();
			String pass = new String(passwordTextField.getPassword());
			ResultSet results = stmt.executeQuery("select username, password from " + tableName +" where username ='"+login+"'");
			String username = "";
			String password = "";
			
			while(results.next())
			{
				username = results.getString("username");
				password = results.getString("password");
			}
				//validate login and password here. validity will be done by sending login/password to the server
				if (login.equals(username) && pass.equals(password)) {
					System.out.println("login successful");
					//button = new ButtonView();
					//button.ourLayout.show(button.cardPanel, button.MENU);
					setVisible(false);
					buttonView.myInit();
				} 	
				else {
					JOptionPane.showMessageDialog(this,"Incorrect login or password","Error",JOptionPane.ERROR_MESSAGE);
					loginTextField.setText("");
					passwordTextField.setText("");
					loginTextField.requestFocusInWindow();
				}
				
			
			results.close();
			stmt.close();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
		
	

	
	private void exit(ActionEvent e) {
		setVisible(false);
	}


	public Login(ButtonView buttonView)
	{
		super(new BorderLayout());
		this.buttonView = buttonView;
		resize(500,200);
		//getContentPane().setLocation(400,400);
		//getContentPane().setSize(500, 500);
		setLayout(borderLayout1);
		jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
		jLabel1.setText(text);
		jPanel2.setLayout(gridBagLayout1);
		jLabel2.setText("Password:");
		jLabel3.setText("Login:");
		exitButton.setText("Exit");
		exitButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(ActionEvent e) {
				exit(e);
			}
		});
		
		enterButton.setText("Enter");
		enterButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(ActionEvent e) {
				login(e);
			}
		});
		
		jPanel3.setLayout(flowLayout1);
		flowLayout1.setAlignment(FlowLayout.RIGHT);
		this.add(jPanel1, BorderLayout.CENTER);
		jPanel1.add(jLabel1, BorderLayout.NORTH);
		jPanel1.add(jPanel2, BorderLayout.CENTER);
		jPanel2.add(loginTextField, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0
				,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 11, 0, 0), 0, 0));
		jPanel2.add(jLabel2, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
				,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(11, 0, 0, 0), 0, 0));
		jPanel2.add(passwordTextField, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
				,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(11, 11, 0, 0), 0, 0));
		jPanel2.add(jLabel3, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0
				,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
		jPanel1.add(jPanel3, BorderLayout.SOUTH);
		jPanel3.add(enterButton, null);
		jPanel3.add(exitButton, null);
	}
}
 



ButtonView:

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JPanel;

public class ButtonView extends JApplet implements ActionListener
	{
	final static String LOGIN = "Login Page";
	final static String MENU = "Main Menu";
	final static String FILE = "View FileSystem";
	final static String EMP = "Employee Details";
	final static String HELLO = "Hello, Hi";
	
	//GridLayout gridLayout1 = new GridLayout(2,2);
	BorderLayout borderLayout1 = new BorderLayout();
	//JScrollPane jScrollPane1 = new JScrollPane();
	CardLayout ourLayout;
	JPanel cardPanel;
	JPanel card1;
	Login card0;
	JButton file;
	JButton emp;
	JButton hello;
	
	public void init()
	{
		getContentPane().add(new Login(this));
	}
	
	
	public void actionPerformed(ActionEvent event)
		{
		if (event.getSource() == file)
		{
			ourLayout.show(cardPanel, FILE);
		}
		else if (event.getSource() == emp)
		{
			ourLayout.show(cardPanel, EMP);
		}
		
		else 
		{
			ourLayout.show(cardPanel, HELLO);
		}
		
		}
		
	public void myInit()
	{
			//getContentPane().add(jPanel1);
		getContentPane().getPreferredSize();
		getContentPane().setVisible(true);
		cardPanel = new JPanel();
		ourLayout = new CardLayout();
		cardPanel.setLayout(ourLayout);
		
		
		card1 = new JPanel();
		file = new JButton(FILE);
		file.setActionCommand(FILE);
		file.addActionListener(this);
		card1.add(file);

		emp = new JButton(EMP);
		emp.setActionCommand(EMP);
		emp.addActionListener(this);
		card1.add(emp);
		
		hello = new JButton(HELLO);
		hello.setActionCommand(HELLO);
		hello.addActionListener(this);
		card1.add(hello);
		
		//Login card0 = new Login(this);
		FileExplorer card2 = new FileExplorer();
		Employee card3 = new Employee();
		Hello card4 = new Hello();
		
		//cardPanel.add(card0, LOGIN);
		cardPanel.add(card1, MENU);
		cardPanel.add(card2, FILE);
		cardPanel.add(card3, EMP);
		cardPanel.add(card4, HELLO);

		add(cardPanel, BorderLayout.CENTER);
	}


		}

Was This Post Helpful? 0
  • +
  • -

#13 pbl  Icon User is offline

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

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

Re: applet using CardLayout problem

Posted 28 June 2011 - 09:43 PM

you are mixing getContentPane() and simple add

Dogstopper can contredict me with reasons he can explain (he is the specialist on that subject, but if you are using
add(cardPanel, BorderLayout.CENTER);
to your Applet, your Applet ContentPane() does not have a BorderLayout as default but a FlowLayout

theorically you should use getContentPane().add(cardPanel);
or set your Applet Layout to BorderLayout and ignore all calls to getContentPane()

Or you use the pre JRE 1.5 syntax that always acccess the contentPane()
or you go with JRE 1.5 and higher and completly ignore its existence

That might be a problem to set background color, but there are always alternatives :)

also not a good idea to setSize() to a panel in an Applet, applet size are determined by the .html page not the Java code

The whole idea is that the concept is there with your legacy code...
I have been paid big $ for years to do refactoring, your code is a really good example :)
No offense
Was This Post Helpful? 1
  • +
  • -

#14 nashbender  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 21-April 11

Re: applet using CardLayout problem

Posted 28 June 2011 - 09:51 PM

View Postpbl, on 28 June 2011 - 09:43 PM, said:

you are mixing getContentPane() and simple add

Dogstopper can contredict me with reasons he can explain (he is the specialist on that subject, but if you are using
add(cardPanel, BorderLayout.CENTER);
to your Applet, your Applet ContentPane() does not have a BorderLayout as default but a FlowLayout

theorically you should use getContentPane().add(cardPanel);
or set your Applet Layout to BorderLayout and ignore all calls to getContentPane()

Or you use the pre JRE 1.5 syntax that always acccess the contentPane()
or you go with JRE 1.5 and higher and completly ignore its existence

That might be a problem to set background color, but there are always alternatives :)

also not a good idea to setSize() to a panel in an Applet, applet size are determined by the .html page not the Java code

The whole idea is that the concept is there with your legacy code...
I have been paid big $ for years to do refactoring, your code is a really good example :)
No offense


haha okay thanks for your advice..and sorry if i bothered you...i'm clearly a beginner, there's so much i gotta learn. if i have big $ i would hire you lol :)

i'm off to correct my code, and if i bump into any problem, i'm afraid i have to trouble you again :)
Was This Post Helpful? 0
  • +
  • -

#15 nashbender  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 43
  • Joined: 21-April 11

Re: applet using CardLayout problem

Posted 29 June 2011 - 02:22 AM

good morning, me again.

i did the following to access the main menu button panel from loginPanel:

if (login.equals(username) && pass.equals(password)) {
System.out.println("login successful");
setVisible(false);
buttonView.myInit();
buttonView.ourLayout.show(buttonView.cardPanel, buttonView.MENU); //addition
} 	


i executed it from eclipse IDE with no problem, and it displays the buttons when i log in successfully.

but then i compiled the codes into a jar file and run it from html page, the buttons panel did not show up.
and then i tried running the jar file from terminal/cmd and it gives me the error below:


Exception in thread "AWT-EventQueue-0" java.lang.ClassFormatError: Incompatible magic value 1347093252 in class file AbstractTreeModel
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(Unknown Source)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$000(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at FileExplorer.<init>(FileExplorer.java:10)
        at ButtonView.myInit(ButtonView.java:77)
        at Login.login(Login.java:59)
        at Login.access$100(Login.java:12)
        at Login$2.actionPerformed(Login.java:106)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$000(Unknown Source)
        at java.awt.EventQueue$1.run(Unknown Source)
        at java.awt.EventQueue$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue$2.run(Unknown Source)
        at java.awt.EventQueue$2.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)



what do you think is the problem? this is a new one for me. thanks for your help. :flowers:
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2