- 전체
- JAVA 일반
- JAVA 수학
- JAVA 그래픽
- JAVA 자료구조
- JAVA 인공지능
- JAVA 인터넷
- Java Framework
- Java GUI (AWT,SWING,SWT,JFACE)
- SWT and RCP (web RAP/RWT)[eclipse], EMF
Java GUI (AWT,SWING,SWT,JFACE) Show a tool tip inside a rectangle : ToolTip « SWT « Java Tutorial
2015.08.22 22:04
Show a tool tip inside a rectangle : ToolTip « SWT « Java Tutorial
/******************************************************************************* * Copyright (c) 2000, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ //package org.eclipse.swt.snippets; /* * Tool Tips example snippet: show a tool tip inside a rectangle * * For a list of all SWT example snippets see * http://www.eclipse.org/swt/snippets/ */ import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; public class ToolTipRectangle { public static void main(String[] args) { Display display = new Display(); final Color[] colors = { display.getSystemColor(SWT.COLOR_RED), display.getSystemColor(SWT.COLOR_GREEN), display.getSystemColor(SWT.COLOR_BLUE), }; final Rectangle[] rects = { new Rectangle(10, 10, 30, 30), new Rectangle(20, 45, 25, 35), new Rectangle(80, 80, 10, 10), }; final Shell shell = new Shell(display); Listener mouseListener = new Listener() { public void handleEvent(Event event) { switch (event.type) { case SWT.MouseEnter: case SWT.MouseMove: for (int i = 0; i < rects.length; i++) { if (rects[i].contains(event.x, event.y)) { String text = "ToolTip " + i; if (!(text.equals(shell.getToolTipText()))) { shell.setToolTipText("ToolTip " + i); } return; } } shell.setToolTipText(null); break; } } }; shell.addListener(SWT.MouseMove, mouseListener); shell.addListener(SWT.MouseEnter, mouseListener); shell.addListener(SWT.Paint, new Listener() { public void handleEvent(Event event) { GC gc = event.gc; for (int i = 0; i < rects.length; i++) { gc.setBackground(colors[i]); gc.fillRectangle(rects[i]); gc.drawRectangle(rects[i]); } } }); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
[출처] http://www.java2s.com/Tutorial/Java/0280__SWT/Showatooltipinsidearectangle.htm
본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
댓글 0
번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
---|---|---|---|---|
17 | 스프링(Spring) 프레임워크 기본 개념 강좌 (6) - Dynamic Proxy | 졸리운_곰 | 2017.10.02 | 71 |
16 | 스프링(Spring) 프레임워크 기본 개념 강좌 (5) - AOP Proxy | 졸리운_곰 | 2017.10.02 | 158 |
15 | 스프링(Spring) 프레임워크 기본 개념 강좌 (4) - AOP | 졸리운_곰 | 2017.10.02 | 109 |
14 | 스프링(Spring) 프레임워크 기본 개념 강좌 (3) - IoC | 졸리운_곰 | 2017.10.02 | 114 |
13 | 스프링(Spring) 프레임워크 기본 개념 강좌 (2) - 주요 구성 요소 & DI | 졸리운_곰 | 2017.10.02 | 107 |
12 | 스프링(Spring) 프레임워크 기본 개념 강좌 (1) - 스프링 이해하기 | 졸리운_곰 | 2017.10.02 | 290 |
11 | Spring - IoC & DI | 졸리운_곰 | 2017.10.02 | 64 |
10 | MyBatis 기본 - selectList | 졸리운_곰 | 2016.06.07 | 292 |
9 | Mybatis ResultMap 그리고 select | 졸리운_곰 | 2016.06.07 | 267 |
8 | Cliche Command-Line Shell | 졸리운_곰 | 2015.07.12 | 570 |
7 | [스프링] 스프링 Java 어노테이션 | 졸리운_곰 | 2014.06.11 | 758 |
6 | [스프링] 스프링 MVC | 졸리운_곰 | 2014.06.11 | 324 |
5 | [스프링] 어노테이션 | 졸리운_곰 | 2014.06.11 | 848 |
4 | [Spring] @Autowired 와 Java Spring | 졸리운_곰 | 2014.01.29 | 1158 |
3 | [Spring] 내가 Spring을 사랑하는 다섯 가지 이유 | 가을의 곰을... | 2013.12.22 | 834 |
2 | [Spring] VO 객체의 복사 | 가을의 곰을... | 2013.11.26 | 4123 |
1 | [Spring] Spring MVC Basics | 가을의 곰을... | 2013.10.09 | 795 |