NetBeans look&feel same as resulting one - java

I am trying to find a java look&feel that can be used in NetBeans (I'm currently usign version 14) to have a "what you see is what you get" result
As I said here: netbeans design missing bold, I was using the Metal l&f, both in NetBeans (by launching it with the "--laf javax.swing.plaf.metal.MetalLookAndFeel" parameter) and in the code
But lately it doesn't work as it used to: in NetBeans the varoius graphical objects (labels etc...) have a "normal" font, but when i run the project, they have a bold font, which makes them larger and ruins their positioning. Thus I can't create a good graphical interface anymore, because I have lost the "what you see is what you get" effect
I have also tried different l&f, for example Nimbus. With it, I can solve my problem: NetBeans correctly shows the graphical objects as expected. But imho Nimbus has a big lack: non-editable obects (for example text fields) are showed identical as editable ones! (the Metal l&f instead makes a good work at this)
I'm searching for a l&f that can correctly be displayed by NetBeans, and that can differentiate between editable and non-editable objects. Can you point me out any?

Try com.sun.java.swing.plaf.windows.WindowsLookAndFeel.
You need not to put startup options in NetBeans, check look and feels Tools / Options / Apperance menu.
Another workaround would be making all non-editable widgets to be disabled - setEnabled(false).

Related

Can I change the JComboBox thumb style?

I am getting a strange discrepancy between the preview and actual running of my jar file with a combo box, and it seems to be a default in both of my laptops which are entirely different design. I included a simple example image (below). The combobox does have 36 entries and should only allow one selection - which is why I prefer to use this element type. My issue is a strange look of the combo box thumb (image on right) in comparison with the typical and expected look shown in the image on the right from viewing the Preview Design in NetBeans. See image
Scouring the internet I cannot find much that shows this discrepancy. Thank you.
This looks like a matter of "Look and Feel":
https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
The Preview Design is using a different default L&F than the environment where you're running the application.

Java: Dynamic Layout using Eclipse Windowbuilder

I'm working on a Java project (for those curious, it's a Rcon and Query client for Minecraft servers) and I'm trying to create a GUI. I'm using Eclipse Windowbuilder, and I'm trying to make the program window dynamic (in other words, when the window is resized, everything else moves and scales to fit), but none of the layouts seem to do that (which defeats the purpose of the layout, doesn't it). It's worth mentioning that I'm putting four groups on the screen, which will contain other things and should take up all available space. I would put the code here, but there's nothing besides the default application framework generated by Eclipse. So, what layout do I use for dynamic resizing and such? Or am I missing something stupid?
(P.S. I've tried GridLayout, FormLayout, and many others. They didn't work.)
The following is for Eclipse Windowbuilder users.
For this to work (assuming GridLayout is used) you must set several properties for every single thing in the GridLayout:
grabExcessHorizontalSpace should be true (check the box)
grabExcessVerticalSpace should also be true (again, check the box)
horizontalAlignment should be set to FILL (selected from drop-down)
verticalAlignment should also be set to FILL (also selected from drop-down)
Thanks to greg-449 for giving me this link, which solved the problem.

Is there a way to convert from Visual Editor created GUI to WindowBuilder GUI in Eclipse?

Since Visual Editor is no longer supported in newer versions of eclipse, I am trying to make the switch to WindowBuilder.
It seems that I should just be able to open a panel created in Visual Editor in WindowBuilder and all components should display, but this does not seem to be the case. All components sizes seem to come in as 0px x 0px and even after changing this, the components still do not show up in the preview window.
All components are custom that extend the standard JComponent (such as JLabel).
I am not sure if the problem is some sort of incompatibility, the fact that I am using custom components and containers, or a problem with my WindowBuilder installation (or something else!). Does anyone have any insight? I would be much appreciated! :)
If I understand your question correctly, all you'd have to do is right click the class in the package explorer > Open with > WindowBuilder Editor
I have found that sometimes the code doesn't transfer over nicely when trying to directly re-open the file using the WindowBuilder editor. I found that creating a new WindowBuilder document of the same type as your existing code, then replacing the file contents works pretty well, if you don't mind the inconvenience.
After working on this problem for some time I have found out what was causing the errors. It seems that Visual Editor was a bit more forgiving when parsing the code to display the preview.
My issues with Window Builder generally stemmed from the following things:
lack of paramterless contructors in both the panel/dialog to be displayed and components within. WB relies on these constructors to parse the code
trouble getting dynamically generated resources which led to throwing null pointer exceptions. Visual Editor seemed to ignore these and display what it could. Window Builder would not display any part of the offending component. Adding null checks in certain places remedied this.
After fixing these problems, I did not have to recreate any of my GUI screens in Window Builder

java L&F to obtain modern "wpf" look

Recently I found some absolutely beautiful applications made using WPF.
I'd really like to add this lovely look to my java applications.
Do you know if there are look and feels which make it possible?
First of all think what are the key concepts of the new metro-UI ?
Its flat and simple
1) use metro studio 2 to create icons for the project, use flat borders always
2) either create a full L&F or simply create small custom components ? or use Java FX (http://pixelduke.wordpress.com/2012/10/23/jmetro-windows-8-controls-on-java/ , http://pixelduke.wordpress.com/category/javafx/page/3/)
I was able to come little bit close to metro like text-buttons and background repeat panels, you might also want to see my repo here https://github.com/JaDogg/BhathiGUI
above image is for my near metro custom controls
NOTE : this will not create an actual metro app just one that looks like it
Update
Here is a screenshot of JavaFX application built using Undecorator and JMetro (JavaFX8)
Java was always stingy on new L&F. So new WPF style (developed for Windows 8 apps) is not available yet and i doubt it will be anytime soon.
The latest L&F released and provided together with Java SE was NimbusLookAndFeel. It is based on SynthLookAndFeel, which supposed to be a base for any custom L&F from now on.
There are also native L&Fs with:
Windows 2000 and Vista/7 styles (WindowsLookAndFeel)
GTK style (GTKLookAndFeel)
Mac OS style (AquaLookAndFeel)
There are also some good commercial L&Fs:
Java Look and Feel (L&F)
So if you really want to have such L&F - you will have to modify some existing L&F so it matches WPF styling or wait for a miracle (that someone will release such L&F).

Breaking up Java Swing classes in Netbeans palette

I would like to know the best method of breaking up large Java Swing classes. Some of mine are quite large and I would like to begin the process of properly modularizing my code. I saw that I could add my classes to Netbeans' palette but the problem is they are not showing me a graphical representation of what it will look like when I "drop" them into the GUI designer. Some third party jar files support getting added to the palette and they provide a graphical preview of what they'll look like once run.
My question is, I don't know the proper terminology for what this "preview" is called so I'm finding it very difficult to search for. I would like some documentation or a tutorial on how to make my current classes able to be added to the palette and see what it is they will look like in the GUI designer.
Thank you!
To get an icon, you need to provide a BeanInfo for you class.
The easiest way to do this is right click on the class in the Project window and select BeanInfo editor....
You'll want to switch to the designer view to configure which properties are expert/hidden/preferred.
Preferred properties appear in the top most fold (Properties) of the Property window.
Expert properties appear in the second fold (Other Properties).
Hidden do not appear at all.
You can also specify whether properties are bound, constrained, etc. To set icons, choose the topmost node of the tree (BeanInfo) and you'll see properties for the icons.
To make NetBeans treat your component as a container (or not a container):
Switch to Source view
Find the line reading
// Here you can add code for customizing the BeanDescriptor.
Add this line:
beanDescriptor.setValue("isContainer", Boolean.TRUE); // Or FALSE if it's not a container

Categories