private void jbInit() throws Exception { this.getContentPane().setLayout(null); Bienvenue.setFont(new java.awt.Font("Garamond", 1, 24)); Bienvenue.setForeground(SystemColor.textHighlight); Bienvenue.setRequestFocusEnabled(true); Bienvenue.setVerifyInputWhenFocusTarget(true); Bienvenue.setText("Bienvenue dans JChat"); Bienvenue.setBounds(new Rectangle(125, 28, 305, 44)); Pseudo_L.setFont(new java.awt.Font("Dialog", 1, 14)); Pseudo_L.setText("Pseudonyme :"); Pseudo_L.setBounds(new Rectangle(75, 94, 128, 28)); nom.setText(""); nom.setBounds(new Rectangle(229, 95, 108, 24)); pwd.setText(""); pwd.setBounds(new Rectangle(230, 135, 108, 25)); pwd_L.setFont(new java.awt.Font("Dialog", 1, 14)); pwd_L.setText("Mot de passe :"); pwd_L.setBounds(new Rectangle(76, 133, 122, 31)); gestionnaire_B gestionnaire = new gestionnaire_B(); Connect.addActionListener(gestionnaire); Connect.setBackground(new Color(239, 240, 234)); Connect.setBounds(new Rectangle(281, 251, 142, 30)); Connect.setText("Connexion"); Connect.setIcon(new ImageIcon(image_c)); Annuler.addActionListener(gestionnaire); Annuler.setBackground(new Color(239, 240, 234)); Annuler.setBounds(new Rectangle(104, 252, 140, 29)); Annuler.setText("Annuler"); Annuler.setIcon(new ImageIcon(image_d)); this.getContentPane().setBackground(new Color(239, 240, 234)); this.setForeground(new Color(239, 240, 234)); this.setTitle("Interface de connexion des clients au serveur de chat"); jLabel1.setFont(new java.awt.Font("Dialog", 1, 14)); jLabel1.setText("Adresse du serveur :"); jLabel1.setBounds(new Rectangle(75, 176, 156, 26)); jTextField1.setBounds(new Rectangle(230, 176, 108, 25)); Icon siegle = new ImageIcon(image); siegle_L = new JLabel("", siegle, SwingConstants.LEFT); siegle_L.setBounds(new Rectangle(0, 1, 76, 105)); this.getContentPane().add(jLabel1, null); this.getContentPane().add(pwd_L, null); this.getContentPane().add(Pseudo_L, null); this.getContentPane().add(jTextField1, null); this.getContentPane().add(nom, null); this.getContentPane().add(pwd, null); this.getContentPane().add(Bienvenue, null); this.getContentPane().add(Connect, null); this.getContentPane().add(Annuler, null); this.getContentPane().add(siegle_L, null); this.setSize(new Dimension(439, 321)); this.setResizable(false); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); }
/*Creates the East section of the mancala board. Contains Collection Pit*/ private JPanel eastBoardPanel() { JPanel eastPanel = new JPanel(); eastPanel.setOpaque(false); eastPanel.setPreferredSize(new Dimension(150, 600)); b6 = new JButton(String.valueOf(game.board.getPitAt(6).getCount())); b6.setPreferredSize(new Dimension(100, 330)); b6.setFont(new Font("Belta Regular", Font.BOLD, 32)); b6.setBackground(new Color(214, 162, 173)); eastPanel.add(b6); return eastPanel; }
// Method to build the dialog box for help. private void buildDialogBox() { // Set the JDialog window properties. setTitle("Learning about Java"); setResizable(false); setSize(dialogWidth, dialogHeight); // Define behaviors of container. c.setLayout(null); c.setBackground(Color.cyan); c.add(image); c.add(okButton); // Set the bounds for the image. image.setBounds( (dialogWidth / 2) - (imageWidth / 2), (top + (offsetMargin / 2)), imageWidth, imageHeight); // Set the behaviors, bounds and action listener for the button. okButton.setBounds( (dialogWidth / 2) - (buttonWidth / 2), (imageHeight + (int) 1.5 * offsetMargin), buttonWidth, buttonHeight); // Set the font to the platform default Font for the object with the // properties of bold and font size of 11. okButton.setFont(new Font(okButton.getFont().getName(), Font.BOLD, 11)); // Set foreground and background of JButton(s). okButton.setForeground(Color.white); okButton.setBackground(Color.blue); // The class implements the ActionListener interface and therefore // provides an implementation of the actionPerformed() method. When a // class implements ActionListener, the instance handler returns an // ActionListener. The ActionListener then performs actionPerformed() // method on an ActionEvent. okButton.addActionListener(this); // Set the screen and display dialog window in relation to screen size. dim = tk.getScreenSize(); setLocation((dim.width / 2) - (dialogWidth / 2), (dim.height / 2) - (dialogHeight / 2)); // Display the dialog. show(); } // End of buildDialogBox method.
private JButton createCopyToClipboardButton() { JButton button = new JButton("COPY TO CLIPBOARD"); button.setBackground(Color.BLACK); button.setForeground(Color.GRAY); button.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { copyOverviewToClipboard(); } catch (InsufficientDataException ex) { ex.printStackTrace(); JOptionPane.showMessageDialog( ReviewDialog.this, "Failed to copy the overview to clipboard: " + ex.getMessage()); } } }); return button; }
public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("close")) { if (m_nType == CONFIG) saveData(); else if (m_nType == DEFAULT && m_pnlAccPolicy != null) m_pnlAccPolicy.saveData(); setVisible(false); dispose(); } else if (cmd.equals("validate")) { if (timer != null) timer.cancel(); if (m_nType == CHECKSUM && m_pnlChecksum != null) m_pnlChecksum.checksumValidation(); else doSysValidation(); validateButton.setBackground(closeButton.getBackground()); } else if (cmd.equals("checksum")) { String strValue = m_pnlChecksum.getChecksum(); m_pnlChecksum.setData(strValue); } else if (cmd.equals("checksumdir")) { m_pnlChecksum.setData(""); } else if (cmd.equals("cancel")) { // build(m_bAccPolicy); setVisible(false); dispose(); } else if (cmd.equals("help")) displayHelp(); }
/** * The function creates a button, which opens a file chooser and writes a summary of the displayed * results into a user-selected file. * * @return The 'save to file' button. */ private JButton createSaveToFileButton() { JButton b = new JButton("SAVE TO FILE"); b.setBackground(Color.BLACK); b.setForeground(Color.GRAY); b.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { checkTotal(); fileChooser.setSelectedFile(new File(getDefaultFilename())); int returnValue = fileChooser.showDialog(ReviewDialog.this, "Save"); if (returnValue != JFileChooser.APPROVE_OPTION) return; writeToFile(fileChooser.getSelectedFile()); ReviewDialog.this.setVisible(false); } catch (Exception ex) { JOptionPane.showMessageDialog( ReviewDialog.this, ex.getMessage(), "Error occurred", JOptionPane.ERROR_MESSAGE); } } }); return b; }
/** This method is called from within the constructor to initialize the form. */ public void initComponents() { /** *************** The main frame ************************************** */ // width, height this.setSize(560, 370); Container container = this.getContentPane(); container.setLayout(new BoxLayout(getContentPane(), 1)); container.setBackground(containerBackGroundColor); this.setLocation(0, 0); this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { new AlertInstantMessaging( "Your changes will not be checked: use the Submit button!!!", JOptionPane.WARNING_MESSAGE); hideFrame(); } }); /** **************** The components ********************************* */ firstPanel = new JPanel(); firstPanel.setBorder(BorderFactory.createEmptyBorder(15, 4, 15, 4)); // If put to False: we see the container's background firstPanel.setOpaque(false); // rows, columns, horizontalGap, verticalGap firstPanel.setLayout(new GridLayout(11, 2, 2, 2)); container.add(firstPanel); outboundProxyAddressLabel = new JLabel("Outbound proxy IP address:"); outboundProxyAddressLabel.setForeground(Color.black); outboundProxyAddressTextField = new JTextField(20); outboundProxyAddressLabel.setBorder(labelBorder); outboundProxyAddressLabel.setOpaque(true); outboundProxyAddressLabel.setBackground(labelBackGroundColor); firstPanel.add(outboundProxyAddressLabel); firstPanel.add(outboundProxyAddressTextField); outboundProxyPortLabel = new JLabel("Outbound proxy port:"); outboundProxyPortLabel.setForeground(Color.black); outboundProxyPortTextField = new JTextField(20); outboundProxyPortLabel.setBorder(labelBorder); outboundProxyPortLabel.setOpaque(true); outboundProxyPortLabel.setBackground(labelBackGroundColor); firstPanel.add(outboundProxyPortLabel); firstPanel.add(outboundProxyPortTextField); registrarAddressLabel = new JLabel("Registrar IP address:"); registrarAddressLabel.setForeground(Color.black); registrarAddressTextField = new JTextField(20); registrarAddressLabel.setBorder(labelBorder); registrarAddressLabel.setOpaque(true); registrarAddressLabel.setBackground(labelBackGroundColor); firstPanel.add(registrarAddressLabel); firstPanel.add(registrarAddressTextField); registrarPortLabel = new JLabel("Registrar port:"); registrarPortLabel.setForeground(Color.black); registrarPortTextField = new JTextField(20); registrarPortLabel.setBorder(labelBorder); registrarPortLabel.setOpaque(true); registrarPortLabel.setBackground(labelBackGroundColor); firstPanel.add(registrarPortLabel); firstPanel.add(registrarPortTextField); imAddressLabel = new JLabel("Contact IP address:"); imAddressLabel.setForeground(Color.black); imAddressTextField = new JTextField(20); imAddressLabel.setBorder(labelBorder); imAddressLabel.setOpaque(true); imAddressLabel.setBackground(labelBackGroundColor); firstPanel.add(imAddressLabel); firstPanel.add(imAddressTextField); imPortLabel = new JLabel("Contact port:"); imPortLabel.setForeground(Color.black); imPortTextField = new JTextField(20); imPortLabel.setBorder(labelBorder); imPortLabel.setOpaque(true); imPortLabel.setBackground(labelBackGroundColor); firstPanel.add(imPortLabel); firstPanel.add(imPortTextField); imProtocolLabel = new JLabel("Contact transport:"); imProtocolLabel.setForeground(Color.black); imProtocolTextField = new JTextField(20); imProtocolLabel.setBorder(labelBorder); imProtocolLabel.setOpaque(true); imProtocolLabel.setBackground(labelBackGroundColor); firstPanel.add(imProtocolLabel); firstPanel.add(imProtocolTextField); outputFileLabel = new JLabel("Output file:"); outputFileLabel.setForeground(Color.black); outputFileTextField = new JTextField(20); outputFileLabel.setBorder(labelBorder); outputFileLabel.setOpaque(true); outputFileLabel.setBackground(labelBackGroundColor); firstPanel.add(outputFileLabel); firstPanel.add(outputFileTextField); buddiesFileLabel = new JLabel("Buddies file:"); buddiesFileLabel.setForeground(Color.black); buddiesFileTextField = new JTextField(20); buddiesFileLabel.setBorder(labelBorder); buddiesFileLabel.setOpaque(true); buddiesFileLabel.setBackground(labelBackGroundColor); firstPanel.add(buddiesFileLabel); firstPanel.add(buddiesFileTextField); authenticationFileLabel = new JLabel("Authentication file:"); authenticationFileLabel.setForeground(Color.black); authenticationFileTextField = new JTextField(20); authenticationFileLabel.setBorder(labelBorder); authenticationFileLabel.setOpaque(true); authenticationFileLabel.setBackground(labelBackGroundColor); firstPanel.add(authenticationFileLabel); firstPanel.add(authenticationFileTextField); defaultRouterLabel = new JLabel("Default router class name:"); defaultRouterLabel.setForeground(Color.black); defaultRouterTextField = new JTextField(20); defaultRouterLabel.setBorder(labelBorder); defaultRouterLabel.setOpaque(true); defaultRouterLabel.setBackground(labelBackGroundColor); firstPanel.add(defaultRouterLabel); firstPanel.add(defaultRouterTextField); thirdPanel = new JPanel(); thirdPanel.setOpaque(false); // top, left, bottom, right thirdPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); submitButton = new JButton(" Submit "); submitButton.setToolTipText("Submit your changes!"); submitButton.setFocusPainted(false); submitButton.setFont(new Font("Dialog", 1, 16)); submitButton.setBackground(buttonBackGroundColor); submitButton.setBorder(buttonBorder); submitButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { submitButtonActionPerformed(evt); } }); thirdPanel.add(submitButton); container.add(thirdPanel); }
public void launchChess() { mainWindow = new JFrame("网络黑白棋 作者:张炀"); jpWest = new JPanel(); jpEast = new JPanel(); jpNorth = new JPanel(); jpSouth = new JPanel(); jpCenter = new JPanel(); turnLabel = new JLabel(); blackNumberLabel = new JLabel("黑棋:\n" + black + " "); whiteNumberLabel = new JLabel("白棋:\n" + white + " "); timeLabel = new JLabel("时间: " + time + " s"); noticeLabel = new JLabel(); noticeLabel = new JLabel("请选择:"); numberPane = new JPanel(); readyPane = new JPanel(); jt1 = new JTextField(18); // 发送信息框 jt2 = new JTextArea(3, 30); // 显示信息框 js = new JScrollPane(jt2); jt2.setLineWrap(true); jt2.setEditable(false); // jt1.setLineWrap(true); send = new JButton("发送"); cancel = new JButton("取消"); regret = new JButton("悔棋"); submit = new JButton("退出"); begin = new JButton("开始"); save = new JButton("存盘"); save.setEnabled(true); begin.setEnabled(true); fighter = new JRadioButton("下棋"); audience = new JRadioButton("观看"); group = new ButtonGroup(); group.add(audience); group.add(fighter); group.add(AIPlayer); submit.addActionListener(this); begin.addActionListener(this); save.addActionListener(this); send.addActionListener(this); cancel.addActionListener(this); regret.addActionListener(this); fighter.addActionListener(this); audience.addActionListener(this); jpNorth.setLayout(new BorderLayout()); jpNorth.add(turnLabel, BorderLayout.NORTH); jpNorth.add(jpCenter, BorderLayout.CENTER); jpSouth.add(js); jpSouth.add(jt1); jpSouth.add(send); jpSouth.add(cancel); jpEast.setLayout(new GridLayout(3, 1)); submit.setBackground(new Color(130, 251, 241)); panel x = new panel(); jpEast.add(x); jpEast.add(numberPane); jpEast.add(readyPane); numberPane.add(blackNumberLabel); numberPane.add(whiteNumberLabel); numberPane.add(timeLabel); numberPane.add(submit); numberPane.add(begin); numberPane.add(save); numberPane.add(regret); readyPane.add(noticeLabel); readyPane.add(fighter); readyPane.add(audience); // readyPane.add(save); // readyPane.add(regret); jpCenter.setSize(400, 400); jmb = new JMenuBar(); document = new JMenu("游戏 "); edit = new JMenu("设置 "); insert = new JMenu("棋盘 "); help = new JMenu("帮助 "); jmb.add(document); jmb.add(edit); jmb.add(insert); jmb.add(help); // mainWindow.setJMenuBar(jmb); mainWindow.setBounds(80, 80, 600, 600); mainWindow.setResizable(false); jsLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, jpNorth, jpSouth); jsBase = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, jsLeft, jpEast); mainWindow.add(jsBase); mainWindow.setVisible(true); mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jsBase.setDividerLocation(0.7); jsLeft.setDividerLocation(0.78); jpCenter.setLayout(new GridLayout(8, 8, 0, 0)); ImageIcon key = new ImageIcon("chess1.jpg"); for (int i = 0; i < cell.length; i++) for (int j = 0; j < cell.length; j++) { cell[i][j] = new ChessBoard(i, j); cell[i][j].addMouseListener(this); jpCenter.add(cell[i][j]); } cell[3][3].state = cell[4][4].state = '黑'; cell[4][3].state = cell[3][4].state = '白'; cell[3][3].taken = cell[4][4].taken = true; cell[4][3].taken = cell[3][4].taken = true; RememberState(); new Thread(new TurnLabel(this)).start(); file = new File("D:/" + myRole); try { fout = new FileOutputStream(file); out = new ObjectOutputStream(fout); } catch (IOException e1) { e1.printStackTrace(); } Connect(); try { out99 = new ObjectOutputStream(socket99.getOutputStream()); in99 = new ObjectInputStream(socket99.getInputStream()); out66 = new ObjectOutputStream(socket66.getOutputStream()); in66 = new ObjectInputStream(socket66.getInputStream()); out88 = new DataOutputStream(socket88.getOutputStream()); } catch (IOException e) { e.printStackTrace(); } new Thread(new Client9999(this)).start(); new Thread(new Client6666(this)).start(); }
private void makeMenuScreen() { menu = new JPanel(); menu.setBackground(Color.BLACK); menu.setLayout(null); menu.setBounds(0, 0, width, height); try { BufferedImage menuIMG = ImageIO.read(this.getClass().getResource("/Resources/MenuBackground.png")); // BufferedImage menuIMG = ImageIO.read(new // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/MenuBackground.png")); menuIMGL = new JLabel( new ImageIcon( menuIMG.getScaledInstance( (int) (width * 0.8), (int) (height * 0.8), Image.SCALE_SMOOTH))); menuIMGL.setBounds(0, 0, width, height); } catch (Exception e) { } highscoreL = new JLabel(String.valueOf(highscore)); highscoreL.setBackground(Color.darkGray); highscoreL.setBounds((width / 2) + 100, (height / 2) + 70, 500, 100); highscoreL.setForeground(Color.white); easy = new JButton("Easy"); hard = new JButton("Hard"); easy.addActionListener(this); hard.addActionListener(this); easy.setBounds((width / 2) - 60, (height / 2) - 50, 120, 20); hard.setBounds((width / 2) - 60, height / 2 - 10, 120, 20); onePlayerRB = new JRadioButton("One Player"); twoPlayerRB = new JRadioButton("Two Player"); mouseRB = new JRadioButton("Mouse (Player 1)"); keyboardRB = new JRadioButton("Keyboard (Player 1)"); keyboardSpeedS1 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50); keyboardSpeedS2 = new JSlider(JSlider.HORIZONTAL, 10, 300, 50); musicCB = new JCheckBox("Music"); onePlayerRB.setBackground(null); twoPlayerRB.setBackground(null); mouseRB.setBackground(null); keyboardRB.setBackground(null); keyboardSpeedS1.setBackground(null); keyboardSpeedS2.setBackground(null); musicCB.setBackground(null); onePlayerRB.setForeground(Color.WHITE); twoPlayerRB.setForeground(Color.WHITE); mouseRB.setForeground(Color.WHITE); keyboardRB.setForeground(Color.WHITE); keyboardSpeedS1.setForeground(Color.WHITE); keyboardSpeedS2.setForeground(Color.WHITE); musicCB.setForeground(Color.WHITE); ButtonGroup playerChoice = new ButtonGroup(); playerChoice.add(onePlayerRB); playerChoice.add(twoPlayerRB); onePlayerRB.setSelected(true); ButtonGroup peripheralChoice = new ButtonGroup(); peripheralChoice.add(mouseRB); peripheralChoice.add(keyboardRB); mouseRB.setSelected(true); musicCB.setSelected(true); onePlayerRB.setBounds((width / 2) + 100, (height / 2) - 50, 100, 20); twoPlayerRB.setBounds((width / 2) + 100, (height / 2) - 30, 100, 20); mouseRB.setBounds((width / 2) + 100, (height / 2), 200, 20); keyboardRB.setBounds((width / 2) + 100, (height / 2) + 20, 200, 20); keyboardSpeedS1.setBounds(width / 2 - 120, height / 2 + 100, 200, 50); keyboardSpeedS2.setBounds(width / 2 - 120, height / 2 + 183, 200, 50); musicCB.setBounds((width / 2) + 100, (height / 2) + 50, 100, 20); keyboardSpeedL1 = new JLabel("Keyboard Speed (Player One)"); keyboardSpeedL1.setForeground(Color.WHITE); keyboardSpeedL1.setBounds(width / 2 - 113, height / 2 + 67, 200, 50); keyboardSpeedL2 = new JLabel("Keyboard Speed (Player Two)"); keyboardSpeedL2.setForeground(Color.WHITE); keyboardSpeedL2.setBounds(width / 2 - 113, height / 2 + 150, 200, 50); howTo = new JButton("How To Play"); howTo.addActionListener(this); howTo.setBounds((width / 2) - 60, height / 2 + 30, 120, 20); try { BufferedImage howToIMG = ImageIO.read(this.getClass().getResource("/Resources/HowTo.png")); // BufferedImage howToIMG = ImageIO.read(new // File("M:/ComputerProgrammingJava/InsaneMouse_03/src/Resources/HowTo.png")); howToIMGL = new JLabel(new ImageIcon(howToIMG)); howToIMGL.setBounds( width / 2 - howToIMG.getWidth() / 2, height / 2 - howToIMG.getHeight() / 2, howToIMG.getWidth(), howToIMG.getHeight()); } catch (Exception e) { } howToBack = new JButton("X"); howToBack.setBounds( (int) (width / 2 + width * 0.25) - 50, (int) (height / 2 - height * 0.25), 50, 50); howToBack.setBackground(Color.BLACK); howToBack.setForeground(Color.WHITE); howToBack.addActionListener(this); menu.add(easy); menu.add(hard); menu.add(howTo); menu.add(highscoreL); menu.add(onePlayerRB); menu.add(twoPlayerRB); menu.add(mouseRB); menu.add(keyboardRB); menu.add(keyboardSpeedL1); menu.add(keyboardSpeedL2); menu.add(keyboardSpeedS1); menu.add(keyboardSpeedS2); menu.add(musicCB); menu.add(menuIMGL); back = new JButton("Back"); back.setBounds(width / 2 - 40, height / 2, 100, 20); back.addActionListener(this); back.setVisible(false); this.add(back); }
public MancalaPanel(LetsPlayMancala game) { // ------------------------------------------------------------------------------ // Import font "Belta Regular" // ----------------------------------------------------------------------------- try { InputStream in = MancalaPanel.class.getResourceAsStream("belta-regular.ttf"); Font font = Font.createFont(Font.TRUETYPE_FONT, in); } catch (Exception ex) { System.out.println("Font couldn't be loaded."); } // ---------------------------------------------------------------------------- // Set background image // ---------------------------------------------------------------------------- imageFile = "/Images/GameBackground.png"; this.game = game; SMALL_PIT_COUNT = 12; setLayout(new BorderLayout()); add(northWindowPanel(), BorderLayout.NORTH); add(westWindowPanel(), BorderLayout.WEST); add(makeBoardPanel(), BorderLayout.CENTER); add(eastWindowPanel(), BorderLayout.EAST); add(southWindowPanel(), BorderLayout.SOUTH); winners = new LinkedStack<String>(); winnersLabel = new JLabel(); resultFrame = new JFrame(); boardResultPanel = new BkImagePanel("/Images/board2.png"); resultNorth = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 50)); resultNorth.setOpaque(false); resultCenter = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0)); resultCenter.setOpaque(false); resultSouth = new JPanel(new FlowLayout(FlowLayout.CENTER, 20, 20)); resultSouth.setOpaque(false); playAgainBtn.setPreferredSize(new Dimension(240, 80)); playAgainBtn.setBackground(new Color(135, 17, 76)); playAgainBtn.setForeground(Color.white); playAgainBtn.setBorder(BorderFactory.createLineBorder(Color.white, 6)); playAgainBtn.setFont(new Font("Belta Regular", Font.BOLD, 40)); playAgainBtn.addActionListener(new ButtonListener()); scoresBtn.setPreferredSize(new Dimension(340, 80)); scoresBtn.setBorder(BorderFactory.createLineBorder(Color.white, 6)); scoresBtn.addActionListener(new ButtonListener()); quitBtn.setPreferredSize(new Dimension(150, 80)); quitBtn.setBorder(BorderFactory.createLineBorder(Color.white, 6)); quitBtn.addActionListener(new ButtonListener()); result = new JLabel(); result.setFont(new Font("Belta Regular", Font.BOLD, 40)); result.setForeground(Color.white); result.setBackground(new Color(0, 158, 121)); result.setBorder(BorderFactory.createLineBorder(Color.white, 6)); result.setOpaque(true); result.setPreferredSize(new Dimension(380, 80)); winnersLabel = new JLabel(); winnersLabel.setFont(new Font("Belta Regular", Font.BOLD, 40)); winnersLabel.setForeground(Color.white); winnersLabel.setPreferredSize(new Dimension(420, 200)); boardResultPanel.setLayout(new BorderLayout(50, 50)); boardResultPanel.setPreferredSize(new Dimension(800, 700)); boardResultPanel.setBackground(Color.yellow); boardResultPanel.add(resultNorth, BorderLayout.NORTH); boardResultPanel.add(resultCenter, BorderLayout.CENTER); boardResultPanel.add(resultSouth, BorderLayout.SOUTH); resultCenter.add(winnersLabel); resultSouth.add(scoresBtn); resultSouth.add(playAgainBtn); resultSouth.add(quitBtn); resultFrame.add(boardResultPanel); }
public void init() { areaventana = new JPanel(); areabotones = new JPanel(); imagen = new JLabel(""); presentacion = new JButton(imgPlay); siguiente = new JButton(imgSiguiente); atras = new JButton(imgAnterior); ptiempo = new JSlider(); carpeta = new JButton(imgNuevaCarpeta); grid = new JButton(imgGrid); bcomentario = new JButton(imgComentario); zoom = new JButton(imgZoom); /* Agregando los componentes */ areaventana.add(imagen); // areaventana.add(desplazamiento); areabotones.add(grid); areabotones.add(atras); areabotones.add(presentacion); areabotones.add(siguiente); areabotones.add(ptiempo); areabotones.add(carpeta); areabotones.add(bcomentario); areabotones.add(zoom); areabotones.setBackground(colorGris); areaventana.setBackground(colorGris); // desplazamiento.setVisible(false); // areaventana.add(desplazamiento); /* GUI GUI GUI GUI */ presentacion.setBackground(colorGris); atras.setBackground(colorGris); siguiente.setBackground(colorGris); carpeta.setBackground(colorGris); grid.setBackground(colorGris); ptiempo.setBackground(colorGris); bcomentario.setBackground(colorGris); zoom.setBackground(colorGris); presentacion.setPreferredSize(new Dimension(100, 80)); atras.setPreferredSize(new Dimension(100, 80)); siguiente.setPreferredSize(new Dimension(100, 80)); carpeta.setPreferredSize(new Dimension(100, 80)); grid.setPreferredSize(new Dimension(100, 80)); bcomentario.setPreferredSize(new Dimension(100, 80)); zoom.setPreferredSize(new Dimension(100, 80)); grid.setFocusPainted(false); atras.setFocusPainted(false); siguiente.setFocusPainted(false); carpeta.setFocusPainted(false); presentacion.setFocusPainted(false); bcomentario.setFocusPainted(false); zoom.setFocusPainted(false); grid.setBorder(null); atras.setBorder(null); siguiente.setBorder(null); carpeta.setBorder(null); presentacion.setBorder(null); areabotones.setBorder(null); areaventana.setBorder(null); bcomentario.setBorder(null); zoom.setBorder(null); /* GUI GUI GUI GUI */ /* Action Listeners */ siguiente.addActionListener(this); atras.addActionListener(this); presentacion.addActionListener(this); carpeta.addActionListener(this); grid.addActionListener(this); bcomentario.addActionListener(this); zoom.addActionListener(this); this.setLayout(new BorderLayout()); add(areaventana, BorderLayout.CENTER); add(areabotones, BorderLayout.SOUTH); ptiempo.setVisible(false); siguiente.setEnabled(false); atras.setEnabled(false); presentacion.setEnabled(false); grid.setEnabled(false); bcomentario.setEnabled(false); zoom.setEnabled(false); /* Abre el selector desde que inicia el programa */ chooser = new JFileChooser(); chooser.setDialogTitle("Selecciona una imagen..."); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(false); // Abrir archivo es de acá... returnChooser = chooser.showOpenDialog(ArcViewer.this); if (returnChooser == 0) { imagenes = lista.Miranda(chooser, returnChooser); siguiente.setEnabled(true); atras.setEnabled(true); presentacion.setEnabled(true); grid.setEnabled(true); bcomentario.setEnabled(true); zoom.setEnabled(true); for (int asd1 = 0; asd1 < imagenes.size(); asd1++) { imagenesbean.add(new ImagenBean(imagenes.get(asd1), 0, 0)); } String getImgSelected = chooser.getSelectedFile().getPath(); for (int index = 0; index < imagenesbean.size(); index++) { if (getImgSelected.equals(imagenesbean.get(index).getIcon())) { imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon())); indexaux = index; } } } else { System.out.println("No Selection"); carpeta.setEnabled(true); } // for (int asd1=0; asd1 < imagenes.size(); asd1++) { // imagenesbean.add(new ImagenBean(imagenes.get(asd1),0,0)); // } // String getImgSelected = chooser.getSelectedFile().getPath(); // for (int index=0; index < imagenesbean.size(); index++) { // if (getImgSelected.equals( imagenesbean.get(index).getIcon() )) { // imagen.setIcon(new ImageIcon(imagenesbean.get(index).getIcon())); // indexaux = index; // } // } }
editprof(String str, String user) { cp = getContentPane(); cp.setLayout(null); user1 = user; try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception e) { } JTextField ft = new JTextField(); name1 = new JLabel("First Name"); try { r = new FileReader(user + "/First name.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } name = new JTextField(); name.setText(ft.getText()); last1 = new JLabel("Enter Last Name"); try { r = new FileReader(user + "/last name.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } last = new JTextField(); last.setText(ft.getText()); pass = new JLabel("Password"); try { r = new FileReader(user + "/password.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } pwd = new JPasswordField(); pwd.setText(ft.getText()); pwd.setEditable(false); email1 = new JLabel("Enter email address"); try { r = new FileReader(user + "/email.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } email = new JTextField(); email.setText(ft.getText()); addimage = new JButton("Add Image"); icon = new JLabel(); date1 = new JLabel("Date Of Birth"); date = new JComboBox(); for (int i = 1; i <= 31; i++) { date.addItem(i); } month = new JComboBox(); month.addItem("Jan"); month.addItem("Feb"); month.addItem("Mar"); month.addItem("Apr"); month.addItem("May"); month.addItem("Jun"); month.addItem("Jul"); month.addItem("Aug"); month.addItem("Sep"); month.addItem("Oct"); month.addItem("Nov"); month.addItem("Dec"); year = new JComboBox(); for (int j = 1900; j <= 2010; j++) { year.addItem(j); } sx = new JLabel("Gender"); gen = new JComboBox(); gen.addItem("Male"); gen.addItem("Female"); con1 = new JLabel("Country Name"); con = new JComboBox(); con.addItem(" Austrelia"); con.addItem(" America"); con.addItem(" Antartica"); con.addItem(" Africa"); con.addItem(" Canda"); con.addItem(" Corea"); con.addItem(" Chaina"); con.addItem(" Denmark"); con.addItem(" England"); con.addItem(" Franc"); con.addItem(" Hangery"); con.addItem(" Holand"); con.addItem(" Itali"); con.addItem(" India"); con.addItem(" Indonesia"); con.addItem(" Jermany"); con.addItem(" Japan"); con.addItem(" Korea"); con.addItem(" Kembridge"); con.addItem(" Merusalem"); con.addItem(" Noth America"); con.addItem(" Norvey"); con.addItem(" West Indies"); con.addItem(" Peru"); con.addItem(" Zimbawe"); about = new JLabel("About me"); try { r = new FileReader(user + "/about.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS; int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS; main = new JTextArea(); main.setText(ft.getText()); JScrollPane jsp = new JScrollPane(main, v, h); allow = new JLabel("Allow To:"); JCheckBox c1 = new JCheckBox(" orkut Friends"); JCheckBox c2 = new JCheckBox("Collage Friends"); JCheckBox c3 = new JCheckBox("Business Partner"); JCheckBox c4 = new JCheckBox("Relatives"); col = new JLabel("Collage Name:"); try { r = new FileReader(user + "/Collage.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } col1 = new JTextField(); col1.setText(ft.getText()); try { r = new FileReader(user + "/UniverSity.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } uni = new JLabel("Univercity"); uni1 = new JTextField(); uni1.setText(ft.getText()); state1 = new JLabel("State Name"); try { r = new FileReader(user + "/state.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } state = new JTextField(); state.setText(ft.getText()); city = new JLabel("City"); try { r = new FileReader(user + "/City.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } city1 = new JTextField(); city1.setText(ft.getText()); try { r = new FileReader(user + "/imagepath.txt"); ft.read(r, null); r.close(); } catch (Exception de) { } ImageIcon io = new ImageIcon(ft.getText()); icon.setIcon(io); next = new JButton("Update"); next.setBackground(Color.white); // adding to container name1.setBounds(10, 10, 130, 25); name.setBounds(150, 10, 130, 25); last1.setBounds(10, 40, 130, 25); last.setBounds(150, 40, 130, 25); email1.setBounds(10, 70, 130, 25); email.setBounds(150, 70, 130, 25); pass.setBounds(290, 70, 130, 25); pwd.setBounds(390, 70, 130, 25); addimage.setBounds(350, 440, 100, 25); icon.setBounds(490, 410, 100, 100); date1.setBounds(10, 100, 130, 25); date.setBounds(120, 100, 40, 25); month.setBounds(180, 100, 130, 25); year.setBounds(320, 100, 130, 25); sx.setBounds(10, 140, 130, 25); gen.setBounds(150, 140, 130, 25); about.setBounds(10, 180, 130, 25); jsp.setBounds(150, 180, 250, 80); allow.setBounds(10, 260, 130, 25); c1.setBounds(150, 260, 130, 25); c2.setBounds(290, 260, 130, 25); c3.setBounds(150, 290, 130, 25); c4.setBounds(290, 290, 130, 25); uni.setBounds(10, 330, 130, 25); uni1.setBounds(150, 330, 130, 25); col.setBounds(10, 360, 130, 25); col1.setBounds(150, 360, 130, 25); con1.setBounds(10, 390, 130, 25); con.setBounds(150, 390, 130, 25); state1.setBounds(10, 430, 130, 25); state.setBounds(150, 430, 130, 25); city.setBounds(10, 460, 130, 25); city1.setBounds(150, 460, 130, 25); next.setBounds(50, 490, 130, 25); cp.add(name); cp.add(name1); cp.add(last); cp.add(last1); cp.add(email); cp.add(email1); cp.add(addimage); cp.add(icon); cp.add(date1); cp.add(date); cp.add(month); cp.add(year); cp.add(about); cp.add(jsp); cp.add(sx); cp.add(gen); cp.add(allow); cp.add(c1); cp.add(c2); cp.add(c3); cp.add(c4); cp.add(next); cp.add(uni); cp.add(uni1); cp.add(col); cp.add(col1); cp.add(con); cp.add(con1); cp.add(state1); cp.add(state); cp.add(city); cp.add(city1); cp.add(next); cp.add(pwd); cp.add(pass); addimage.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { filepath = name.getText(); JFileChooser chooser = new JFileChooser(); while (true) { int val = chooser.showOpenDialog(editprof.this); File f = chooser.getSelectedFile(); String path = f.getPath(); String name = f.getName(); try { if (val == JFileChooser.CANCEL_OPTION || val == -1) { break; } else { image = new ImageIcon(path); icon.setIcon(image); w = new FileWriter(filepath + "/" + "imagePath.txt"); w.write(path + ""); w.close(); break; } } catch (Exception se) { } } } }); date.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { int str = (Integer) e.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "date.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); month.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e1) { String str = (String) e1.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "month.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); con.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e2) { String str = (String) e2.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "contry.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); year.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e2) { int str = (Integer) e2.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "year.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); gen.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e3) { String str = (String) e3.getItem(); File f = new File(name.getText()); f.mkdir(); try { w = new FileWriter(name.getText() + "/" + "gender.txt"); w.write(str + ""); w.close(); } catch (IOException de) { } } }); next.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent se) { try { w = new FileWriter(name.getText() + "/" + "First name.txt"); w.write(name.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "last name.txt"); w.write(last.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "email.txt"); w.write(email.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "Collage.txt"); w.write(col1.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "UniverSity.txt"); w.write(uni1.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "state.txt"); w.write(state.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "City.txt"); w.write(city1.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "about.txt"); w.write(main.getText()); w.close(); w = new FileWriter(name.getText() + "/" + "password.txt"); w.write(pwd.getText()); w.close(); profile e1 = new profile("My Profile", user1); e1.setVisible(true); e1.setLocation(00, 00); e1.setSize(800, 800); setVisible(false); } catch (Exception be) { } } }); }