java
whats the problem with my code? it's giving me one error illegal start of expression on line 201? and also help me change the colors to their names instead of numbers. thx
public class EmployeeDetails3 extends JFrame
{
public EmployeeDetails3()
{
initComponents();
}
@SuppressWarnings("unchecked")
private void initComponents()
{
buttonGroup1 = new JButtonGroup();
buttonGroup2 = new JButtonGroup();
jPanel1 = new JPanel();
jPanel2 = new JPanel();
jPanel4 = new JPanel();
jPanel5 = new JPanel();
jLabel1 = new JLabel();
jTextField1 = new JTextField();
jLabel2 = new JLabel();
jTextField2 = new JTextField();
jLabel4 = new JLabel();
jTextField3 = new JTextField();
jLabel5 = new JLabel();
jTextField5 = new JTextField();
jLabel3 = new JLabel();
jTextField4 = new JTextField();
jPanel6 = new JPanel();
jPanel7 = new JPanel();
jLabel6 = new JLabel();
jScrollPane1 = new JScrollPane();
jTextArea1 = new JTextArea();
jPanel8 = new JPanel();
jPanel9 = new JPanel();
jRadioButton1 = new JRadioButton();
jRadioButton2 = new JRadioButton();
jPanel10 = new JPanel();
jCheckBox1 = new JCheckBox();
jCheckBox2 = new JCheckBox();
jCheckBox3 = new JCheckBox();
jPanel3 = new JPanel();
jButton1 = new JButton();
jButton2 = new JButton();
jButton3 = new JButton();
jButton4 = new JButton();
jButton5 = new JButton();
jButton6 = new JButton();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Employee Details");
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));
jPanel1.setLayout(new java.awt.BorderLayout());
jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.X_AXIS));
jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel4.setLayout(new java.awt.GridLayout(1, 0));
jPanel5.setBackground(new java.awt.Color(153, 0, 153));
jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel5.setLayout(new java.awt.GridLayout(5, 2));
jLabel1.setText("Name:");
jPanel5.add(jLabel1);
jPanel5.add(jTextField1);
jLabel2.setText("Phone:");
jPanel5.add(jLabel2);
jPanel5.add(jTextField2);
jLabel4.setText("Street:");
jPanel5.add(jLabel4);
jPanel5.add(jTextField3);
jLabel5.setText("City:");
jPanel5.add(jLabel5);
jPanel5.add(jTextField5);
jLabel3.setText("Country:");
jPanel5.add(jLabel3);
jPanel5.add(jTextField4);
jPanel4.add(jPanel5);
jPanel6.setBackground(new java.awt.Color(153, 153, 255));
jPanel6.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel6.setLayout(new java.awt.GridLayout(2, 1));
jPanel7.setBackground(new java.awt.Color(153, 153, 153));
jPanel7.setLayout(new java.awt.GridLayout(1, 2));
jLabel6.setBackground(new java.awt.Color(0, 153, 204));
jLabel6.setText("Address");
jPanel7.add(jLabel6);
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
jPanel7.add(jScrollPane1);
jPanel6.add(jPanel7);
jPanel8.setLayout(new java.awt.GridLayout(2, 0));
jPanel9.setBackground(new java.awt.Color(255, 0, 102));
jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Sex"));
jPanel9.setLayout(new java.awt.GridLayout(1, 2));
buttonGroup1.add(jRadioButton1);
jRadioButton1.setText("Male");
jPanel9.add(jRadioButton1);
buttonGroup1.add(jRadioButton2);
jRadioButton2.setSelected(true);
jRadioButton2.setText("Female");
jPanel9.add(jRadioButton2);
jPanel8.add(jPanel9);
jPanel10.setBackground(new java.awt.Color(0, 153, 153));
jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Hobbies"));
jPanel10.setLayout(new java.awt.GridLayout(1, 3));
jCheckBox1.setText("Football");
jCheckBox1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
jCheckBox1ActionPerformed(evt);
}
});
jPanel10.add(jCheckBox1);
jCheckBox2.setText("Netbell");
jPanel10.add(jCheckBox2);
jCheckBox3.setText("Chess");
jPanel10.add(jCheckBox3);
jPanel8.add(jPanel10);
jPanel6.add(jPanel8);
jPanel4.add(jPanel6);
jPanel2.add(jPanel4);
jPanel1.add(jPanel2, java.awt.BorderLayout.CENTER);
jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jButton1.setText("ADD");
jButton1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
jButton1ActionPerformed(evt);
}
});
jPanel3.add(jButton1);
jButton2.setText("UPDATE");
jPanel3.add(jButton2);
jButton3.setText("FIRST");
jButton3.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
jButton3ActionPerformed(evt);
}
});
jPanel3.add(jButton3);
jButton4.setText("<<");
jPanel3.add(jButton4);
jButton5.setText(">>");
jPanel3.add(jButton5);
jButton6.setText("LAST");
jPanel3.add(jButton6);
jPanel1.add(jPanel3, java.awt.BorderLayout.SOUTH);
getContentPane().add(jPanel1);
pack();
}
public void actionPerformed (ActionEvent e)
{
if(e.getSource()==btn)
}
public static void main(String args[])
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new EmployeeDetails3().setVisible(true);
}
});
}
}
View Answers
August 28, 2010 at 12:44 PM
Hi Friend,
We have modified your code:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class EmployeeDetails3 extends JFrame{
public EmployeeDetails3(){
initComponents();
}
@SuppressWarnings("unchecked")
private void initComponents()
{
ButtonGroup buttonGroup1 = new ButtonGroup();
ButtonGroup buttonGroup2 = new ButtonGroup();
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JPanel jPanel4 = new JPanel();
JPanel jPanel5 = new JPanel();
JLabel jLabel1 = new JLabel();
JTextField jTextField1 = new JTextField();
JLabel jLabel2 = new JLabel();
JTextField jTextField2 = new JTextField();
JLabel jLabel4 = new JLabel();
JTextField jTextField3 = new JTextField();
JLabel jLabel5 = new JLabel();
JTextField jTextField5 = new JTextField();
JLabel jLabel3 = new JLabel();
JTextField jTextField4 = new JTextField();
JPanel jPanel6 = new JPanel();
JPanel jPanel7 = new JPanel();
JLabel jLabel6 = new JLabel();
JScrollPane jScrollPane1 = new JScrollPane();
JTextArea jTextArea1 = new JTextArea(5,20);
JPanel jPanel8 = new JPanel();
JPanel jPanel9 = new JPanel();
JRadioButton jRadioButton1 = new JRadioButton();
JRadioButton jRadioButton2 = new JRadioButton();
JPanel jPanel10 = new JPanel();
JCheckBox jCheckBox1 = new JCheckBox();
JCheckBox jCheckBox2 = new JCheckBox();
JCheckBox jCheckBox3 = new JCheckBox();
JPanel jPanel3 = new JPanel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
JButton jButton6 = new JButton();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setTitle("Employee Details");
getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.LINE_AXIS));
jPanel1.setLayout(new java.awt.BorderLayout());
jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.X_AXIS));
jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel4.setLayout(new java.awt.GridLayout(1, 0));
jPanel5.setBackground(Color.magenta);
jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel5.setLayout(new java.awt.GridLayout(5, 2));
jLabel1.setText("Name:");
jPanel5.add(jLabel1);
jPanel5.add(jTextField1);
jLabel2.setText("Phone:");
jPanel5.add(jLabel2);
jPanel5.add(jTextField2);
jLabel4.setText("Street:");
jPanel5.add(jLabel4);
jPanel5.add(jTextField3);
jLabel5.setText("City:");
jPanel5.add(jLabel5);
jPanel5.add(jTextField5);
jLabel3.setText("Country:");
jPanel5.add(jLabel3);
jPanel5.add(jTextField4);
jPanel4.add(jPanel5);
jPanel6.setBackground(new java.awt.Color(153, 153, 255));
jPanel6.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel6.setLayout(new java.awt.GridLayout(2, 1));
jPanel7.setBackground(Color.gray);
jPanel7.setLayout(new java.awt.GridLayout(1, 2));
jLabel6.setText("Address");
jPanel7.add(jLabel6);
jScrollPane1.setViewportView(jTextArea1);
jPanel7.add(jScrollPane1);
August 28, 2010 at 12:44 PM
continue..
jPanel6.add(jPanel7);
jPanel8.setLayout(new java.awt.GridLayout(2, 0));
jPanel9.setBackground(Color.red);
jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Sex"));
jPanel9.setLayout(new java.awt.GridLayout(1, 2));
buttonGroup1.add(jRadioButton1);
jRadioButton1.setText("Male");
jPanel9.add(jRadioButton1);
buttonGroup1.add(jRadioButton2);
jRadioButton2.setSelected(true);
jRadioButton2.setText("Female");
jPanel9.add(jRadioButton2);
jPanel8.add(jPanel9);
jPanel10.setBackground(Color.green);
jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Hobbies"));
jPanel10.setLayout(new java.awt.GridLayout(1, 3));
jCheckBox1.setText("Football");
jCheckBox1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
}
});
jPanel10.add(jCheckBox1);
jCheckBox2.setText("Netbell");
jPanel10.add(jCheckBox2);
jCheckBox3.setText("Chess");
jPanel10.add(jCheckBox3);
jPanel8.add(jPanel10);
jPanel6.add(jPanel8);
jPanel4.add(jPanel6);
jPanel2.add(jPanel4);
jPanel1.add(jPanel2, java.awt.BorderLayout.CENTER);
jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jButton1.setText("ADD");
jButton1.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
}
});
jPanel3.add(jButton1);
jButton2.setText("UPDATE");
jPanel3.add(jButton2);
jButton3.setText("FIRST");
jButton3.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
}
});
jPanel3.add(jButton3);
jButton4.setText("<<");
jPanel3.add(jButton4);
jButton5.setText(">>");
jPanel3.add(jButton5);
jButton6.setText("LAST");
jPanel3.add(jButton6);
jPanel1.add(jPanel3, java.awt.BorderLayout.SOUTH);
getContentPane().add(jPanel1);
pack();
}
public static void main(String args[]){
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new EmployeeDetails3().setVisible(true);
}
});
}
}
Thanks
Related Tutorials/Questions & Answers:
javajava diff bt core
java and
java Advertisements
java java why iterator in
java if we for loop
Java Java Whether
Java is pure object oriented Language
JAVAJAVA how the name came for
java language as "
JAVA javajava explain technologies are used in
java now days and structure
java javajava different between
java & core
java javajava is
java open source
javajava what is
java reflection
java java in
java does not pointers concept but what is nullpointers in
java?
nullpointer is a runtime Exception
javawhat is the size of array in
java ? what is the size of array in
java ?
what is the mean of finalize in
java javajava why to set classpath in
java javajava RARP implementation using
java socket
javajava sample code for RARP using
java JavaJava how to do
java in command prompt
javajava how use
java method
javajava is
java purely object oriented language
javajava why multiple inheritance is not possible in
java javajava give a simple example for inheritance in
java javajava give a simple example for inheritance in
java javajava why to set classpath in
java javajava why to set classpath in
java javajava why to set classpath in
java java java What is ?static? keyword
javajava Does
java allows multiline comments
javajava Write a
java code to print "ABABBABCABABBA
javajava write a program in
java to acess the email
javajava send me
java interview questions
javajava what are
JAVA applications development tools
JavaJava Whether
Java is Programming Language or it is SOftware
javajava explain object oriented concept in
java java java difference between class and interface
JavaJava how to draw class diagrams in
java javajava write a
java program using filenotfoundexception
javajava how to edit text document by using
java
then how to edit starting and ending of text document by using
java javajava different between
java & core
java
print("code sample
java java how can use sleep in
java
which book learn of
java language
java java How to set
java Policy for applet using jdk 6
javajava pattern code for a given words
java pattern code for a given words pattern
javajava dear,
i want a field for date picker using
java/
java script
javajava create
java program for delete and update the details,without using database, just a normal
java program
javajava why methods in
java raise exceptions
Have a look at the following link:
Java Exceptions
javajava code to search the nodes how to write the
java code to search the nodes using routers
javajava online telephone directory i need coding for online telephone directory..by using
java....pls help me
javajava different between
java & core
java
print("code sample
javajava how to invoke one chart
java file from another
java file
javajava how to prepare the
java
Hi Friend,
If you want to learn how to install
java, creating and running a
java program then go through the following links:
http://www.roseindia.net/
java/beginners/index.shtml
http
javajava
java swing
Swing is a principal GUI toolkit for the
Java programming language. It is a part of the JFC (
Java Foundation Classes), which is an API for providing a graphical user interface for
Java programs
javajava what is the need of
java if
java is not there what will happen... work unless you have
Java installed, and more are created every day.
Java... to scientific supercomputers, cell phones to the Internet,
Java is everywhere!
http