Java Drawing DrawTop

Language

JP  US  UK

 

Main

 H. Jyounishi, Tokyo Japan
 

Frame (Index), No frame                 version:0.3(latest)  

Summary: This page describes the main class of this application.

Relevant major classes of Java SE: java.awt.*, javax.swing.*

Classes on this page:DrawMain, ObjectTable

1. Class DrawMain public class DrawMain extends JFrame

Method

Description

main

public static void main(String[] args)

Sets the following.

DrawMain drawMain=new DrawMain();
ObjectTable.main=drawMain;
drawMain.setFrame();

setFrame

void setFrame()

=>Figure1

∙ Sets window listeners to this object.

DrawWindowAdapter adaptor=new DrawWindowAdapter(this);
this.addWindowListener(adaptor);
this.addWindowFocusListener(adaptor);
this.addWindowStateListener(adaptor);

∙ Creates Command object.

new Command();

∙ Creates the MenuUtil object.

MenuUtil menuUtil=new MenuUtil();
ObjectTable.menuUtil=menuUtil;

∙ Gets the GlassPane object.

JPanel glassPane=(JPanel)this.getGlassPane();
Currently, the GlassPaneis used in the GuidancePanelclass.

∙ Create the TabbedPane, StatusPanel object and sets them to the DrawMain(JFrame).

Sets the BorderLayout to the contentPane of the DrawMain(JFrame) and add the TabbedPane and StatusPanel to the contentPane.
The StatusPanel(Figure1) is managed in the same way.
contentPane.add(tabbedPane, BorderLayout.NORTH);
contentPane.add(statusPanel, BorderLayout.SOUTH);

∙ Adds "Home", "Shape" and "Help" tabs to the TabbedPane.

∙ Creates the pop up menu.

PopupPulldownMenu.createShapePopupMenu();
PopupPulldownMenu.createGroupPopupMenu();
PopupPulldownMenu.createDrawPanelPopupMenu();

∙ Creates the DrawPanel and ListenerPanel objects.

The DrawPanel object is used to draw shapes, text and so on. The ListenerPanel is the extended class of the DrawPanel.
The KeyListener, InputMethodListener, InputMethodRequests interfaces are implemented on it for text input and the MouseListener, MouseMotionListener are also implemented on it for drawing operation.

∙ Creates the JScrollPane object and adds it to the contentPane of the DrawMain(JFrame)..

contentPane.add(scrollPane, BorderLayout.CENTER);
Sets the JViewport to the JScrollPane and sets a view(viewPanel) to the JViewport.
JPanel viewPanel=ViewUtil.getFramePanel(drawPanel);
viewport.setView(viewPanel);
scrollPane.setViewport(viewport);

∙ viewPanel

The viewPanel is the gray part in Figure1. Without the viewPanel , the DrawPanel is placed at the left end of the viewport.

∙ Creates the following major objects and registers them to the ObjectTable.

ContainerManager, UndoDrawManager, MousePositionLS, SelectionLS, FileIo, Edit, ViewUtil, ExecCommand, ExecPopupMenu etc.


Figure1 Configulation of the DrawMain(JFrame)



2. Class DrawWindowAdapter return=>page top

class DrawWindowAdapter extends WindowAdapter


This class is implemented to avoid the problem of overwriting the drawings on the JTabbedPane, the tool bar and other components when the view is scrolled. I don't know the reason, however repainting the window (or frame) seems to avoid this problem.

Figure2 The problem of overwriting


Field

Description

window

Window window

The Window (DrawMain) object.


Method

Description

Constructor

DrawWindowAdapter(Window window)

windowActivated public void windowActivated(WindowEvent e)
Calls the repaint method of the Window.
windowGainedFocus public void windowGainedFocus(WindowEvent e)
Calls the repaint method of the Window.
windowLostFocus public void windowLostFocus(WindowEvent e)
Calls the repaint method of the Window.


2. Class ObjectTable return=>page top

Registers the frequently referred objects to the static fields of this object.

Field

Description

main

protected static DrawMain main

The DrawMain object.

tabbedPane

protected static JTabbedPane tabbedPane

The JTabbedPane object.

glassPane

protected static JPanel glassPane

The GlassPane object.

drawPanel

protected static DrawPanel drawPanel

The DrawPanel object.

listenerPanel

protected static ListenerPanel listenerPanel

ListenerPanel object.

guidancePanel

protected static GuidancePanel guidancePanel

GuidancePanel object.

statusPanel

protected static StatusPanel statusPanel

StatusPanel object.

scrollPane

protected static JScrollPane scrollPane

JScrollPane object.

viewport

protected static JViewport viewport

JViewport object.

pageManager

public static PageManager pageManager

PageManager object.

containerManager

protected static ContainerManager containerManager

ContainerManager object.

execCommand

protected static ExecCommand execCommand

ExecCommand object.

execPopupMenu

protected static ExecPopupMenu execPopupMenu

ExecPopupMenu object.

selectionLS

protected static SelectionLS selectionLS

SelectionLS object.

mousePositionLS

protected static MousePositionLS mousePositionLS

MousePositionLS object.

menuUtil

protected static MenuUtil menuUtil

MenuUtil object.

undoDrawManager

public static UndoDrawManager undoDrawManager

UndoDrawManager object.

fileIo

protected static FileIo fileIo

FileIo object.

edit

protected static Edit edit

Edit object.

viewUtil

protected static ViewUtil viewUtil

ViewUtil object.


Field

Description

getXXXX

public static XXXX getXXXX()

Returns the XXXX object.



Copyright (c) 2009-2013
All other trademarks are property of their respective owners.