I designed (Netbeans Project) the swing GUI in one computer 15" screen.
Next, I moved the project to another computer 14" screen. When I launch the app in the 14" screen, it's like zooming the GUI and I can't see some part of it.
How can I let my design adjust itself from one computer to another?
Ps : In the GUI editor of netbeans, the size is the same in both computers
Update
I don't know if layout manage will solve it as they said in comments. I've just notice my Windows 10 displays 125 % zoom scaling on 1920 x 1080 resolution. When I switched to 100%, though all other applications of the computer looked aweful, the design I made in Netbeans looked exactly the same. What can I do then ? I think it's more related to Windows scaling than Swing's LayoutManager features. Am I correct ?
You need to use layout managers. Layout managers will organize your components in different ways depending on screen size, aspect ratio, etc.
Depending on what kind of GUI you want, you are going to choose a different layout manager. Once you have picked a layout manager, you can pass it to a JPanel on construction
JPanel panel = new JPanel(new FlowLayout());
More on info on how to use layout managers, here
Related
look at the image and you will understand what my problem
that's happened in this computer which is 4k UHD
this problem was under netbeans itself but i fix it using netbeans-ide-scaling-on-windows-8-10
when i tried to test it under swing this problem appear again.
setSize and setFont(new Font(MAX_FONT_SIZE)) are not what i'm looking for.
my working environment is:
windows 10 home
netbeans v8.0.2
May be you are not preparing the dimension on jframe.
Go to the design panel and click jframe.
set the preferredSize, width, height to change the size of jframe on properties window.
I think that it will be work.
How can I globally compress Matisse-generated GroupLayout and perhaps other gap spacings to make Swing dialogs generated with Matisse and GroupLayout more compact?
I have used Matisse to re-implement in Java Swing some large dialogs originally developed for Windows in Visual Basic's GUI builder.
The results in the Swing Windows L&F are very similar to native (of a certain age), except more "spread out." At lower res they leak off the screen. This is a real problem for the app.
Measuring shows all the gaps proportionally bigger than the Windows defaults. (The way Swing scales for different resolutions is not helping either.) This includes ContainerGaps emitted by Matisse and L&F-controlled gaps between GUI components.
I have looked at GroupLayout documents and the Matisse documentation I can find. I've looked at L&F parameters and the ContainerGap and related classes in the GroupLayout source. Nothing is taking me where I need to go.
All insight appreciated.
There are too many ways this could be wrong and no single point of adjustment that will fix it. The Visual Basic version surely looks good on its single target platform. By design, Swing relies on pack(), which "Causes this Window to be sized to fit the preferred size and layouts of its subcomponents." The preferred size may vary by platform, as shown in this nested layout example. Instead, study available layouts and use the GUI designer in a focused way, as suggested here.
There's no easy way to fix layout problems in the GUI designer without understanding Swing layouts; happily, the GUI designer is an excellent way to study the effects of various Swing layouts.
I am working on a desktop application in Java which uses Swing with MIG layout for building the GUI. I have a lot of drag&drop actions which require "fixed" screen positions (the application works with plugs and sockets). Currently we support only one screen resolution
Is it possible to build the GUI so that it is scaled somehow according to the screen resolution?
Thank you in advance
You can get the screen resolution this way:
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Set the size of your JFrame accordingly to it. (Remember to use setSize() only on Frame not on child Components with their own LayoutManager)
My Swing Application's GUI is built using Window Builder Pro GUI editor. Layouts used are MigLayout and AbsoluteLayout. Application is developed using Windows Machine, So UI is well aligned and neat in Windows, but when I run the same application in Mac OS X, Application's Frame couldn't accommodate the components inside its bounds. I mean, size of Components inside the frame changes across platforms. When I give extra space(Increased frame bounds), it looks nice in Mac but weird in Windows. Is there any way to have Frame or Panel to grow with respect to its contents or Components.
Don't use the absolute layout. Layout managers are used precisely to avoid the kind of problems that you're facing.
Assuming you used AbsoluteLayout because none of the existing layout managers suited your needs,
Have a look at Creating a Custom Layout Manager and use one instead of AbsoluteLayout.(Before that make sure none of the present layout managers suit your need)
I'm using Qt Jambi 4.4 for a project I'm working on (and designing the windows in the Qt Designer eclipse plugin). One of the windows I'd like to use is a preview window which is basically just a window with a QWebView on it. How can I make it so that the QWebView resizes as the window does? I've set the sizePolicy to expanding for both Horizontal and Vertical position. What else do I need to do?
(also bear in mind that I'm a newbie to both Java and eclipse and need to be talked to in stupid people terms on both of those subjects)
UPDATE
Just to illustrate the point, here are a couple of screenshots (I've made the window background bright just to illustrate my point):
alt text http://img13.imageshack.us/img13/2103/screenshot2oi7.jpg
alt text http://img152.imageshack.us/img152/6250/screenshot1mz9.jpg
I don't know Jambi, but with Qt Designer just give the background the focus and then apply a layout from the toolbar. Then the main widget will get resized by that layout manager -- if you don't add that layout manager you'll get the widget resizing but the contents staying at their old positions.
I haven't used qt-jambi, but if it is anything like Qt in C++ or PyQt, the QWebView would resize automatically as the window size changes. As far as I know, setting size policies/ expansion factors, adding QSpacerItem objects etc. is only necessary if the sizing behavior is not working right. Just laying it out using an appropriate layout within the preview window should be sufficient. Do let me know if I have misunderstood the question.
You need to place the QWebView in a layout, that it will follow the change in its "container". For using layout with Qt Designer, refer to http://doc.trolltech.com/4.5/designer-layouts.html
From Qt Designer docs:
The form's top level layout can be set by clearing the selection
(click the left mouse button on the form itself) and applying a
layout. A top level layout is necessary to ensure that your widgets
will re-size correctly when its window is re-sized.