Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > a simple JButton and some output text on file. Doesn't work...

Reply
Thread Tools

a simple JButton and some output text on file. Doesn't work...

 
 
Bici
Guest
Posts: n/a
 
      07-30-2007
Here's the code for a little program (APPLET). I tried to run it but
when i click on the button to print my thing... well, nothing happens
and then when i check the file there is nothing on it. What to do?

Here's the function:

public void ScrivisuFile(String percorsouno) {


try {
FileOutputStream file = new FileOutputStream(percorsouno);
PrintStream Output = new PrintStream(file);

Output.println("ma tu scrivi?");

}

catch (IOException e) {
System.out.println("Errore: " + e);
System.exit(1);
}
}

**************************************************
and here is when i actually call the function
************************************************** **

btBut1 = new JButton( "save" );
gbcPanel0.gridx = 0;
gbcPanel0.gridy = 3;
gbcPanel0.gridwidth = 1;
gbcPanel0.gridheight = 1;
gbcPanel0.fill = GridBagConstraints.NONE;
gbcPanel0.weightx = 0;
gbcPanel0.weighty = 0;
gbcPanel0.anchor = GridBagConstraints.EAST;
gbcPanel0.insets = new Insets( 0,2,5,5 );
gbPanel0.setConstraints( btBut1, gbcPanel0 );
//AZIONE?
btBut1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
ScrivisuFile("./bandiere/testouno.txt");
}
});
pnPanel0.add( btBut1 );


********************************************

And the strange thing is that when i click on the "save" button the
button itself "freezes" (the background colour changes without getting
back to normal until the curson is set away from the button itself...
Any idea?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
vertical BoxLayout, JLabel, and JButton and alignment Duane Evenson Java 5 09-27-2007 07:33 PM
JButton with Mouseover and sound kifissia Java 0 08-22-2006 02:41 PM
can JButton text span a line? Cloud Burst Java 3 12-15-2003 02:51 PM
Jbutton and text kevinc Java 5 11-26-2003 10:40 PM
JButton borders in JToolBars with XP look and feel Brian J. Sayatovic Java 1 08-13-2003 12:04 PM



Advertisments