Пример #1
0
  // swing gui / constructor
  public Main(final Field f) {
    super("Sudoku Solver");
    URL iconURL = getClass().getResource("icon.png");
    ImageIcon img = new ImageIcon(iconURL);
    jFrame.setIconImage(img.getImage());
    Color darkBlue = new Color(51, 102, 153);
    Color lightBlue = new Color(18, 61, 104);

    grid = new JTextField[9][9];
    jGrid.setLayout(new GridLayout(9, 9));
    jGrid.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 5, darkBlue));
    jGrid.setBackground(darkBlue);
    for (int i = 0; i < 9; i++) {
      for (int j = 0; j < 9; j++) {
        grid[i][j] = new JTextField();
        grid[i][j].setDocument(new JTextFieldLimit(1));
        grid[i][j].setFont(new Font("Arial", Font.PLAIN, 20));
        grid[i][j].setHorizontalAlignment(JTextField.CENTER);
        grid[i][j].setText("");
        grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, lightBlue));
        if (j == 2 || j == 5) {
          grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 1, 5, lightBlue));
        }
        if (i == 2 || i == 5) {
          grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 1, lightBlue));
        }
        if (i == 2 && j == 2) {
          grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 5, lightBlue));
        }
        if (i == 5 && j == 2) {
          grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 5, lightBlue));
        }
        if (i == 2 && j == 5) {
          grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 5, lightBlue));
        }
        if (i == 5 && j == 5) {
          grid[i][j].setBorder(BorderFactory.createMatteBorder(1, 1, 5, 5, lightBlue));
        }
        jGrid.add(grid[i][j]);
      }
    }

    jButton.setLayout(new FlowLayout());
    jButton.setBackground(darkBlue);
    jButton.setPreferredSize(new Dimension(420, 45));

    jButton.add(solve);
    solve.setLabel("Solve");
    solve.setVisible(true);
    solve.setFont(new Font("HelveticaNeue", Font.PLAIN, 20));
    solve.setForeground(Color.BLACK);

    jButton.add(upload);
    upload.setLabel("Upload");
    upload.setVisible(true);
    upload.setFont(new Font("Arial", Font.PLAIN, 20));
    upload.setForeground(Color.BLACK);

    jButton.add(clear);
    clear.setLabel("Clear");
    clear.setVisible(true);
    clear.setFont(new Font("Arial", Font.PLAIN, 20));
    clear.setForeground(Color.BLACK);

    jGrid.setPreferredSize(new Dimension(400, 400));

    jFrame.setResizable(false);
    jFrame.setVisible(true);
    jFrame.setLocationRelativeTo(null);
    jFrame.setSize(420, 480);
    jFrame.setBackground(darkBlue);

    jFrame.add(jGrid, BorderLayout.PAGE_START);
    jFrame.add(jButton, BorderLayout.PAGE_END);

    ActionListener solvedClicked =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            makeGridWhite();
            gridToModel(f);
            if (!errorFound(f)) {
              runSolve(f);
              makeGrid(f, false);
              solve.setEnabled(false);
            }
          }
        };

    ActionListener uploadClicked =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            makeGridWhite();
            f.clearModel();
            makeGrid(f, true);
            solve.setEnabled(true);
            f.fromFile();
            makeGrid(f, true);
          }
        };

    ActionListener clearClicked =
        new ActionListener() {
          public void actionPerformed(ActionEvent actionEvent) {
            makeGridWhite();
            f.clearModel();
            makeGrid(f, true);
            solve.setEnabled(true);
          }
        };

    solve.addActionListener(solvedClicked);
    upload.addActionListener(uploadClicked);
    clear.addActionListener(clearClicked);
  }
Пример #2
0
  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);
  }