- 전체
- JAVA 일반
- JAVA 수학
- JAVA 그래픽
- JAVA 자료구조
- JAVA 인공지능
- JAVA 인터넷
- Java Framework
- Java GUI (AWT,SWING,SWT,JFACE)
- SWT and RCP (web RAP/RWT)[eclipse], EMF
[SWT, Java] Make Tooltip by Text Widget, Java SWT Text 위젯으로 툴팁생성
2015.08.22 21:57
[SWT, Java] Make Tooltip by Text Widget, Java SWT Text 위젯으로 툴팁생성
/* * Tooltip example snippet: create a balloon tooltip for a tray item * * For a list of all SWT example snippets see * http://www.eclipse.org/swt/snippets/ * * @since 3.2 */ import org.eclipse.swt.SWT; import org.eclipse.swt.events.FocusEvent; import org.eclipse.swt.events.FocusListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.ToolTip; public class TextFieldTooltip { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout(SWT.VERTICAL)); final ToolTip tip = new ToolTip(shell, SWT.BALLOON); tip.setMessage("Here is a message for the user. When the message is too long it wraps. I should say something cool but nothing comes to my mind."); Text tfTooltip = new Text(shell, SWT.BORDER); tfTooltip.setText("sample text field"); tfTooltip.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { tip.setVisible(false); } @Override public void focusGained(FocusEvent e) { Text actionWidget = (Text) e.widget; Point loc = actionWidget.toDisplay(actionWidget.getLocation()); tip.setLocation(loc.x + actionWidget.getSize().x - actionWidget.getBorderWidth(), loc.y); tip.setVisible(true); } }); Text tfNext = new Text(shell, SWT.BORDER); tfNext.setText("TF without tooltip"); shell.setBounds(50, 50, 300, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
[출처] http://stackoverflow.com/questions/8517739/how-to-create-a-balloon-tool-tip-for-text-box-in-swt
본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.

