Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

arun iyer

Greenhorn
+ Follow
since Nov 29, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by arun iyer

hi,
I have put an animated GIF in a JLabel in the following manner.
ImageIcon ic1 = new ImageIcon("names.gif");
JLabel jl = new JLabel(ic1);
The Jlabel is placed on a Panel.
I have developed an application and I am showing the credits on an animated gif (names.gif).
I am setting the panel visibility on or off depending on the user action.
When the panel is set Visible again, the animated gif does not reload.
I would like to know the method by which the animated gif reloads so that it starts from first when the panel visibility is turned on.
I created a new instance of the ImageIcon everytime, the panel visibility is turned on, but in Vain........
I would be grateful, if you could kindly throw some light on the above matter.
Thanking you in advance,

Regards,
Arun Iyer
18 years ago
hi,
I have developed a package using JavaSound API. The software runs slow on my machine. Is there any software available to speed up the java execution time? The OS I am using is Windows. Is there any software available to directly convert the bytecode to windows specific environment?
Thanks in advance.
Arun Iyer
18 years ago
Hi,
I have made a quiz applet. I am trying to use the jdbc - odbc bridge to connect to my sql server
I get the ClassNotFoundException at Class.forname("jdbc dbc:hrms"); in Internet Explorer while it is working in Netscape.

I would be highly grateful, if u could help me write the Quiz results to my databse.
Arun Iyer
19 years ago
hi,
I have got a frame and a button on it. I am opening another frame from that. I am not able to set the menubar in the new frame.
I am setting the menubar in the following method:

JMenuItem menuItem = new JMenuItem("Do This");
JMenu menu = new JMenu("Global");
menu.add(menuItem);
JMenuBar menuBar = new JMenuBar();
menuBar.add(menu);
setJMenuBar(menuBar);
Wanted help at the earliest.

Arun Iyer
19 years ago
hi,
I am printing the jtable in the following method. It prints fine but I am not able to print a graph which i have plotted on the getcontentpane(). I would be grateful, if u could kindly throw some light on the matter.

if (ae.getSource()==test)
{
PrinterJob pj=PrinterJob.getPrinterJob();
pj.setPrintable(tides1.this);
pj.printDialog();
try{
pj.print();
}catch (Exception PrintException) {}
}
public int print(Graphics g, PageFormat pageFormat,
int pageIndex) throws PrinterException {
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.black);
int fontHeight=g2.getFontMetrics().getHeight();
int fontDesent=g2.getFontMetrics().getDescent();
//leave room for page number
double pageHeight =
pageFormat.getImageableHeight()-fontHeight;
double pageWidth = pageFormat.getImageableWidth();
double tableWidth =
(double) jt.getColumnModel(
).getTotalColumnWidth();
double scale = 1;
if (tableWidth >= pageWidth) {
scale = pageWidth / tableWidth;
}
double headerHeightOnPage=
jt.getTableHeader().getHeight()*scale;
double tableWidthOnPage=tableWidth*scale;
double oneRowHeight=(jt.getRowHeight()+
jt.getRowMargin())*scale;
int numRowsOnAPage=
(int)((pageHeight-headerHeightOnPage)/oneRowHeight);
double pageHeightForTable=oneRowHeight*numRowsOnAPage;
int totalNumPages= (int)Math.ceil((
(double)jt.getRowCount())/numRowsOnAPage);
if(pageIndex>=totalNumPages) {
return NO_SUCH_PAGE;
}
g2.translate(pageFormat.getImageableX(),
pageFormat.getImageableY());
g2.drawString("Page: "+(pageIndex+1),(int)pageWidth/2-35,
(int)(pageHeight+fontHeight-fontDesent));//bottom center
g2.translate(0f,headerHeightOnPage);
g2.translate(0f,-pageIndex*pageHeightForTable);
//TODO this next line treats the last page as a full page
g2.setClip(0, (int)(pageHeightForTable*pageIndex),(int)
Math.ceil(tableWidthOnPage),
(int) Math.ceil(pageHeightForTable));
g2.scale(scale,scale);
jt.paint(g2);
g2.scale(1/scale,1/scale);
g2.translate(0f,pageIndex*pageHeightForTable);
g2.translate(0f, -headerHeightOnPage);
g2.setClip(0, 0,(int) Math.ceil(tableWidthOnPage),
(int)Math.ceil(headerHeightOnPage));
g2.scale(scale,scale);
jt.getTableHeader().paint(g2);//paint header at top
return Printable.PAGE_EXISTS;
}
19 years ago
hi,
I used a keylistener in my piano applet. the problem is that when the user keeps and key pressed, the event gets fired again and again. Is there any way, by which I can stop that...
For example: if the user has pressed q and has not released the key..... he should get only one q and not qqqqqqqqqqqq........
i.e. the event should get fired only once irrespective of the time the user has pressed the key without releasing it.

Expecting help in this regard......
Arun Iyer
19 years ago
Hi,
I would like to use flash files (.fla & .swf) in applet or frames
How can I do it? Is it possible?
Thanking you,
Arun Iyer
19 years ago
hi,
i have witten an applet which executes an exe file fromt he client's hard disk. It works fine with appletviewer but does not work in a browser. I would like to know how and in what manner i can allow the applet to run the exe file. I would like to know how to make certificate, if required.

arun iyer
19 years ago
hi,
how can i use .pfr fonts in java applets?(bitstream fonts)

arun iyer
19 years ago
hi,
can i use pfr fonts in java?
if yes, how?
arun
19 years ago
hi,
i wanted to know if i can use jhsearch in Javahelp as an applet?
arun
19 years ago
hi,
thanks for the reply......
expecting a reply soon.
code is as follows:
----------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.applet.*;
public class admin extends Applet implements ActionListener
{
Font theFont = new Font("TimesRoman",Font.BOLD,14);
Label l0,l1,l2,l3,l5,l6,l7;
TextField t0,t1,t2,t3,t5,t6,t7;
String s0,s1,s2,s3,s5;
static String s6,s7;
Button b1,b2;
int i=0;
public void entry (){
System.out.println("Inside Entry");
Label l0 = new Label("Number of Rounds (1-10) :");
Label l1 = new Label("Questions per Round (1-36) :");
Label l2 = new Label("Time (In Minutes) :");
Label l3 = new Label("Review Allowed (True/False):");
Label l5 = new Label("Minimum Score required :");
TextField t0 = new TextField(10);
TextField t1 = new TextField(10);
TextField t2 = new TextField(10);
TextField t3 = new TextField("True",10);
TextField t5 = new TextField(10);
Button b1 = new Button("Save");
setLayout(new GridLayout (11,2));
add(l0);
add(t0);
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(l5);
add(t5);
add(b1);
b1.addActionListener(this);
repaint();
}
public void init()
{
setBackground(Color.white);
l6 = new Label("Login");
l7 = new Label("Password");
t0 = new TextField(10);
t1 = new TextField(10);
t2 = new TextField(10);
t3 = new TextField("True",10);
t5 = new TextField(10);
t6 = new TextField(10);
t7 = new TextField(10);
b1 = new Button("Save");
b2 = new Button("Enter");

//setLayout(new GridLayout (3,2));
add(l6);
add(t6);
add(l7);
add(t7);
t7.setEchoChar('*');
add(b2);
b2.addActionListener(this);
}

public void actionPerformed(ActionEvent e) {
if (e.getSource() ==b2)
{
s6 = t6.getText();
s7 = t7.getText();
System.out.println("Hello");
if (s6.equals("admin") && s7.equals("webaccess"))
{
remove(l6);
remove(t6);
remove(l7);
remove(t7);
remove(b2);
removeAll();
entry();
}
}

if (e.getSource() ==b1)
{
s1 =t1.getText();
s2 =t2.getText();
s3 =t3.getText();
s5 =t5.getText();
s0 =t0.getText();
try{


FileWriter f0 = new FileWriter("c:\\jr\\numofround.txt", false);

f0.write(s0);
f0.close();
FileWriter f1 = new FileWriter("c:\\jr\\questround.txt", false);

f1.write(s1);
f1.close();

FileWriter f2 = new FileWriter("c:\\jr\\time.txt", false);

int num = Integer.parseInt(s2);
num=num-1;
f2.write(String.valueOf(num));
f2.close();

FileWriter f3 = new FileWriter("c:\\jr\\review.txt", false);
if (s3.equals("true") | | s3.equals("True"))
{
f3.write("1");
f3.close();
}
else {
f3.write("2");
f3.close();
}

FileWriter f5 = new FileWriter("c:\\jr\\tscore.txt", false);

f5.write(s5);
f5.close();

remove(l0);
remove(t0);
remove(l1);
remove(t1);
remove(l2);
remove(t2);
remove(l3);
remove(t3);
remove(l5);
remove(t5);
remove(b1);
i=1;
repaint();
} catch (Exception e1) {}
}
}

public void paint(Graphics g) {
if (i==1)
{
g.setColor(Color.blue);
g.setFont(theFont);
g.drawString("Results Saved",20,20);
}

}
}
19 years ago
hi,
i add a button b1 with action listener to my applet. in the action performed method, i remove the button b1 and add another button b2.
in applet viewer, on clicking the button b1, b1 gets removed and b2 appears. WHEREAS in broswer(i checked with IE 5.5) on clicking b1.. b1 gets removed but b2 does not get added.
pls help me on this topic regarding the execution of the same code in browser and the appletviewer.

arun iyer
19 years ago
hi,
i wrote the following applet. When i click on enter button, all the components are removed but the new textfields and buttons are not added. i would like to know how to remove the components and add new ones.
----------------
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.applet.*;
public class admin extends Applet implements ActionListener
{
Font theFont = new Font("TimesRoman",Font.BOLD,14);
Label l0,l1,l2,l3,l5,l6,l7;
TextField t0,t1,t2,t3,t5,t6,t7;
String s0,s1,s2,s3,s5;
static String s6,s7;
Button b1,b2;
int i=0;
public void entry (){
System.out.println("Inside Entry");
setLayout(new GridLayout (11,2));
add(l0);
add(t0);
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(t3);
add(l5);
add(t5);
add(b1);
b1.addActionListener(this);
repaint();
}
public void init()
{
setBackground(Color.white);
l0 = new Label("Number of Rounds (1-10) :");
l1 = new Label("Questions per Round (1-36) :");
l2 = new Label("Time (In Minutes) :");
l3 = new Label("Review Allowed (True/False):");
l5 = new Label("Minimum Score required :");
l6 = new Label("Login");
l7 = new Label("Password");
t0 = new TextField(10);
t1 = new TextField(10);
t2 = new TextField(10);
t3 = new TextField("True",10);
t5 = new TextField(10);
t6 = new TextField(10);
t7 = new TextField(10);
b1 = new Button("Save");
b2 = new Button("Enter");

//setLayout(new GridLayout (3,2));
add(l6);
add(t6);
add(l7);
add(t7);
t7.setEchoChar('*');
add(b2);
b2.addActionListener(this);
}

public void actionPerformed(ActionEvent e) {
if (e.getSource() ==b2)
{
s6 = t6.getText();
s7 = t7.getText();
System.out.println("Hello");
if (s6.equals("admin") && s7.equals("webaccess"))
{
remove(l6);
remove(t6);
remove(l7);
remove(t7);
remove(b2);
entry();
}
}

if (e.getSource() ==b1)
{
s1 =t1.getText();
s2 =t2.getText();
s3 =t3.getText();
s5 =t5.getText();
s0 =t0.getText();
try{


FileWriter f0 = new FileWriter("c:\\jr\\numofround.txt", false);

f0.write(s0);
f0.close();
FileWriter f1 = new FileWriter("c:\\jr\\questround.txt", false);

f1.write(s1);
f1.close();

FileWriter f2 = new FileWriter("c:\\jr\\time.txt", false);

int num = Integer.parseInt(s2);
num=num-1;
f2.write(String.valueOf(num));
f2.close();

FileWriter f3 = new FileWriter("c:\\jr\\review.txt", false);
if (s3=="true" | | s3=="True")
{
f3.write("1");
f3.close();
}
else {
f3.write("2");
f3.close();
}

FileWriter f5 = new FileWriter("c:\\jr\\tscore.txt", false);

f5.write(s5);
f5.close();

remove(l0);
remove(t0);
remove(l1);
remove(t1);
remove(l2);
remove(t2);
remove(l3);
remove(t3);
remove(l5);
remove(t5);
remove(b1);
i=1;
repaint();
} catch (Exception e1) {}
}
}

public void paint(Graphics g) {
if (i==1)
{
g.setColor(Color.blue);
g.setFont(theFont);
g.drawString("Results Saved",20,20);
}

}
}
19 years ago
hi,
i have stored certain data in a text file.
I use string tokenizer and get the data in the form of a string. How can i convert string to an integer.
arun
19 years ago