compilation error
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class BLayout implements ActionListener
{
JFrame f ;
JPanel jp;
JButton b[];
CardLayout cl;
BLayout(String s)
{
jp = new JPanel();
cl = new CardLayout();
jp.setLayout(cl);
f = new JFrame("Swing");
b = new JButton[20];
String s1[] = {"north","south","east","west","center"};
String x[] = {BorderLayout.NORTH,BorderLayout.SOUTH,BorderLayout.WEST,BorderLayout.CENTER};
for(int i = 0 ; i<b.length;i++)
{
b[i] = new JButton(s1[i]);
b[i].addActionListener(this);
jp.add(b[i],x[i]);
f.add(jp);
f.setLayout(cl);
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setSize(400,400);
//f.pack
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
cl.next(jp);
}
public static void main(String ...s)
{
new BLayout("second frame");
new BLayout("second frame");
}
}
** compilation error on OUT OF BOUND ARRAY INDEX....
View Answers
August 4, 2010 at 1:36 PM
Hi Friend,
Try the following code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class BLayout implements ActionListener
{
JFrame f ;
JPanel jp;
JButton b[];
CardLayout cl;
BLayout(String s)
{
jp = new JPanel();
cl = new CardLayout();
jp.setLayout(cl);
f = new JFrame("Swing");
b = new JButton[5];
String s1[] = {"north","south","east","west","center"};
String x[] = {BorderLayout.NORTH,BorderLayout.SOUTH,BorderLayout.EAST,BorderLayout.WEST,BorderLayout.CENTER};
for(int i = 0 ; i<b.length;i++)
{
b[i] = new JButton(s1[i]);
b[i].addActionListener(this);
jp.add(b[i],x[i]);
}
f.add(jp);
f.setLayout(cl);
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setSize(400,400);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
cl.next(jp);
}
public static void main(String ...s)
{
new BLayout("second frame");
}
}
Thanks
Related Tutorials/Questions & Answers:
compilation errorcompilation error Hi my program below is not compiling,when I try to compile it i'm getting the
error message "tool completed with exit code 1".The loop has to be at the end of the program can you help me.
Blockquoteimport
java compilation error - Appletjava
compilation error I am getting
compilation error in the following code.:
public void paint(Graphics g)
{
switch(screen...;
}
}
Error is:
Illegal start of expression
Plz. find why am I getting this
error Advertisements
groovy compilation error - Framework]
[groovyc] 1
error
Compilation error:
Compilation Failed
how we can resolve...groovy
compilation error while i am running the grails application , i got the
error message like:
[groovyc
Webshpere compilation errorWebshpere
compilation error
I want clear result . Thank you
WSWS3166E:
Error: No client transport named 'http' found.
faultActor: null
faultDetail:
[10/5/10 13:19:40:937 EDT] 00000043 SystemOut O WSWS3166E:
Error jdbc compilation error - JDBCjdbc
compilation error java.lang.Exception: Problem in call_select
when i am executing the program i am getting the above
error. how can i resolve it? Hi friend,
plz specify in detail and send me code
java compilation error - Appletjava
compilation error hi friends
the following is the awt front design program
error, give me the replay
E:\ramesh>javac product.java
Note: product.java uses or overrides a deprecated API.
Note
java compilation error - Hibernatejava
compilation error hi
i am getting org.hibernate.exception.GenericJDBCException: Cannot open connection exception when runnig the code why this exception is coming
compilation error - Java Beginnerscompilation error i 'm not able to compile a program :
prblem is there is one package in which 2 class person & dog reside. both classes r public... in same package
Dog class is being compiled bt. Person is not compiled .
error compilation error - Java Beginnerscompilation error import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class BLayout implements ActionListener
{
JFrame f ;
JPanel jp;
JButton b[];
CardLayout cl;
BLayout(String s)
{
jp = new JPanel
compilation error - Java Beginnerscompilation error class s
{
public static void main(String ar[])
{
int j=0834... this program it is giving an
error as integer number is too large.why? and what
Compilation Error - StrutsCompilation Error description The server encountered an internal
error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Failed to load or instantiate TagExtraInfo class
Java Compilation error - SQLJava
Compilation error ava.lang.NullPointerException
at beanUtils.SaleHeaderUtility.getFullRemainPatientList(SaleHeaderUtility.java:754)
at forms.ProcessDialog.updatePatientBalances(ProcessDialog.java:119
compilation error - Java Beginnerscompilation error sir what is the
error inthis code
after executing the below code i got
java.lang.NoSuchMethodError: main
Exception in thread "main"
package org.array;
import java.io.*;
public class Employee
compilation error - Java Beginnerscompilation error Dear sir,
When i compile some pgms i am getting below error.what may be the reason?
"uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details." Hi Friend
java compilation error - Antjava
compilation error hi, i have a application in which i m reading from an xml file and then storing its values in database.but when i started using ant its main program is not running as it is unable to detect the jar file
java compilation error - Hibernatejava
compilation error hi, i have made an registration page whosevalues should be inserted into database. i have used hibernate and eclipse it is working fine. but when i make a war file and deploy it using ant and then run
compilation error - JSP-Servletcompilation error Hi sir, i'm using following code to upload an image to the database.I'm facing the following problem.
<%
String contentType = request.getContentType();
if ((contentType != null
java compilation error - JDBCjava
compilation error
/*
*Project:employee.java
*Date:April 04,2007.
*Purpose:To All Java Developers
**/
package employee;
import javax.swing.*;
import java.awt.*;
import javax.swing.border.
java compilation error - Java Beginnersjava
compilation error Sir Thanx for ur response for reading a doc file but when i tried to execute ur code
compilation error occurs,
it says --> org.apache.poi.hwpf package does not exist.
-->
java compilation error - Java Beginnersjava
compilation error HELLO SIR,I HAVE ASKED QUESTION AND I GOT REPLY FOR THAT ALSO BUT I AM GETING
COMPILATION ERROR UNCHECKED OR UNSAFE OPERATION PLZ RECTIFY THIS. HOW TO READ ELEMENTS FROM TWO ARRAYLIST
AND PRINT
Java Compilation error - Java BeginnersJava
Compilation error I got this
error while convert java to pdf...
Exception:java.lang.IndexOutOfBoundsException: reserve - incorrect column/size
can somebody told me how to handle this
error... Hi Friend
java compilation error - Java Beginnersjava
compilation error i have downloaded java software(version 6 update 12) from www.java.com. whenever i try to compile the program using javac command,
error message is displayed
javac is not recognized as an internal
Java Compilation error - Java BeginnersJava
Compilation error
i wrote a simple hello world program i get this
error every time please help
Exception in thread "main" java.lang.NullPointerException
Java compilation error - Java BeginnersJava
compilation error Hello I am having this problem while compiling
I create a file
the package is com.deitel.ch14;
the filename...\AccountRecord.java
I save AccountRecord.java in ch14
However I get an
error saying
java compilation error - Java Beginnersjava
compilation error Dear Sir ........
I was installed the java soft ware in PC by following your guidelines only,
after installing I'm... getting the
error like file not found : exxx.java(my file name is exx),
Ill
java compilation error - Java Beginnersjava
compilation error I need to know how to correct a compiler
error for my program to run. The
error I keep getting is unclosed string literal...
and this is when my compiler
error occurs. Let me know if you need any
java compilation error - Java Beginnersjava
compilation error i am going to type program and the
error is shaded one this one is giving
error please sole this one sir
import java.io....:"+ch);
}
}
Hi friend,
Having some
error in your code check
java compilation error - Java Beginnersjava
compilation error Hello,
I'm having problems with trying.... It's flagging two errors for this one code. The first
error says identifier expected and the next
error says invalid method declaration; return type required
java compilation error - Java Beginnersjava
compilation error i am going to type program and the
error is shaded one this one is giving
error please sole this one sir
import java.io....:"+ch);
}
}
Hi friend,
Having some
error in your code check
Compilation error in java - Java BeginnersCompilation error in java i have a properties file named "connecton.properties" which has details about database server connection.
when i load i... FileInputStream(f);
props.load(in);
but i got a
error the system could
java compilation error - Swing AWTjava
compilation error NestedPopupMenu n = new NestedPopupMenu();
getting
error as "local variable n is never read Hi dharani,
This is running code. I hope that this code will help you.
import java.util.
java compilation error - Java Beginnersjava
compilation error Hello madam/sir, i m a beginners in java. My problem is that i want to connect a login form to a frame containing 4 panels. how could i do it?Please help
compilation error in java - Java Beginnerscompilation error in java Here is the pgm usinf if-else statement.... For removing the
error you have to use the String type in place of char & your code will work without any
error java compilation error - Java Beginnersjava
compilation error 1)java code:
import java.awt.*;
import javax.swing.*;
public class ButtonsPanelApplet extends JApplet{
public void... ButtonPanelApplet does give me
error of "exception in thread main...."
Java compilation error - Java BeginnersJava
compilation error Hello,
i am getting an
error while running simple core java program on command prompt.java is installed on my pc. the
error is:
javac:file not found
usage:javac
Regards,
jyoti prakash
Java Compilation Error - Java BeginnersJava
Compilation Error
Actually Iam having a packaging. Whatever methods and the imported packages are used in the program are available... imported packages.
What ever
error iam getting is at the array usage. So, guide me
java compilation error - JSP-Servletjava
compilation error How to compile a java Program,If i am having jdk1.5 in webligic it support jdk1.4..When i put a .class file into WEB-INF/classes/Mybeans/Datacon.class it was given a error Hi friend
java compilation error - Java Beginnersjava
compilation error can not find symbol
sysbol:method println(int,int,int)
location: class java.io.PrintStream)
System.out.println(+a,+b,+c); Hi friend,
Please, specify in detail what's your problem
Java compilation error - Java BeginnersJava
compilation error hai,
now only i have started to work with java.I have been given a task as execute unix codes using eclipse.But i dont know the source codes.Please help me to start the program...
Regards,
R.Punitham
java compilation error - Java Beginnersjava
compilation error Hello,
I had recently sent an email...);
MY
ERROR FLAGS HERE public class DisplayImage extends Panel {
BufferedImage image;
public DisplayImage() {
try{
MY SECOND
ERROR FLAGS HERE
Java Compilation error - Java BeginnersJava
Compilation error import java.io.*;
import java.util....?
}
}
when i write [owner = check.resulAcc()throws IOException;]
get
error... the same
error..
can u help me solve this problm?please
Java Compilation error - Java BeginnersJava
Compilation error import java.io.*;
import java.util....
error there,..
[';' expected]
the semicolon i already put at the end like above,..but still the same
error..
can u help me solve this problm?please
: Java Compilation error. - Java Beginners: Java
Compilation error. what is the difference between static block and static method? Hi friend,
Static block will execute when ever execution starts, it
means this block executes first of all, where
Java Compilation Error - Java BeginnersJava
Compilation Error hi,
i'm chandrakanth.i got a dought regarding below program.
It generates
compilation error.but it executes and generates the out put.
i can't understand the reason.
please suggest me
Java Compilation and running error - RMIJava
Compilation and running
error The following set of programs... some problem and gives following on
compilation"java uses unchecked or unsafe...);
}
catch(Exception e)
{
System.out.println("
Error: " + e
java compilation error - Java Beginnersjava
compilation error Hello,
I sent a previous message regarding... can't run it
ProductInventoryVGUI
Uncaught
error fetching image... thats maybe why I'm getting that
error message. Is there a way I can find an image
java compilation error - Java Beginnersjava
compilation error how to set path and class path for java.. why is it necessary Hi Friend,
Classpath specifies the location of the user defined classes and the packages in a Java program for the Java Virtual
java compilation error - JSP-Servletjava
compilation error i have a field like name if name is not given then it should give an alert like name cannot be null, i want this type of validations. Hi uma,
I am sending you a link. This link will help