GUI
whats wrong with my code failed to compile
// Department interface
//import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class EmployeeInformation extends JFrame implements ActionListener
{
//Connection con= null;
JDesktoppane desk;
JInternalFrame iframe;
JPanel panel1,panel2,panel3,panel4,panel5,panel6,panel7;
JTextField txt1,txt2,txt3,txt4,txt5,txt6,txt7,txt8,txt9,txt10;
JComboBox CB;
JTextArea txtA;
JButton btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10;
JLabel label1, label2, label3,label4,label5,label6,label7,label8,label9,label10,label11,label12,label13,label14,label15,label16,label17,label18,label19,label20,label21,label22,label23,label24,label25,label26,label27,label28,label29,label30;
//PreparedStatement pstmt=null;
//ResultSet rs;
public EmployeeInformation()
{
super("Nakasero Hospital [Employee Information]");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
setSize(250,400);
widgets();
// acquireConnection();
}
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new EmployeeInformation().setVisible(true);
}
});
}
public void widgets()
{
panel1= new JPanel();
panel1.setBorder(BorderFactory.createEtchedBorder(Color.PINK, Color.GRAY));
add(panel1,BorderLayout.WEST);
panel1.setBackground(Color.BLUE);
panel1.add(new JLabel label1("RECORD EXPLORER"));
add(label1);
panel1.add(new JLabel label2("OutPatients"));
add(label2);
panel1.add(new JLabel label3("InPatients"));
add(label3);
panel1.add(new JLabel label4("Appoitments"));
add(label4);
panel1.add(new JLabel label5("Payments"));
add(label5);
panel1.add(new JLabel label6("Search"));
add(label6);
getContentPane.add(panel1);
panel7=new JPanel();
btn10= new JButton("User Account Panel");
btn10.addActionListener(this);
panel7.setBorder(BorderFactory.createEtchedBorder(Color.PINK, Color.BLACK));
add(panel7,BorderLayout.WEST);
panel7.add(new JLabel label20("Change Password"));
add(label20);
panel7.add(new JLabel label21("Log Off/ Exit"));
add(label21);
getContentPane.add(panel7);
panel2= new JPanel();
panel1.setBackground(Color.BLUE);
panel1.setBorder(BorderFactory.createEtchedBorder(Color.BLACK));
add(panel2,BorderLayout.NORTH);
label1.setFont(new Font("Algerian Regular",Font.ITALIC+Font.BOLD,25));
add(label1);
getContentPane.add(panel2);
panel3= new JPanel();
setBackground(Color.WHITE);
setBorder(BorderFactory.createTitledBorder("Personal Details"));
add(panel3,BorderLayout.CENTER);
setLayout(new FlowLayout());
panel3.add(new JLabel label7("Employee ID"));
add(label7);
txt1=new JTextField(12);
txt1.setEditable(false);
add(txt1);
panel3.add(new JLabel label8("First Name"));
add(label8);
txt2=new JTextField(12);
txt2.setEditable(false);
add(txt2);
panel3.add(new JLabel label9("Last Name"));
add(label9);
txt3=new JTextField(12);
txt3.setEditable(false);
add(txt3);
panel3.add(new JLabel label10("Gender"));
add(label10);
txt4=new JTextField(12);
txt4.setEditable(false);
add(txt4);
String[] str={"Female","Male"};
CB=new JComboBox(str);
add(CB);
CB.addItemListener(this);
panel3.add(new JLabel label11("Date Of Birth"));
add(label11);
txt5=new JTextField(12);
txt5.setEditable(false);
add(txt5);
panel3.add(new JLabel label12("Address"));
add(label12);
txtA=new JTextArea(8.10);
txtA.setBackground(Color.PINK);
add(new JScrollPane(txtA),BorderLayout.CENTER);
panel3.add(new JLabel label13("Phone Number"));
add(label13);
txt6=new JTextField(12);
txt6.setEditable(false);
add(txt6);
panel3.add(new JLabel label14("License No"));
add(label14);
txt7=new JTextField(12);
txt7.setEditable(false);
add(txt7);
getContentPane.add(panel3);
panel4= new JPanel();
setBackground(Color.WHITE);
setBorder(BorderFactory.createTitledBorder("Employee Details"));
add(panel4,BorderLayout.EAST);
setLayout(new FlowLayout());
label15=new JLabel("Department Name");
add(label15);
txt8=new JTextField(12);
txt8.setEditable(false);
add(txt8);
label16=new JLabel("Specialisation");
add(label16);
txt9=new JTextField(12);
txt9.setEditable(false);
add(txt9);
label17=new JLabel("Service Charges");
add(label17);
txt10=new JTextField(12);
txt10.setEditable(false);
add(txt10);
label18=new JLabel("Salary");
add(label18);
txt11=new JTextField(12);
txt11.setEditable(false);
add(txt11);
getContentPane.add(panel4);
panel5=new JPanel();
panel5.setBorder(BorderFactory.createEtchedBorder(Color.PINK, Color.GRAY));
add(panel5,BorderLayout.EAST);
btn1= new JButton("FIRST");
btn1.setFont(new Font("Algerian Regular",Font.BOLD,25));
add(btn1);
btn1.addActionListener(this);
btn2= new JButton("PREVIOUS");
btn2.setFont(new Font("Algerian Regular",Font.BOLD,25));
add(btn2);
btn2.addActionListener(this);
btn3= new JButton("NEXT");
btn3.setFont(new Font("Algerian Regular",Font.BOLD,25));
add(btn3);
btn3.addActionListener(this);
btn4= new JButton("LAST");
btn4.setFont(new Font("Algerian Regular",Font.BOLD,25));
add(btn4);
btn4.addActionListener(this);
getContentPane.add(panel5);
panel6=new JPanel();
panel5.setBorder(BorderFactory.createEtchedBorder(Color.PINK, Color.BLACK));
add(panel6,BorderLayout.SOUTH);
btn5= new JButton("Add NEW");
btn5.setFont(new Font("Algerian Regular",Font.BOLD,25));
add(btn5);
btn5.addActionListener(this);
btn6= new JButton("SAVE");
btn6.setFont(new Font("Algerian Regular",Font.BOLD,25));
add(btn6);
btn6.addActionListener(this);
btn7= new JButton("UPDATE");
btn7.setFont(new Font("Algerian Regular",Font.BOLD,25));
add(btn7);
btn7.addActionListener(this);
btn8= new JButton("DELETE");
btn8.setFont(new Font("Algerian Regular",Font.BOLD,25));
add(btn8);
btn8.addActionListener(this);
btn9= new JButton("CLOSE");
btn9.setFont(new Font("Algerian Regular",Font.BOLD,25));
add(btn9);
btn9.addActionListener(this);
getContentPane.add(panel6);
}
//public void acquireConnection()
//{
//try
//{
// Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// con=DriverManager.getConnection("jdbc.odbc:Hullo");
//String x = "select * from Emp where name=?";
//pstmt.prepareStatement(x);
// }
//catch(ClassNotFoundException e1)
//{
//e1.printStackTrace();
//}
//catch(SQLException e2)
//{
//e2.printStackTrace();
// }
//}
//public void searchName(String name)
//{
//try
//{
//pstmt.setString(1,name);
//rs=pstmt.executeQuery();
//rs.next();
//bind();
//}
//catch(SQLException e3)
//{
//e3.printStackTrace();
//}
//}
// public void bind()
//{
// try
//{
// txt1.setText(rs.getString(1));
//txt2.setText(""+rs.getString(2));
//txt3.setText(""+rs.getString(3));
//txt4.setText(rs.getString(4));
//}
//catch(SQLException e4)
//{
//e4.printStackTrace();
//}
//}
public void actionPerformed(ActionEvent e)
//{
//if(e.getSource()==btn)
//{
//String name=txt5.getText();
//searchName(name);
///}
}
}
View Answers
September 24, 2010 at 11:39 AM
Hi Friend,
We have modified your code:
import java.sql.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.awt.*;
class EmployeeInformation extends JFrame implements ActionListener
{
//Connection con= null;
JDesktopPane desk;
JInternalFrame iframe;
JPanel panel1,panel2,panel3,panel4,panel5,panel6,panel7;
JTextField txt1,txt2,txt3,txt4,txt5,txt6,txt7,txt8,txt9,txt10,txt11;
JComboBox CB;
JTextArea txtA;
JButton btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10;
public EmployeeInformation()
{
super("Nakasero Hospital [Employee Information]");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
setSize(1072,768);
widgets();
// acquireConnection();
}
public static void main(String[] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new EmployeeInformation().setVisible(true);
}
});
}
public void widgets()
{
panel1= new JPanel();
panel1.setBorder(BorderFactory.createEtchedBorder(Color.PINK, Color.GRAY));
panel1.setBackground(Color.BLUE);
panel1.add(new JLabel("RECORD EXPLORER"));
panel1.add(new JLabel("OutPatients"));
panel1.add(new JLabel("InPatients"));
panel1.add(new JLabel("Appoitments"));
panel1.add(new JLabel("Payments"));
panel1.add(new JLabel("Search"));
add(panel1,BorderLayout.WEST);
panel7=new JPanel();
btn10= new JButton("User Account Panel");
btn10.addActionListener(this);
panel7.setBorder(BorderFactory.createEtchedBorder(Color.PINK, Color.BLACK));
panel7.add(new JLabel("Change Password"));
panel7.add(new JLabel("Log Off/ Exit"));
add(panel7,BorderLayout.WEST);
panel2= new JPanel();
panel2.setBackground(Color.BLUE);
Border b1=BorderFactory.createEtchedBorder(Color.BLACK,Color.WHITE);
panel2.setBorder(b1);
panel2.add(new JLabel());
panel2.setFont(new Font("Algerian Regular",Font.ITALIC+Font.BOLD,25));
add(panel2,BorderLayout.NORTH);
panel3= new JPanel();
setBackground(Color.WHITE);
Border b2=BorderFactory.createTitledBorder("Personal Details");
panel3.setBorder(b2);
add(panel3,BorderLayout.CENTER);
setLayout(new FlowLayout());
panel3.add(new JLabel("Employee ID"));
txt1=new JTextField(12);
txt1.setEditable(false);
panel3.add(txt1);
panel3.add(new JLabel("First Name"));
txt2=new JTextField(12);
txt2.setEditable(false);
panel3.add(txt2);
panel3.add(new JLabel("Last Name"));
txt3=new JTextField(12);
txt3.setEditable(false);
panel3.add(txt3);
panel3.add(new JLabel("Gender"));
txt4=new JTextField(12);
txt4.setEditable(false);
panel3.add(txt4);
String[] str={"Female","Male"};
CB=new JComboBox(str);
add(CB);
CB.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent ie) {
String s = (String)ie.getItem();
System.out.println(s);
}
});
September 24, 2010 at 11:40 AM
continue..
panel3.add(new JLabel("Date Of Birth"));
txt5=new JTextField(12);
txt5.setEditable(false);
panel3.add(txt5);
panel3.add(new JLabel("Address"));
txtA=new JTextArea(10,20);
txtA.setBackground(Color.PINK);
panel3.add(new JScrollPane(txtA),BorderLayout.CENTER);
panel3.add(new JLabel("Phone Number"));
txt6=new JTextField(12);
txt6.setEditable(false);
panel3.add(txt6);
panel3.add(new JLabel("License No"));
txt7=new JTextField(12);
txt7.setEditable(false);
panel3.add(txt7);
add(panel3);
panel4= new JPanel();
setBackground(Color.WHITE);
Border b3=BorderFactory.createTitledBorder("Employee Details");
panel4.setBorder(b3);
add(panel4,BorderLayout.EAST);
setLayout(new FlowLayout());
panel4.add(new JLabel("Department Name"));
txt8=new JTextField(12);
txt8.setEditable(false);
panel4.add(txt8);
panel4.add(new JLabel("Specialisation"));
txt9=new JTextField(12);
txt9.setEditable(false);
panel4.add(txt9);
panel4.add(new JLabel("Service Charges"));
txt10=new JTextField(12);
txt10.setEditable(false);
panel4.add(txt10);
panel4.add(new JLabel("Salary"));
txt11=new JTextField(12);
txt11.setEditable(false);
panel4.add(txt11);
add(panel4);
panel5=new JPanel();
panel5.setBorder(BorderFactory.createEtchedBorder(Color.PINK, Color.GRAY));
add(panel5,BorderLayout.EAST);
btn1= new JButton("FIRST");
btn1.setFont(new Font("Algerian Regular",Font.BOLD,25));
panel5.add(btn1);
btn1.addActionListener(this);
btn2= new JButton("PREVIOUS");
btn2.setFont(new Font("Algerian Regular",Font.BOLD,25));
panel5.add(btn2);
btn2.addActionListener(this);
btn3= new JButton("NEXT");
btn3.setFont(new Font("Algerian Regular",Font.BOLD,25));
panel5.add(btn3);
btn3.addActionListener(this);
btn4= new JButton("LAST");
btn4.setFont(new Font("Algerian Regular",Font.BOLD,25));
panel5.add(btn4);
btn4.addActionListener(this);
add(panel5);
panel6=new JPanel();
panel6.setBorder(BorderFactory.createEtchedBorder(Color.PINK, Color.BLACK));
add(panel6,BorderLayout.SOUTH);
btn5= new JButton("Add NEW");
btn5.setFont(new Font("Algerian Regular",Font.BOLD,25));
panel6.add(btn5);
btn5.addActionListener(this);
btn6= new JButton("SAVE");
btn6.setFont(new Font("Algerian Regular",Font.BOLD,25));
panel6.add(btn6);
btn6.addActionListener(this);
btn7= new JButton("UPDATE");
btn7.setFont(new Font("Algerian Regular",Font.BOLD,25));
panel6.add(btn7);
btn7.addActionListener(this);
btn8= new JButton("DELETE");
btn8.setFont(new Font("Algerian Regular",Font.BOLD,25));
panel6.add(btn8);
btn8.addActionListener(this);
btn9= new JButton("CLOSE");
btn9.setFont(new Font("Algerian Regular",Font.BOLD,25));
panel6.add(btn9);
btn9.addActionListener(this);
add(panel6);
}
public void actionPerformed(ActionEvent e)
{
}
}
Thanks
Related Tutorials/Questions & Answers:
GUIGUI How to
GUI in Net-beans ... ??
Please visit the following link:
http://www.roseindia.net/java/java-tips/background/30java_tools/netbeans.shtml
GUIGUI Write a
GUI application for the WebBuy Company that allows a user to compose the three parts of a complete email message: the â??To:â??, â??Subject:â?? and â??Message:â?? text. The â??To:â??, and â??Subject:â?? Text areas
Advertisements
GUI componentGUI component How can a
GUI component handle its own events
gui questiongui question design a
gui application for me and write its code in which the user enters a no. in a textfield and onn clicking the button the sum of the digits of the no. should be displayed. hint: suppose the user enters 12
GUI problemGUI problem Create a class called CDProgram and write a
GUI program to compute the amount of a certificate of deposit on maturity. The sample data follows:
Amount deposited: 80000.00
Years: 15
Interest Rate: 7.75
Hint
java gui java
gui friends... good day..
i have doubt in java
gui.
? i created 1 java
gui application. That has two text fields jtext1,jtext2.
case: user entered value in first textfield(jtext1) and pressed the enter key . the cursor
Java GUIJava GUI 1) Using Java
GUI, create a rectangular box that changes color each time a user click a change color button.
2) Modify Question 1 to include a new button named insert image, that allow user to insert a bitmap image
gui questiongui question design a
gui application and write code to accept a string from the user in a textfeild and print using option pane whether it is a palindrome or not. hint: abba is a palindrome
import java.awt.*;
import
GUI problemGUI problem How do I make a Jbutton which is shaped like a circle. This button needs to be clicked in order to change color.
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
public class
ModuleNotFoundError: No module named 'gui'ModuleNotFoundError: No module named '
gui' Hi,
My Python program is throwing following error:
ModuleNotFoundError: No module named '
gui'
How to remove the ModuleNotFoundError: No module named '
gui' error
Magic Matrix in GUIMagic Matrix in GUI I want program in java
GUI contain magic matrix for numbers
Maven Repository/Dependency: gj-gui | gj-guiMaven Repository/Dependency of Group ID gj-
gui and Artifact ID gj-
gui. Latest version of gj-
gui:gj-
gui dependencies.
#
Version
Release Date
You can read more at:
Maven
Tutorials
Flex SDK GUIFlex SDK GUI Hi.......
please give me ans of this question..
What classes do you typically extend in the Flex SDK for creating
GUI controls and why?
Thanks
GUI application programGUI application program Write a
GUI application program that meets the following requirements:
Create an array with 100 randomly chosen integers.
Create a textfield to enter an array index and another textfield to display
Java GUI - Java3DJava GUI 1) Using Java
GUI, create a rectangular box that changes color each time a user click a change color button. 2) Modify Question 1 to include a new button named insert image, that allow user to insert a bitmap image
Maven Dependency gj-gui >> 0.1You should include the dependency code given in this page to add Maven Dependency of gj-
gui >> gj-
gui version0.1 in your project
java gui-with jscroll panejava
gui-with jscroll pane Dear friends..
I have a doubt in my
gui application.
I developed 1 application. In this application is 1 Jscrollpane of height 600 and width 400. Normally it is showing 200 height and 400 width
java gui-with jscroll panejava
gui-with jscroll pane Dear friends..
I have a doubt in my
gui application.
I developed 1 application. In this application is 1 Jscrollpane of height 600 and width 400. Normally it is showing 200 height and 400 width
ModuleNotFoundError: No module named 'argus-gui'ModuleNotFoundError: No module named 'argus-
gui' Hi,
My Python... 'argus-
gui'
How to remove the ModuleNotFoundError: No module named 'argus-
gui' error?
Thanks
Hi,
In your python environment you
ModuleNotFoundError: No module named 'argus-gui'ModuleNotFoundError: No module named 'argus-
gui' Hi,
My Python... 'argus-
gui'
How to remove the ModuleNotFoundError: No module named 'argus-
gui' error?
Thanks
Hi,
In your python environment you
ModuleNotFoundError: No module named 'argus-gui'ModuleNotFoundError: No module named 'argus-
gui' Hi,
My Python... 'argus-
gui'
How to remove the ModuleNotFoundError: No module named 'argus-
gui' error?
Thanks
Hi,
In your python environment you
ModuleNotFoundError: No module named 'bottle-gui'ModuleNotFoundError: No module named 'bottle-
gui' Hi,
My Python... 'bottle-
gui'
How to remove the ModuleNotFoundError: No module named 'bottle-
gui' error?
Thanks
Hi,
In your python environment you
ModuleNotFoundError: No module named 'bottle-gui'ModuleNotFoundError: No module named 'bottle-
gui' Hi,
My Python... 'bottle-
gui'
How to remove the ModuleNotFoundError: No module named 'bottle-
gui' error?
Thanks
Hi,
In your python environment you
ModuleNotFoundError: No module named 'dlc-gui'ModuleNotFoundError: No module named 'dlc-
gui' Hi,
My Python...-
gui'
How to remove the ModuleNotFoundError: No module named 'dlc-
gui... to install padas library.
You can install dlc-
gui python with following command
ModuleNotFoundError: No module named 'eccw-gui'ModuleNotFoundError: No module named 'eccw-
gui' Hi,
My Python... 'eccw-
gui'
How to remove the ModuleNotFoundError: No module named 'eccw-
gui... to install padas library.
You can install eccw-
gui python with following
ModuleNotFoundError: No module named 'giwaxs-gui'ModuleNotFoundError: No module named 'giwaxs-
gui' Hi,
My Python... 'giwaxs-
gui'
How to remove the ModuleNotFoundError: No module named 'giwaxs-
gui' error?
Thanks
Hi,
In your python environment you