コード例 #1
0
ファイル: Main.java プロジェクト: davidsjoo/chat_client
  public static void ConfigureMainWindow() {
    userNameLabel.setFont(new Font("Lucida Console", 0, 14));
    userNameLabel.setForeground(new Color(255, 255, 255));

    mainWindow.getContentPane().setBackground(new Color(4, 3, 10));
    mainWindow.setSize(800, 600);
    mainWindow.getContentPane().setLayout(null);
    connectButton.setBackground(new Color(255, 255, 255));
    connectButton.setForeground(new Color(4, 3, 10));
    connectButton.setFont(new Font("Lucida Console", 0, 14));

    connectButton.setText("Anslut");
    connectButton.setToolTipText("");
    mainWindow.getContentPane().add(connectButton);
    connectButton.setBounds(455, 10, 100, 25);

    conversation.setColumns(20);
    conversation.setFont(new Font("Lucida Console", 0, 14));
    conversation.setForeground(new Color(4, 3, 10));
    conversation.setLineWrap(true);
    conversation.setRows(5);
    // conversation.setEditable(false);

    tpConversation.setForeground(new Color(255, 255, 255));
    tpConversation.setBounds(10, 10, 600, 500);
    tpConversation.setBackground(new Color(4, 3, 10));
    tpConversation.setFont(new Font("Lucida Console", 0, 14));

    spConversation.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    spConversation.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    spConversation.setViewportView(tpConversation);
    mainWindow.getContentPane().add(spConversation);
    spConversation.setBounds(10, 10, 600, 500);

    userNameBox.setBounds(120, 10, 325, 25);
    userNameLabel.setBounds(10, 10, 130, 25);
    mainWindow.getContentPane().add(userNameBox);
    mainWindow.getContentPane().add(userNameLabel);

    usersOnline.setForeground(new Color(0, 180, 255));
    usersOnline.setBackground(new Color(4, 3, 10));
    usersOnline.setFont(new Font("Lucida Console", 0, 14));
    spUsersOnline.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    spUsersOnline.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    spUsersOnline.setViewportView(usersOnline);
    mainWindow.getContentPane().add(spUsersOnline);
    spUsersOnline.setBounds(620, 10, 165, 300);

    messageField.setForeground(new Color(255, 255, 255));
    messageField.setBackground(new Color(4, 3, 10));
    messageField.requestFocus();
    messageField.addActionListener(action);
    mainWindow.getContentPane().add(messageField);
    messageField.setBounds(10, 520, 600, 30);

    send.setBackground(new Color(255, 255, 255));
    send.setForeground(new Color(4, 3, 10));
    send.setText("Skicka");
    send.setFont(new Font("Lucida Console", 0, 14));
    mainWindow.getContentPane().add(send);
    send.setBounds(620, 520, 165, 30);

    disconnect.setBackground(new Color(255, 255, 255));
    disconnect.setForeground(new Color(4, 3, 10));
    disconnect.setText("Avsluta chatten");
    disconnect.setFont(new Font("Lucida Console", 0, 14));
    mainWindow.getContentPane().add(disconnect);
    disconnect.setBounds(620, 320, 165, 30);

    error.setFont(new Font("Lucida Console", 0, 14));
    error.setForeground(new Color(255, 0, 23));
    error.setBounds(120, 40, 525, 25);

    mainWindow.getContentPane().add(error);
  }
コード例 #2
0
ファイル: MoleGamePlay.java プロジェクト: jsw2060/P1MOLE
  public MoleGamePlay() {
    for (int i = 0; i < 2; i++) {
      pan[i] = new JPanel();
      pan[i].setBackground(Color.black);
      idtf[i] = new JTextField();
      idtf[i].setEditable(false);
      idtf[i].setHorizontalAlignment(JLabel.CENTER);
    }
    // 게임내 채팅창
    ta = new JTextArea();
    ta.setEditable(false);
    JScrollPane js = new JScrollPane(ta);
    bar = js.getVerticalScrollBar();
    tf = new JTextField();

    pan[0].setBounds(455, 15, 150, 150);
    add(pan[0]);
    idtf[0].setBounds(455, 170, 150, 30);
    add(idtf[0]);

    pan[1].setBounds(610, 15, 150, 150);
    add(pan[1]);
    idtf[1].setBounds(610, 170, 150, 30);
    add(idtf[1]);

    // 게임내 채팅창 위치
    js.setBounds(455, 220, 305, 160);
    tf.setBounds(455, 390, 305, 30);

    // 채팅창
    add(js);
    add(tf);

    scoreJLabel = new JLabel(new ImageIcon("image/score.png")); // 스코어 이미지 위치
    scoreJLabel.setBounds(10, 10, 144, 44);

    jTextPane = new JTextPane(); // 스코어  위치
    jTextPane.setEditable(false);
    jTextPane.setBounds(154, 10, 180, 43);
    jTextPane.setText("0");
    jTextPane.setFont(new Font("Pompadour", 50, 35));

    jButtonStn = new JButton(new ImageIcon("image/start.png"));
    jButtonStn.setBounds(10, 20, 144, 44);
    jButtonStn.setBorderPainted(false);
    jButtonStn.setContentAreaFilled(false);

    jButtonRdy = new JButton(new ImageIcon("image/ready.png"));
    jButtonRdy.setBounds(184, 20, 144, 44);
    jButtonRdy.setBorderPainted(false);
    jButtonRdy.setContentAreaFilled(false);

    jButtonPause = new JButton(new ImageIcon("image/pause.png"));
    jButtonPause.setBounds(10, 74, 144, 44);
    jButtonPause.setBorderPainted(false);
    jButtonPause.setContentAreaFilled(false);

    jButtonCancel = new JButton(new ImageIcon("image/cancel.png"));
    jButtonCancel.setBounds(184, 74, 144, 44);
    jButtonCancel.setBorderPainted(false);
    jButtonCancel.setContentAreaFilled(false);

    jButtonExit = new JButton(new ImageIcon("image/exit.png"));
    jButtonExit.setBounds(10, 128, 144, 44);
    jButtonExit.setBorderPainted(false);
    jButtonExit.setContentAreaFilled(false);

    JLabel gamemenuJLabel = new JLabel();
    gamemenuJLabel.setLayout(null);
    gamemenuJLabel.setBounds(440, 400, 338, 192);
    gamemenuJLabel.add(jButtonStn);
    gamemenuJLabel.add(jButtonRdy);
    gamemenuJLabel.add(jButtonPause);
    gamemenuJLabel.add(jButtonCancel);
    gamemenuJLabel.add(jButtonExit);

    image = Toolkit.getDefaultToolkit().getImage("image/back.png");
    cursorImage = Toolkit.getDefaultToolkit().getImage("image/01.png");
    cursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImage, new Point(0, 0), "null");
    this.setCursor(cursor);
    this.setLayout(null);
    moleGameMyView.setBounds(26, 70, 400, 450);
    notiMyBar.setBounds(15, 530, 420, 30); // 타이머 노티 영역

    this.add(notiMyBar);
    this.add(scoreJLabel);
    this.add(jTextPane);
    this.add(moleGameMyView);
    this.add(gamemenuJLabel);
  }
コード例 #3
0
  About() {
    window = new JWindow();
    this.setPreferredSize(new Dimension(650, 550));
    this.setVisible(true);
    this.setLayout(null);

    JTextPane text = new JTextPane();
    text.setBounds(5, 150, 625, 525);
    text.setVisible(true);
    text.setEditable(false);
    text.setOpaque(false);
    HTMLEditorKit htmlKit =
        new HTMLEditorKit() {
          public Parser getParser() {
            return super.getParser();
          }
        };
    HTMLDocument htmlDoc = new HTMLDocument();
    text.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              if (Desktop.isDesktopSupported()) {
                try {
                  Desktop.getDesktop().browse(e.getURL().toURI());
                  return;
                } catch (IOException e1) {
                } catch (URISyntaxException e1) {
                }
              }
              try {
                Runtime.getRuntime().exec("xdg-open ".concat(e.getURL().toString()));
              } catch (IOException ioex) {
                ControlRoom.log(
                    Level.WARNING,
                    "Failed to show file: '"
                        + e.getURL().toString()
                        + "'. Possible unsupported File Manager...",
                    null);
              }
            }
          }
        });
    text.setEditorKit(htmlKit);
    text.setDocument(htmlDoc);
    try {
      BufferedReader reader =
          new BufferedReader(
              new InputStreamReader(
                  this.getClass().getResourceAsStream("/resources/about.html"), "UTF-8"));
      htmlKit.read(reader, htmlDoc, htmlDoc.getLength());
    } catch (IOException ioex) {
      ControlRoom.log(Level.SEVERE, "Failed to read about.html", ioex);
    } catch (BadLocationException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }

    text.addMouseListener(this);
    window.getContentPane().add(text);
    window.getContentPane().add(this);
    window.addMouseListener(this);
    window.pack();
    ControlRoom.setWindowRelativeToCentral(window);
    window.setVisible(true);
    window.setAlwaysOnTop(true);
  }