コード例 #1
2
ファイル: AdminMain.java プロジェクト: nikhilsaxena/STM
  AdminMain() {
    l = new JLabel();
    l.setBounds(10, 20, 1340, 1000);
    l.setBackground(Color.black);
    Font ft = new Font("Arial", Font.BOLD, 30);
    Font ft1 = new Font("Arial", Font.BOLD, 14);
    Font ft2 = new Font("Arial", Font.BOLD, 20);

    f1 = new Frame("Soft Test Management (Beta)");
    f1.setLayout(null);

    l1 = new Label("Test Instructions", l1.CENTER);
    l1.setBounds(10, 20, 1300, 60);
    l1.setForeground(Color.blue);
    l1.setBackground(Color.white);
    l1.setFont(ft);

    l2 = new JLabel("Deletion of Faculty/Students");
    l2.setBounds(20, 30, 1000, 500);
    l2.setBackground(Color.blue);
    l2.setFont(ft2);
    l3 = new JLabel("Test Pattern");
    l3.setBounds(20, 90, 1300, 500);
    l3.setBackground(Color.green);
    l3.setFont(ft2);

    b1 = new JButton("Go !");
    b1.setBounds(300, 220, 120, 30);
    b1.setBackground(Color.white);
    b1.setForeground(Color.blue);
    b1.setFont(ft2);

    b2 = new JButton("Go");
    b2.setBounds(300, 240, 120, 30);
    b2.setBackground(Color.white);
    b2.setForeground(Color.blue);
    b2.setFont(ft2);

    f1.add(l);
    l.add(l1);
    l2.add(b1);
    l.add(l2);
    l3.add(b2);
    l.add(l3);

    b1.addActionListener(this);
    b2.addActionListener(this);

    f1.setVisible(true);
    f1.setSize(1800, 800);
  }
コード例 #2
0
ファイル: mupdate.java プロジェクト: ayushisrvstv/POS
  mupdate() {
    f = new JFrame("POS");
    p = new Panel();
    l1 = new Label("Welcome:Admin");
    l2 = new Label("POINT   OF   SALE");
    l14 = new Label("Enter Manager_Id");

    l3 = new Label("Name");
    l4 = new Label("Father's_Name");
    l5 = new Label("Manager_Id");
    l6 = new Label("Password");
    l7 = new Label("Gender");
    l9 = new Label("Address");
    l8 = new Label("D.O.B.");
    l10 = new Label("Contact_No.");
    l11 = new Label("E-Mail_Id");
    l12 = new Label("Location");
    l13 =
        new Label(
            "_______________________________________________________________________________________________");

    l15 =
        new Label(
            "_______________________________________________________________________________________________________________________");
    cbg = new CheckboxGroup();
    c1 = new Checkbox("Male", cbg, false);
    c2 = new Checkbox("Female", cbg, false);

    t11 = new TextField();
    t2 = new TextField();
    t3 = new TextField();
    t4 = new TextField();
    t5 = new TextField();
    t6 = new TextField();
    t7 = new TextField();
    t8 = new TextField();
    t9 = new TextField();
    t10 = new TextField();

    try {
      t1 = new Choice();
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      Connection con = DriverManager.getConnection("jdbc:odbc:raman1");
      Statement stm = con.createStatement();
      ResultSet rs = stm.executeQuery("select * from mprofile");
      while (rs.next()) {
        String a2 = rs.getString(3);
        t1.add(a2);
      }
    } catch (Exception e) {
      System.out.println(e);
    }

    b1 = new Button("Search");
    b2 = new Button("Update");
    b3 = new Button("Calendar");
    b4 = new Button("Close");
    b5 = new Button("Back");
    b6 = new Button("Logout");

    f1 = new Font("sherif", Font.BOLD | Font.ITALIC, 45);
    f2 = new Font("sherif", Font.BOLD | Font.ITALIC, 30);
    f3 = new Font("sherif", Font.BOLD | Font.ITALIC, 35);
    f4 = new Font("sherif", Font.BOLD, 20);
    f5 = new Font("sherif", Font.BOLD | Font.ITALIC, 15);
    f6 = new Font("sherif", Font.BOLD | Font.ITALIC, 20);
    l1.setFont(f5);
    l2.setFont(f1);
    l3.setFont(f6);
    l4.setFont(f6);
    l5.setFont(f6);
    l6.setFont(f6);
    l7.setFont(f6);
    l8.setFont(f6);
    l9.setFont(f6);
    l10.setFont(f6);
    l11.setFont(f6);
    l12.setFont(f6);
    l13.setFont(f6);
    l14.setFont(f6);

    b1.setFont(f6);
    b2.setFont(f6);
    b3.setFont(f6);
    b4.setFont(f6);
    b5.setFont(f6);
    b6.setFont(f6);
  }
コード例 #3
0
  public void start(Stage primaryStage) throws Exception {

    // Connecting to Access DB
    connect();

    // Declaration of variable window as primaryStage
    window = primaryStage;
    window.setTitle("Icooköp");
    primaryStage.setTitle("Icooköp");

    // Calls method closeProgram() also when terminating the program
    window.setOnCloseRequest(e -> closeProgram());

    // ---------------------SCENE1--------------------------

    // Scene 1 Welcome Label
    Label labelScene1 = new Label();
    labelScene1.setText("Välkommen till Icooköp beta v0.2!");
    labelScene1.setFont(Font.font("Verdana", 20));

    // Scene 1 left menu with spacing
    VBox scene1leftMenu = new VBox(15);
    scene1leftMenu.setPadding(new Insets(20, 20, 20, 20));

    // Calls closeProgram()
    Button s1q1 = new Button("Avsluta");
    s1q1.setOnAction(e -> closeProgram());

    // Displays all available product types
    Button s1b1 = new Button("Visa produkttyper");
    s1b1.setOnAction(e -> createStatement());

    // TableView object for displaying database data.
    tableview = new TableView();

    // TextField for user input of a selected product.
    Label s1l1 = new Label();
    s1l1.setText("Visa märken till produktgrupp");

    // Calls preparedStatement with product parameter
    choiceBox1 = new ChoiceBox<>();
    getProductTypes();
    choiceBox1
        .getSelectionModel()
        .selectedItemProperty()
        .addListener((v, oldValue, newValue) -> preparedStatement(newValue));

    // Button for switching to scene 2 (insertStamkund)
    Button s1b3 = new Button("Lägg till stamkund");
    s1b3.setOnAction(e -> window.setScene(scene2));

    // Label for drop down menu
    Label s1l2 = new Label();
    s1l2.setText("Se butiksaldo");

    // Creating ChoiceBox (drop down) with all the stores.
    // When choosing a store, storeStock() method is called for that store.
    choiceBox2 = new ChoiceBox<>();
    getStores();
    choiceBox2
        .getSelectionModel()
        .selectedItemProperty()
        .addListener((v, oldValue, newValue) -> storeStock(newValue));

    // Adding buttons, labels, text fields and choicebox (drop down) to left menu
    scene1leftMenu
        .getChildren()
        .addAll(labelScene1, s1q1, s1b1, s1l1, choiceBox1, s1b3, s1l2, choiceBox2);

    // Creating BorderPane object and aligning left and center content
    BorderPane Borderpane1 = new BorderPane();
    Borderpane1.setLeft(scene1leftMenu);
    Borderpane1.setCenter(tableview);

    // Setting scene 1 using BorderPane1. Both scenes have identical dimensions.
    scene1 = new Scene(Borderpane1, 700, 500);

    // ------------------- SCENE2 (insert Stamkund) --------------------

    // HBox for scene 2 created and a Label for it.
    HBox scene2topMenu = new HBox();
    Label labelScene2 = new Label();
    labelScene2.setText("Lägg till stamkund");
    labelScene2.setFont(Font.font("Verdana", 20));

    // Left menu VBox created.
    VBox scene2leftMenu = new VBox(15);

    // Scene 2 Main manu and Quit Button created
    Button s2b1 = new Button("Huvudmeny");
    s2b1.setOnAction(e -> window.setScene(scene1));
    Button s2q1 = new Button("Avsluta");
    s2q1.setOnAction(e -> closeProgram());

    // GridPane for scene 2 created with spacing
    GridPane s2grid = new GridPane();
    s2grid.setPadding(new Insets(10, 10, 10, 10));
    s2grid.setVgap(15);
    s2grid.setHgap(10);

    // Label displaying required input fields
    Label oblLabel = new Label("* = Obligatoriskt fält");
    GridPane.setConstraints(oblLabel, 0, 0);

    // Label for prnParam
    Label pnrLabel = new Label("*Personnummer:");
    GridPane.setConstraints(pnrLabel, 0, 1);

    // pnrParam is forced by regular expression to "6 digits"-"dash"-"4 digits"
    FormattedTextField pnrParam = new FormattedTextField("^\\d{6}-\\d{4}$");
    pnrParam.setPromptText("XXXXXX-XXXX");
    GridPane.setConstraints(pnrParam, 1, 1);

    // Label for fnameParam
    Label fnameLabel = new Label("*Förnamn:");
    GridPane.setConstraints(fnameLabel, 0, 2);

    // First name TextField
    TextField fnameParam = new TextField();
    fnameParam.setPromptText("t.ex. Arne");
    GridPane.setConstraints(fnameParam, 1, 2);

    // Label for snameParam
    Label snameLabel = new Label("*Efternamn:");
    GridPane.setConstraints(snameLabel, 0, 3);

    // Surname TextField
    TextField snameParam = new TextField();
    snameParam.setPromptText("t.ex. Andersson");
    GridPane.setConstraints(snameParam, 1, 3);

    // Label for addrParam
    Label addrLabel = new Label("*Adress:");
    GridPane.setConstraints(addrLabel, 0, 4);

    // Address TextField
    TextField addrParam = new TextField();
    addrParam.setPromptText("t.ex. Storgatan 1");
    GridPane.setConstraints(addrParam, 1, 4);

    // Label for mailParam
    Label mailLabel = new Label("E-post:");
    GridPane.setConstraints(mailLabel, 0, 5);

    // Mail TextField
    TextField mailParam = new TextField();
    mailParam.setPromptText("*****@*****.**");
    GridPane.setConstraints(mailParam, 1, 5);

    // Label for cellParam
    Label cellLabel = new Label("Mobilnummer:");
    GridPane.setConstraints(cellLabel, 0, 6);

    // cellParam is forced by regular expression to "3 digits"-"dash"-"7 digits"
    FormattedTextField cellParam = new FormattedTextField("^\\d{3}-\\d{7}$");
    cellParam.setPromptText("XXX-XXXXXXX");
    GridPane.setConstraints(cellParam, 1, 6);

    // This Label displays user information such as errors and confirmations.
    Label executeLabel = new Label();
    GridPane.setConstraints(executeLabel, 1, 8);

    // Adding Button "Registrera" with a lot of functionality
    Button s2b2 = new Button("Registrera");
    GridPane.setConstraints(s2b2, 1, 7);
    s2b2.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {

            // First if-statement checks for data in required fields.
            // Required: pnrParam, fnameParam, lnameParam and addrParam.
            if ((pnrParam.getText() != null && !pnrParam.getText().isEmpty())
                && (fnameParam.getText() != null && !fnameParam.getText().isEmpty())
                && (snameParam.getText() != null && !snameParam.getText().isEmpty())
                && (addrParam.getText() != null && !addrParam.getText().isEmpty())) {

              // Second if-statement calls checkPnr() to see if pnrParam (Personnummer)
              // is unique in database. If unique, checkPnr() returns False.
              // If !checkPnr = True, all data is valid and we run insertStamkund
              if (!checkPnr(pnrParam.getText())) {

                // Calls insertStamkund() with data from all TextFields.
                // Saves card number to integer cardParam.
                int cardParam =
                    insertStamkund(
                        pnrParam.getText(),
                        fnameParam.getText(),
                        snameParam.getText(),
                        addrParam.getText(),
                        mailParam.getText(),
                        cellParam.getText());

                // Converts cardParam value to String c.
                // Prints a welcoming and customer card number.
                String c = String.valueOf(cardParam);
                executeLabel.setText(
                    "Välkommen som stamkund hos Icooköp!\n" + "Ditt kortnummer är: " + c);

                // Clear TextFields
                pnrParam.clear();
                fnameParam.clear();
                snameParam.clear();
                addrParam.clear();
                mailParam.clear();
                cellParam.clear();
              }

              // If !checkPnr = False, pnrParam is already in database and user is notified.
              else {
                executeLabel.setText(
                    "Personnumret finns redan registrerat!\n" + "Välj ett annat tack.");
              }

            }

            // If any required fields are empty, user is notified.
            else {
              executeLabel.setText("Fyll i alla obligatoriska fält!");
            }
          }
        });

    // Button for clearing data in all TextFields and executeLabel
    Button s2b3 = new Button("Rensa fält");
    GridPane.setConstraints(s2b3, 0, 7);
    s2b3.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            pnrParam.clear();
            fnameParam.clear();
            snameParam.clear();
            addrParam.clear();
            mailParam.clear();
            cellParam.clear();
            executeLabel.setText(null);
          }
        });

    // Adding buttons to left and top menus
    scene2leftMenu.getChildren().addAll(s2b1, s2q1);
    scene2topMenu.getChildren().add(labelScene2);

    // Adding Labels and TextFields to scene 2 center grid
    s2grid
        .getChildren()
        .addAll(
            oblLabel,
            pnrLabel,
            pnrParam,
            fnameLabel,
            fnameParam,
            snameLabel,
            snameParam,
            addrLabel,
            addrParam,
            mailLabel,
            mailParam,
            cellLabel,
            cellParam,
            s2b2,
            s2b3,
            executeLabel);

    // Creating BorderPane object and aligning left, top and center content
    BorderPane Borderpane2 = new BorderPane();
    Borderpane2.setLeft(scene2leftMenu);
    Borderpane2.setTop(scene2topMenu);
    Borderpane2.setCenter(s2grid);

    // Setting scene 2 using BorderPane2. Both scenes have identical dimensions.
    scene2 = new Scene(Borderpane2, 700, 500);

    // Setting primary scene and display window
    window.setScene(scene1);
    window.show();
  }