netbeans gui panels don't stay where they are supposed to be - netbeans

I am trying to create a java gui using netbeans but the swing panels that look great in the IDE are all over the place after I compile and run the program. what can be causing this?

NetBeans' Matisse GUI editor is not a WYSIWYG editor, even though it pretends to be one. The fundamental reason is the philosophy of Swing layout managers; there's no way to position the components to absolute positions, because the size of components vary with the platform as well as with the "look and feel".
In practice, it's best to code the layout by hand, using some third-party layout manager. MiGLayout is one of the best and amazingly easy to use.

Related

In an eclipse plugin: How can I programmatically highlight lines of codes in the java editor?

I am trying to develop an eclipse plugin that does some documentation check on java code and highlights some lines of code in the editor.
To achieve my goal, I DON'T want to create a new editor in eclipse, I simply want to extend the default java editor to draw a line under (or highlight) the methods that do not satisfy some set of predetermined requirements.
Do I need to create a PresentationReconciler? If yes, how do I make the JDT or workbench use my reconciler.
I have never done plugin development and this is my first attempt.
Several starting points for you:
Annotations are an UI feature of JFace's text editor that allows you to visually mark some places in an open editor.
Markers are a Workbench feature, more high-level. They are generic "objects that may be associated with Workbench resources", and they can display in several places: in text editors (as annotations) or in the Problems view, for example.
Depending on what you want to do, you would plug in your plug-in into extension points related to either of those.
The Eclipse Java editor is located in the org.eclipse.jdt.internal.ui.javaeditor.JavaEditor package.
The "internal" in the package name means that the Eclipse development team can change how the Java editor works with new revisions.
Try this help page: Juno Help on syntax highlighting
At the end of the page, it describes how to dynamically add a PresentationReconciler, which is used for syntax highlighting. See if that fits the problem that you want to solve.
I assume you already have a plugin project.
In your plugin.xml, open the tab Extensions, click Add..., search for org.eclipse.ui.editors, then you should see a template named Editor, which will produce a simple xml editor to experiment and play with. Also, you will be able to see the needed structure to define a custom editor.
Hope this helps...
I don't know if you still have a need for this, but you are going to want to use Annotations to keep track of what parts of the editor you need to highlight.
For actually doing the graphical effect of highlighting, you could do syntax highlighting via a PresentationReconciler, but I have no experience with that.
We used a technique we borrowed from http://editbox.sourceforge.net/, replacing the background image of the editor Shell. Its open source, so check it out. (Our code might also help -- its at https://github.com/IDE4edu/EclipseEditorOverlay )

Eclipse Swing designer

Is there a plugin for Eclipse that can help with designing the Swing GUI like in Netbeans?
The WindowBuilder is too simple and primitive. For example:
it only allows me to place a component in one of the 5 pre-defined regions
The GUI designer in Netbeans is much, much more powerful
There is a port of the Mantisse GUI Editor from NetBeans to Eclipse.
http://marketplace.eclipse.org/content/swing-gui-designer
There actually is several options to how control components are placed in the window. In the Design tab of your class under the Layouts dropdown there are several options. For example there is an Absolute option which allows x and y coordinate precision in placing and moving components.

windowbuilder jface actions in swt designer

I'm writing a JFace standalone application using eclipse/windowbuilder pro. Windowbuilder is a nice tool to work with, but I'm having trouble finding information on the organizational structure of such an application.
Currently I'm extending the standard ApplicationWindow class (as is standard in windowbuilder examples) for the main window of my application and subclassing SWT composites for my 'sub windows' in the application. The problem I'm having is that I lose the ability to use JFace actions / databindings when I'm graphically building SWT Composite subclasses in windowbuilder. The palette for adding JFace actions is inaccessible when using SWT designer while subclassing standard SWT components. I've searched at length for how to add this palette to no avail (the standard method fails since this isn't a 'normal' palette that appears in the palette manager). I've also tried adding the JFace action component to my existing palette, but can't find documentation on how to add an abstract class (Action) to the palette. I know that I can write all the code I want by hand, but it defeats the purpose of using windowbuilder.
I'd really like to stick to the standard JFace viewer/action model, but I can't figure out which components I should be subclassing for my 'sub windows' in my app. I've tried subclassing the Window class directly but this doesn't yield access to windowbuilder's JFace Actions palette. I'm not sure under what conditions that palette is accessible (I've been iteratively removing and adding components to ApplicationWindow, I'm getting desperate). I have a few custom widgets that I'd gladly write JFace Viewers for if I could figure this out.
Any windowbuilder fans out there? Is subclassing SWT Composite a reasonable/standard way to go about making components of this application? What is the standard for writing apps that are more complicated than a single ApplicationWindow? I've searched high and low, but can only seem to find tutorials and examples that are a single application window -- nothing composite. I feel like I'm missing some key pieces of information with regard to the structure of more complicated JFace applications. I suppose my holy grail would be the JFace version of SWT Composite that would allow me access to JFace actions code generation through windowbuilder.
Any tips and/or reading material explaining standard JFace design for larger applications would be appreciated!
I've been working with WBPro for about 6 to 7 years now... I think we can have a conversation about your problem. I might not be able to answer your question completely, but I will do my best. So, first off, for your sub-windows you should use JFace Dialogs. You can create a template one from New>Other>WbPro>JFace>Dialog or just subclass it yourself. You can also use TitleAreaDialog which is cooler and has a Title Bar at the top just like all Eclipse Dialogs. These two classes are both within JFace and are available in WBPro.
You have the JFace widgets and viewers available in the Design Tab, but not the actions. But the reason for that is that Dialogs and sub-Windows do not have Toolbars or Menu bars, I think that's why they are not there in the palette, but if you have a Context Menu for one of your inner widgets, I think you should implement that yourself. I can dig a little deeper for you if you want, se tell me if there is still something to address.

Eclipse look & feel customization

I need to customize the look & feel of my RCP application.
I took a look at Eclipse Presentation API and I suppose it allows to customize everything in workbench except controls.
So is there any solution to customize controls?
I made some research work and implemented some ad-hoc SWT cunstomization using control canvas drawning. May be there are better solutions?
In Swing you can use Synth theme. It would be great if some 'skin' framework exists for SWT.
One way of customizing an RCP app is by using a plugin_customization.ini file. Like this:
Create a new file called "plugin_customization.ini" in the root of your project.
If you have not already done so, create a product configuration and define a Product.
In your plugin's manifest editor, on the "Extensions" tab, locate the "org.eclipse.core.runtime.products" extension, expand the node, right click on your product node and select "New > property" from the context menu.
Enter "preferenceCustomization" in the "name" field and "plugin_customization.ini" in the "value" field.
Select "File > Save" from the main menu.
You can then customize a lot of things simply by editing plugin_customization.ini file. For example, adding the following line
org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=false
will give you rounded tabs on your views and editors (similar to those that Eclipse IDE has) instead of the default ones.
You can find other constants that you can use in IWorkbenchPreferenceConstants javadoc.
Also, check out the Eclipse skins project, if you haven't already.
There is also the possibility to use CSS to change the look & feel of your app, but that is still in development and can be buggy
As for customizing the SWT controls themselves, the only way to do that (apart from small customizations such as changing the background colour of a control etc.) is by creating your own custom controls by extending Canvas or Composite, but you already know that. Keep in mind that the point of SWT is to use native controls, so if you desire the ability to completely customize your controls, perhaps using Swing would be a better option. However, if you're going to use Swing, it may be better to use another RCP entirely - namely, NetBeans RCP. I haven't tried it out yet, but I know that whereas Eclipse RCP uses SWT as a widget toolkit, NetBeans RCP relies on Swing, so that may save you from some headaches regarding compatibility problems and so on.
The new Eclipse 4 work contains plugins that allow the L&F to be customized using CSS. These plugins can be run in a 3.7 Eclipse environment. See Kai's blog for a presentation on the subject: http://www.toedter.com/blog/?p=477
The Eclipse 4 Styling Tutorial has a slide (p.66) on where to get an 3.7 based RCP example.

My subclipse colors don't work

This is probably a simple issue for some subclipse guru. My decorator colors don't work in eclipse. I'm guessing that some plugin I have is interfering with it somehow. I'm on the current public release of ganymede. Going to the fonts and colors option area lets me change the decorator text color, but I get no effect in the project explorer. Any ideas?
Are you using KDE on Linux? There is a known bug if you use the gtk-qt-engine to make GTK programs (like Eclipse) look more like KDE apps. If this gtk theming engine is active the text colors in views don't work. This is a common problem for mylyn users.
This is probably not important any more, but the decorator issue came down to using the correct view. The "project" view and the "file" view look extremely similar, but the decorators work correctly in one and not the other.