Multiple windows in eclipse window builder - java

I am using Google Window Builder for eclipse to create the UI aspect of my program. I need to create a preferences window so that the user can change different settings for the program. I want the user to be able to press the 'preferences' button in the menu to bring up a separate window. The problem I am having is that I do not know how to create or add components to this separate window visually through Window Builder. Is there a way I can create a jpanel that is not a child of the main jframe program through Window Builder?

Right click on the package where you want the file for the new window to be stored. Go "New -> Other" and select "WindowBuilder -> Swing Designer -> JDialog". Write in a name for the class of the new Window. That will bring up an editor, select "Design" tab at the bottom of the window. Now you can customize this new window.
To open this window from your main JFrame you'll need do this:
MyNewWindowClass newWindow = new MyNewWindowClass();
newWindow.setVisible(true);

Related

Creating a new window on button click - Vaadin14

I want to create a new Window using:
final Window window = new Window("Window");
this.getUI().addWindow(window);
This is from the Vaadin homepage https://demo.vaadin.com/sampler/#ui/structure/window
But unfortunately my IDE is showing the following error:
The constructor Window(String) is undefined.
When i delete the string, it says: the constructor Window() is not visible.
Why is that? In the vaadin demo it works just fine.
There is no Window class in Vaadin 14.
The demo page you linked in the question is about Vaadin 8.
In Vaadin Flow (Vaadin 10+), the Dialog is used instead of the old Window. It's not exactly the same as the old Window - for example the Dialog has no maximize or close button automatically. But along with other components you want to show within that Dialog, you can add for example a button that will close the dialog when clicked. Or let the dialog close when the user clicks outside it using dialog.closeOnOutsideClick(true);
Edit: go check out this vaadin blog post of a good looking Dialog example, with video (and code is also linked there): https://vaadin.com/blog/new-component-features-and-development-time-improvements-in-vaadin-14
The Window class is part of the Vaadin-Framework. It doesn't exist like that in rapidclipse and other IDE's. You have to write your own Window class (by extending Panel) or you can copy the Window class from their github.
refer to:
https://github.com/vaadin/framework/blob/master/server/src/main/java/com/vaadin/ui/Window.java
You are getting this error, because you are trying to access the Window class of the rapidclipse framework, which apparently has no constructor and is meant for something else.

JDialog over Desktop area

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?

how to restrict more than one java application icon on taskbar?

I have created an application in java which have several forms.
During application start getting open new form on button click event,On windows's taskbar the number of icons of that form getting increases.
what I want is only applicatoin icon should be displayed on task bar whether one form is open or more than one.
The problem happens because each JFrame gets a task-bar icon. See The Use of Multiple JFrames, Good/Bad Practice? for links to a multitude of solutions.
I think this tutorial will help you to solve your task.
Multiple Document Interfaces with JDesktopPane and JInternalFrame
If you already have your new window as a JDialog and are still facing the problem of having two icons in the taskbar, it may be that you are creating your modal JDialog like this:
JDialog dialog = new JDialog((JFrame) null, true);
With owner (first) argument set to null, the application creates a new icon in the taskbar for the dialog. So, to avoid this, just pass the reference to your frame to the dialog constructor when opening the dialog (e.g. by clicking on a button). Like this:
public class MyBrandNewDialog {
public MyBrandNewDialog(JFrame owner) {
// create new modal dialog (the second argument is for modality)
JDialog dialog = new JDialog(owner, true);
// ...
}

Java "Create New" window

I'm relatively new to GUI with Java and I have a JFrame with a simple menu bar with your typical create new button(Like create new file and stuff). I want to have it so when I select this button another window pops up and it has several things to fill out after which you select an ok button or a cancel button. Then the focus is returned to the main JFrame.
This sounds like the perfect job for a JDialog. Dialog tutorial.

Change jFrame to jDialog?

I've been trying to change a jFrame to a jDialog so it inherits the icon of the main window but I don't have a clue how to do that. I tried setting it's code from public class jSemestriala extends javax.swing.JFrameto public class jSemestriala extends javax.swing.JDialog but that didn't change the icon of the window. Any ideas? I'm using NetBeans 7.0.1
The JDialog takes its icon from the owner frame.
You have two options:
Create an invisible JFrame, set your icon to it and set that frame as owner of the dialog.
Create the Dialog, get the owner, and set the icon to it.
I would choose the first option, it seems saver to me. The second one makes use of the (shared) owner of the dialog. This could cause side effects.
For further reading.
But if you already have an main frame, you simply need to set it as owner in the constructor of the dialog.
You need to specify the "main window" frame as the owner of the JDialog:
// ownerframe is a JFrame;
JFrame ownerframe = new JFrame();
JDialog dlg = new JDialog(ownerframe);
JDialogs have owner frames. The frame is either created for you if you call the constructor new JDialog(), in which case the frame is invisible; or you supply it to the dialog in its constructor using new JDialog(ownerframe).
create a new jdialog
hard copy the components from design view of jframe(you can use navigator window to copy all in clearly. ofcourse just copy the components under jframe)
paste it on jdialog(again use navigator window . ofcourse paste under jdialog)
hard copy the source code from jframe's source code window
paste it on jdialog's source code
do not touch the automaticly created codes
if you need it, add them again by using design window.
fix the errors in source code window of new jdialog by using your eyes and hands :)
remember all the time: be careful about choosing the type of class form.
sorry for my english.
it could take a long time but it will work.

Categories

Resources