Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


Janet
GUI
2 Answer(s)      3 years and 11 months ago
Posted in : Java Beginners


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);

///}
}
}


Advertisement
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:
GUI
GUI  How to GUI in Net-beans ... ??   Please visit the following link: http://www.roseindia.net/java/java-tips/background/30java_tools/netbeans.shtml
GUI framework
GUI framework  what do u mean by GUI framework
Advertisements
GUI component
GUI component  How can a GUI component handle its own events
gui question
gui 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 problem
GUI 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
Convert the code to GUI
GUI code  GUI code
Java GUI
Java 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
Convert the code to GUI
GUI Application example  GUI Application example
Convert the code to GUI
GUI Example  GUI Example code to learn
gui question
gui 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 problem
GUI 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
Convert the code to GUI
Java and GUI application Example  Java and GUI application Example
Convert the code to GUI
How to Convert the code to GUI   How to convert a code into GUI
Convert the code to GUI
Java GUI Class Example  Java GUI Class Example
Convert the code to GUI
GUI Java JSP application  GUI Java JSP application
Convert the code to GUI
GUI Application Development   GUI Application Development
Convert the code to GUI
Write a GUI Application  best way to write a GUI based application
Netbeans GUI Ribbon
Netbeans GUI Ribbon  how to create ribbon task in java GUI using netbeans
Convert the code to GUI
How to create GUI application in Java   How to create GUI application in Java
Convert the code to GUI
Java Code to GUI   can any one convert My code to GUI code
Java GUI - Java Beginners
Java GUI  HOW TO ADD ICONS IN JAVA GUI PROGRAMMES
Convert the code to GUI
Convert the code   How to convert a code to GUI look alike
Convert the code to GUI
Is it possible to convert a code into GUI  Is it possible to convert a code into GUI
Regarding GUI Applications
Regarding GUI Applications  How to create a save and open jmenu item in java desktop application
Magic Matrix in GUI
Magic Matrix in GUI  I want program in java GUI contain magic matrix for numbers
how to refresh my GUI page
how to refresh my GUI page  how to refresh a GUI in java
Flex SDK GUI
Flex 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 program
GUI 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 - Java3D
Java 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
java gui-with jscroll pane
java 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 pane
java 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
Gui Interface - Java Beginners
Gui Interface  hi I have two seperate interfaces in the same projects . my question is how can I access this interface using a jbutton (i.e jbutton = next where next points to another interface addCourse.java) What would
GUI problem - Java Beginners
GUI problem  how to write java program that use JTextField to input data and JTextField to display the output when user click Display Button??  Handle the actionPerformed event for JButton and try doing something like
GUI - Java Beginners
GUI testing  GUI testing in software testing  HiNow, use the code and get the answer.import javax.swing.*;public class DemoTryCatchDialog...;GUI Example");pack();show();}public void actionPerformed(ActionEvent event
GUI 2 - Java Beginners
GUI 2  How can I modify this code? Please give me a GUI Example.Thanks!!  This can be done using KeyEvent in the following way... written...;GUI Example");pack();show();}public void actionPerformed(ActionEvent event
Java GUI code
Java GUI code  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 Total Amount: Hint** to solve this problem
Convert the code to GUI ??
Convert the code to GUI ??  hi >> can anyone help me to conver this code to GUI ?? /** * @(#)RegistorClass.java * *. * @author * @version 1.00 2011/12/16 */ import java.util.Scanner; public class RegistorClass
Java GUI - Applet
Java GUI  HELLO, i am working on java chat server, i add JFrame and make GUI structure by draging buttons and labels, now i want to insert image on left corner JLable. how thats possible?  Hi friend, Code
Gui plz help
Gui plz help   Create a Java application that would allow a person to practice math (either addition, subtraction, multiplication or division). The questions must be randomly generated ( the values for each number should
Regarding GUI Applications
GUI Applications  How to create a save and open jmenu item in java desktop application.   Here is a simple JMenuItem example in java swing through which you can perform open and save operations on File. import
GUI Interface - Java Beginners
GUI Interface  Respected sir, please send me the codimg of basic calculator,functionality must be include additon ,subtraction,division and multiplication. But use classes javax swing java awt java awt.event no other
how to do gui
is RM" + num1); } } } how to do gui for this coding..tq   import
Convert the code to GUI
GUI example for beginners  GUI example for beginners  sory ,, I will posted my code again import java.util.Scanner; public class RegistorClass { private int accumulator; private int instructionCounter; private
Convert the code to GUI
Convert the code to GUI   can any one convert My code to GUI code import java.util.Scanner; public class RegistorClass { private int accumulator; private int instructionCounter; private int instructionRegister
bank account gui
; Transaction>(); I already done with the GUI i just need the code to make the button
I need to develop a gui like this
I need to develop a gui like this  Hai Friends, I need to develop such a menu in my gui programs. The gui contains 1 text field.whenever the text field Gained focus. then the list appear with some string values...someone
Moving Images in GUI - Swing AWT
Moving Images in GUI  I want to add an image of a person in my GUI and make it move to a specific location. How can I add the image to the frame and move
Raju?s GUI-API
Raju?s GUI-API       Raju?s GUI-API Ajax reusable GUI Classes are based on ?patent pending? inventions, which let developers build easy to use and more flexible reusable GUI Classes than
java gui database - Java Beginners
java gui database  I have eight files. Each file has exactly same number(say 100) of entries. Each corresponding entry of all files correspond to one... gui. Could anybody help me. Thanks. Shah
 

 

 

DMCA.com