public abstract class JavaJVMConsole
extends javax.swing.JFrame
implements java.lang.Runnable, java.awt.event.ActionListener
This is done for cases when Eclipse and other processes want to launch a Java Process but have no visible console.
Example usage (from org.safs.selenium.utils.SeleniumServerRunner):
public class SeleniumServerRunner extends JavaJVMConsole{
public static void main(String[] args) {
String[] passArgs = new String[0];
SeleniumServerRunner console;
try{
console = new SeleniumServerRunner();
passArgs = processArgs(args); // -jar path/To/selenium-server-standalone.jar passed in args
Class aclass = Class.forName("org.openqa.grid.selenium.GridLauncher");
Method main = aclass.getMethod("main", String[].class);
main.invoke(null, new Object[]{passArgs});
}
catch(Throwable everything){ ...
javax.swing.JFrame.AccessibleJFramejava.awt.Window.AccessibleAWTWindow, java.awt.Window.Type| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_RMISERVER_CLASSNAME
'org.safs.selenium.rmi.server.SeleniumServer'
|
static boolean |
DEFAULT_SEARCH_MATCH_CASE |
protected javax.swing.JTextArea |
display
JTextArea containing the text data normally sent to System.out and System.err.
|
protected int |
keep_mode |
static int |
KEEP_MODE_FIFO
Limit the number of text lines kept and displayed to the numberOfRows in the textarea.
|
protected int |
lastFoundPosition
The position of the token found last time in the text area 'display'.
|
static java.lang.String |
MENU_EDIT |
static java.lang.String |
MENU_FILE |
static java.lang.String |
MENU_ITEM_CLEAR |
static java.lang.String |
MENU_ITEM_EXIT |
static java.lang.String |
MENU_ITEM_FIND |
static java.lang.String |
MENU_ITEM_FIND_NEXT |
static java.lang.String |
MENU_ITEM_FIND_PREVIOUS |
static java.lang.String |
MENU_ITEM_SAVE |
static java.lang.String |
MENU_SEARCH |
(package private) static java.lang.String |
nl |
protected int |
numberOfrows |
protected boolean |
outputToConsole
As the STANDARD out/err has been redirected to this JavaJVMConsole, we need a way to
get the 'execution message' on STANDARD out/err.
If outputToConsole is true, the 'execution message' will also be printed to STANDARD out/err. |
static java.lang.String |
PARAM_STATE
'-state' specifies the console window's state.
"-state MIN|MAX|NORMAL|MINIMIZE|MAXIMIZE" |
static int |
PAUSE_BEFORE_OUTPUT_READY
The default time (in milliseconds) to sleep before the out/err output-stream is ready
|
protected int |
pauseBeforeReady
This field represents the time (in milliseconds) to sleep before the out/err output-stream is ready.
The default value is 100 milliseconds. |
static java.lang.String |
PROPERTY_RMISERVER
'safs.rmi.server'
JVM command line: -Dsafs.rmi.server=org.safs.selenium.rmi.server.SeleniumServer |
protected boolean |
shutdown
Set this true to allow the monitoring thread to shutdown.
|
protected java.lang.String |
state
The console winodw's state to set.
|
static java.lang.String |
STATE_DEFAULT |
static java.lang.String |
STATE_MAX |
static java.lang.String |
STATE_MAXIMIZE |
static java.lang.String |
STATE_MIN |
static java.lang.String |
STATE_MINIMIZE |
static java.lang.String |
STATE_NORMAL |
protected java.lang.String |
token
The text to search in the text area 'display'.
|
protected javax.swing.JComboBox<java.lang.String> |
tokenCombobox
The combo-box for containing the search history in search dialog.
|
protected javax.swing.JCheckBox |
tokenMatchCaseCheckbox
The check-box to tell if the search is case sensitive in search dialog.
|
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabledCROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSORBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT| Modifier | Constructor and Description |
|---|---|
protected |
JavaJVMConsole() |
protected |
JavaJVMConsole(boolean outputToConsole) |
protected |
JavaJVMConsole(boolean outputToConsole,
java.lang.String state) |
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerformed(java.awt.event.ActionEvent event) |
static void |
addFile(java.io.File f)
Adds a File to the System runtime classpath.
Calls addURL(URL) |
static void |
addFile(java.lang.String s)
Adds a file to the System runtime classpath.
Calls addFile(File). |
static void |
addURL(java.net.URL u)
Adds the content pointed by the URL to the System runtime classpath.
|
static void |
clearHighLight(javax.swing.JTextArea display,
java.lang.Object tag)
Clear highlight in the text area.
|
protected javax.swing.JMenuItem |
createJMenuItem(java.lang.String name,
int mnemonicKeyIndex,
int accelerateKey,
int accelerateModifier)
Create menu item with mnemonic and accelerate key.
Add ActionListener for the menu item. |
protected void |
displayLine(java.lang.String message)
DO NOT USE.
|
int |
getPauseBeforeReady() |
static void |
highLight(javax.swing.JTextArea display,
int position,
int length)
Highlight some text in the text area.
|
protected boolean |
highlightInDispaly(boolean forwardSearch)
Find a token within Text Area 'display', if found then highlight it.
|
void |
init()
Initialize the console's UI elements.
Start a thread to redirect the stdout/stderr. This method MUST be called after calling the constructors. |
void |
maximize()
Maximize the console window.
|
void |
minimize()
Minimize the console window.
|
void |
restore()
Restore the console window to its normal size.
|
void |
run()
Continuously monitors the JVM out and err streams routing them to the local JFrame display.
|
static boolean |
search(javax.swing.text.Document document,
int position,
java.lang.String token,
boolean caseSensitive)
Search a token within a Document, return true if found.
|
void |
setPauseBeforeReady(int pauseBeforeReady) |
protected void |
setState(java.lang.String state)
Set the console window's state.
|
protected boolean |
showSearchDialog()
Show the dialog for searching token.
|
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, updateaddNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecoratedaddPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFrontadd, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleprotected javax.swing.JTextArea display
protected boolean shutdown
protected boolean outputToConsole
public static final int PAUSE_BEFORE_OUTPUT_READY
protected int pauseBeforeReady
public static final int KEEP_MODE_FIFO
protected int numberOfrows
protected int keep_mode
static final java.lang.String nl
public static final java.lang.String MENU_FILE
public static final java.lang.String MENU_ITEM_SAVE
public static final java.lang.String MENU_ITEM_EXIT
public static final java.lang.String MENU_EDIT
public static final java.lang.String MENU_ITEM_CLEAR
public static final java.lang.String MENU_SEARCH
public static final java.lang.String MENU_ITEM_FIND
public static final java.lang.String MENU_ITEM_FIND_NEXT
public static final java.lang.String MENU_ITEM_FIND_PREVIOUS
public static final boolean DEFAULT_SEARCH_MATCH_CASE
protected java.lang.String token
protected int lastFoundPosition
public static final java.lang.String PARAM_STATE
public static final java.lang.String STATE_MAX
public static final java.lang.String STATE_MAXIMIZE
public static final java.lang.String STATE_MIN
public static final java.lang.String STATE_MINIMIZE
public static final java.lang.String STATE_NORMAL
public static final java.lang.String STATE_DEFAULT
protected java.lang.String state
STATE_NORMAL.STATE_MAX or STATE_MIN.protected javax.swing.JComboBox<java.lang.String> tokenCombobox
protected javax.swing.JCheckBox tokenMatchCaseCheckbox
public static final java.lang.String PROPERTY_RMISERVER
public static final java.lang.String DEFAULT_RMISERVER_CLASSNAME
protected JavaJVMConsole()
protected JavaJVMConsole(boolean outputToConsole)
outputToConsole - boolean, if true the message will also be output to Standard out/err.protected JavaJVMConsole(boolean outputToConsole,
java.lang.String state)
outputToConsole - boolean, if true the message will also be output to Standard out/err.state - String, The console winodw's state to set. See state.public void init()
public void minimize()
public void restore()
public void maximize()
protected void setState(java.lang.String state)
state - String, the state to set. It could be "MAX", "MIN" or "NORMAL".protected javax.swing.JMenuItem createJMenuItem(java.lang.String name,
int mnemonicKeyIndex,
int accelerateKey,
int accelerateModifier)
name - String, the menu item's namemnemonicKeyIndex - int, the mnemonic key's index in the menu item's name.accelerateKey - int, the accelerate key.accelerateModifier - int, the accelerate modifier.
It could be 'ctrl', 'shift', 'alt' defined ActionEvent; 0 means no modifier.public void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed in interface java.awt.event.ActionListenerprotected boolean showSearchDialog()
protected boolean highlightInDispaly(boolean forwardSearch)
forwardSearch - boolean, search forward or backwardpublic static boolean search(javax.swing.text.Document document,
int position,
java.lang.String token,
boolean caseSensitive)
document - Document, within which to find a match.position - int, the start position to find a match.token - String, the token to match.caseSensitive - boolean, if true the token will be matched case sensitively.public static void highLight(javax.swing.JTextArea display,
int position,
int length)
display - JTextArea, the text area where to highlight some text.position - int, the beginning position to start the highlight.length - int, the length of text to highlight.public static void clearHighLight(javax.swing.JTextArea display,
java.lang.Object tag)
display - JTextArea, the text area where to highlight some text.tag - Object, the tag name of highlight to clear.public static void addFile(java.lang.String s)
throws java.io.IOException
s - a String fullpath pointing to the filejava.io.IOExceptionaddFile(File),
addURL(URL)public static void addFile(java.io.File f)
throws java.io.IOException
f - the file to be addedjava.io.IOExceptionaddFile(String),
addURL(URL)public static void addURL(java.net.URL u)
throws java.io.IOException
u - the URL pointing to the content to be addedjava.io.IOExceptionaddFile(String),
addFile(File)protected void displayLine(java.lang.String message)
Displays the message in the text area. A newline is added to the message so each is printed on a separate line. Limits the number of lines displayed to the last numberOfrows via KEEP_MODE_INFO as keep_mode. Right now, setting any other keep_mode value will retain and append ALL messages received without limiting the size displayed, or the amount of memory used.
message - public int getPauseBeforeReady()
run()public void setPauseBeforeReady(int pauseBeforeReady)
pauseBeforeReady - int, The time (in milliseconds) to sleep before the out/err output-stream is ready.run()public void run()
run in interface java.lang.RunnableCopyright © SAS Institute. All Rights Reserved.