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



Home Answers Viewqa Java-Beginners graphical user interface
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Janet
graphical user interface
1 Answer(s)      4 years and 5 months ago
Posted in : Java Beginners


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


Advertisement
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 interface
Java 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 Beginners
graphical 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 Beginners
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
graphical user interface - Java Beginners
graphical 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 Beginners
graphical 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 interface - Design concepts & design patterns
graphical user interface  Hi sir, could you help me in the designing and implementation of an election system graphical user interface please .any examples or suggestions will be highly appreciated .thank you
Graphical User Interfaces
; for graphical user interface design. The implementation of the user interface... be preserved.  AWT Basics The superclass of all graphical user interface objects... a Graphical User Interface (GUI). Moreover containers can be nested arbitrarily
User Interface Toolkits
User Interface Toolkits User Interface Toolkits / Libraries are given below... boxes etc and also dealing user input via those components. Swing The Swing... by it is light weight. These elements can be incorporate in user interfaces. Click
Ajax user interface - Ajax
Ajax 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 tool
How 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
Linux as a Command Line Interface (CLI) Vs. Graphics User Interface (GUI).
a command line interface (CLI) to the operating system, while graphical shells provide a graphical user interface (GUI). A graphical user interface (GUI) is a human...Linux as a Command Line Interface (CLI) Vs. Graphics User Interface (GUI
MySQL User Interface
MySQL User Interface      ...;: You can add function with the help of UDF (user defined function) interface... installed user-defined function, but if in upgrade version UDF interface
interface
interface   what is the use of marking interface
interface.
interface.  Write short note on interface.   Please visit the following link: Java Interface
interface
interface  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
show the database values graphical represantation
show the database values graphical represantation   show the database values graphical represantation and auto refresh for every 30 secand displaying in webpage
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
INTERFACE
INTERFACE  how interface support multiple inheritance in java
interface
interface  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
interface
interface  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
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
interface
interface  What is marker interface ?? what is its use in java programming?? is this us in programming ??Explain is implementation with code
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
interface
interface  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
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
Interface
Interface  I need to implement the interface without overriding its method and also don't use abstract class for this. How to do
interface
interface  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
Pizza Order Application
Pizza 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
Interface
Interface  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
Interface
Interface  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
 

 

 

DMCA.com