public class Canvas
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_HEIGHT |
static int |
DEFAULT_WIDTH |
Constructor and Description |
---|
Canvas()
Constructs and shows a canvas with size 800 x 600.
|
Canvas(int width,
int height)
Constructs and shows a canvas with specific width and height.
|
Modifier and Type | Method and Description |
---|---|
void |
add(CanvasObject canvasObject)
Adds a canvas object to the canvas at position (0, 0).
|
void |
add(CanvasObject canvasObject,
int x,
int y)
Adds a canvas object to the canvas at position (x, y).
|
void |
addMouseListener(java.awt.event.MouseListener listener)
Registers a java.awt.event.MouseMotionListener object to the canvas.
|
void |
addMouseMotionListener(java.awt.event.MouseMotionListener listener)
Registers a java.awt.event.MouseListener object to the canvas.
|
int |
getCanvasHeight()
Returns the height of the canvas.
|
int |
getCanvasWidth()
Returns the width of the canvas.
|
javax.swing.JPanel |
getPanel()
Gets the JPanel of the canvas.
|
void |
remove(CanvasObject canvasObject)
Removes a specific canvas object that is added to the canvas.
|
void |
removeAll()
Removes all canvas objects on the canvas.
|
void |
setComponentAtBottom(javax.swing.JComponent component)
Adds a JComponent at the bottom of the canvas.
|
void |
setComponentAtTop(javax.swing.JComponent component)
Adds a JComponent at the top of the canvas.
|
void |
setResizable(boolean isResizable)
Sets if the canvas is resizable.
|
public static final int DEFAULT_WIDTH
public static final int DEFAULT_HEIGHT
public Canvas()
public Canvas(int width, int height)
width
- The width of the canvas to be constructed.height
- The height of the canvas to be constructed.public int getCanvasWidth()
public int getCanvasHeight()
public void setResizable(boolean isResizable)
isResizable
- Flag indicating whether the canvas is resizable.public void add(CanvasObject canvasObject)
canvasObject
- The canvas object to be added (e.g. barcode, colorimage, text)public void add(CanvasObject canvasObject, int x, int y)
canvasObject
- The canvas object to be added (e.g. barcode, colorimage, text).x
- The x position of the canvas object.y
- The y position of the canvas object.public void setComponentAtTop(javax.swing.JComponent component)
component
- The JComponent to be added.public void setComponentAtBottom(javax.swing.JComponent component)
component
- The JComponent to be added.public void removeAll()
public void remove(CanvasObject canvasObject)
canvasObject
- The canvas object to be removed from the canvas.public void addMouseMotionListener(java.awt.event.MouseMotionListener listener)
listener
- the MouseListener object to be registered.public void addMouseListener(java.awt.event.MouseListener listener)
listener
- the MouseMotionListener object to be registered.public javax.swing.JPanel getPanel()