Total members 11894 |It is currently Sat Nov 23, 2024 3:17 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka



Go to page Previous  1, 2


Thank You




Author:

Can you please post GUILogger please.....



Author:

Code:



import java
.awt.Color;
import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultStyledDocument;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;
import javax.swing.text.StyledDocument;

/**
 *
 * @author Mohamed.Sami
 */
public class GUILogger {

    private static GUILogger logger = null;
    private static StyleContext context = new StyleContext();
    private static StyledDocument document = new DefaultStyledDocument(context);
    private static javax.swing.text.Style style = context.getStyle(StyleContext.DEFAULT_STYLE);
    private static final JTextPane textArea = new JTextPane(document);
    private static final JScrollPane TextAreaScroll = new JScrollPane(textArea, 
JScrollPane
.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    private static DataOutputStream dataOutputStream;
    private static final String filePath="./errorLog.txt";
    private static final File file=new File(filePath);

    private GUILogger() {
        textArea.setSize(400, 400);
        TextAreaScroll.setSize(400, 400);
        StyleConstants.setAlignment(style, StyleConstants.ALIGN_LEFT);
        StyleConstants.setFontSize(style, 10);
        StyleConstants.setSpaceAbove(style, 1);
        StyleConstants.setSpaceBelow(style, 1);
       
        
        if
(dataOutputStream==null){


        FileOutputStream fileOutputStream=null;
            try {
                fileOutputStream = new FileOutputStream(file, true);
                dataOutputStream = new DataOutputStream(fileOutputStream);
            } catch (FileNotFoundException ex) {
                Logger.getLogger(GUILogger.class.getName()).log(Level.SEVERE, null, ex);
            }
        
          
}
    }

    public static GUILogger getInstance() {
        if (logger == null) {
            logger = new GUILogger();
        }
        return logger;
    }
  public void clearArea() {
        try {
            document.remove(0, document.getLength());
        } catch (BadLocationException ex) {
            Logger.getLogger(GUILogger.class.getName()).log(Level.SEVERE, null, ex);
        }
        

    
}
    public void logInfo(String info) {

        try {

            document.insertString(document.getLength(), "\n" + new Date() + ": " + info, style);

        } catch (BadLocationException ex) {
            Logger.getLogger(GUILogger.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void logError(String error) {
        try {
            StyleConstants.setForeground(style, Color.red);
            document.insertString(document.getLength(), "\n" + new Date() + ": " + error, style);
            StyleConstants.setForeground(style, Color.black);
        } catch (BadLocationException ex) {
            Logger.getLogger(GUILogger.class.getName()).log(Level.SEVERE, null, ex);
        }



    }
    public void logGood(String good) {
        try {
            StyleConstants.setForeground(style, Color.GREEN.darker());
            document.insertString(document.getLength(), "\n" + new Date() + ": " + good, style);
            StyleConstants.setForeground(style, Color.black);
        } catch (BadLocationException ex) {
            Logger.getLogger(GUILogger.class.getName()).log(Level.SEVERE, null, ex);
        }



    }
    public void logToFile(String information){
        try {
          
            dataOutputStream
.writeUTF("\n Log Date:" + new Date() + ": " + information);
            dataOutputStream.flush();
        } catch (IOException ex) {
            ex.printStackTrace();
            logError("Failed To Log To System File"+filePath+" :Error"+ex);
            Logger.getLogger(GUILogger.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static GUILogger getLogger() {
        return logger;
    }

    public static void setLogger(GUILogger logger) {
        GUILogger.logger = logger;
    }

    public static JScrollPane getTextAreaScroll() {
        return TextAreaScroll;
    }

    public static JTextPane getTextArea() {
        return textArea;
    }

    
}
 



_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

i am getting this error


javax.mail.MessagingException: Connect failed;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:130)
at javax.mail.Service.connect(Service.java:236)
at javax.mail.Service.connect(Service.java:137)
at com.servingxml.app.consoleapp.ReadMailPOP.readAllMessages(ReadMailPOP.java:73)
at com.servingxml.app.consoleapp.ReadMailPOP.main(ReadMailPOP.java:288)



Author:
Post new topic Reply to topic  [ 14 posts ]  Go to page Previous  1, 2

  Related Posts  to : Read your gmail using Java code
 simple code to read properties in java     -  
 Read list of files in java I/O code     -  
 Read stream from URL using Java     -  
 Write and Read to File In Java Example     -  
 Read double values type from file in java     -  
 Algorithms code in java     -  
 GamePLay java code ( please help )     -  
 java code for chat     -  
 polyalphabetic cipher java code     -  
 apriori algorithm java code     -  



Topic Tags

Java Email






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com