Java

Ads

 
 
 

Share on Google+Share on Google+

Janet
Java
1 Answer(s)      6 years and 8 months ago
Posted in : Java Beginners
What could be wrong with this code please

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;

class Billing extends JFrame{
JLabel l1,l2,l3,l4,l5,l6,lPhoto,lN;
JTextField text1,text2,text3,text4;
JTextArea area;
JScrollPane pane;
JButton b1,b2,b3,b4,b5,b6;
JRadioButton r1,r2;
JPanel p1,p2,p3,p4,p;
ButtonGroup bg;

public Billing(){
super("Nakasero Hospital Managment System [ Billing Maintance Module]");
l1=new JLabel("Name");
l2=new JLabel("Phone Number");
l3=new JLabel("Street");
l4=new JLabel("City");
l5=new JLabel("Address");
l6=new JLabel("Gender");
lPhoto=new JLabel();
lPhoto.setIcon(new ImageIcon("img.gif"));
lN=new JLabel("Billing Maintenance Module");
lN.setFont(new Font("Lucida Handwriting",Font.PLAIN,16));
lN.setForeground(Color.RED);
JPanel p3=new JPanel();
p3.add(lPhoto);
p3.add(lN);
getContentPane().add(p,BorderLayout.NORTH);

text1=new JTextField(20);
text2=new JTextField(20);
text3=new JTextField(20);
text4=new JTextField(20);

area=new JTextArea();
pane=new JScrollPane(area);



b1=new JButton("Add");
b2=new JButton("Update");
b3=new JButton("First");
b4=new JButton("Last");
b5=new JButton("Next");
b6=new JButton("Previous");

r1=new JRadioButton("Male",false);
r2=new JRadioButton("Female",false);
bg=new ButtonGroup();
bg.add(r1);
bg.add(r2);
p=new JPanel();
p1=new JPanel(new GridLayout(5,2));
p2=new JPanel();

p4=new JPanel();
Border border1 = BorderFactory.createTitledBorder("Employee Details");
p1.setBorder(border1);
p1.add(l1);
p1.add(text1);
p1.add(l2);
p1.add(text2);
p1.add(l3);
p1.add(text3);
p1.add(l4);
p1.add(text4);
p1.add(l5);
p1.add(pane);

Border border2 = BorderFactory.createTitledBorder("Gender");
p2.setBorder(border2);
p2.add(l6);
p2.add(r1);
p2.add(r2);



p4.add(b1);
p4.add(b2);
p4.add(b3);
p4.add(b4);
p4.add(b5);
p4.add(b6);

p.add(p1,BorderLayout.NORTH);
p.add(p2,BorderLayout.EAST);
p.add(p4,BorderLayout.SOUTH);
add(p);
setVisible(true);
setLocation(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout());
setSize(660,600);

}
public static void main(String[] args) {
new Billing();
}
}
Ads
View Answers

September 25, 2010 at 2:47 PM


Hi Friend,

We have modified your code. Try this:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;

class Billing extends JFrame{
JLabel l1,l2,l3,l4,l5,l6,lPhoto,lN;
JTextField text1,text2,text3,text4;
JTextArea area;
JScrollPane pane;
JButton b1,b2,b3,b4,b5,b6;
JRadioButton r1,r2;
JPanel p1,p2,p3,p4,p;
ButtonGroup bg;

public Billing(){
super("Nakasero Hospital Managment System [ Billing Maintance Module]");
l1=new JLabel("Name");
l2=new JLabel("Phone Number");
l3=new JLabel("Street");
l4=new JLabel("City");
l5=new JLabel("Address");
l6=new JLabel("Gender");
lPhoto=new JLabel();
lPhoto.setIcon(new ImageIcon("image2.png"));
lN=new JLabel("Billing Maintenance Module");
lN.setFont(new Font("Lucida Handwriting",Font.PLAIN,16));
lN.setForeground(Color.RED);
JPanel p3=new JPanel();
p3.add(lPhoto);
p3.add(lN);
text1=new JTextField(20);
text2=new JTextField(20);
text3=new JTextField(20);
text4=new JTextField(20);
area=new JTextArea(5,10);
pane=new JScrollPane(area);
b1=new JButton("Add");
b2=new JButton("Update");
b3=new JButton("First");
b4=new JButton("Last");
b5=new JButton("Next");
b6=new JButton("Previous");

r1=new JRadioButton("Male",false);
r2=new JRadioButton("Female",false);
bg=new ButtonGroup();
bg.add(r1);
bg.add(r2);
p=new JPanel();
p1=new JPanel(new GridLayout(5,2));
p2=new JPanel();

p4=new JPanel();
Border border1 = BorderFactory.createTitledBorder("Employee Details");
p1.setBorder(border1);
p1.add(l1);
p1.add(text1);
p1.add(l2);
p1.add(text2);
p1.add(l3);
p1.add(text3);
p1.add(l4);
p1.add(text4);
p1.add(l5);
p1.add(pane);

Border border2 = BorderFactory.createTitledBorder("Gender");
p2.setBorder(border2);
p2.add(l6);
p2.add(r1);
p2.add(r2);
p4.add(b1);
p4.add(b2);
p4.add(b3);
p4.add(b4);
p4.add(b5);
p4.add(b6);
p.add(p3);
p.add(p1);
p.add(p2);
p.add(p4);
add(p);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(600,400);
}
public static void main(String[] args) {
new Billing();
}
}

Thanks

Ads









Related Tutorials/Questions & Answers:
java
java  diff bt core java and java
java
java  what is java
Advertisements
Java
Java   Whether Java is pure object oriented Language
java
java  different between java & core java
java
java  explain technologies are used in java now days and structure java
java
java   why iterator in java if we for loop
JAVA
JAVA  how the name came for java language as "JAVA
java
java  what is java reflection
java
java  is java open source
java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
java
java  write a java program using filenotfoundexception
Java
Java  how to draw class diagrams in java
java
java   difference between class and interface
java
java  why multiple inheritance is not possible in java
java
java  explain object oriented concept in java
java
java  is java purely object oriented language
Java
Java   Whether Java is Programming Language or it is SOftware
java
java  what are JAVA applications development tools
java
java  how use java method
java
java  send me java interview questions
java
java  write a program in java to acess the email
java
java  Write a java code to print "ABABBABCABABBA
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  give a simple example for inheritance in java
java
java  give a simple example for inheritance in java
Java
Java  how to do java in command prompt
java
java  Does java allows multiline comments
Tutorials   
Java Spring Hibernate Struts Training ClassNotFoundException HttpRequestInterceptor java.lang.noclassdeffounderror: org/apache/http/httprequest noclassdeffounderror: org/apache/http/client/methods/httpurirequest java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java

Ads

 
Advertisement null

Ads