graphical component above the jxbrowser - jxbrowser

I use JxBrowser 6.2 on Windows.
I try to add a swing component (a drop-down menu) above the browser view.
Even adding this component in the modal_layer, the component appears under the browser.
I use this code :
JButton btn = new JButton("Hello");
btn.setBackground(Color.RED);
btn.setBounds(0, 0, 500, 300);
frame.getLayeredPane().add(btn, JLayeredPane.MODAL_LAYER, 0);

Please try using the following approach:
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
Browser browser = new Browser();
BrowserView view = new BrowserView(browser);
You can find more details about this approach at https://jxbrowser.support.teamdev.com/support/solutions/articles/9000013078-jmenubar

Related

monodevelop gtk# button on top of webview

question about monodevelop and Gtk#. I want to put the button on top of WebKit.WebView, but cannot figure out the way to do so. WebView renders on top of button... I try to achieve it using Gtk.Fixed as following:
Gtk.ScrolledWindow htmlScroll= new Gtk.ScrolledWindow();
WebKit.WebView htmlView = new WebView ();
Gtk.Fixed myFixed = new Gtk.Fixed();
Gtk.Button btn= new Gtk.Button();
btn.Visible = true;
btn.Label = "scrl test button";
htmlScroll.Add(htmlView);
myFixed.Put (htmlScroll, 20, 0);
myFixed.Put(btn, 0, 0);
The button is parent for webview. In case I click on the webview area which overlaps with button, the button gets clicked (part of the button is visible). But webview is rendered on top of button. Any hint is highly appreciated.
BR, Madis

JavaFx add context menu from controller

I am trying my way through JavaFX and still have many - probably silly - beginner questions.
My problem of the day is the following:
I am creating, in Scene builder and Controller, a FlowPane to which I want to add a right-click option, that opens a Context Menu.
Through the scene builder I have added the function OnContextMenuRequested and defined it in the Controller.
To check, I have added a print commend and a Dialog Box to the function, which work well.
Yet, the Context Menu does not work..
Anybody could help and tell me what am I missing???
Thanks in advance...
public void contextMenu(ContextMenuEvent contextMenuEvent) {
// working fine ..
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Information");
alert.setHeaderText("Look");
alert.setContentText("Message");
alert.showAndWait();
// working fine
System.out.println("Hello");
// Context Menu ......... not working
ContextMenu contextMenu = new ContextMenu();
MenuItem quit = new MenuItem("quit");
MenuItem hello = new MenuItem("hello");
contextMenu.getItems().addAll(quit, hello);
contextMenu.setX(10.0);
contextMenu.setY(10.0);
contextMenu.show();
????.setContextMenu(????)
}
Unless you have a control, you need to show the ContextMenu "manually" using one of the methods defined in ContextMenu:
// contextMenu.setX(10.0);
// contextMenu.setY(10.0);
contextMenu.show((Node) contextMenuEvent.getSource(), contextMenuEvent.getScreenX(), contextMenuEvent.getScreenY());

Adding a button to a dialog

Are AX dialog buttons limited to OK and Cancel?
Is it possible to add a custom button to the dialog?
I have the following code for my dialog:
static void mitTabPage(Args _args)
{
Dialog dialog;
DialogGroup dialoggroup, dialoggroup2;
DialogField dialogfield, dialogfield2;
;
dialog = new Dialog ("A new Dialog");
dialog.addTabPage("Brand Id's");
dialoggroup = dialog.addGroup("Brand Id's");
dialogfield = dialog.addField(extendedTypeStr(SYCCarBrandId));
dialog.addTabPage("Owners");
dialoggroup2 = dialog.addGroup("Owners");
dialogfield2 = dialog.addField(extendedTypeStr(SYCOwner));
dialog.run();
}
I'd like to add another button to the dialog. How can I do that?
The Dialog framework is a simple framework for prompting users to obtain some data/settings then performing some action or canceling.
For what you're trying to do, it most likely doesn't make sense to use the dialog framework and instead you could/should create another form if you need additional functionality.
However, if you do insist on using the Dialog framework for this, you would add a runtime button and use registerOverrideMethod.
See following links:
https://msdn.microsoft.com/en-us/library/dialogfield.registeroverridemethod.aspx
https://blogs.msdn.microsoft.com/axsupport/2015/06/07/using-x-to-add-a-control-at-runtime/

Create Dialogs with Default Images in JavaFX (Info/Warning/Error)

I am creating a JavaFX Dialog and want to use the default icons for Info/Warning/Error.
In Swing, I can get the Information icon this way:
UIManager.getIcon("OptionPane.informationIcon")
How can I do the same in JavaFX?
I asked for this some days ago. I use this code to make labels with default icons:
Label img = new Label();
img.getStyleClass().addAll("alert", "error", "dialog-pane");
dialog.setGraphic(img);
If you get a copy of the images you can use these ideas.
Alert example:
#FXML void handleHelpButton(ActionEvent event){
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Help");
alert.setHeaderText("Help");
alert.setGraphic(new ImageView(this.getClass().getResource("img/help.png").toString()));
alert.setContentText("Place the cursor over a button for hint.");
Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
stage.getIcons().add(new Image(this.getClass().getResource("img/help.png").toString()));
alert.showAndWait();
}
Dialog example:
ChoiceDialog<String> dialog = new ChoiceDialog<>(currentFullscreenSetting, choices);
dialog.setTitle("Settings");
dialog.setHeaderText("Settings");
dialog.setContentText("Fullscreen on startup: ");
dialog.setGraphic(new ImageView(this.getClass().getResource("img/settings.png").toString()));
Stage stage2 = (Stage) dialog.getDialogPane().getScene().getWindow();
stage2.getIcons().add(new Image(this.getClass().getResource("img/settings.png").toString()));
// Traditional way to get the response value.
Optional<String> result = dialog.showAndWait();
This part of both examples is tricky. I noticed that this would not work unless I had the image in the same folder as the .fxml and controller.java files or in a folder that is in the same folder has the files mentioned. You might have to play with you file location. In my example it appears that my setGraphic and getIcons images are in the same folder, but they are not.
stage.getIcons().add(new
Image(this.getClass().getResource("img/help.png").toString()));
My file structure looks like:
    PlanningChart
        css
        img
        planningchart
            img
The second img folder holds the images for stage.getIcons.add(). The images could also be probably use to for setGraphic. I did not try it.
You do not need to create custom JavaFX dialogs for Info/Warning/Error, since JavaFX already have created Alerts for you.
The Alert class subclasses the Dialog class, and provides support for a number of pre-built dialog types that can be easily shown to users to prompt for a response.
You can create different types of Alerts, depending on the AlertType, it will embed the necessary image.
For Information alert use :
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle("Information Dialog");
alert.setHeaderText("An Information Dialog");
alert.setContentText("Information Message");
alert.showAndWait();
Similarly, for Warning alert, you can use
AlertType.WARNING
and for Error alert, you can use :
AlertType.ERROR

Stage Icon is not visible

I am creating a sample code to show the Stage designed in Javafx, It should not have Minimize and Maximize Button only Close ('X') button required.
For that we are using following code.
Stage stage = new Stage();
// Here we have load it using JFXML
stage.initModality(Modality.WINDOW_MODAL);
stage.initStyle(StageStyle.UTILITY);
stage.setResizable(true);
if (title != null && !title.trim().isEmpty()) {
stage.setTitle(title);
}
stage.setWidth(w);
stage.setHeight(h);
stage.getIcons().add(new Image(Dialog.class.getResourceAsStream("/image/myicon.png")));
stage.showAndWait();
Now the icon I set on the stage is not visible.
What I am missing ?
I assume Windows as the OS (in MacOSX the icon is shown). Under Windows, StageStyle.UTILITY leads to using WS_EX_TOOLWINDOW in which case the icon is not shown. You probably need to use another StageStyle.
"PRB: WS_EX_TOOLWINDOW Windows Do Not Show System Menu Icon": http://support.microsoft.com/kb/179376

Resources