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.
Related
My issue is that I need to use Java code and Python code, each generating a window, Java still being the main process.
What I need is to link those two windows together. When I resize one, it resize the other, and same behavior when moving one, minimizing,...
I tried looking at the documentation or other solution on the Internet but I found nothing near my issue.
Will I need to implement a whole solution for it (listeners on both window to get size and resize the other, or position,...) or is there something I have been missing ?
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).
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.
The Window component that I use has Resizable flag set to false but the resize cursor on the edges still appear. Is there any way to change the cursor to normal ?
I am using Sencha GXT 3, with appearance pattern.
EDIT:
Both answers (SSR and Jonathan) are correct but a bit overkill. And what happens to other Windows which are resizable ?
I notified Sencha about the issue and they labeled it as a bug. Upgrading to GXT 3.0.3+ will solve the issue.
It might be not be possible without hacking into gxt code. The resize cursor code seems to be hardcoded into css styles in gwt code which is obfuscated. You can see in the below image a obfuscated style with cursor : e-resize;
Open up gxt jar. Copy the relevant Window code into your code base in same package structure as gxt and then make the changes in gwt template style related to Window. Ensure this class is in higher classpath hierarchy than gxt code when gwt compiler picks it up.
Log a bug with GXT team to get a official patch.
The Resizable class has ResizableAppearance. If we look in ResizableBaseAppearance, we can take a look at how the GXT team has implemented this stuff.
I'm guessing that what is going on is that when a Window is initially created, Window.setResizable(true) is called which injects the styles and sets up the handlers for resizing.
You could roll your own ResizeableAppearance and set up your deferred-binding rules to use yours instead of the default ResizableBaseAppearance (make sure those rules come after your inherit of GXT in your *.gwt.xml).
This will replace the appearance of the Resizer in ALL Windows. So, the trick would be to figure out how to determine if resizing is turned off or not.
Hope this helps.
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