|
Re: How to repair canvas? [message #534136 is a reply to message #534089] |
Tue, 18 May 2010 08:19 |
Vijay Raj Messages: 608 Registered: July 2009 |
Senior Member |
|
|
You can refresh the canvas by calling redraw and update....
but if you want to update that specific area then you need to know the exact bounds and use redraw(int x, int y, int width, int height, boolean all)
but the question is why is it not repainting itself when the combo collapses?
How are you painting the canvas??
---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
|
|
|
|
Re: How to repair canvas? [message #534321 is a reply to message #534313] |
Tue, 18 May 2010 16:13 |
Vijay Raj Messages: 608 Registered: July 2009 |
Senior Member |
|
|
How come this snippet works
or can you reproduce it in this
package org.eclipse.gef.examples.shapes;
//Send questions, comments, bug reports, etc. to the authors:
//Rob Warner (rwarner@interspatial.com)
//Robert Harris (rbrt_harris@yahoo.com)
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
/**
* This class demonstrates a Canvas
*/
public class SimpleCanvas {
/**
* Runs the application
*/
public void run() {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Canvas Example");
createContents(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
/**
* Creates the main window's contents
*
* @param shell the main window
*/
private void createContents(Shell shell) {
shell.setLayout(new GridLayout());
// Create a button on the canvas
Combo combo = new Combo(shell, SWT.PUSH);
//combo.setBounds(10, 10, 300, 40);
combo.setItems(new String[]{"ONE","TWO","FOUR","FIVE"});
combo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// Create a canvas
Canvas canvas = new Canvas(shell, SWT.BORDER);
canvas.setLayoutData(new GridData(GridData.FILL_BOTH));
// Create a paint handler for the canvas
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
// Do some drawing
Rectangle rect = ((Canvas) e.widget).getClientArea();
e.gc.setBackground(e.display.getSystemColor(SWT.COLOR_RED));
e.gc.fillRectangle(rect);
}
});
}
/**
* The application entry point
*
* @param args the command line arguments
*/
public static void main(String[] args) {
new SimpleCanvas().run();
}
}
---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
|
|
|
|
Powered by
FUDForum. Page generated in 0.03348 seconds