Results 1 to 4 of 4
Thread: Log file trouble
- 04-03-2011, 04:54 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 19
- Rep Power
- 0
Log file trouble
hello guys,
i have made a .log file:
when i run a programme in output window shows this directory of logFileJava Code:public class Start { public static void main(String[] args) { //Zápis do logu String logFile = System.getProperty("java.io.tmpdir") + "adventure.log"; System.out.println(logFile); . . . GUI gui = new GUI(); gui.setVisible(true); }
and now i want to put a button into my GUI and when you click on it then will show up a dialog window with logFile....:C:\Users\VLASTN~1\AppData\Local\Temp\adventure.log
So, my question is: How to get the .log file which i created in main method and put it into Dialog window??....thanks for help....Java Code:private class OvladacLog implements ActionListener { private JDialog log; private JEditorPane logOutput; private String fileDirectory; @Override public void actionPerformed(ActionEvent e) { log = new JDialog(); log.setTitle("Log"); log.setModal(false); log.setVisible(true); logOutput = new JEditorPane(); logOutput.setEditable(false); log.add(new JScrollPane(logOutput)); URL fileDirectory = ???? try { logOutput.setPage(fileDirectory); } catch (IOException exception) { JOptionPane.showMessageDialog(null, "Log file not found", "Loading failed", JOptionPane.ERROR_MESSAGE); } log.setLocation(700, 200); log.setSize(400, 600); } }
- 04-03-2011, 05:01 PM #2
Senior Member
- Join Date
- Nov 2010
- Location
- Delhi
- Posts
- 135
- Blog Entries
- 1
- Rep Power
- 0
Read the contents of log file using BufferedReader and then add those contents to JTextArea.
See this code example for more help:
http://download.oracle.com/javase/tu...tAreaDemo.java
- 04-03-2011, 05:12 PM #3
Member
- Join Date
- Nov 2010
- Posts
- 19
- Rep Power
- 0
i dont understand it
-
Similar Threads
-
Having trouble opening and reading a txt file
By DBaskov in forum New To JavaReplies: 14Last Post: 01-29-2011, 02:55 AM -
Trouble drawing image from file picked by JFileChooser
By I = new NewToJava() in forum New To JavaReplies: 6Last Post: 12-26-2010, 03:54 PM -
Trouble with Try Catch blocks and file reading.
By theBurgh22 in forum New To JavaReplies: 2Last Post: 11-30-2010, 01:11 AM -
Having trouble reading external txt file to an array
By Metastar in forum New To JavaReplies: 18Last Post: 07-21-2010, 11:29 PM -
[SOLVED] Trouble with Scanner FileInputStream not finding the file
By miss.meli in forum New To JavaReplies: 0Last Post: 12-01-2008, 09:50 PM


LinkBack URL
About LinkBacks


Bookmarks