Results 1 to 1 of 1
-
Creating a caret (using an image) in SWT
Java Code:import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Caret; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class Snippet43 { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.open(); Caret caret = new Caret(shell, SWT.NONE); Color white = display.getSystemColor(SWT.COLOR_WHITE); Color black = display.getSystemColor(SWT.COLOR_BLACK); Image image = new Image(display, 20, 20); GC gc = new GC(image); gc.setBackground(black); gc.fillRectangle(0, 0, 20, 20); gc.setForeground(white); gc.drawLine(0, 0, 19, 19); gc.drawLine(19, 0, 0, 19); gc.dispose(); caret.setLocation(10, 10); caret.setImage(image); gc = new GC(shell); gc.drawImage(image, 10, 64); caret.setVisible(false); gc.drawString("Test", 12, 12); caret.setVisible(true); gc.dispose(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } image.dispose(); display.dispose(); } }"The sole cause of man’s unhappiness is that he does not know how to stay quietly in his room." - Blaise Pascal
Similar Threads
-
How to use TextLayout with Caret
By Java Tip in forum java.awtReplies: 0Last Post: 06-25-2008, 10:36 AM -
creating image using java
By mmahesh_mca in forum New To JavaReplies: 1Last Post: 04-26-2008, 11:23 PM -
Creating ZIP files
By Java Tip in forum Java TipReplies: 0Last Post: 03-03-2008, 05:14 PM -
Converting multiple banded image into single banded image... Image enhancement
By archanajathan in forum Advanced JavaReplies: 0Last Post: 01-08-2008, 05:29 PM -
creating an image button when using struts
By yuchuang in forum Web FrameworksReplies: 1Last Post: 05-03-2007, 04:48 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks