I am working on a project with using Swing. Recently, I ve encountered a weird problem that I can't figure out how to solve. Had a look at similar questions and tried to use layouts for frame but it didnt solve the problem. All design is done with using free design. I am using Netbeans.
My question is, I want every panel to be resized properly. Without losing half of the panel and buttons on the screen.
Also tried to call pack() method in the componentListener(another solution that i saw here) but it didnt work neither. Here are some pictures of my project.
Regards.
After resizing:
Related
I'm trying to use Eclipse windowbuilder, but when I go to the design page the frame gets cut. Below is an image of what I am seeing.
This is just a simple JFrame (nothing added besides the default). If I run or preview the window, it shows me the whole frame as it should. For some reason unknown to me, the design tab is just cutting my frame.
I've seen a similar question, but my eclipse.ini file already has the --illegal-access=permit added at the end.
Does anyone know what this might be about? I am using JDK 16 by the way. Sorry if this is somewhat of a newb question, but it is my first time with swing and GUI building in Java.
I am trying to create Swing GUI in netbeans. But when I run it, it does not work as I designed it. Somehow horizontally & vertically it's a little bit bigger than I designed. shown in image the bottom one is running & the top one is the design.
I have tried manually changing the size of jFrame & jPanel but not helping.
code
I am a total noob and I don't know where the problem is.
I'm trying to build a GUI for a program I just finished writing. I don't have any prior experience with building a GUI, but I have found enough online to get started.
I initially used the GridLayout and got the setup I wanted, however, I found that I couldn't resize any of the components. Instead, when the program launches, they are at their smallest size. After some research, I found that the GridLayout doesn't allow for resizing and that the GridBagLayout would be a much better solution though it is more complicated. I cannot find this layout in the palette and have been unable to find anyone with the same issue in a few google searches. Does anyone know if I might be missing something obvious?
Here is the image of the options that show up for layouts.
I was going through this thread and I was wondering, if maybe we could use the scroll-bars to do that?
How to Use Scroll Panes describes how to do things using scroll bars. If I am making a terminal based application using Java for a Linux OS, then can't I use code that will move the terminal knob/scrollbar move down further? I mean, that is how even the BASH "clear" works, right? So, maybe this console-based Java app can move the console scroll down and pretend to clear the screen?
Now, my problem is that I am unable to find any class within this "Scroll Pane API" documentation that would help me do that. If anyone has worked with this API before can help me, it would be much appreciated!
..maybe we could use the scroll-bars to do that?
No. You cannot 'wrap the CLI in a JScrollPane (or add any JScrollBar instances)'. It is a native component that is outside the control (beyond textual output) of Java.
I'm trying to make a swing gui but currently experiencing trouble with making JMenus "close" when clicking elsewhere.
If a JMenu is selected/open i want it to close when clicking somewhere else on the gui but instead it remains open (most of the time) and the only way for me to close it is to click on the selected JMenu again.
I've searched for a solution but only seem to find bug reports on this matter.
Any help is appreciated, thanks.
Ok i found the problem last night.
One of the ActionListeners for the JMenuItems had an initializer for a JDialog in the contructor, i found it when i was trying to recreate the problem.
Thanks for replying.
I have never seen this problem.
Read the section from the Swing tutorial on How to Use Menus for working examples.
Compare your code to the working code to see what is different.
If you still can't find the problem then post your SSCCE that demonstrates the problem because there is no way we can guess what you are doing different from the working examples.