Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

jplot
Class SimpleEditor  view SimpleEditor download SimpleEditor.java

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byjplot.SimpleEditor
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class SimpleEditor
extends javax.swing.JPanel

The class shows a frame which enables to look at and eventually edit a file, any type of file. Build in a JPanel, so someone can reuse the editor in another class.


Nested Class Summary
private  class SimpleEditor.DataFileFilter
           
(package private)  class SimpleEditor.FindPanel
           
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  SmallToggleButton b_bold
           
private  SmallToggleButton b_italic
           
private  java.awt.Color currentColor
           
private  java.awt.Font currentFont
           
private  java.io.File file
           
private  SimpleEditor.FindPanel findPanel
           
private  javax.swing.JComboBox fonts
           
private  javax.swing.JFrame frame
           
private  javax.swing.text.DefaultHighlighter.DefaultHighlightPainter g
           
private  boolean isEditable
           
private  java.awt.Dimension panelSize
           
private  javax.swing.JPanel parent
           
private  javax.swing.JScrollPane scrollpane
           
private  int size
           
private  javax.swing.JComboBox sizes
           
private  int style
           
private  java.lang.String text
           
private  javax.swing.JEditorPane textArea
           
private  boolean textChanged
           
private  javax.swing.JPanel thisPanel
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SimpleEditor(javax.swing.JPanel parent, java.lang.String title, boolean isEditable)
          Constructor, builds a simple editor/viewer with default dimensions.
SimpleEditor(javax.swing.JPanel parent, java.lang.String title, boolean isEditable, int width, int height)
          Principal constructor, builds the panel which includes the report as text.
 
Method Summary
private  void addButton(javax.swing.JToolBar toolbar, javax.swing.Action action, java.lang.String tip)
          Add a button of type SmallButton to the toolbar.
 void clear()
          Clears the current canvas
 void dispose()
          Disposes the frame.
private  void fileToString()
           
private  void find()
           
private  javax.swing.ImageIcon getImageIcon(javax.swing.JPanel parent, java.lang.String name)
           
 java.awt.Dimension getPreferredSize()
          Get the component's preferred size.
(package private)  javax.swing.JMenuBar makeMenuBar()
          Builds the menubar.
 void openFile()
          Saves the text after an edit to a new file.
private  void printFile()
           
private  void printText()
           
 void refresh(java.io.File f)
          Refreshes the text, updates with the content of the current outputfile.
 void refresh(java.lang.String s)
          Refreshes the text, updates with the content of the current viewer/editor.
 void save()
          Saves the text after an edit to the current file.
 void saveAs()
          Saves the text after an edit to a new file.
private  void setSelectedFont()
           
 void show(int x, int y, java.io.File f)
          Pops up a frame with the report printed in it.
 void show(int x, int y, java.lang.String t)
          Pops up a frame with the report printed in it.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

textArea

private javax.swing.JEditorPane textArea

file

private java.io.File file

frame

private javax.swing.JFrame frame

text

private java.lang.String text

fonts

private javax.swing.JComboBox fonts

sizes

private javax.swing.JComboBox sizes

size

private int size

style

private int style

currentFont

private java.awt.Font currentFont

currentColor

private java.awt.Color currentColor

b_bold

private SmallToggleButton b_bold

b_italic

private SmallToggleButton b_italic

scrollpane

private javax.swing.JScrollPane scrollpane

textChanged

private boolean textChanged

thisPanel

private javax.swing.JPanel thisPanel

parent

private javax.swing.JPanel parent

findPanel

private SimpleEditor.FindPanel findPanel

isEditable

private boolean isEditable

panelSize

private java.awt.Dimension panelSize

g

private final javax.swing.text.DefaultHighlighter.DefaultHighlightPainter g
Constructor Detail

SimpleEditor

public SimpleEditor(javax.swing.JPanel parent,
                    java.lang.String title,
                    boolean isEditable,
                    int width,
                    int height)
Principal constructor, builds the panel which includes the report as text.


SimpleEditor

public SimpleEditor(javax.swing.JPanel parent,
                    java.lang.String title,
                    boolean isEditable)
Constructor, builds a simple editor/viewer with default dimensions.

Method Detail

addButton

private void addButton(javax.swing.JToolBar toolbar,
                       javax.swing.Action action,
                       java.lang.String tip)
Add a button of type SmallButton to the toolbar. Done here to bypass a bug in jdk 1.4 which resets the border of a button to some default value when added to the toolbar.


getImageIcon

private javax.swing.ImageIcon getImageIcon(javax.swing.JPanel parent,
                                           java.lang.String name)

makeMenuBar

javax.swing.JMenuBar makeMenuBar()
Builds the menubar.


setSelectedFont

private void setSelectedFont()

fileToString

private void fileToString()

clear

public void clear()
Clears the current canvas


refresh

public void refresh(java.io.File f)
Refreshes the text, updates with the content of the current outputfile.


refresh

public void refresh(java.lang.String s)
Refreshes the text, updates with the content of the current viewer/editor.


save

public void save()
Saves the text after an edit to the current file.


saveAs

public void saveAs()
Saves the text after an edit to a new file.


openFile

public void openFile()
Saves the text after an edit to a new file.


dispose

public void dispose()
Disposes the frame. Prefer hide(), but then, show doesn't work with my current jdk (it pops the frame up iconified).


printText

private void printText()

printFile

private void printFile()

getPreferredSize

public java.awt.Dimension getPreferredSize()
Description copied from class: javax.swing.JComponent
Get the component's preferred size. If the JComponent.preferredSize>JComponent.preferredSize 55 property has been explicitly set, it is returned. If the JComponent.preferredSize>JComponent.preferredSize 55 property has not been set but the JComponent.ui>JComponent.ui 55 property has been, the result of ComponentUI.getPreferredSize(javax.swing.JComponent)>ComponentUI.getPreferredSize(javax.swing.JComponent) 55 is returned. If neither property has been set, the result of Container.getPreferredSize()>Container.getPreferredSize() 55 is returned.


show

public void show(int x,
                 int y,
                 java.io.File f)
Pops up a frame with the report printed in it.


show

public void show(int x,
                 int y,
                 java.lang.String t)
Pops up a frame with the report printed in it.


find

private void find()