Exemplo n.º 1
0
  public void addDays() {
    this.removeAll();
    this.panel.removeAll();

    for (int i = 1; i <= this.model.getMaxDays(); i++) {
      Button button = new Button(i + "");
      button.setEnabled(false);
      boolean isBlack = false;
      for (Integer integer : this.model.getList()) {
        if (integer.equals(i)) {
          isBlack = true;
          button.setBackground(Color.BLACK);
          button.addActionListener(
              new DayController(this.db, this.model.getPictures(i), this.files));
          button.setActionCommand("Day");
          this.revalidate();
        } else {
        }
      }
      button.setVisible(true);
      if (isBlack) {
        button.setEnabled(true);
      }

      this.panel.add(button);
      this.add(this.panel, BorderLayout.CENTER);

      revalidate();
    }

    revalidate();
  }
Exemplo n.º 2
0
  public ReciveFile() {
    super("파일전송");
    setLayout(null);
    lbl = new Label("파일 전송을 기다립니다.");
    lbl.setBounds(10, 30, 230, 20);
    lbl.setBackground(Color.gray);
    lbl.setForeground(Color.white);
    add(lbl);
    txt = new TextArea("", 0, 0, TextArea.SCROLLBARS_BOTH);
    txt.setBounds(10, 60, 230, 100);
    txt.setEditable(false);
    add(txt);
    btn = new Button("닫기");
    btn.setBounds(105, 170, 40, 20);
    btn.setVisible(false);
    btn.addActionListener(this);
    add(btn);
    addWindowListener(new WinListener());
    setSize(250, 200);
    show();

    try {
      ServerSocket socket = new ServerSocket(port);
      Socket sock = null;
      FileThread client = null;
      try {
        sock = socket.accept();
        client = new FileThread(this, sock);
        client.start();
      } catch (IOException e) {
        System.out.println(e);
        try {
          if (sock != null) sock.close();
        } catch (IOException e1) {
          System.out.println(e1);
        } finally {
          sock = null;
        }
      }
    } catch (IOException e) {
    }
  }
Exemplo n.º 3
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);
  }