javafx


Javafx window crashes, after I have created a root, scene, title and stage.show();


I am writing code for hotel registration and I want to show rooms available in javafx window. It's in Estonian but I hope you will understand what's the problem. Everything worked until I added Group root = new Group(); and three lines after that.
public class Peaklass extends Application {
public static void main(String[] args) {
launch(args);
}
#Override
public void start(Stage pealava) throws IOException, ParseException {
List<Hotellituba> toad = new ArrayList<>();
//loeme faili algse sisu listi, et hiljem seda muuta ja uuesti välja kirjutada
List <String> sisu = new ArrayList<>();
//loeme failist sisse kõik olemasolevad toad ning koostame neist listi
try(BufferedReader lugeja = new BufferedReader(new InputStreamReader(new FileInputStream("toad.txt"), "UTF-8"))){
String rida = lugeja.readLine();
String[] tükid;
while(rida!=null){
tükid = rida.split(",");
if(Integer.parseInt(tükid[2])>60){
toad.add(new Sviit(tükid[0], Integer.parseInt(tükid[1]), Integer.parseInt(tükid[2]),
Boolean.parseBoolean(tükid[3]), Boolean.parseBoolean(tükid[4])));
}
else{
toad.add(new Tavatuba(tükid[0], Integer.parseInt(tükid[1]), Integer.parseInt(tükid[2]),
Boolean.parseBoolean(tükid[3]), Boolean.parseBoolean(tükid[4])));
}
sisu.add(rida);
rida = lugeja.readLine();
}
}
System.out.println(toad);
System.out.println(sisu);
Scanner sisendid = new Scanner(System.in);
JOptionPane.showMessageDialog(null,"Tere tulemast meie hotelli broneerimissüsteemi! Broneeringu tegemiseks" +
" palume vastata järgnevale ankeedile. ");
//System.out.print("Tere tulemast meie hotelli broneerimissüsteemi! Broneeringu tegemiseks" +
//" palume vastata järgnevale ankeedile. " + System.lineSeparator() + "Teie eesnimi: ");
String eesnimi = JOptionPane.showInputDialog(null,"Teie eesnimi: ");
String perekonnanimi = JOptionPane.showInputDialog(null, "Teie perekonnanimi: ");
int külastajaid = Integer.parseInt(JOptionPane.showInputDialog(null,"Külastajate arv (maksimaalselt 4 inimest): "));
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
Date saabumineDate;
Date lahkumineDate;
try {
String saabumineString = JOptionPane.showInputDialog(null, "Saabumiskuupäev (sisestage palun formaadis pp-kk-aaaa): ");
saabumineDate = dateFormat.parse(saabumineString);
}catch (ParseException p){
String saabumineString = JOptionPane.showInputDialog(null, "Vigane kuupäevaformaat! Sisesta kuupäev uuesti. " +
"Saabumiskuupäev (sisestage palun formaadis pp-kk-aaaa): ");
saabumineDate = dateFormat.parse(saabumineString);
}
try {
String lahkumineString = JOptionPane.showInputDialog(null, "Lahkumiskuupäev (sisestage palun formaadis pp-kk-aaaa: ");
lahkumineDate = dateFormat.parse(lahkumineString);
}catch(ParseException p){
String lahkumineString = JOptionPane.showInputDialog(null, "Vigane kuupäevaformaat! Sisesta kuupäev uuesti. " +
"Lahkumiskuupäev (sisestage palun formaadis pp-kk-aaaa: ");
lahkumineDate = dateFormat.parse(lahkumineString);
}
int maxHind = Integer.parseInt(JOptionPane.showInputDialog(null,"Toa maksimaalne maksumus öö kohta eurodes: " ));
//koostame sisestatud info põhjal uue Klient isendi
Klient klient = new Klient(eesnimi + " " + perekonnanimi, külastajaid, saabumineDate, lahkumineDate, maxHind);
System.out.println("Teie kriteeriumitele vastavad meie hotellis järgmised toad: ");
//saadaval olevad külastajate arvu poolest sobivad
//hotellitoad väljastada tsüklina ja seejärel lasta külastajal nende seast valida
//lisame loenduri i, mis väljastab vastava teate juhul, kui sobivaid tube hotellis ei leidu
int i = 0;
List<Hotellituba> sobivadToad = new ArrayList<>();
for (Hotellituba hotellituba : toad) {
if (hotellituba.getSaadavus() && hotellituba.getMahutavus() >= klient.getInimesteArv() && hotellituba.getMaksumus() <= maxHind) {
sobivadToad.add(hotellituba);
} else {
i++;
}
}
//juhul, kui sobivaid tube ei leidu, lõpeb programmi töö:
if (i == toad.size()) {
System.out.println("Teie kriteeriumitele sobivaid tube meie hotellis kahjuks ei leidu. ");
System.exit(0);
}
Group root = new Group();
Scene scene = new Scene(root, 500, 500, Color.BLACK);
pealava.setTitle("JavaFX Scene Graph Demo");
pealava.setScene(scene);
pealava.show();
System.out.println();
System.out.print("Sisestage soovitud toa number (juhul, kui sobivat ei leidu, sisestage \"0\"): ");
String valik = sisendid.next();
System.out.println();
if (valik.equals("0")) {
System.exit(0);
}
Broneering broneering = null; //tehakse siin, sest muidu for-tsüklis jääb skoopi ja ei saaks väljastada teda. Teen siin ära, siis
//muudetakse teda for-i sees.
for (Hotellituba hotellituba : toad) {
if (valik.equals(hotellituba.getToanumber())) {
hotellituba.setSaadavus(false);
broneering = new Broneering(klient, hotellituba, saabumineDate, lahkumineDate);
}
}
int o = 0;
for(String rida: sisu){
if(rida.contains(valik)){
String[] tükid = rida.split(",");
tükid[3]= "false";
String uusrida = valik + ",";
for(int a = 1; a<tükid.length;a++){
if(!(a==(tükid.length-1))){
uusrida += (tükid[a] + ",");
}
else{
uusrida+=(tükid[a]);
}
}
sisu.set(o,uusrida);
}
o++;
}
try(BufferedWriter kirjutaja1 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("toad.txt"),"UTF-8"))){
for(String rida: sisu){
kirjutaja1.write(rida);
kirjutaja1.newLine();
}
}
try( PrintWriter out = new PrintWriter(new FileWriter("broneeringud.txt", true));){
out.write(broneering.haldajaleToString() + "\r\n");
}
System.out.println(broneering.kliendileToString());
}
}

Related Links

Hide Calendar Button on DatePicker?
Add event handler to whole column cells with button
What's the difference (in FXML) between layout.Pane and control.Control?
JavaFX : Draggable node (Label ) horizontally only not vertically
How to load several FXML in one class?
Position labels to different sides in the parent pane
How to get metadata from a list of .mp3 files and store it in ArrayLists? [duplicate]
How to keep angle of DropShadow when node is rotated
JavaFX - How to edit a treeView TreeItem to TextField
Remove left padding of Alert
JavaFX set title to be removed on the left side
How to create a scrollable panel of components in JavaFX?
JavaFX 8 Dialog Button Area
JavaFX action handler for MenuItem does nothing (FXML)
JFreeChart with JavaFX, when zoom in or zoom out, repaint works not well
KeyEvents for AnchorPane don't work

Categories

HOME
ssms
twitter-bootstrap
botframework
wifi
azure-eventhub
casting
assign
perl6
opacity
markdown
phpexcel
chef-recipe
camunda
multibinding
facebook-marketing-api
web-parts
orange
coccinelle
email-client
devexpress-mvc
ballerinalang
hierarchical-data
boosting
xlib
overflow
akamai
ios-autolayout
tikz
spring-oauth2
scene7
webspeech-api
imageprocessor
bootcamp
maven-2
form-fields
const
area
android-graphview
pyexcel
irr
firefox-developer-edition
html-entities
logan-square
ack
azure-data-catalog
npoco
spring-ide
anonymous-function
jenkins-2
ng-class
visio-2010
openpgp.js
grib
catalyst
easy68k
deck.js
bytearray
3d-rendering
jcalendar
fadein
sqldataadapter
newlib
event-tracking
notice
identifying
bootstrap-tabs
openhab
hexagonal-tiles
vspackage
grails-3.0.9
screen-lock
accpac
asp.net-2.0
dockerpy
api-eveonline
lwuit
worklight-appcenter
reactjs-native
smartxls
sigma-grid-control
kernel-density
fade
extensibility
panelgrid
junction-table
auctex
libx264
jquery-ui-map
nsscrollview
animationdrawable
mysql-connector
helicontech
joomla1.7
fileoutputstream
response-time
fxcopcmd
rollover
mysql-pconnect
konsole
pixel-bender
manuals
file-icons
high-load
urlscan

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile