Results 1 to 7 of 7
Thread: output to applet
- 06-11-2010, 09:49 AM #1
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
output to applet
i am new to java.
i have written the following code and now want the output to be printed on an applet..i have used jxl in this.
import java.io.*;
import java.util.Locale;
import jxl.*;
import jxl.read.biff.BiffException;
public class Test
{
String st="i have to abate this";
String[] arr=new String[5];
public Test()
{ System.out.println("primary sentence is: ");
arr=st.split(" ");
for(int i=0;i<arr.length;i++)
System.out.print(arr[i]+" ");
System.out.println("\n");
}
public void init(String filePath)
{
FileInputStream fs = null;
try
{
fs = new FileInputStream(new File(filePath));
contentReading(fs);
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
fs.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
//Returns the Headings used inside the excel sheet
public void getHeadingFromXlsFile(Sheet sheet)
{
int columnCount = sheet.getColumns();
for (int i = 0; i < columnCount; i++)
{
System.out.println(sheet.getCell(i, 0).getContents());
}
}
public void contentReading(InputStream fileInputStream)
{
WorkbookSettings ws = null;
Workbook workbook = null;
Sheet s = null;
Cell rowData[] = null;
int rowCount = 0;
int columnCount = 0;
DateCell dc = null;
int totalSheet = 0;
Cell c=null;
String[][] str=new String[arr.length][];
try {
ws = new WorkbookSettings();
ws.setLocale(new Locale("en", "EN"));
workbook = Workbook.getWorkbook(fileInputStream, ws);
//Getting Default Sheet i.e. 0
s = workbook.getSheet(0);
//total number of rows
rowCount = s.getRows();
// System.out.println("Total Rows inside Sheet:" + rowCount);
//Total Total No Of Columns in Sheet
columnCount = s.getColumns();
// System.out.println("Total Column inside Sheet:" + columnCount);
//Reading Individual Row Content
for (int i = 0; i < arr.length; i++)
{ // System.out.println("mkd 86");
c=s.findCell(arr[i]);
if(c==null)
{ str[i]=new String[1];
str[i][0]=arr[i];
}
//System.out.println(arr[i]);
else
{// System.out.println("mkd 89");
rowData=s.getRow(c.getRow());
str[i]=new String[rowData.length-1];
for(int j=1;j<rowData.length;j++)
{ str[i][j-1]=rowData[j].getContents();
}
//System.out.println(c.getContents());
}
}
System.out.println("possible combinations are: ");
String[] str1=new String[5];
//make all possible combination of collected data
for(int i1=0;i1<str[0].length;i1++)
{ str1[0]=str[0][i1];
for(int i2=0;i2<str[1].length;i2++)
{ str1[1]=str[1][i2];
for(int i3=0;i3<str[2].length;i3++)
{ str1[2]=str[2][i3];
for(int i4=0;i4<str[3].length;i4++)
{ str1[3]=str[3][i4];
for(int i5=0;i5<str[4].length;i5++)
{ str1[4]=str[4][i5];
for(int k=0;k<str1.length;k++)
System.out.print(str1[k]+" ");
System.out.println("\n");
} } } } }
workbook.close();
} catch (IOException e)
{
e.printStackTrace();
}
catch (BiffException e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
try
{
Test tst = new Test();
tst.init("C:\\shivi\\test.xls");
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
the test file contains few thousaand words with their meaning in the consecutive cell of the file. like for the sentence provided here " i have to abate this"..
'abate' has two meanings both in the Test.xls file..
and similarly 'this' has only one meaning..
hoping to get a solution.
thanks for ur help! :)
- 06-11-2010, 04:38 PM #2
Can you describe the problem more? What does the program do that is wrong?want the output to be printed on an applet
What should it do that it doesn't do?
What does applet have to do with this code? It has a main() method and does not extend an applet class.
- 06-11-2010, 07:21 PM #3
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
Sir,
i need to create a GUI for the program. Thats why i need to print the output on an applet.
I know that Applet does not contain main(). i havent tried the program on applet, providing u with what u can call a raw code.
I am not able to understand which applet method to override. how to proceed on..
- 06-11-2010, 07:43 PM #4
not sure what that means?Thats why i need to print the output on an applet.
Applets are special programs that load into a browser. They use GUI like any other program would use GUI. They have special methods that browsers use to communicate with them.
Why do you want to use an applet?
For a program to have GUI it needs a window like you can get with a JFrame. Then you add some panels and in those panels you add the components that you need. To control where the components and panels are located in the containers they are in, you use a layout manager.
- 06-11-2010, 07:50 PM #5
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
Ok.
actually its my college project and my head asked me to present the output in a better way.
and i want to use applet because i know a little about it. i have no clue about JFrames.
- 06-11-2010, 08:20 PM #6
Applets extend panels. So any GUI building that works in an Applet will work with other panels. No magic about using JFrames. There must be thousands of simple programs on the forums that show how to use a JFrame. Build your panel and add it to the JFrame.
- 06-11-2010, 08:23 PM #7
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Need help with output
By cedric11 in forum New To JavaReplies: 4Last Post: 11-30-2009, 01:09 PM -
Pass parameter from one applet to another applet in different webpages...
By anubhavranjan in forum Java AppletsReplies: 2Last Post: 09-29-2009, 03:33 PM -
Java, output string, getting correct output? HELP!
By computerboyo in forum New To JavaReplies: 2Last Post: 02-25-2009, 11:44 PM -
Calling another applet on click of button in one applet
By niteshwar.bhardwaj in forum Java 2DReplies: 1Last Post: 02-19-2009, 12:54 PM -
Applet, To center text and To open I engage in a dialog in an Applet
By Marcus in forum Java AppletsReplies: 4Last Post: 06-08-2007, 06:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks