package data.base;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.*;
import javafx.scene.control.Button;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.control.PasswordField;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.*;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class DataBase extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start( Stage loginStage ) {
final int insets = 25;
loginStage.setTitle( "This is a secure Database" );
Group root = new Group();
Scene scene = new Scene( root, 1900, 1000, new LinearGradient( 0f, 1f, 1f, 0f, true, CycleMethod.NO_CYCLE, new
Stop[] {
new Stop( 0, Color.web( "#CC00CC" )),
new Stop( 0.14, Color.web( "#9966CC" )),
new Stop( 0.28, Color.web( "#6666FF" )),
new Stop( 0.43, Color.web( "#336699" )),
new Stop( 0.57, Color.web( "#009966" )),
new Stop( 0.71, Color.web( "#009933" )),
new Stop( 0.85, Color.web( "#00CC00" )),
new Stop( 1, Color.web( "#99FF99" )),
}));
loginStage.setScene( scene );
Group display = new Group();
Group root2 = new Group();
GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap( 10 );
grid.setVgap( 10 );
grid.setPadding( new Insets( insets, insets, insets, insets ));
Text scenetitle = new Text("Please Signe In.");
grid.add(scenetitle, 60, 39 );
TextField userNameText = new TextField();
userNameText.setPromptText( "Username" );
userNameText.setPrefColumnCount( 10 );
PasswordField pwText = new PasswordField();
pwText.setPromptText( "Password" );
pwText.setPrefColumnCount( 10 );
Button submit = new Button( "Submit" );
submit.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t ) {
if ( userNameText.getText().equals( "marmalade" ) && pwText.getText().equals( "theHax" )) {
System.out.println( "Hey Louis" );
Scene scene2 = new Scene( root2, 1900, 1000,
new LinearGradient( 0f, 1f, 1f, 0f, true, CycleMethod.NO_CYCLE, new
Stop[] {
new Stop( 0, Color.web( "#CC00CC" )),
new Stop( 0.14, Color.web( "#9966CC" )),
new Stop( 0.28, Color.web( "#6666FF" )),
new Stop( 0.43, Color.web( "#336699" )),
new Stop( 0.57, Color.web( "#009966" )),
new Stop( 0.71, Color.web( "#009933" )),
new Stop( 0.85, Color.web( "#00CC00" )),
new Stop( 1, Color.web( "#99FF99" )),
}));
loginStage.setScene( scene2 );
MenuItem menuEditorNew = new MenuItem( "New" );
menuEditorNew.setOnAction( new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t){
//open a new editor
}
});
MenuItem menuEditorOpen = new MenuItem( "Open" );
menuEditorOpen.setOnAction( new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t){
// open a file made by the editor
}
});
MenuItem menuEditorSave = new MenuItem( "Save" );
menuEditorSave.setOnAction( new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t){
// save the editor
}
});
TabPane tabPane = new TabPane();
Tab editor = new Tab();
Tab mainMenu = new Tab();
Tab viewer = new Tab();
editor.setText( "Editor" );
editor.setClosable( false );
mainMenu.setText( "Main Menu" );
mainMenu.setClosable( false );
viewer.setText( "View old entries" );
viewer.setClosable( false );
tabPane.getTabs().addAll( viewer, editor, mainMenu );
final Menu menu1 = new Menu( "File" );
menu1.getItems().addAll( menuEditorNew, menuEditorOpen, menuEditorSave );
MenuBar menuBar = new MenuBar();
menuBar.getMenus().add( menu1 );
root2.getChildren().add( tabPane );
root2.getChildren().add( menuBar );
}
else {
System.out.println( "Never will you get my secrets!!");
loginStage.close();
}
}
});
grid.add( userNameText, 60, 40 );
grid.add( pwText, 60, 41 );
grid.add( submit, 61, 39 );
display.getChildren().add( grid );
root.getChildren().add( display );
loginStage.show();
}
}