hello guys i'm trying to load an image viewer in javafx using intellij and scene builder the image shows in scene bulder it desnt show after running - intellij-idea

this is the preview in scene builder
below is the fxml code
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.BorderPane?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="452.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1">
<center>
<ImageView fitHeight="187.0" fitWidth="372.0" pickOnBounds="true" preserveRatio="true" BorderPane.alignment="CENTER">
<image>
<Image url="#../../../../java/testImages/testImage.jpeg" />
</image>
</ImageView>
</center>
<bottom>
<Button mnemonicParsing="false" text="Button" BorderPane.alignment="CENTER" />
</bottom>
</BorderPane>
the image below is the executed code result where the image should appear
below is the java code
package com.ultijavafx.ultijavafx;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
public class jfx extends Application {
#Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(jfx.class.getResource("javafxVeiw.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 1500, 1000);
stage.setTitle("Hello!");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}
the image below is the resource structure

Related

Update the Counter in Badge, Xamarin Forms app

I'm using this Plugin.Badge to display cart items count on tabbed view in Xamarin Forms app.
here is my tabbed page xaml code MainPage.xaml
<?xml version="1.0" encoding="utf-8"?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
xmlns:plugin="clr-namespace:Plugin.Badge.Abstractions;assembly=Plugin.Badge.Abstractions"
xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core" android:TabbedPage.ToolbarPlacement="Bottom"
SelectedTabColor="{StaticResource HighlightText}" BarBackgroundColor="{StaticResource HighlightBg}" UnselectedTabColor="Gray"
xmlns:views="clr-namespace:Projectname.Views" x:Class="Projectname.Views.MainPage" >
<TabbedPage.Children>
<NavigationPage Title="Home" IconImageSource="home.png">
<x:Arguments>
<views:HomePage />
</x:Arguments>
</NavigationPage>
<NavigationPage Title="Search" IconImageSource="search.png">
<x:Arguments>
<views:AboutPage />
</x:Arguments>
</NavigationPage>
<NavigationPage Title="Cart" IconImageSource="cart.png"
plugin:TabBadge.BadgeText= "{Binding Counter}"
plugin:TabBadge.BadgeColor="Red"
plugin:TabBadge.BadgeTextColor="White" plugin:TabBadge.BadgePosition="PositionTopRight" >
<x:Arguments>
<views:AboutPage />
</x:Arguments>
</NavigationPage>
<NavigationPage Title="Account" IconImageSource="account.png">
<x:Arguments>
<views:AccountPage />
</x:Arguments>
</NavigationPage>
</TabbedPage.Children>
</TabbedPage>
below is the Code behind in MainPage.xaml.cs
using System;
using System.ComponentModel;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Xamarin.Essentials;
using Plugin.Badge.Abstractions;
using System.Collections.ObjectModel;
//using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
namespace Projectname.Views
{
[DesignTimeVisible(false)]
public partial class MainPage : TabbedPage
{
int Counter;
public MainPage()
{
InitializeComponent();
Counter = 2;
}
}
}
In one of the tabbedpage children you can see, the badge is set like
plugin:TabBadge.BadgeText= ""{Binding Counter}"
But is not working.
I want to set the value of the badge counter to the value of variable in the code behind page MainPage.xaml.cs
for that what all changes to be done in the code. Please help me on this.
This will not work. You are creating local variable and not even setting binding context.
First of all I recommend to create ViewModel for example:
public class MainPageViewModel : INotifyPropertyChanged
{
private int counter = 0;
public MainPageViewModel()
{
}
public event PropertyChangedEventHandler PropertyChanged;
public int Counter
{
set { counter = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Counter))); }
get { return counter; }
}
}
Then in your MainPage create binding context to viewmodel
public partial class MainPage : TabbedPage
{
private MainPageViewModel viewModel;
public MainPage()
{
InitializeComponent();
viewModel = new MainPageViewModel();
BindingContext = viewModel;
viewModel.Counter = 2;
}
}

LoadException when trying to load new window fxml

I have javafx menu, I want to switch to another window. When I was using Java-8 everything worked, but now I switched to javafx-11 and java-11 and I cannot switch.
Switching code
AnchorPane pane = FXMLLoader.load(getClass().getResource("/main/main.fxml"), resources);
I was searching internet and stackoverflow and I tried following
1. In Inteliij idea I added all modules and libraries and applied the changes in Project Structure.
2. I added to src package module-info.java
3. I checked if fxml I am trying to load doesn´t contain any errors or unsed ids.
4. I checked names of controllers and fxmls I am trying to load
Code of the module-info.java
module duno {
requires javafx.fxml;
requires javafx.controls;
requires java.logging;
requires javafx.web;
opens main;
}
Code of the method from Controller which I am calling to get the Settings window
#FXML
void goto_settings(ActionEvent event) {
try {
ResourceBundle resources;
switch(settings.getLanguage().get(settings.getSelectedLanguage())) {
case "Czech":
resources = ResourceBundle.getBundle("/bundles/LangBundle_cz");
break;
default:
resources = ResourceBundle.getBundle("/bundles/LangBundle_en");
}
AnchorPane pane = load(getClass().getResource("/settings/settings.fxml"), resources);
rootpane.getChildren().setAll(pane);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
Settings Controller
package settings;
import duno.Serialization;
import duno.Settings;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.AnchorPane;
import javafx.stage.DirectoryChooser;
import main.Main;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* FXML Controller class
*
* #author Filip
*/
public class SettingsController implements Initializable {
#FXML
private AnchorPane rootpane;
#FXML
private ComboBox<String> adf_combobox;
#FXML
private ComboBox<String> pf_combobox;
#FXML
private CheckBox del_checkbox;
#FXML
private ComboBox<String> language_combobox;
private Settings settings;
/**
* Initializes the controller class.
*/
#Override
public void initialize(URL url, ResourceBundle rb) {
/*
Load old settings or create new if settings file doesnt exist
*/
Serialization ser = new Serialization();
String fileName = ser.getFolder() + "settings" + ser.getExt();
File f = new File(fileName);
if(f.exists() && !f.isDirectory()) {
try {
Settings oldSettings = (Settings) ser.deserialize("settings");
settings = oldSettings;
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
} else {
settings = new Settings();
}
/*
Setup the GUI
*/
adf_combobox.getItems().addAll(settings.getActiveDownloadFolder());
adf_combobox.getSelectionModel().select(settings.getSelectedActiveDownloadFolder());
pf_combobox.getItems().addAll(settings.getPreferredFormat());
pf_combobox.getSelectionModel().select(settings.getSelectedPreferredFormat());
del_checkbox.setSelected(settings.isDownloadEntireList());
language_combobox.getItems().addAll(settings.getLanguage());
language_combobox.getSelectionModel().select(settings.getSelectedLanguage());
}
#FXML
void addNewDownloadFolder(ActionEvent event) {
DirectoryChooser directoryChooser = new DirectoryChooser();
File selectedDirectory = directoryChooser.showDialog(rootpane.getScene().getWindow());
if(selectedDirectory == null){
// Nothing was selected
} else{
settings.addActiveDownloadFolder(selectedDirectory.getAbsolutePath());
System.out.println(settings.getActiveDownloadFolder().toString());
adf_combobox.getItems().setAll(settings.getActiveDownloadFolder());
}
}
#FXML
void removeSelectedDownloadFolder(ActionEvent event) {
if(adf_combobox.getItems().size() <= 1) {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Warning Dialog");
alert.setHeaderText("You can´t remove this download folder");
alert.setContentText("You can´t remove all download folders");
alert.showAndWait();
} else {
int item = adf_combobox.getSelectionModel().getSelectedIndex();
settings.removeActiveDownloadFolder(item);
adf_combobox.getItems().setAll(settings.getActiveDownloadFolder());
adf_combobox.getSelectionModel().selectFirst();
}
}
#FXML
void saveSettings(ActionEvent event) {
settings.setSelectedActiveDownloadFolder(adf_combobox.getSelectionModel().getSelectedIndex());
settings.setSelectedPreferredFormat(pf_combobox.getSelectionModel().getSelectedIndex());
settings.setDownloadEntireList(del_checkbox.isSelected());
settings.setSelectedLanguage(language_combobox.getSelectionModel().getSelectedIndex());
System.out.println(settings.getLanguage().get(settings.getSelectedLanguage()));
Serialization ser = new Serialization();
String fileName = ser.getFolder() + "settings" + ser.getExt();
File f = new File(fileName);
if(f.delete()) {
System.out.println("File deleted");
ser.serialize(settings, "settings");
} else {
System.out.println("Settings file not deleted");
}
}
#FXML
void gotoDownloads(ActionEvent event) {
try {
ResourceBundle resources;
switch(settings.getLanguage().get(settings.getSelectedLanguage())) {
case "Czech":
resources = ResourceBundle.getBundle("bundles/LangBundle_cz");
break;
default:
resources = ResourceBundle.getBundle("bundles/LangBundle_en");
}
AnchorPane pane = FXMLLoader.load(getClass().getResource("/main/main.fxml"), resources);
rootpane.getChildren().setAll(pane);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Settings fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<AnchorPane id="AnchorPane" fx:id="rootpane" minHeight="800.0" minWidth="1000.0" prefHeight="800.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="settings.SettingsController">
<children>
<GridPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<MenuBar>
<menus>
<Menu mnemonicParsing="false" onAction="#gotoDownloads" text="Download">
<items>
<MenuItem mnemonicParsing="false" onAction="#gotoDownloads" text="Download" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Settings">
<items>
<MenuItem mnemonicParsing="false" text="Settings" />
</items>
</Menu>
</menus>
</MenuBar>
<GridPane GridPane.rowIndex="1">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" maxWidth="443.79998779296875" minWidth="10.0" prefWidth="272.8000244140625" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="561.4000396728516" minWidth="10.0" prefWidth="303.1999755859375" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="737.199951171875" minWidth="10.0" prefWidth="289.60002441406255" />
<ColumnConstraints hgrow="SOMETIMES" maxWidth="575.4000244140625" minWidth="10.0" prefWidth="121.20002441406245" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints minHeight="10.0" prefHeight="30.0" />
</rowConstraints>
<children>
<Label text="%active_download_folder_text" />
<ComboBox fx:id="adf_combobox" prefHeight="26.0" prefWidth="294.0" GridPane.columnIndex="1" />
<HBox prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="2">
<children>
<Button mnemonicParsing="false" onAction="#addNewDownloadFolder" text="%add_new_active_download_folder_button_text" />
<Button mnemonicParsing="false" onAction="#removeSelectedDownloadFolder" text="%remove_selected_active_download_folder_button_text" />
</children>
<padding>
<Insets top="5.0" />
</padding>
</HBox>
<Label text="%preferred_format_text" GridPane.rowIndex="1" />
<ComboBox fx:id="pf_combobox" prefHeight="26.0" prefWidth="114.0" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<HBox prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="1">
<opaqueInsets>
<Insets top="5.0" />
</opaqueInsets>
<padding>
<Insets top="5.0" />
</padding>
</HBox>
<Label text="%always_download_entire_list_text" GridPane.rowIndex="2" />
<CheckBox fx:id="del_checkbox" mnemonicParsing="false" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Label text="%language_text" GridPane.rowIndex="3" />
<ComboBox fx:id="language_combobox" prefHeight="26.0" prefWidth="162.0" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<HBox prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="2" GridPane.rowIndex="3">
<padding>
<Insets top="5.0" />
</padding>
</HBox>
<Button mnemonicParsing="false" onAction="#saveSettings" text="%save_button_text" GridPane.columnIndex="3" GridPane.rowIndex="4" />
</children>
<padding>
<Insets left="20.0" top="10.0" />
</padding>
</GridPane>
</children>
</GridPane>
</children>
</AnchorPane>
It should load settings window as it did in java-8 but now I got and error
Run log
"C:\Program Files\Java\jdk-11.0.3\bin\java.exe" --add-modules javafx.base,javafx.graphics --add-reads javafx.base=ALL-UNNAMED --add-reads javafx.graphics=ALL-UNNAMED "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1.1\lib\idea_rt.jar=50856:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2019.1.1\bin" -Dfile.encoding=UTF-8 -p C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.base.jar;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.graphics.jar;E:\duno\out\production\duno;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx-swt.jar;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.controls.jar;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.fxml.jar;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.media.jar;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.swing.jar;C:\Users\Filip\Documents\javafx-sdk-11.0.2\lib\javafx.web.jar -m duno/main.Main
English
kvě 10, 2019 10:57:10 DOP. main.Controller goto_settings
SEVERE: null
javafx.fxml.LoadException:
/E:/duno/out/production/duno/settings/settings.fxml:17
at javafx.fxml/javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2625)
at javafx.fxml/javafx.fxml.FXMLLoader.access$700(FXMLLoader.java:105)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:943)
at javafx.fxml/javafx.fxml.FXMLLoader$InstanceDeclarationElement.processAttribute(FXMLLoader.java:980)
at javafx.fxml/javafx.fxml.FXMLLoader$Element.processStartElement(FXMLLoader.java:227)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:752)
at javafx.fxml/javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2722)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2552)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2466)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3237)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3194)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3163)
at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3136)
at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:3128)
at duno/main.Controller.goto_settings(Controller.java:184)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.sun.javafx.reflect.Trampoline.invoke(MethodUtil.java:76)
at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at javafx.base/com.sun.javafx.reflect.MethodUtil.invoke(MethodUtil.java:273)
at javafx.fxml/com.sun.javafx.fxml.MethodHelper.invoke(MethodHelper.java:83)
at javafx.fxml/javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1782)
at javafx.fxml/javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1670)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.controls/javafx.scene.control.MenuItem.fire(MenuItem.java:465)
at javafx.controls/com.sun.javafx.scene.control.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1380)
at javafx.controls/com.sun.javafx.scene.control.ContextMenuContent$MenuItemContainer.lambda$createChildren$12(ContextMenuContent.java:1333)
at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3851)
at javafx.graphics/javafx.scene.Scene$MouseHandler.access$1200(Scene.java:3579)
at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1849)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2588)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:397)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:295)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:434)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:390)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:433)
at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.IllegalAccessException: class javafx.fxml.FXMLLoader$ValueElement (in module javafx.fxml) cannot access class settings.SettingsController (in module duno) because module duno does not export settings to module javafx.fxml
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:361)
at java.base/jdk.internal.reflect.Reflection.ensureMemberAccess(Reflection.java:99)
at java.base/java.lang.Class.newInstance(Class.java:579)
at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processAttribute(FXMLLoader.java:936)
... 66 more
Don´t mind the English in the output it´s just the language used in app
I figured it out on my own.
Here is how I proceeded.
I read the error several times, and then I though it need to export something. So I found that module info have exports something to something. So I added exports settings to javafx.fxml.
Another problem that I could not access settings because rootpane was private and settings were not opened. So I tried open settings; and it works :)
So here is final version
module duno {
requires javafx.fxml;
requires javafx.controls;
requires java.logging;
requires javafx.web;
exports settings to javafx.fxml;
opens main;
opens settings;
}
I hope it helps someone in future with same error

Defer Plugin Automatic Loading/Opening on Eclipse startup

I created a new plugin under PDE in eclipse.
Exported it to deployable plugin and pasted it in plugins folder of eclipse.
On Startup of eclipse, the plugins load automatically and come stacked with the console and other windows at the bottom of Eclipse.
I want to defer its automatic load/opening.
I want it to be opened only when I explicitly open it through Show View>My Plugin
Following is my plugin.xml :
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin autoStart="false">
<extension
id="application"
point="org.eclipse.core.runtime.applications">
<application>
<run
class="com.Myplugin.packages.Application">
</run>
</application>
</extension>
<extension
point="org.eclipse.ui.perspectives">
<perspective
name="Myplugin"
class="com.Myplugin.packages.Perspective"
id="Myplugin.perspective">
</perspective>
</extension>
<extension
point="org.eclipse.ui.views">
<view
name="Myplugin"
class="com.Myplugin.login.view.OpenView"
id="Myplugin.view">
</view>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="*">
<view
closeable="false"
id="Myplugin.view"
minimized="false"
relationship="stack"
relative="org.eclipse.debug.ui.ModuleView"
standalone="true"
visible="true">
</view>
</perspectiveExtension>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu">
</menuContribution>
</extension>
</plugin>
Perspective.java:
public class Perspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) {
try{
layout.setEditorAreaVisible(false);
layout.setFixed(true);
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.addPerspectiveListener(new PerspectiveListener());
}catch(Exception e){
OpenView.log4jCallingForError("Perspective error : " +getStackTrace(e));
// Plugin.getLog().log(new Status(Status.INFO, Activator.PLUGIN_ID, Status.OK, e.getMessage(), e));
}
}
public static String getStackTrace(final Throwable throwable) {
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw, true);
throwable.printStackTrace(pw);
return sw.getBuffer().toString();
}
}
You are specifying visible="true" in the perspective extensions definition of the view - this makes the view visibile as soon as the perspective is shown. Replace this with visible="false".
Note: You may have to reset the perspective to pick up changes to the perspective definition.
Changing my view properties from
<view
closeable="false"
id="Myplugin.view"
minimized="false"
relationship="stack"
relative="org.eclipse.debug.ui.ModuleView"
standalone="true"
visible="true">
</view>
to this
<view
closeable="true"
id="Myplugin.view:*"
minimized="false"
relationship="stack"
relative="org.eclipse.ui.views.ResourceNavigator"
standalone="true"
visible="false">
</view>
worked for me.

Primefaces TabView does not maintain selectOneMenu Values

Hi I have a primefaces tabView looks like this
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<p:messages />
<h:form id="form">
<p:tabView dynamic="true">
<p:tab title="Tab">
<p:inputText required="true" value="value"></p:inputText>
</p:tab>
<p:tab title="Select">
<p:selectOneMenu value="#{dummyController.selectedValue}" id="select" required="true" requiredMessage="Select is required">
<f:selectItem itemValue="1" itemLabel="asd"></f:selectItem>
<f:selectItem itemValue="2" itemLabel="qwe"></f:selectItem>
<f:selectItem itemValue="3" itemLabel="zc"></f:selectItem>
</p:selectOneMenu>
<p:message for="select" />
</p:tab>
<p:tab title="Tab">
<p:inputText required="true" value="value"></p:inputText>
</p:tab>
</p:tabView>
<h:commandButton action="#{dummyController.submit}" />
</h:form>
</h:body>
</ui:composition>
and it's controller
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
#ManagedBean
#ViewScoped
public class DummyController implements Serializable {
private static final long serialVersionUID = 1L;
private int selectedValue;
public void submit() {
}
public int getSelectedValue() {
return selectedValue;
}
public void setSelectedValue(int selectedValue) {
this.selectedValue = selectedValue;
}
}
it has a strange behaviour, follow the steps tp reproduce:
open the Select tab
open other tab
press Submit twice
the first press nothing happens as regular, the next press triggers required message for the select, though it always has a value
Please tell if something is missing or if there are any solutions
There's no direct solution to this, it's a bug in primefaces tabView, I came with this workaround and worked
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<p:messages />
<h:form id="form">
<p:tabView dynamic="true" activeIndex="#{dummyController.activeindex}" >
<p:tab title="Tab" id="tab1">
<p:inputText required="true" value="value"></p:inputText>
</p:tab>
<p:tab title="Select" id="selectTab">
<p:selectOneMenu disabled="#{dummyController.activeindex != 1}" value="#{dummyController.selectedValue}" id="select" required="true" requiredMessage="Select is required">
<f:selectItem itemValue="" itemLabel=""></f:selectItem>
<f:selectItem itemValue="1" itemLabel="asd"></f:selectItem>
<f:selectItem itemValue="2" itemLabel="qwe"></f:selectItem>
<f:selectItem itemValue="3" itemLabel="zc"></f:selectItem>
</p:selectOneMenu>
<p:message for="select" />
</p:tab>
<p:tab title="Tab" id="tab3">
<p:inputText required="true" value="value"></p:inputText>
</p:tab>
</p:tabView>
<h:commandButton action="#{dummyController.submit}" />
</h:form>
</h:body>
</ui:composition>
and the controller :
package com.ibm.sa.kap.ui.controller;
import java.io.Serializable;
#ManagedBean
#ViewScoped
public class DummyController implements Serializable {
private static final long serialVersionUID = 1L;
private int selectedValue;
private int activeindex;
public void submit() {
}
public int getSelectedValue() {
return selectedValue;
}
public void setSelectedValue(int selectedValue) {
this.selectedValue = selectedValue;
}
public int getActiveindex() {
return activeindex;
}
public void setActiveindex(int activeindex) {
this.activeindex = activeindex;
}
}
it's a conditional disabled according to the tab index, so that to prevent the tabview from resetting the value, how dirty !!
Unfortunatelly, the implementation of p:tabView with dynamic="true" is buggy. There are various issues: http://code.google.com/p/primefaces/issues/list?can=2&q=tabView+dynamic&colspec=ID+Type+Status+Priority+TargetVersion+Reporter+Owner+Summary&y=5000&cells=tiles but the most affected are the components such as p:selectOneMenu.
I've had this issue in my own project - the values from select lists were not submitted, if they were on the other tab as active. The solution is - don't use dynamic tabs, as long as they won't be fixed. There are too many bugs within.
Another thing that doesn't work, is to update the tab view from the ajax event onTabChange.
Because <p:selectOneMenu needs value to save element choosen.

variable to custom component - flex

I'm trying to pass a variable from my main flex application to a custom component I've created, but haven't really figured anything out.
my variable is just a string - public var test:String = "a test";
my custom component is implement in my main application like this - <ns1:finaltest includeIn="FinalTest" x="26" y="19" />
In my custom component 'finaltest' I'd like just to display the variable 'test'. something like this - finalmessage.text = test;
MainApp.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600" xmlns:local="*"
>
<fx:Script>
<![CDATA[
[Bindable]
public var test:String = "a test";
]]>
</fx:Script>
<local:FinalTest finalMessage="{test}" />
</s:Application>
FinalTest.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="400" height="300"
>
<fx:Script>
<![CDATA[
[Bindable]
public var finalMessage:String;
]]>
</fx:Script>
<s:Label text="{finalMessage}" />
</s:Group>