graphical user interface
Hi, could u please tell me whats wrong with the code below.
tried compiling but it gives me 2 errors. class or interface expected.thx
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class EmployeeDetails extends JFrame implements ActionListener
{
JLabel lbl1,lbl2,lbl3,lbl4,lbl5,lbl6,lbl7,lbl8;
JPanel pan1,pan2,pan3,pan4,pan5;
JRadioButton r1,r2;
JCheckBox chk1,chk2,chk3;
JTextField txt1,txt2,txt3,txt4,txt5;
JButton btn1,btn2,btn3,btn4,btn5,btn6,btn;
JTextArea area;
JScrollPane pane;
public EmployeeDetails()
{
setTitle("EmployeeDetails:");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(2,2));
setSize(700,400);
widgets();
}
}
public static void main(String args[]);
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
new EmployeeDetails.setVisible(true);
}
});
}
public void widgets()
{
JPanel pan1=new JPanel();
pan1.setLayout(new FlowLayout());
pan1.add(new JLabel("LEFT"));
lbl1=new JLabel("Name");
lbl2=new JLabel("Phone");
lbl3=new JLabel("Street");
lbl4=new JLabel("City");
lbl5=new JLabel("Country");
txt1=new JTextField(12);
txt2=new JTextField(12);
txt3=new JTextField(12);
txt4=new JTextField(12);
txt5=new JTextField(12);
getContentPane().add(pan1,BorderLayout.NORTH);
pan2=new JPanel();
pan2.setLayout(new FlowLayout());
pan2.add(newJlabel("RIGHT"));
lbl6=new JLabel("Address");
area=new JTextArea(8,15);
getContentPane().add(pan2,BorderLayout.EAST);
pan3=new JPanel();
pan3.setLayout(new FlowLayout());
rd1=new JRadioButton("Male");
rd2=new JRadioButton("Female");
ButtonGroup bg1=new ButtonGroup();
bg1.add(rd1);
bg2.add(rd2);
pan3.setBorder(BorderFactory.createTitledBorder("Sex"));
getContentPane().add(pan2,BorderLayout.EAST);
pan4=new JPanel();
pan4.setLayout(new FlowLayout());
chk1= new JCheckBox("FootBall");
chk2= new JCheckBox("Netball");
chk3= new JCheckBox("Chess");
ButtonGroup bg2= new ButtonGroup();
bg2.add(chk1);
bg2.add(chk2);
bg2.add(chk3);
pan4.add(chk1);
pan4.add(chk2);
pan4.add(chk3);
pan4.setBorderFactory.createTitledBorder("Hobbies");
getContentPane.add(pan4,Borderlayout.EAST);
pan5=new JPanel();
pan5.setLayout(new FlowLayout());
btn1= new JButton("ADD");
btn2= new JButton("UPDATE");
btn3= new JButton("FIRST");
btn4= new JButton("<<");
btn5= new JButton(">>");
btn6= new JButton("LAST");
btn.addActionListener(this);
pan5.add(btn1);
pan5.add(btn2);
pan5.add(btn3);
pan5.add(btn4);
pan5.add(btn5);
pan5.add(btn6);
getContentPane().add(pan5,BorderLayout.SOUTH);
setVisible(true);
}
View Answers
August 10, 2010 at 12:05 PM
Hi Friend,
We have modified your code:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.border.Border;
class EmployeeDetails extends JFrame //implements ActionListener
{
JLabel lbl1,lbl2,lbl3,lbl4,lbl5,lbl6,lbl7,lbl8;
JPanel pan1,pan2,pan3,pan4,pan5;
JRadioButton rd1,rd2;
JCheckBox chk1,chk2,chk3;
JTextField txt1,txt2,txt3,txt4,txt5;
JButton btn1,btn2,btn3,btn4,btn5,btn6,btn;
JTextArea area;
JScrollPane pane;
public EmployeeDetails()
{
setTitle("EmployeeDetails:");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(2,2));
setSize(700,400);
widgets();
}
public static void main(String args[])
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
EmployeeDetails details=new EmployeeDetails();
details.setVisible(true);
}
});
}
public void widgets()
{
JPanel pan1=new JPanel();
pan1.setLayout(new FlowLayout());
pan1.add(new JLabel("LEFT"));
lbl1=new JLabel("Name");
lbl2=new JLabel("Phone");
lbl3=new JLabel("Street");
lbl4=new JLabel("City");
lbl5=new JLabel("Country");
txt1=new JTextField(12);
txt2=new JTextField(12);
txt3=new JTextField(12);
txt4=new JTextField(12);
txt5=new JTextField(12);
getContentPane().add(pan1,BorderLayout.NORTH);
pan2=new JPanel();
pan2.setLayout(new FlowLayout());
pan2.add(new JLabel("RIGHT"));
lbl6=new JLabel("Address");
area=new JTextArea(8,15);
getContentPane().add(pan2,BorderLayout.EAST);
pan3=new JPanel();
pan3.setLayout(new FlowLayout());
rd1=new JRadioButton("Male");
rd2=new JRadioButton("Female");
ButtonGroup bg1=new ButtonGroup();
bg1.add(rd1);
bg1.add(rd2);
pan3.setBorder(BorderFactory.createTitledBorder("Sex"));
getContentPane().add(pan2,BorderLayout.EAST);
pan4=new JPanel();
pan4.setLayout(new FlowLayout());
chk1= new JCheckBox("FootBall");
chk2= new JCheckBox("Netball");
chk3= new JCheckBox("Chess");
ButtonGroup bg2= new ButtonGroup();
bg2.add(chk1);
bg2.add(chk2);
bg2.add(chk3);
pan4.add(chk1);
pan4.add(chk2);
pan4.add(chk3);
Border border = BorderFactory.createTitledBorder("Hobbies");
pan4.setBorder(border);
getContentPane().add(pan4,BorderLayout.EAST);
pan5=new JPanel();
pan5.setLayout(new FlowLayout());
btn1= new JButton("ADD");
btn2= new JButton("UPDATE");
btn3= new JButton("FIRST");
btn4= new JButton("<<");
btn5= new JButton(">>");
btn6= new JButton("LAST");
//btn.addActionListener(this);
pan5.add(btn1);
pan5.add(btn2);
pan5.add(btn3);
pan5.add(btn4);
pan5.add(btn5);
pan5.add(btn6);
getContentPane().add(pan5,BorderLayout.SOUTH);
setVisible(true);
}
}
Thanks
Related Tutorials/Questions & Answers:
Java Graphical user interfaceJava
Graphical user interface Hi, guys. I'm christina, need help with my home work
Task 1: GUI Design and Implementation
The
user requirements... of the screen when it starts. It provides an
interface to register the student name
graphical user interface - Java Beginnersgraphical user interface how do i write a code for a jmenu bar, File with items like open, save , save as. that lead to another
interface? Hi Friend,
Please visit the following link:
http://www.roseindia.net
Advertisements
graphical user interface - Java Beginnersgraphical user interface Hi, could u please tell me whats wrong with the code below.
tried compiling but it gives me 2 errors. class or
interface expected.thx
import javax.swing.*;
import java.awt.event.*;
import
graphical user interface - Java Beginnersgraphical user interface write a java program to display Employee details with a border heading,name,phone number, street,city,then on the other side Right text area for address, under it sex with a border title then radio
graphical user interface - Java Beginnersgraphical user interface Help me write a code for this please Thank you. tried adjusting the previous one and got errors.
Employee Details as Title
Name (Text Field) Address (Text Area)
Phone
Graphical User Interfaces; for
graphical user interface design.
The implementation of the
user interface... to create a
Graphical User Interface
(GUI). Moreover containers can be nested...
Graphical User Interfaces
User Interface ToolkitsUser Interface Toolkits
User Interface Toolkits / Libraries are given below..., dialog boxes etc and also
dealing
user input via those components.
Swing... weight. These elements can be incorporate in
user
interfaces.
Click here to go
Ajax user interface - AjaxAjax
user interface hello could anyone help
my requirement is to design the database interaction using AJAX
my requirement is a table will be displayed with checkbox as its first column
when we select the checkbox
How to save user interface in flex for design toolHow to save
user interface in flex for design tool Hi
I want to create a flex application "sticker design tool" in which i want to save all...
user want to re-customize it later on then he can able to re-customize it.
please
MySQL User Interface
MySQL
User Interface
...;:
You can add function with the help of UDF (
user defined function)
interface... defined function Interface
MySQL
user-defined function
interface interface interface what is the use of marking
interface interface.interface. Write short note on
interface.
Please visit the following link:
Java
Interface interfaceinterface will the
interface implements a
interface
Hi Friend,
No.
Interface can extends another
interface but cannot implements it, because
interface will not contain the implementation.
Thanks
INTERFACEINTERFACE how
interface support multiple inheritance in java
interface interface Hi
I have
interface in that
interface 3 methods are there , after some days client said that,i want to add one more method in that
interface ,so how can add 4 method so that the implemented class did not affect
interfaceinterface can we extend
interface?
Hi Friend,
Yes an
interface can be extended by other
interface like using extends keyword
interface A{
}
interface B extends A{
}
For Example:
interface IntefaceA {
void
interfaceinterface what the use of
interface?
An
interface is one... variables.Any class can
implement(inherit)the
interface and make use... is achieved by using the
interface (by implementing more than one
interface at a time
interfaceinterface What is marker
interface ??
what is its use in java programming??
is this us in programming ??Explain is implementation with code
interfaceinterface develop a library
interface which has drawbook(),returnbook()(with fine),checkstatus()
and reservebook() methods.all the methods tagged with public
interfaceinterface develop a library
interface which has drawbook(),returnbook()(with fine),checkstatus()
and reservebook() methods.all the methods tagged with public
Interface for
Interface in java? and want to know why they used
interface instead of multiple inheritance? Thanks in advance
An
interface is one which has abstract... implement(inherit)the
interface and make use of the methods(functions
interfaceinterface why do we need
interface in java..if it`s usefull for to obtain multiple inheritance in the sense how it gonna be achieved...and i can...)...the y we need
interface...THis is question often i heard from my developer
InterfaceInterface I need to implement the
interface without overriding its method and also don't use abstract class for this. How to do
interfaceinterface What is the exact use of
interface in real time scenario? some people says that
interface provides multiple inheritance. Is it true...; Through
interface, we can achieve the multiple inheritance.
Java does
InterfaceInterface 1.Create an
interface names ShapeInterface that has two... class
a.Rectangle that uses the
interface
b.Circle that uses the
interface and abstract class
interface ShapeInterface{
int l=0,b=0;
public
InterfaceInterface 1.Create an
interface names ShapeInterface that has two... class
a.Rectangle that uses the
interface
b.Circle that uses the
interface and abstract class
interface ShapeInterface{
int l=0,b=0;
public
InterfaceInterface Declare an
Interface called property containting a method compute price to compute &return the price.The inerface is to be implemented by follwaing two class
(1)Bungalow&(2)Flat
both the lasses have following
Web-CAT CxxTest Plug-in Web-CAT CxxTest Plug-in
The CxxTest plug-in for Eclipse
provides Eclipse users who are developing C++ code with a
graphical user
interface for CxxTest
Pizza Order ApplicationPizza Order Application
Here we have created an application using
graphical user interface that will allow the
user to order the Pizza. For the pizza...). The
user should be able to pay the total cost of the ordered pizza
JList box javaJList box java
We are going to describe JList box java. First of all we have created JList
component of Swing. List is a component of GUI()
Graphical User
Interface. It allows the multiple items in a list and In this class
extend
Show Calendar Icon
Show Calendar Icon
This section illustrates you how to draw the calendar icon.
An icon is a pictorial image used in a
graphical user interface to represent
a program
Java Swing Java programs with a
graphical user interface (GUI). There are
many components...
the basic
user interface such as customizable painting, event handling, drag and
drop
Java Swing for weak and inflexible AWT controls for providing
more sophisticated
graphical user interface (GUI) components for Java programs.
Swings are lightweight and 100
Create ToolTip Text in SWT
Create ToolTip Text in SWT
In this section, you will learn how to create ToolTip.
The ToolTip is the element of
graphical user interface used in the
conjunction
Netwiser a
graphical user interface, a network simulator, and a
portable C++ framework... configuring your components as easy as
point-and-click with its
graphical TUM TUM
Tikal Update Manager is a YUM-like
graphical user
interface, which wraps Eclipse and Callisto-format update sites, adding
intuitive discover... with Eclipse's native update site support, mainly due to its
interface Graphical calculator using AWT - Java BeginnersGraphical calculator using AWT hi Sir,
I need a source code for the following prgm...pls help me..
Implement a simple
graphical calculator using AWT.The calculator shd perform simple operation like addition, subtraction
Graphical calculator using AWT - Java BeginnersGraphical calculator using AWT Hi Sir,
Thanks for the reply... But i got some errors while compiling some of them i made clear but still one error.....and is it the same code we need implement on
Graphical Calc using Swing?
Here is the prg code
Interface implimentationInterface implimentation How to impliment an
interface For Achieveing MVC & loosCupling in Any Project