no problem with the jdk package im using..
prob lang is it wont run if the apps server and database resides in one single linux box...
no problem with the jdk package im using..
prob lang is it wont run if the apps server and database resides in one single linux box...
wat if naa sa linux imong appserver ug db then access it from other pc? mo work or dli?
wnt work bro..Originally Posted by M@rv|n
mu work diay, but throwing some errors...
Does anyone know of a free java API in the net for Printing, making hardcopy. I don't want to use Crystal Report, is there a free option?
^^^ naa, mura JasperReports ang name... its opensourced...
Thanks, I'll check out Jasper Reports
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class TextFileOpen extends JFrame implements ActionListener{
public static final int width = 400;
public static final int height = 300;
JTextArea textArea;
JTextField tfFilename;
public TextFileOpen(){
JPanel North;
JPanel South;
setTitle("TextFileOpen");
setSize(width,height);
addWindowListener(new WindowTerminator());
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
contentPane.setBackground(Color.GRAY);
JLabel fileName = new JLabel("File Name:");
tfFilename = new JTextField(10);
JButton open = new JButton("Open");
// open.setBackground(Color.RED);
open.addActionListener(this);
JButton delete = new JButton("Delete");
//delete.setBackground(Color.RED);
delete.addActionListener(this);
North = new JPanel();
North.setLayout(new FlowLayout());
North.add(fileName);
North.add(tfFilename);
North.add(open);
North.add(delete);
contentPane.add(North,BorderLayout.NORTH);
textArea = new JTextArea(10,30);
South = new JPanel();
South.setLayout(new FlowLayout());
South.add(textArea);
contentPane.add(South,BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent e){
String command = e.getActionCommand();
if(e.getSource() instanceof JButton){
if("Open".equals(command)){
String filename = tfFilename.getText();
try{
BufferedReader inputStream = null;
inputStream = new BufferedReader(new FileReader(filename));
String line = null;
line = inputStream.readLine();
textArea.setText(line);
textArea.getText();
line = inputStream.readLine();
textArea.setText(line);
textArea.getText();
inputStream.close();
}catch(FileNotFoundException ex){
textArea.setText("Error Opening the file!! ");
}
catch(IOException exe){
textArea.setText("Error reading from file!!");
}
}
if("Delete".equals(command)){
textArea.setText("");
}
}
}
public static void main(String[] args){
TextFileOpen r = new TextFileOpen();
r.setVisible(true);
}
}
naa lang unta koy i konsulta ninyo mga maayo ug java bah!! kani nga program kay naggamit ug filehandling!!, now, ang problema nako! kay dli mo display ang iyang content sa source nga akong gi open! ang mo display ra kay ang last sentence sa txtfile! ngano mana?? can u pls. help me about this problem!! i think ang problema jud ani nga program kay kanang gi bold nako nga part sa program! can u help me about this!? tanx..!!
if("Open".equals(command)){
String filename = tfFilename.getText();
try{
BufferedReader inputStream = null;
inputStream = new BufferedReader(new FileReader(filename));
String line = null;
line = inputStream.readLine();
textArea.setText(line);
textArea.getText(); // Useless man ni
line = inputStream.readLine();
textArea.setText(line); // Automatic mo-puli ni siya
textArea.getText(); // Same. Useless sad ni
inputStream.close();
}catch(FileNotFoundException ex){
textArea.setText("Error Opening the file!! ");
}
catch(IOException exe){
textArea.setText("Error reading from file!!");
}
}
[br]Posted on: September 04, 2006, 04:01:36 PM_________________________________________________
@jerx d great: Try lang ni siya bai. Dili gani mo-work aw. Dili gyud gyud heheh..
if("Open".equals(command)){
String filename = tfFilename.getText();
try{
BufferedReader inputStream = null;
inputStream = new BufferedReader(new FileReader(filename));
String tmpStr = "";
if (inputStream != null) {
while((line = inputStream.readLine()) != null) {
tmpStr += (line + "\n");
}
textArea.setText(tmpStr);
}
inputStream.close();
}catch(FileNotFoundException ex){
textArea.setText("Error Opening the file!! ");
}
catch(IOException exe){
textArea.setText("Error reading from file!!");
}
}
I think it is better to use append method not setText
textArea.append("the message to be appended");
Similar Threads |
|