When I go into the design panel of an Application Window class and I want to put a button, or rather anything I can't put it where I want it. It let's me to choice 1 of the 5 sides(top,right,left,center) and the button is as large as the whole panel.
What can I do?
Related
I'm trying to make a simple program with Java, Swing, that shows you a Window and by clicking the button "Start" it should show you a new panel with a login interface (enter username, password, login).
I've read a question asked here that says that it's better to use only one JFrame and it makes sense because I don't want to start a new window between clicking "start" button and going to the login interface. But, how should I do this? I've created two JPanel containers named loginPanel and startPanel, but I don't know how to set visible loginPanel when the application runs, and then by clicking a button (in startPanel) set visible loginPanel (and obviously stop showing startPanel).
I'm using the graphical Swing interface that comes with NetBeans (because the IDE have greyed the zone to edit the code by yourself, IDK why).
Could anyone give me a example of what I'd like to do?
I am making project with GUI. The thing is, that I have a button and what I need to do is that after clicking this button I need to change Frame layout. For example, like when you are installing some program and you click "next" button, the Frame layout changes and you can see some different content. Basicly, dynamic wizard.
I have tried use another Frame, but it opens in another window and that is not what I want. I want to open it in the same window.
Another thing I have tried is set visibility of these components I don't want to be displayed to false, but I find it unprofessional and it is overlook in making a desing, when I have components over themselfs.
So do you guys have any idea? Thank you.
Most of the times for a wizard like GUI, you should have JFrame and a set of JPanels. In each step you can pass the shared data as constructor arguments to each panel, and when you are making one of them invisible and make another one visible, you can get some date from the previous step panel and pass it to the next step panel(if needed).
It is very common that your panels extend the JPanel and have some argument in their constructor(s). You use these data for initializing your panel and managing the state of the overall progress.
There is no a total plan for all situations. So you should decide what to do which is best fit for your case.
Try not to have multiple JFrames.
Hope this would be helpful.
I am trying to use a JDialog at the right of the screen, everything is almost perfect, but, if someone press the button on ther right end of the TaskBar, click on "Show Desktop area" my JDialog disappears I have to use ALT + TAB to get it back in in front. I can't set it AlwaysOnTop because I use other 3rd party programs that are fullscreen.
I tried:
jdigCentral.setAutoRequestFocus(true);
jdigCentral.setAlwaysOnTop(true);
and others, but without success
How can I have my JDialog to stay over just the Desktop Area?
Is jdigCentral your dialog box? If so then try this:
jdigCentral.setModal(true);
That will keep the dialog box on top of the parent JFrame. But I'm confused about the use of the word Desktop Area. Do you mean you want to keep the dialog box on top of the parent frame, or do you want it to always show on top of all other programs running on your desktop?
So I have this project to make and I'm somehow stuck. I have an encyclopedia to make and I do not know how to make the pages.
For example, I have a JFrame with two buttons, called Back and Next. When I press that button, I want my program to switch to the next page, same as an e-book.
I thought of creating a new JPanel, get the X and the Y of the first frame and close the first frame when this one opens, reopen it only when I press back. How can I do that?
You have several options:
Create new JPanels for each "page" and swap them via a CardLayout.
Create a single JPanel for displaying page information, and then swap content on pressing the button. I favor this solution if at all possible as the simplest and the one best suited to a good MVC solution.
As an aside, if you're new to the Swing GUI library, then I suggest that you put the GUI-builder to the side for a bit til you learn the underpinnings of the library. This will help prevent you from painting yourself in a corner should you use the GUI builder later.
I'm trying to reproduce a feature I've seen on several apps:
I have a GUI app with several JDialogs.
I'd like to easily organize them tightly on screen:
when I move one JDialog, and one of its borders gets "close" (within 5 pixels for example) to another JDialog, I'd like it to automatically snap and stick right along it.
any idea how to achieve that ?
Add a ComponentListener to the dialog and listen for the comopnentMoved() event.
You can use the Window.getWindows() method to get all the Windows. Then you loop through the Windows and get the bounds of each window. Whenever you are near a window you manually set the size of the window you are moving.
Of course you will also need to handle the situation when you want to move the window away from another window so maybe you need to start a Timer with every componentMoved event and only manually position the window after events have stopped being generated.