Results 1 to 5 of 5
Thread: interface in swings
- 01-28-2009, 03:52 PM #1
Member
- Join Date
- Jan 2009
- Posts
- 4
- Rep Power
- 0
interface in swings
Thank you
i know interface concept but the interface is not working while it is used in swings .That is my doubt.
If i used in java its working. But in my program its throwing arrayindexoutofbounds exception.
I have quoted the important things in red please see this and clear my doubt
This is my where i am declaring a method which going to be called b using interface conceptimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.lang.*;
public class test extends JFrame implements ActionListener,iest
{
private static final long serialVersionUID = 1L;
JButton b,b1,b2,b3;
JLabel l[],l1,l3,l4,l5,l6,l7;
Font f,f1;
JTextField t[],t1[],t2[],t3[],t4[],t5[],t6;
Container c;
int row[],col[],i,col1[];
float m,k,z[] ;
float n,p,q,r,s;
int d;
int ver,hor;
JScrollPane bar;
public test(int a)
{
super("AREA OF THE POOJA ROOM");
b=new JButton("OK");
b.addActionListener(this);
b.setBounds(100, 500, 80, 30);
b1=new JButton("CLEAR DATA");
b1.addActionListener(this);
b1.setBounds(210, 500, 120, 30);
b2=new JButton("BACK");
b2.addActionListener(this);
b2.setBounds(340, 500, 80, 30);
f=new Font("CopperBlack",Font.BOLD,13);
f1=new Font("CopperBlack",Font.BOLD,11);
l1=new JLabel("LENGTH (in SFT)");
l1.setFont(f);
l3=new JLabel("BREADTH (in SFT)");
l3.setFont(f);
l4=new JLabel("AREA (in SFT)");
l4.setFont(f);
l5=new JLabel("FEET IN");
l5.setFont(f1);
l6=new JLabel("FEET IN");
l6.setFont(f1);
l7=new JLabel(" FEET");
l7.setFont(f1);
c = getContentPane();
c.setLayout(null);
c.setBackground(Color.lightGray);
c.setForeground(Color.black);
t=new JTextField[10];
l=new JLabel[10];
t1=new JTextField[10];
t2=new JTextField[10];
t3=new JTextField[10];
t4=new JTextField[10];
t6=new JTextField(10);
c.add(l1);
c.add(l4);
c.add(l3);
c.add(l5);
c.add(l6);
c.add(l7);
c.add(b);
c.add(b1);
c.add(b2);
l1.setBounds(320, 10, 130, 50);
l3.setBounds(450, 10, 130, 50);
l4.setBounds(580, 10, 100, 50);
l5.setBounds(345, 25, 100, 50);
l6.setBounds(475, 25, 100, 50);
l7.setBounds(605, 25, 100, 50);
int col=60;
int col1=60;
d=a;
for(i=1;i<=d;i++)
{
int row=40;
l[i] = new JLabel("ENTER THE LENGTH & BREADTH FOR POOJA ROOM "+i);
l[i].setBounds(row,col,350,30);
c.add(l[i]);
row=row+300;
t[i]=new JTextField();
c.add(t[i]);
t[i].setBounds(row,col1,30,30);
row=row+30;
t1[i]=new JTextField();
c.add(t1[i]);
t1[i].setBounds(row,col1,30,30);
row=row+100;
t2[i]=new JTextField();
c.add(t2[i]);
t2[i].setBounds(row,col1,30,30);
row=row+30;
t3[i]=new JTextField();
c.add(t3[i]);
t3[i].setBounds(row,col1,30,30);
row=row+100;
t4[i]=new JTextField();
c.add(t4[i]);
t4[i].setBounds(row,col1,70,30);
col=col+70;
col1=col1+70;
}
setSize(800, 800);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b)
{
for (int i = 1; i <=d; i++)
{
z=new float[10];
try
{
m= Integer.parseInt(t[i].getText());
n= Integer.parseInt(t1[i].getText());
n=n/12;
k=m+n;
p= Integer.parseInt(t2[i].getText());
q= Integer.parseInt(t3[i].getText());
q=q/12;
r=p+q;
s=k*r;
t4[i].setText(" "+s);
z[i]=s;
}
catch (Exception err)
{
System.out.println("test"+err);
}
}
}
if(ae.getSource()==b2)
{
new est2();
}
if(ae.getSource()==b1)
{
new est5(d,z);
}
}
public void pass()
{
System.out.println("test");
}}
This is my interface
public interface iest
{
void pass();
}
here i am calling pass method
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
public class iest1
{
public static void main(String args[])
{
iest obe = new test(' ');
obe.pass();
}
}
Once again thank you
-
This seems to be an unnecessary duplicate post of a currently active thread: Interface concept
I vote that we keep all responses in the other active thread and let this thread die a natural death.
- 01-28-2009, 08:52 PM #3
How about System.exit(1);
- 01-29-2009, 08:32 AM #4
Can you post the full exception error?
- 01-29-2009, 08:44 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
And use code tags also, hard to read such a long code.
Similar Threads
-
Drawing charts using swings
By ravindarjobs in forum New To JavaReplies: 19Last Post: 07-21-2009, 11:03 PM -
How to use multiple timer classes in swings
By theone3nu in forum AWT / SwingReplies: 12Last Post: 12-30-2008, 02:30 AM -
awt and swings
By masa in forum AWT / SwingReplies: 2Last Post: 11-24-2008, 07:09 AM -
Printing Tree Structure using Swings
By pradeep1_mca@yahoo.com in forum AWT / SwingReplies: 5Last Post: 08-30-2008, 01:54 PM -
java swings
By emperoraj in forum AWT / SwingReplies: 0Last Post: 03-26-2008, 11:50 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks