swt

Changing labels in a JFace TreeViewer on node expansion/collapse

喜欢而已 提交于 2019-12-06 02:04:00
I have a TreeViewer where some nodes represent folders, so I wanted to show the icon of an open folder when the node is expanded and a closed folder when it is collapsed. Sounds easy, I just need to add a tree listener (the code is in Scala, but Java equivalent should be easy to imagine): val tree = new TreeViewer(contents) tree.addTreeListener(folderIconFixingListener) private def folderIconFixingListener = new ITreeViewerListener { def treeCollapsed(event: TreeExpansionEvent) { tree.update(event.getElement, null) } def treeExpanded(event: TreeExpansionEvent) { tree.update(event.getElement,

How to change SWT Tree plus/minus icons

安稳与你 提交于 2019-12-06 01:54:11
问题 I am working on a SWT Tree similar to the one here, however, I want to be able to show + signs in some cases instead of - for an expanded tree item. Is this possible ? If not, is there Windows API to have custom icons for the expanded/collapsed state of a tree item ? 回答1: The SWT Tree component makes use of native Tree widget if available, for example in case of Windows - it uses native widget while on Linux (depends on the UI engine being used), it may create custom tree on its own. On the

Swt combobox name/key pair

不问归期 提交于 2019-12-06 01:07:20
问题 I want to have the text say one thing, but have the value say another Text Key But it only takes a string for adding items. How do Java programmers typically store text/id pairs in comboboxes 回答1: Maybe you can use the setData(String key, Object value) method of the combobox to achive what you want. Example: Combo box = new Combo(parent, SWT.DROP_DOWN); String s = "Item 1"; box.add(s); box.setData(s, "Some other info or object here"); s = "Item 2"; box.add(s); box.setData(s, "This is item two

HTML Editor with Java and And webkit - SWT Browser

五迷三道 提交于 2019-12-05 22:51:12
问题 i want to add WYSIWYG HTML editor to my Java program. my idea is to do Something like this but not with python - with Java. i know about couple of options and their problems : HTMLEditorKit - not sophisticated enough. JWebpane - fairy tale. QtWebKit - not open source. JWebEngine - not open source. metaphaseeditor - to simple. The Lobo Project - not support the contenteditable attribute. JavaXPCOM - I don't Succeed to operate it on my mac OS X 10.6. Anyway, I just prefer not to use it because

SWT - Table Viewer - hiding columns and getting values from columns

孤者浪人 提交于 2019-12-05 21:49:44
I am trying to create an arraylist from the data in my table. I need to get the values from the visible columns, but I also need to get values from columns that are not visible in the table. Using SWT with a Table Viewer, I have no idea on how to not display columns in my table. I also have no idea on how to pull the data from the table by specifying column names. I have always used Swing, so I have always used a Table Model Class. In swing it is pretty simple to create the columns, hide them and get data from them. This is how I have done it in previous Swing projects. In my table model class

java SWT transparent composite background

限于喜欢 提交于 2019-12-05 21:07:18
i have composite object Composite composite = new Composite(shell, SWT.NONE); composite.setBounds(new Rectangle(10,10,100,100); How do i make this composite to have transparent background? I will need to have widgets(non transparent) placed in this composite... That not possible to create a Composite with transparent background. You can use a Shell with a transparent background (see example ), and put widgets inside it. 来源: https://stackoverflow.com/questions/9542524/java-swt-transparent-composite-background

SWT label size is not correctly updated

无人久伴 提交于 2019-12-05 19:56:38
I'm new in Java/SWT. I'm experiencing some troubles using a SWT label . When I update the text on the label, its size is not correctly updated (the label is cut, respecting the original size). However, if I perform a very small resize in my dialog, the size is updated correctly. Basically, I create the label with a default text and then, when I load data I update the label with the real text, that is bigger than the original one. I tried calling label.update() and label.redraw() without luck. Try to call parent.layout() , where parent is the Composite which contains your label. Also see

Items decorations in a TreeViewer

一个人想着一个人 提交于 2019-12-05 17:23:13
I have the following problem: I'm preparing an editor in Eclipse and one of the tab contains TreeViewer to show items in the tree. Each item has a name and a value, which is editable. The problem I need to indicate to user that value is incorrect (e.g. exceeds a given range). My idea is to decorate incorrect cells with a warning or error icon which will be shown also after editing is complete. Does anybody have an idea how to decorate items in the tree? I was experimenting with ControlDecoration class but without success. Thanks in advance, Marcin PS. I'm limited to Eclipse 3.4 There are two

SWT composite - redraw problem

一个人想着一个人 提交于 2019-12-05 16:38:44
问题 I have a composite element, that initially has a Label. Now I call dispose on the it (the label) and create another label in the same container (composite elm), but I don't see the new text. It brings me to question how do I enable redraw on the composite, so that the new label (or any other component I might create) will render in place of the old one. Here is the code I have (separated into a unit test for redraw a composite) private Label createLabel( Composite parent) { Label label = new

How to keep SWT menu open after user clicks menu item?

偶尔善良 提交于 2019-12-05 16:03:40
I have an Eclipse RCP / SWT application with a Menu of Check Box Menu Items. I would like to be able to check/uncheck multiple items before clicking elsewhere to close the menu. However, the default SWT behavior is to close the menu after a single click. I have implemented the following very hacked solution which works, but is certainly not elegant and probably won't work properly on all platforms or under all circumstances. So I'm very interested in a simpler technique if one exists. The following code should compile and run inside eclipse right out of the box (apologies for the length, its