com.joctopus.ui.console
Class JOctopusConsole

java.lang.Object
  extended by com.joctopus.ui.console.JOctopusConsole
All Implemented Interfaces:
java.awt.event.ActionListener, java.lang.Runnable, java.util.EventListener

public class JOctopusConsole
extends java.lang.Object
implements java.awt.event.ActionListener, java.lang.Runnable

This class is a chatter console. A window for writing debug output.Its is multithreaded for operating asynchronously.

Since:
1.0

Field Summary
static int DISPOSE_ON_CLOSE
          The dispose-window default window close operation.
static int DO_NOTHING_ON_CLOSE
          The do-nothing default window close operation.
static int EXIT_ON_CLOSE
          The exit application default window close operation.
static int HIDE_ON_CLOSE
          The hide-window default window close operation
 
Constructor Summary
JOctopusConsole()
          Default constructor for initializing UI itself in constructor.
JOctopusConsole(int mode)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void clearConsole()
          clears the consoles text.
 void createAndShowGUI()
          starts the console thread
 javax.swing.JButton getBtnClear()
           
 javax.swing.JButton getBtnSave()
           
 java.awt.Font getFontBtn()
           
 java.awt.Font getFontConsole()
           
 javax.swing.JFrame getFrmConsole()
           
 javax.swing.JScrollPane getPaneConsole()
           
 javax.swing.JTextArea getTxtConsole()
           
 void hideConsole()
          hides the console
 void print(java.lang.Object obj)
          Writes output to console, similar to System.out.print the method is synchronized, to avoid multiple thread access at same time
 void println(java.lang.Object obj)
          Writes output to console, similar to System.out.println, and the method is synchronized, to avoid multiple thread access at same time
 void run()
           
 void scrollToEnd()
          scrolls the consoles scrollbar to end, by setting the caret position to max-length of textareas content
 void scrollToPosition(int position)
          scrolls the consoles scrollbar at custom position
 void setBtnClear(javax.swing.JButton btnClear)
           
 void setBtnSave(javax.swing.JButton btnSave)
           
 void setFontBtn(java.awt.Font fontBtn)
           
 void setFontConsole(java.awt.Font fontConsole)
           
 void setFrmConsole(javax.swing.JFrame frmConsole)
           
 void setPaneConsole(javax.swing.JScrollPane paneConsole)
           
 void setTxtConsole(javax.swing.JTextArea txtConsole)
           
 void showConsole()
          pop ups the console,i.e makes it visible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HIDE_ON_CLOSE

public static int HIDE_ON_CLOSE
The hide-window default window close operation


DISPOSE_ON_CLOSE

public static int DISPOSE_ON_CLOSE
The dispose-window default window close operation.


EXIT_ON_CLOSE

public static int EXIT_ON_CLOSE
The exit application default window close operation. If a window has this set as the close operation and is closed in an applet, a SecurityException may be thrown. It is recommended you only use this in an application.


DO_NOTHING_ON_CLOSE

public static int DO_NOTHING_ON_CLOSE
The do-nothing default window close operation.

Constructor Detail

JOctopusConsole

public JOctopusConsole()
Default constructor for initializing UI itself in constructor.


JOctopusConsole

public JOctopusConsole(int mode)
Parameters:
mode - mode of chatter console can be one of the following HIDE_ON_CLOSE, DISPOSE_ON_CLOSE, EXIT_ON_CLOSE, DO_NOTHING_ON_CLOSE
Method Detail

getBtnClear

public javax.swing.JButton getBtnClear()
Returns:
clear button

setBtnClear

public void setBtnClear(javax.swing.JButton btnClear)
Parameters:
btnClear - set Clear button

getBtnSave

public javax.swing.JButton getBtnSave()
Returns:
SAVE button

setBtnSave

public void setBtnSave(javax.swing.JButton btnSave)
Parameters:
btnSave - SAVE button

getFontBtn

public java.awt.Font getFontBtn()
Returns:
Font for button.

setFontBtn

public void setFontBtn(java.awt.Font fontBtn)
Parameters:
fontBtn - Font for buttons(SAVE and CLEAR).

getFontConsole

public java.awt.Font getFontConsole()
Returns:
console's font, where output is written.Inshort JTextAreas font.

setFontConsole

public void setFontConsole(java.awt.Font fontConsole)
Parameters:
fontConsole - set console's font, where output is written.Inshort JTextAreas font.

getFrmConsole

public javax.swing.JFrame getFrmConsole()
Returns:
Console frame

setFrmConsole

public void setFrmConsole(javax.swing.JFrame frmConsole)
Parameters:
frmConsole - console frame.

getPaneConsole

public javax.swing.JScrollPane getPaneConsole()
Returns:
JScrollPane for console.

setPaneConsole

public void setPaneConsole(javax.swing.JScrollPane paneConsole)
Parameters:
paneConsole - Console's JScrollPane

getTxtConsole

public javax.swing.JTextArea getTxtConsole()
Returns:
area where output will be written, it is encapsulated by paneConsole(JScrollPane) object.

setTxtConsole

public void setTxtConsole(javax.swing.JTextArea txtConsole)
Parameters:
txtConsole - set console area for writing debug output.

println

public void println(java.lang.Object obj)
Writes output to console, similar to System.out.println, and the method is synchronized, to avoid multiple thread access at same time

Parameters:
obj -

print

public void print(java.lang.Object obj)
Writes output to console, similar to System.out.print the method is synchronized, to avoid multiple thread access at same time

Parameters:
obj -

clearConsole

public void clearConsole()
clears the consoles text.


showConsole

public void showConsole()
pop ups the console,i.e makes it visible


hideConsole

public void hideConsole()
hides the console


scrollToEnd

public void scrollToEnd()
scrolls the consoles scrollbar to end, by setting the caret position to max-length of textareas content


scrollToPosition

public void scrollToPosition(int position)
scrolls the consoles scrollbar at custom position

Parameters:
position -

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

run

public void run()
Specified by:
run in interface java.lang.Runnable

createAndShowGUI

public void createAndShowGUI()
starts the console thread