Student Survey GUI

Page 1 of 1

11 Replies - 990 Views - Last Post: 04 August 2008 - 09:23 PM Rate Topic: -----

#1 musizian   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 01-August 08

Student Survey GUI

Post icon  Posted 01 August 2008 - 11:56 AM

Below is the code that I have worked on for Registration class..

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class Registration extends JFrame
{
	JLabel jlblName1, jlblName2, jlblNRIC, jlblStudentID, jlblStaffID, jlblDepartment1, jlblDepartment2, jlblUsername1, jlblUsername2, jlblPassword1, jlblPassword11, jlblPassword2, jlblImg;
	JPasswordField jtfPassword1, jtfPassword11, jtfPassword2;
	JTextField jtfname1, jtfname2, jtfNRIC, jtfID1, jtfID2, jtfUsername1, jtfUsername2;
	JButton jbtnUpload, jbtnRegister1, jbtnRegister2, jbtnCheck;
	JComboBox jcbDepartment1, jcbDepartment2;
	JTabbedPane jtpPanel;
	JPanel jp1, jp2;
	
	public Registration()
	{
		setSize(300,550);
		setTitle("Registration");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		jlblName1 = new JLabel("Name:");
		jlblName2 = new JLabel("Name:");
		jlblNRIC = new JLabel("NRIC:");
		jlblStudentID = new JLabel("Student ID:");
		jlblStaffID = new JLabel("Staff ID:");
		jlblDepartment1 = new JLabel("Department:");
		jlblDepartment2 = new JLabel("Department:");
		jlblUsername1 = new JLabel("username:");
		jlblUsername2 = new JLabel("username:");
		jlblPassword1 = new JLabel("password:");
		jlblPassword11 = new JLabel("Retype:");
		jlblPassword2 = new JLabel("password:");
		
		ImageIcon img = new ImageIcon("DogShirt.gif");
		jlblImg = new JLabel(img);
		
		jtfname1 = new JTextField(20);
		jtfname2 = new JTextField(20);
		jtfNRIC = new JTextField(20);
		jtfID1 = new JTextField(15);
		jtfID2 = new JTextField(15);
		jtfUsername1 = new JTextField(8);
		jtfUsername2 = new JTextField(8);
		jtfPassword1 = new JPasswordField(8);jtfPassword1.setEchoChar('*');
		jtfPassword11 = new JPasswordField(8);jtfPassword11.setEchoChar('*');
		jtfPassword2 = new JPasswordField(8);jtfPassword2.setEchoChar('*');
		
		jcbDepartment1 = new JComboBox();
		jcbDepartment1.addItem("Engineering");
		jcbDepartment1.addItem("Business");
		jcbDepartment1.addItem("Applied Sciences");
		
		jcbDepartment2 = new JComboBox();
		jcbDepartment2.addItem("Engineering");
		jcbDepartment2.addItem("Business");
		jcbDepartment2.addItem("Applied Sciences");
		
		jbtnUpload = new JButton("Upload Picture");
		jbtnRegister1 = new JButton("Register");
		jbtnRegister2 = new JButton("Register");
		jbtnCheck = new JButton("Confirm");
		
		jbtnUpload.addActionListener(new UploadListener());
		
		JPanel jpFlow = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow.add(jlblName1);jpFlow.add(jtfname1);
		JPanel jpFlow1 = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow1.add(jlblNRIC);jpFlow1.add(jtfNRIC);
		JPanel jpFlow2 = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow2.add(jlblStudentID);jpFlow2.add(jtfID1);
		JPanel jpFlow3 = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow3.add(jlblDepartment1);jpFlow3.add(jcbDepartment1);
		JPanel jpFlow4 = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow4.add(jlblUsername1);jpFlow4.add(jtfUsername1);
		JPanel jpFlow5 = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow5.add(jlblPassword1);jpFlow5.add(jtfPassword1);
		JPanel jpFlow6 = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow6.add(jlblPassword11);jpFlow6.add(jtfPassword11);jpFlow6.add(jbtnCheck);
		
		JPanel jpGrid = new JPanel();
		jpGrid.setLayout(new GridLayout(7,1,0,20));
		jpGrid.add(jpFlow);
		jpGrid.add(jpFlow1);
		jpGrid.add(jpFlow2);
		jpGrid.add(jpFlow3);
		jpGrid.add(jpFlow4);
		jpGrid.add(jpFlow5);
		jpGrid.add(jpFlow6);
		JPanel jpFlow7 = new JPanel(new FlowLayout());
		jpFlow7.add(jlblImg);
		JPanel jpFlow8 = new JPanel(new FlowLayout());
		jpFlow8.add(jbtnUpload);
		jpFlow8.add(jbtnRegister1);
		jp1 = new JPanel(new BorderLayout());
		jp1.add(jpGrid, "North");
		jp1.add(jpFlow7, "Center");
		jp1.add(jpFlow8, "South");
		
		jp2 = new JPanel();
		jp2.setLayout(new FlowLayout(FlowLayout.LEFT,10,15));
		jp2.add(jlblName2);
		jp2.add(jtfname2);
		jp2.add(jlblStaffID);
		jp2.add(jtfID2);
		jp2.add(jlblDepartment2);
		jp2.add(jcbDepartment2);
		jp2.add(jlblUsername2);
		jp2.add(jtfUsername2);
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(jlblPassword2);
		jp2.add(jtfPassword2);
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(jbtnRegister2);
		
		jtpPanel = new JTabbedPane();
		jtpPanel.addTab("Student", null, jp1, "");
		jtpPanel.addTab("Staff", null, jp2, "");
		
		add(jtpPanel);
			
		setVisible(true);
	}
	
	class UploadListener implements ActionListener
	{
		public void actionPerformed(ActionEvent evt)
		{
			FileChooser fc = new FileChooser();
			fc.FileChooser();
		}
	}
	
	public static void main(String[] args)
	{
		Registration r = new Registration();
	}
		
}		 


And here is another class of FileChooser

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.io.*;
import javax.swing.filechooser.*;

public class FileChooser extends JFrame implements ActionListener
{
	JLabel file;
	JButton browse, cancel, ok;
	JTextField field3;	
	JPanel jpBrowser1, jpBrowser2;
	JFileChooser fc;
	
	public void FileChooser() {
		setTitle("Upload Picture");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setLayout(new BorderLayout());
		setSize(400,110);
		
		fc = new JFileChooser();
		
		file = new JLabel("File");
		
		browse = new JButton("Browse");
		cancel = new JButton("Cancel");
		ok = new JButton("Ok");
		
		field3 = new JTextField(20);
		
		browse.addActionListener(this);
		
		jpBrowser1 = new JPanel();
		jpBrowser1.setLayout(new FlowLayout());
		
		jpBrowser2 = new JPanel();
		jpBrowser2.setLayout(new FlowLayout());
		
		jpBrowser1.add(file);
		jpBrowser1.add(field3);
		jpBrowser1.add(browse);
		
		jpBrowser2.add(cancel);
		jpBrowser2.add(ok);
		
		add(jpBrowser1, "North");
		add(jpBrowser2, "East");
		
		setVisible(true);
		
	}
	
		public void actionPerformed(ActionEvent e)
		{	
			if (e.getSource() == browse) {
				int returnVal = fc.showOpenDialog(FileChooser.this);

				if (returnVal == JFileChooser.APPROVE_OPTION) {
					File file = fc.getSelectedFile();
					field3.setText(file.getName());
				}
			}
		}

}


So my question is when you run the program, you could see that the gap between 'Name' and 'NRIC', 'NRIC' and 'Student ID', and so on, is so big, how can i actually decrease the gap?
I've tried to use the 'setLayout(new GridLayout(7,1,0,20)'
hoping that int 20 will adjust the gap. But it was to no avail.

Secondly, when I click on 'upload' button, a 'upload picture' window for us to choose a file later on will pop up.
My question here is when user clicks on the 'cancel' button, what method can I implement to close the 'upload picture' window and return to previous one?

Thirdly, when user is touching on 'upload picture' window, user can actually navigate around the 'registration' window.
How can I prevent such condition? Maybe like, freezing the 'registration' window until the 'upload picture' has been closed.

Thx for helping.

Is This A Good Question/Topic? 0
  • +

Replies To: Student Survey GUI

#2 pbl   User is offline

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

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Student Survey GUI

Posted 01 August 2008 - 09:32 PM

View Postmusizian, on 1 Aug, 2008 - 11:56 AM, said:

So my question is when you run the program, you could see that the gap between 'Name' and 'NRIC', 'NRIC' and 'Student ID', and so on, is so big, how can i actually decrease the gap?
I've tried to use the 'setLayout(new GridLayout(7,1,0,20)'
hoping that int 20 will adjust the gap. But it was to no avail.

That is what GridLayout are for
If you increase/decrease the size of the frame all the components will reajust their size accordingly and they will have all the same size
You might pad with emply JLabel

View Postmusizian, on 1 Aug, 2008 - 11:56 AM, said:

Secondly, when I click on 'upload' button, a 'upload picture' window for us to choose a file later on will pop up.
My question here is when user clicks on the 'cancel' button, what method can I implement to close the 'upload picture' window and return to previous one?

Make you FileChoser fc variable an instance variable (a variable of the class so anybody can see it) do not declare it in the ActionListener. In the ActionListenr just do:

fc = new FileChooser();

So now your other ActionListener can see it and do fc.dispose();

View Postmusizian, on 1 Aug, 2008 - 11:56 AM, said:

Thirdly, when user is touching on 'upload picture' window, user can actually navigate around the 'registration' window.
How can I prevent such condition? Maybe like, freezing the 'registration' window until the 'upload picture' has been closed.


uploadwindow.setFocusable(false);
Was This Post Helpful? 0
  • +
  • -

#3 musizian   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 01-August 08

Re: Student Survey GUI

Posted 01 August 2008 - 10:08 PM

I'm not clear on your explanation. Can you tell me where should I write the code for the fc.dispose() and uploadwindow.setFocusable(false).
THX..
Was This Post Helpful? 0
  • +
  • -

#4 pbl   User is offline

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

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Student Survey GUI

Posted 01 August 2008 - 10:13 PM

View Postmusizian, on 1 Aug, 2008 - 10:08 PM, said:

Can you tell me where should I write the code for the fc.dispose()

In the ActionListener of the "cancel" button

View Postmusizian, on 1 Aug, 2008 - 10:08 PM, said:

and uploadwindow.setFocusable

Just after creating the uploadwindow.
Was This Post Helpful? 0
  • +
  • -

#5 musizian   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 01-August 08

Re: Student Survey GUI

Posted 01 August 2008 - 11:01 PM

Is the place where I declared the variable correct?

public class Registration extends JFrame
{
	FileChooser fc
	JLabel jlblName1, jlblName2, jlblNRIC, jlblStudentID, jlblStaffID, jlblDepartment1, jlblDepartment2, jlblUsername1, jlblUsername2, jlblPassword1, jlblPassword11, jlblPassword2, jlblImg;
	JPasswordField jtfPassword1, jtfPassword11, jtfPassword2;
	JTextField jtfname1, jtfname2, jtfNRIC, jtfID1, jtfID2, jtfUsername1, jtfUsername2;
	JButton jbtnUpload, jbtnRegister1, jbtnRegister2, jbtnCheck;
	JComboBox jcbDepartment1, jcbDepartment2;
	JTabbedPane jtpPanel;
	JPanel jp1, jp2;




Then for the fc.dispose();

class CancelHandler implements ActionListener
		{
			public void actionPerformed(ActionEvent e)
			{
				fc.dispose();
			}
		}



I don't need to declare FileChooser fc inside the FileChooser class anymore rite? Or do I?

setFocusable(false);

public FileChooser() {
		setTitle("Upload Picture");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setLayout(new BorderLayout());
		setSize(400,110);
		.
		.
		.
		setVisible(true);
		setFocusable(false);
	}


I did all this, but it doesnt seem to work :(
Was This Post Helpful? 0
  • +
  • -

#6 pbl   User is offline

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

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Student Survey GUI

Posted 02 August 2008 - 10:28 AM

Is the place where I declared the variable correct?

public class Registration extends JFrame
{
	FileChooser fc
	JLabel jlblName1, jlblName2, jlblNRIC, jlblStudentID, jlblStaffID, jlblDepartment1, jlblDepartment2, jlblUsername1, jlblUsername2, jlblPassword1, jlblPassword11, jlblPassword2, jlblImg;


Yes this correct

Then for the fc.dispose();

class CancelHandler implements ActionListener
		{
			public void actionPerformed(ActionEvent e)
			{
				fc.dispose();
			}
		}



This is correct again

I don't need to declare FileChooser fc inside the FileChooser class anymore rite? Or do I?

Yes you still need the JFileChooser in your own FileChooser class

setFocusable(false);

public FileChooser() {
		setTitle("Upload Picture");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setLayout(new BorderLayout());
		setSize(400,110);
		.
		.
		.
		setVisible(true);
		setFocusable(false);	<-------  NO
	}


NO !!! You are making your FileChooser not focusable ... it is its father (Registration) that you do not want to be focusable
You will have to pass this frame to your Listener wehen you create it so It will be able to make it not focusable

[code]

jbtnUpload.addActionListener(new UploadListener(this)); // <--- tell who I am
...

class UploadListener implements ActionListener
{
JFrame frameToDisable;
// Constructor
UploadListener(Registration frame)
{
frameToDisable = frame; // save who is my father
}

public void actionPerformed(ActionEvent evt)
{
fc = new FileChooser();
frameToDisable.setFocusable(false);
}
}

[/quote]
Was This Post Helpful? 0
  • +
  • -

#7 musizian   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 01-August 08

Re: Student Survey GUI

Posted 02 August 2008 - 11:37 PM

It didnt work again...
the fc.dispose() gave a nullpointerexception error when i click the 'cancel' button.

And I tried to implement ur code of the UploadListener, it could compile, but Registration frame is still focusable.

Could you please write the code in my source code and paste it here.
I know this seems too much but please.. :(
Was This Post Helpful? 0
  • +
  • -

#8 pbl   User is offline

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

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Student Survey GUI

Posted 03 August 2008 - 01:22 PM

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class Registration extends JFrame
{
	JLabel jlblName1, jlblName2, jlblNRIC, jlblStudentID, jlblStaffID, jlblDepartment1, jlblDepartment2, jlblUsername1, jlblUsername2, jlblPassword1, jlblPassword11, jlblPassword2, jlblImg;
	JPasswordField jtfPassword1, jtfPassword11, jtfPassword2;
	JTextField jtfname1, jtfname2, jtfNRIC, jtfID1, jtfID2, jtfUsername1, jtfUsername2;
	JButton jbtnUpload, jbtnRegister1, jbtnRegister2, jbtnCheck;
	JComboBox jcbDepartment1, jcbDepartment2;
	JTabbedPane jtpPanel;
	JPanel jp1, jp2;
	FileChooser fc;
	
	public Registration()
	{
		setSize(300,550);
		setTitle("Registration");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		jlblName1 = new JLabel("Name:");
		jlblName2 = new JLabel("Name:");
		jlblNRIC = new JLabel("NRIC:");
		jlblStudentID = new JLabel("Student ID:");
		jlblStaffID = new JLabel("Staff ID:");
		jlblDepartment1 = new JLabel("Department:");
		jlblDepartment2 = new JLabel("Department:");
		jlblUsername1 = new JLabel("username:");
		jlblUsername2 = new JLabel("username:");
		jlblPassword1 = new JLabel("password:");
		jlblPassword11 = new JLabel("Retype:");
		jlblPassword2 = new JLabel("password:");
		
		ImageIcon img = new ImageIcon("DogShirt.gif");
		jlblImg = new JLabel(img);
		
		jtfname1 = new JTextField(20);
		jtfname2 = new JTextField(20);
		jtfNRIC = new JTextField(20);
		jtfID1 = new JTextField(15);
		jtfID2 = new JTextField(15);
		jtfUsername1 = new JTextField(8);
		jtfUsername2 = new JTextField(8);
		jtfPassword1 = new JPasswordField(8);jtfPassword1.setEchoChar('*');
		jtfPassword11 = new JPasswordField(8);jtfPassword11.setEchoChar('*');
		jtfPassword2 = new JPasswordField(8);jtfPassword2.setEchoChar('*');
		
		jcbDepartment1 = new JComboBox();
		jcbDepartment1.addItem("Engineering");
		jcbDepartment1.addItem("Business");
		jcbDepartment1.addItem("Applied Sciences");
		
		jcbDepartment2 = new JComboBox();
		jcbDepartment2.addItem("Engineering");
		jcbDepartment2.addItem("Business");
		jcbDepartment2.addItem("Applied Sciences");
		
		jbtnUpload = new JButton("Upload Picture");
		jbtnRegister1 = new JButton("Register");
		jbtnRegister2 = new JButton("Register");
		jbtnCheck = new JButton("Confirm");
		
		jbtnUpload.addActionListener(new UploadListener(this));
		
		JPanel jpFlow = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow.add(jlblName1);jpFlow.add(jtfname1);
		JPanel jpFlow1 = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow1.add(jlblNRIC);jpFlow1.add(jtfNRIC);
		JPanel jpFlow2 = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow2.add(jlblStudentID);jpFlow2.add(jtfID1);
		JPanel jpFlow3 = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow3.add(jlblDepartment1);jpFlow3.add(jcbDepartment1);
		JPanel jpFlow4 = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow4.add(jlblUsername1);jpFlow4.add(jtfUsername1);
		JPanel jpFlow5 = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow5.add(jlblPassword1);jpFlow5.add(jtfPassword1);
		JPanel jpFlow6 = new JPanel(new FlowLayout(FlowLayout.LEFT));jpFlow6.add(jlblPassword11);jpFlow6.add(jtfPassword11);jpFlow6.add(jbtnCheck);
		
		JPanel jpGrid = new JPanel();
		jpGrid.setLayout(new GridLayout(7,1,0,20));
		jpGrid.add(jpFlow);
		jpGrid.add(jpFlow1);
		jpGrid.add(jpFlow2);
		jpGrid.add(jpFlow3);
		jpGrid.add(jpFlow4);
		jpGrid.add(jpFlow5);
		jpGrid.add(jpFlow6);
		JPanel jpFlow7 = new JPanel(new FlowLayout());
		jpFlow7.add(jlblImg);
		JPanel jpFlow8 = new JPanel(new FlowLayout());
		jpFlow8.add(jbtnUpload);
		jpFlow8.add(jbtnRegister1);
		jp1 = new JPanel(new BorderLayout());
		jp1.add(jpGrid, "North");
		jp1.add(jpFlow7, "Center");
		jp1.add(jpFlow8, "South");
		
		jp2 = new JPanel();
		jp2.setLayout(new FlowLayout(FlowLayout.LEFT,10,15));
		jp2.add(jlblName2);
		jp2.add(jtfname2);
		jp2.add(jlblStaffID);
		jp2.add(jtfID2);
		jp2.add(jlblDepartment2);
		jp2.add(jcbDepartment2);
		jp2.add(jlblUsername2);
		jp2.add(jtfUsername2);
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(jlblPassword2);
		jp2.add(jtfPassword2);
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(new JLabel());jp2.add(new JLabel());jp2.add(new JLabel());
		jp2.add(jbtnRegister2);
		
		jtpPanel = new JTabbedPane();
		jtpPanel.addTab("Student", null, jp1, "");
		jtpPanel.addTab("Staff", null, jp2, "");
		
		add(jtpPanel);
			
		setVisible(true);
	}
	
	class UploadListener implements ActionListener
	{
		JFrame frame;
		
		UploadListener(JFrame frame) {
			this.frame = frame;
		}
		public void actionPerformed(ActionEvent evt)
		{
			fc = new FileChooser();
			frame.setFocusable(false);
		}
	}
	
	public static void main(String[] args)
	{
		Registration r = new Registration();
	}
		
}		 



import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.io.*;
import javax.swing.filechooser.*;

public class FileChooser extends JFrame implements ActionListener, WindowListener
{
	JLabel file;
	JButton browse, cancel, ok;
	JTextField field3;	
	JPanel jpBrowser1, jpBrowser2;
	JFileChooser fc;
	JFrame father;
	
	public void FileChooser(JFrame frame) {
		setTitle("Upload Picture");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setLayout(new BorderLayout());
		setSize(400,110);
		father = frame;
		fc = new JFileChooser();
		
		file = new JLabel("File");
		
		browse = new JButton("Browse");
		cancel = new JButton("Cancel");
		ok = new JButton("Ok");
		
		field3 = new JTextField(20);
		
		browse.addActionListener(this);
		
		jpBrowser1 = new JPanel();
		jpBrowser1.setLayout(new FlowLayout());
		
		jpBrowser2 = new JPanel();
		jpBrowser2.setLayout(new FlowLayout());
		
		jpBrowser1.add(file);
		jpBrowser1.add(field3);
		jpBrowser1.add(browse);
		
		jpBrowser2.add(cancel);
		jpBrowser2.add(ok);
		
		add(jpBrowser1, "North");
		add(jpBrowser2, "East");
		
		setVisible(true);
		
	}
	
		public void actionPerformed(ActionEvent e)
		{	
			if (e.getSource() == browse) {
				int returnVal = fc.showOpenDialog(FileChooser.this);

				if (returnVal == JFileChooser.APPROVE_OPTION) {
					File file = fc.getSelectedFile();
					field3.setText(file.getName());
				}
			}
		}

		public void windowActivated(WindowEvent arg0) {
		}
		public void windowClosed(WindowEvent arg0) {
			father.setFocusable(true);	
		}
		public void windowClosing(WindowEvent arg0) {
			father.setFocusable(true);	
		}
		public void windowDeactivated(WindowEvent arg0) {
		}
		public void windowDeiconified(WindowEvent arg0) {
		}
		public void windowIconified(WindowEvent arg0) {
		}
		public void windowOpened(WindowEvent arg0) {
		}

}


Was This Post Helpful? 1
  • +
  • -

#9 musizian   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 01-August 08

Re: Student Survey GUI

Posted 04 August 2008 - 03:23 AM

Sir..

It fails to open the FileChooser window.
Was This Post Helpful? 0
  • +
  • -

#10 pbl   User is offline

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

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Student Survey GUI

Posted 04 August 2008 - 04:18 AM

View Postmusizian, on 4 Aug, 2008 - 03:23 AM, said:

Sir..

It fails to open the FileChooser window.

Surely not my changes that make that
If it does not open now, it didn't open before
Was This Post Helpful? 0
  • +
  • -

#11 musizian   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 22
  • Joined: 01-August 08

Re: Student Survey GUI

Posted 04 August 2008 - 10:18 AM

:D i'll try to fix that

anyway,
BIG THX for ur help sir! I do much appreciate it :)
Was This Post Helpful? 0
  • +
  • -

#12 pbl   User is offline

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

Reputation: 8381
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Student Survey GUI

Posted 04 August 2008 - 09:23 PM

View Postmusizian, on 4 Aug, 2008 - 10:18 AM, said:

:D i'll try to fix that

anyway,
BIG THX for ur help sir! I do much appreciate it :)

OK happy programming... I'll close the topic
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1