Results 1 to 1 of 1
Thread: Zooming Canvas Area
- 02-04-2009, 09:35 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 2
- Rep Power
- 0
Zooming Canvas Area
HI am new to Java Swings. I opened a new internal frame with a canvas in it for drawing. I want to zoom the canvas. I mean i need to zoom the canvas even before i draw anything. Similar to photoshop. we create a new file with so and so pixel and we can zoom the new opened file upto around 1600%. i want similarly.. zoom my canvas with scroll bars.. how can i accomplish this..
the following code creates a new internal frame with a new canvas..
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.MouseWheelListener;
/**
*
* @author Raghavan
*/
public class MyInternalFrame extends javax.swing.JInternalFrame {
static int openFrameCount = 0;
static final int xOffset = 30, yOffset = 30;
static PaintCanvas canvas;
public MyInternalFrame(int h,int w) {
super(OpenNewBox.jTextField1.getText(),
true, //resizable
true, //closable
true, //maximizable
true);//iconifiable
canvas= new PaintCanvas();
Container content = this.getContentPane();
content.setLayout(new BorderLayout());
//canvas.setPreferredSize(new Dimension(w,h));
content.add(canvas, BorderLayout.CENTER);
//...Create the GUI and put it in the window...
//...Then set the window size or call pack...
setSize(w,h);
//Set the window's location.
setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
setBorder(javax.swing.BorderFactory.createEtchedBo rder(javax.swing.border.EtchedBorder.RAISED, null, new java.awt.Color(204, 204, 204)));
setAutoscrolls(true);
setDoubleBuffered(true);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 285, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
// Variables declaration - do not modify
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration
}
Similar Threads
-
Using a Canvas
By a_klasanov in forum CLDC and MIDPReplies: 3Last Post: 12-08-2008, 11:36 AM -
Help with canvas
By tankhardrive in forum New To JavaReplies: 13Last Post: 10-29-2008, 09:08 PM -
Canvas Example
By Java Tip in forum SWT TipsReplies: 0Last Post: 07-25-2008, 03:22 PM -
Using SWT Canvas
By Java Tip in forum Java TipReplies: 0Last Post: 01-08-2008, 10:06 AM
Bookmarks