Skip to main content

Application with different windows

7 replies [Last post]
riepi
Offline
Joined: 2008-03-27

Hello everybody,
i am totally new to javafx (and java, too) and i am playing around with the NB compiler version. For a GUI projekt i want to find out how to develop an application with different windows / frames. There is one main window with a list-like content or different Shapes. When I click on one Entry/Shape I want to open a new Window. In my Windows Task bar only the Main Window should appear (it is one application). When i minimize the main Window all other windows should minimize too. Same to maximize.

First i tried out with Frames, but every time i create a new Frame the Frame is also in my taskbar. So I tried with Dialogs and they work partial:

//main.fx

var circle = Circle {
centerX: 100
centerY: 100
radius: 40
fill: Color.BLACK;
}onMouseClicked: function( e: MouseEvent ):Void {
var frame = FrameMaker{};
frame.getFrame();
}
};

Frame {
title: "FrameTest"
width: 200
height: 200
closeAction: function() {
java.lang.System.exit( 0 );
}
visible: true
content: Canvas {
content: circle;
}
}

//FrameMaker.fx
public class FrameMaker {
function getFrame(): Dialog{
return Dialog{
title: "Dialog"
width: 200
height: 200
visible: true
}
}

I get with every click on my circle a new window and there is only the Frame in my Taskbar. But when i want to minimize the Application only the main Window with the Circle minimizes, all Dialogs stay on place. Perhaps the solution is the attribut "owner" of a Dialog? How to set a owner? In the interpreter version there was the pseudo attribut "var" but it does not work with the compiler version.

Perhaps someone has a hint for me how to realize such a GUI, the way i did or another way? And how can i set the "owner"?

Greetings Riepi

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
riepi
Offline
Joined: 2008-03-27

nice effect, but usefull?
thanks anyway

riepi
Offline
Joined: 2008-03-27

seems to work:

package dialogtest01;

import javafx.ext.swing.Frame;
import javafx.ext.swing.Canvas;
import javafx.scene.geometry.Circle;
import javafx.scene.paint.Color;
import javafx.input.MouseEvent;
import javafx.ext.swing.Dialog;

var frame : Frame;
var circle = Circle {
centerX: 100
centerY: 100
radius: 40
fill: Color.BLACK;
onMouseClicked: function( e: MouseEvent ):Void {
Dialog{
owner: frame
title: "Dialog"
width: 100
height: 100
visible: true
x: frame.x + 30
y: frame.y + 30
}

}
};

frame = Frame {
title: "FrameTest"
width: 300
height: 200
closeAction: function() {
java.lang.System.exit( 0 );
}
visible: true
content: Canvas {
content: circle
}
}

alexsch
Offline
Joined: 2007-07-12

Try this:

[code]
import javafx.input.*;
import javafx.ext.swing.*;
import javafx.scene.paint.*;
import javafx.scene.geometry.*;

var frame: Frame;

class FrameModel{
public attribute width : Integer = 300 on replace{ dialogWidth = width / 2 };
public attribute height: Integer = 200 on replace{ dialogHeight = height / 2 };

public attribute dialogWidth: Integer = 150;
public attribute dialogHeight: Integer = 150;

}

var model = FrameModel{};

frame = Frame {
title: "FrameTest"

width: bind model.width with inverse
height: bind model.height with inverse

closeAction: function() { java.lang.System.exit( 0 ); }
visible: true

content: Canvas {
content: Circle {
centerX: 100
centerY: 100
radius: 40
fill: Color.BLACK;
onMouseClicked: function( e: MouseEvent ):Void {
Dialog{
owner: frame
title: "Dialog"
width: bind model.dialogWidth with inverse
height: bind model.dialogHeight with inverse
visible: true
x: frame.x + 30
y: frame.y + 30
}

}
}
}
}
[/code]

asdf_asdf
Offline
Joined: 2008-07-03

His alexsch,

OFFTOPIC: how do you manage to give your pasted code appropriate highlighting and identation, i am pasing everything clumsy

thanks

alexsch
Offline
Joined: 2007-07-12

> OFFTOPIC: how do you manage to give your pasted code
> appropriate highlighting and identation

Use [ code ] [ /code ] tags

asdf_asdf
Offline
Joined: 2008-07-03

thanks

riepi
Offline
Joined: 2008-03-27

There is a different behavior between SwingFrame/SwingDialog and Application Frame/Dialog with the owner Attribute. The Application Frame Dialog creates an new entry in my taskbar and does not minimize when i minimize the ParentFrame. Probably this is still a bug, isn't it?

Here the code:

[code]
var frame:Frame = Frame {
title: "MyApplication"
width: 400
height: 200
closeAction: function() { java.lang.System.exit( 0 );
}
visible: true

stage: Stage {
content: [
Circle {
centerX: 100, centerY: 100
radius: 10
fill: Color.BLACK
onMouseClicked: function( e: MouseEvent ):Void {
Dialog{
title: "Dialog"
width: 400
height: 200
visible: true
owner: frame
}
}
}
]

}
}
[/code]