Share on Google+Share on Google+

Janet
GUI
2 Answer(s)      6 years and 7 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);

///}
}
}

Ads

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 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
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
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 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
Java and GUI application Example  Java and GUI application Example
Convert the code to GUI
Write a GUI Application  best way to write a GUI based application
Convert the code to GUI
How to Convert the code to GUI   How to convert a code into GUI
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
Netbeans GUI Ribbon
Netbeans GUI Ribbon  how to create ribbon task in java GUI using netbeans
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
Java GUI - Java Beginners
Java GUI  HOW TO ADD ICONS IN JAVA GUI PROGRAMMES
Magic Matrix in GUI
Magic Matrix in GUI  I want program in java GUI contain magic matrix for numbers
Regarding GUI Applications
Regarding GUI Applications  How to create a save and open jmenu item in java desktop application
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
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads