public void mouseExited(MouseEvent e) { JButton jbutton = (JButton) e.getSource(); int comm = Integer.parseInt(jbutton.getActionCommand()); int today = getNowCalendar().get(Calendar.DAY_OF_MONTH); if (comm == today) { jbutton.setBackground(todayBtnColor); } else { jbutton.setBackground(palletTableColor); } }
protected void initComponents() { int border = 2; this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); // Description label JPanel descriptionPanel = new JPanel(new GridLayout(0, 1, 0, 0)); descriptionPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); String text = thread.getRetrievable().getName(); text = text.length() > 40 ? text.substring(0, 37) + "..." : text; descriptionLabel = new JLabel(text); descriptionPanel.add(descriptionLabel); this.add(descriptionPanel); // Progrees and cancel button JPanel progressPanel = new JPanel(); progressPanel.setLayout(new BoxLayout(progressPanel, BoxLayout.X_AXIS)); progressPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border)); progressBar = new JProgressBar(0, 100); progressBar.setPreferredSize(new Dimension(100, 16)); progressPanel.add(progressBar); progressPanel.add(Box.createHorizontalStrut(8)); cancelButton = new JButton("Cancel"); cancelButton.setBackground(Color.RED); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { cancelButtonActionPerformed(event); } }); progressPanel.add(cancelButton); this.add(progressPanel); }
public void initComponents() { /** ******************** The main container *************************** */ Container container = this.getContentPane(); container.setLayout(new BorderLayout()); container.setBackground(Color.black); this.setSize(650, 600); this.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) {} }); /** ************************* MAIN PANEL ******************************* */ mainPanel = new JPanel(); // If put to False: we see the container's background mainPanel.setOpaque(false); mainPanel.setLayout(new BorderLayout()); container.add(mainPanel, BorderLayout.CENTER); allmessagesTextArea = new TextArea(); allmessagesTextArea.setEditable(false); allmessagesTextArea.setFont(new Font("Dialog", 1, 12)); allmessagesTextArea.setForeground(Color.black); allmessagesTextArea.append("Select a session in the list to view its messages"); mainPanel.add(allmessagesTextArea, BorderLayout.CENTER); sessionsList = new List(); sessionsList.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { showMessages(e); } }); sessionsList.setForeground(Color.black); sessionsList.setFont(new Font("Dialog", 1, 14)); mainPanel.add(sessionsList, BorderLayout.WEST); okButton = new JButton(" OK "); okButton.setToolTipText("Returns to the main frame"); okButton.setFont(new Font("Dialog", 1, 16)); okButton.setFocusPainted(false); okButton.setBackground(Color.lightGray); okButton.setBorder(new BevelBorder(BevelBorder.RAISED)); okButton.setVerticalAlignment(SwingConstants.CENTER); okButton.setHorizontalAlignment(SwingConstants.CENTER); container.add(okButton, BorderLayout.SOUTH); okButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { setVisible(false); } }); }
public final void initializeGui() { // set up the main GUI gui.setBorder(new EmptyBorder(5, 5, 5, 5)); JToolBar tools = new JToolBar(); tools.setFloatable(false); gui.add(tools, BorderLayout.PAGE_START); tools.add(new JButton("New")); // TODO - add functionality! tools.addSeparator(); tools.add(new JLabel("Player:")); // TODO - add functionality! tools.addSeparator(); tools.add(message); playBoard = new JPanel(new GridLayout(0, 11)); playBoard.setBorder(new LineBorder(Color.BLACK)); gui.add(playBoard); // create the chess board squares Insets buttonMargin = new Insets(0, 0, 0, 0); for (int ii = 0; ii < playBoardSquares.length; ii++) { for (int jj = 0; jj < playBoardSquares[ii].length; jj++) { JButton b = new JButton(); b.setMargin(buttonMargin); // our chess pieces are 64x64 px in size, so we'll // 'fill this in' using a transparent icon.. ImageIcon icon = new ImageIcon(new BufferedImage(50, 50, BufferedImage.TYPE_INT_ARGB)); b.setIcon(icon); b.setBackground(Color.BLUE); playBoardSquares[jj][ii] = b; } } // fill the chess board playBoard.add(new JLabel("")); // fill the top row for (int ii = 0; ii < 10; ii++) { playBoard.add(new JLabel(COLS.substring(ii, ii + 1), SwingConstants.CENTER)); } // fill the black non-pawn piece row for (int ii = 0; ii < 10; ii++) { for (int jj = 0; jj < 10; jj++) { switch (jj) { case 0: playBoard.add(new JLabel("" + (ii + 1), SwingConstants.CENTER)); default: playBoard.add(playBoardSquares[jj][ii]); } } } }
private void initButton() { int actionCommandId = 1; for (int i = 0; i < 6; i++) { for (int j = 0; j < 7; j++) { JButton numberButton = new JButton(); numberButton.setBorder(BorderFactory.createEmptyBorder()); numberButton.setHorizontalAlignment(SwingConstants.CENTER); numberButton.setActionCommand(String.valueOf(actionCommandId)); numberButton.addMouseListener(this); numberButton.setBackground(palletTableColor); numberButton.setForeground(dateFontColor); numberButton.setText(String.valueOf(actionCommandId)); numberButton.setPreferredSize(new Dimension(25, 25)); daysButton[i][j] = numberButton; actionCommandId++; } } }
/** This method is called from within the constructor to initialize the form. */ public void initComponents() { /** **************** The components ********************************* */ firstPanel = new JPanel(); firstPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 2)); // If put to False: we see the container's background firstPanel.setOpaque(false); // rows, columns, horizontalGap, verticalGap firstPanel.setLayout(new GridLayout(4, 2, 3, 3)); this.setLayout(new GridLayout(2, 1, 3, 3)); this.add(firstPanel); proxyStackNameLabel = new JLabel("Proxy stack name:"); proxyStackNameLabel.setToolTipText("The name of the stack to set"); // Alignment of the text proxyStackNameLabel.setHorizontalAlignment(AbstractButton.CENTER); // Color of the text proxyStackNameLabel.setForeground(Color.black); // Size of the text proxyStackNameLabel.setFont(new Font("Dialog", 1, 12)); // If put to true: we see the label's background proxyStackNameLabel.setOpaque(true); proxyStackNameLabel.setBackground(ProxyLauncher.labelBackGroundColor); proxyStackNameLabel.setBorder(ProxyLauncher.labelBorder); proxyStackNameTextField = new JTextField(20); proxyStackNameTextField.setHorizontalAlignment(AbstractButton.CENTER); proxyStackNameTextField.setFont(new Font("Dialog", 0, 14)); proxyStackNameTextField.setBackground(ProxyLauncher.textBackGroundColor); proxyStackNameTextField.setForeground(Color.black); proxyStackNameTextField.setBorder(BorderFactory.createLoweredBevelBorder()); firstPanel.add(proxyStackNameLabel); firstPanel.add(proxyStackNameTextField); proxyIPAddressLabel = new JLabel("Proxy IP address:"); proxyIPAddressLabel.setToolTipText("The address of the proxy to set"); // Alignment of the text proxyIPAddressLabel.setHorizontalAlignment(AbstractButton.CENTER); // Color of the text proxyIPAddressLabel.setForeground(Color.black); // Size of the text proxyIPAddressLabel.setFont(new Font("Dialog", 1, 12)); // If put to true: we see the label's background proxyIPAddressLabel.setOpaque(true); proxyIPAddressLabel.setBackground(ProxyLauncher.labelBackGroundColor); proxyIPAddressLabel.setBorder(ProxyLauncher.labelBorder); proxyIPAddressTextField = new JTextField(20); proxyIPAddressTextField.setHorizontalAlignment(AbstractButton.CENTER); proxyIPAddressTextField.setFont(new Font("Dialog", 0, 14)); proxyIPAddressTextField.setBackground(ProxyLauncher.textBackGroundColor); proxyIPAddressTextField.setForeground(Color.black); proxyIPAddressTextField.setBorder(BorderFactory.createLoweredBevelBorder()); firstPanel.add(proxyIPAddressLabel); firstPanel.add(proxyIPAddressTextField); outboundProxyLabel = new JLabel("Next hop (IP:port/protocol):"); outboundProxyLabel.setToolTipText( "Location where the message will be sent " + "if all the resolutions (DNS, router,...) fail. If not set: 404 will be replied"); // Alignment of the text outboundProxyLabel.setHorizontalAlignment(AbstractButton.CENTER); // Color of the text outboundProxyLabel.setForeground(Color.black); // Size of the text outboundProxyLabel.setFont(new Font("Dialog", 1, 12)); // If put to true: we see the label's background outboundProxyLabel.setOpaque(true); outboundProxyLabel.setBackground(ProxyLauncher.labelBackGroundColor); outboundProxyLabel.setBorder(ProxyLauncher.labelBorder); outboundProxyTextField = new JTextField(20); outboundProxyTextField.setHorizontalAlignment(AbstractButton.CENTER); outboundProxyTextField.setFont(new Font("Dialog", 0, 14)); outboundProxyTextField.setBackground(ProxyLauncher.textBackGroundColor); outboundProxyTextField.setForeground(Color.black); outboundProxyTextField.setBorder(BorderFactory.createLoweredBevelBorder()); firstPanel.add(outboundProxyLabel); firstPanel.add(outboundProxyTextField); routerClassLabel = new JLabel("The Router class name:"); routerClassLabel.setToolTipText( "The class name (full java package name) of the router" + " used to forward the messages"); // Alignment of the text routerClassLabel.setHorizontalAlignment(AbstractButton.CENTER); // Color of the text routerClassLabel.setForeground(Color.black); // Size of the text routerClassLabel.setFont(new Font("Dialog", 1, 12)); // If put to true: we see the label's background routerClassLabel.setOpaque(true); routerClassLabel.setBackground(ProxyLauncher.labelBackGroundColor); routerClassLabel.setBorder(ProxyLauncher.labelBorder); routerClassTextField = new JTextField(20); routerClassTextField.setHorizontalAlignment(AbstractButton.CENTER); routerClassTextField.setFont(new Font("Dialog", 0, 12)); routerClassTextField.setBackground(ProxyLauncher.textBackGroundColor); routerClassTextField.setForeground(Color.black); routerClassTextField.setBorder(BorderFactory.createLoweredBevelBorder()); firstPanel.add(routerClassLabel); firstPanel.add(routerClassTextField); JPanel panel = new JPanel(); // top, left, bottom, right panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 2)); // If put to False: we see the container's background panel.setOpaque(false); // rows, columns, horizontalGap, verticalGap panel.setLayout(new BorderLayout()); this.add(panel); JLabel lpLabel = new JLabel("Listening points list:"); lpLabel.setVisible(true); lpLabel.setToolTipText("The listening points of the proxy"); lpLabel.setHorizontalAlignment(AbstractButton.CENTER); lpLabel.setForeground(Color.black); lpLabel.setFont(new Font("Dialog", 1, 12)); lpLabel.setOpaque(true); lpLabel.setBackground(ProxyLauncher.labelBackGroundColor); lpLabel.setBorder(ProxyLauncher.labelBorder); panel.add(lpLabel, BorderLayout.NORTH); // this.add(listeningPointsList); JScrollPane scrollPane = new JScrollPane( listeningPointsList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); panel.add(scrollPane, BorderLayout.CENTER); thirdPanel = new JPanel(); thirdPanel.setOpaque(false); // top, left, bottom, right thirdPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 5, 0)); thirdPanel.setLayout(new GridLayout(1, 2, 3, 3)); JButton addLPButton = new JButton(" Add "); addLPButton.setToolTipText("Add a listening point"); addLPButton.setFocusPainted(false); addLPButton.setFont(new Font("Dialog", 1, 16)); addLPButton.setBackground(ProxyLauncher.buttonBackGroundColor); addLPButton.setBorder(ProxyLauncher.buttonBorder); addLPButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { addLPButtonActionPerformed(evt); } }); thirdPanel.add(addLPButton); JButton removeLPButton = new JButton(" Remove "); removeLPButton.setToolTipText("Remove a listening point"); removeLPButton.setFocusPainted(false); removeLPButton.setFont(new Font("Dialog", 1, 16)); removeLPButton.setBackground(ProxyLauncher.buttonBackGroundColor); removeLPButton.setBorder(ProxyLauncher.buttonBorder); removeLPButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { removeLPButtonActionPerformed(evt); } }); thirdPanel.add(removeLPButton); panel.add(thirdPanel, BorderLayout.SOUTH); }
/** 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(); }
public void mouseEntered(MouseEvent e) { JButton jbutton = (JButton) e.getSource(); jbutton.setBackground(moveButtonColor); }
private void flushWeekAndDayPanal(Calendar c) { // c.set c.set(Calendar.DAY_OF_MONTH, 1); c.setFirstDayOfWeek(0); int firstdayofWeek = c.get(Calendar.DAY_OF_WEEK); int lastdayofWeek = c.getActualMaximum(Calendar.DAY_OF_MONTH); String colname[] = {"日", "一", "二", "三", "四", "五", "六"}; int today = getNowCalendar().get(Calendar.DAY_OF_MONTH); // 璁剧疆鍥哄畾瀛椾綋锛屼互鍏嶈皟鐢ㄧ幆澧冩敼鍙樺奖鍝嶇晫闈㈢編瑙� dayPanel.setFont(new java.awt.Font("寰蒋闆呴粦", java.awt.Font.PLAIN, 12)); dayPanel.setLayout(new GridBagLayout()); dayPanel.setBackground(palletTableColor); JLabel cell; for (int i = 0; i < 7; i++) { cell = new JLabel(colname[i]); cell.setHorizontalAlignment(JLabel.CENTER); cell.setPreferredSize(new Dimension(25, 25)); if (i == 0 || i == 6) { cell.setForeground(weekendFontColor); } else { cell.setForeground(weekFontColor); } dayPanel.add( cell, new GridBagConstraints( i, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } int actionCommandId = 1; for (int i = 0; i < 6; i++) { for (int j = 0; j < 7; j++) { JButton numberButton = daysButton[i][j]; actionCommandId = Integer.parseInt(numberButton.getActionCommand()); if (actionCommandId == today) { numberButton.setBackground(todayBtnColor); } if ((actionCommandId + firstdayofWeek - 2) % 7 == 6 || (actionCommandId + firstdayofWeek - 2) % 7 == 0) { numberButton.setForeground(weekendFontColor); } else { numberButton.setForeground(dateFontColor); } if (actionCommandId <= lastdayofWeek) { int y = 0; if ((firstdayofWeek - 1) <= (j + firstdayofWeek - 1) % 7) { y = i + 1; } else { y = i + 2; } dayPanel.add( numberButton, new GridBagConstraints( (j + firstdayofWeek - 1) % 7, y, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); } } } }
public Principal() { setResizable(false); setForeground(UIManager.getColor("CheckBoxMenuItem.selectionBackground")); setFont(new Font("Andalus", 1, 12)); setTitle("CEREAIS PEGER LTDA - EMISSOR DE RECIBO"); setIconImage( Toolkit.getDefaultToolkit() .getImage("img\\Super Collection\\Applications\\Script Editor.png")); setDefaultCloseOperation(0); setBounds(100, 100, 566, 497); JPanel contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new BorderLayout(0, 0)); JLayeredPane layeredPane = new JLayeredPane(); layeredPane.setBorder( new CompoundBorder( new LineBorder(new Color(0, 0, 0), 3), new BevelBorder(1, null, null, null, null))); contentPane.add(layeredPane, "Center"); JButton btEmiteRecibo = new JButton("Emitir Recibo"); btEmiteRecibo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { new Recibo().setVisible(true); } }); btEmiteRecibo.setIcon(new ImageIcon("img\\PNG-48\\Modify.png")); btEmiteRecibo.setFont(new Font("Tahoma", 1, 12)); btEmiteRecibo.setBackground(UIManager.getColor("Button.focus")); btEmiteRecibo.setBounds(74, 212, 181, 56); layeredPane.add(btEmiteRecibo); JButton btRelatorio = new JButton("Relatórios"); btRelatorio.setIcon(new ImageIcon("img\\PNG-48\\Load.png")); btRelatorio.setFont(new Font("Tahoma", 1, 12)); btRelatorio.setBackground(SystemColor.inactiveCaptionBorder); btRelatorio.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new Relatorios().setVisible(true); } }); btRelatorio.setBounds(74, 279, 181, 56); layeredPane.add(btRelatorio); JButton btInfo = new JButton("Informações"); btInfo.setIcon(new ImageIcon("img\\PNG-48\\Info.png")); btInfo.setFont(new Font("Tahoma", 1, 12)); btInfo.setBackground(SystemColor.inactiveCaptionBorder); btInfo.setBounds(304, 279, 181, 56); layeredPane.add(btInfo); btInfo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { (new Informacoes()).setVisible(true); } }); JButton btSair = new JButton("Sair"); btSair.setIcon(new ImageIcon("img\\PNG-32\\Exit.png")); btSair.setFont(new Font("Tahoma", 1, 13)); btSair.setBackground(SystemColor.controlShadow); btSair.setBounds(379, 368, 106, 41); layeredPane.add(btSair); btSair.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (JOptionPane.showConfirmDialog( null, "Deseja Encerrar o programa?", "ATENÇÃO !!! ", 0) == 0) System.exit(EXIT_ON_CLOSE); } }); JButton btfornecedores = new JButton("Fornecedores"); btfornecedores.setIcon(new ImageIcon("img\\PNG-48\\Profile.png")); btfornecedores.setFont(new Font("Tahoma", 1, 12)); btfornecedores.setBackground(SystemColor.inactiveCaptionBorder); btfornecedores.setBounds(304, 212, 181, 56); layeredPane.add(btfornecedores); btfornecedores.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { new CrudFornecedores().setVisible(true); } }); JPanel panelRecibo = new JPanel(); panelRecibo.setForeground(UIManager.getColor("Button.disabledShadow")); panelRecibo.setBackground(UIManager.getColor("CheckBoxMenuItem.foreground")); panelRecibo.setBorder(UIManager.getBorder("DesktopIcon.border")); panelRecibo.setBounds(10, 11, 530, 77); layeredPane.add(panelRecibo); JLabel LabelRecibo = new JLabel("Emissor de Recibo Eletrônico"); LabelRecibo.setForeground(UIManager.getColor("Button.background")); LabelRecibo.setHorizontalAlignment(2); LabelRecibo.setIcon(new ImageIcon("img\\PNG-48\\Modify.png")); LabelRecibo.setFont(new Font("Tahoma", 3, 18)); panelRecibo.add(LabelRecibo); JPanel panel = new JPanel(); panel.setBackground(UIManager.getColor("CheckBox.foreground")); panel.setBounds(45, 420, 457, 26); layeredPane.add(panel); JLabel lblAnthonyTailerCopy = new JLabel(" Anthony Tailer Copyright © "); lblAnthonyTailerCopy.setForeground(UIManager.getColor("Button.background")); panel.add(lblAnthonyTailerCopy); JLabel lblNewLabel = new JLabel(""); lblNewLabel.setIcon(new ImageIcon("img\\LOGO PEGER 2.png")); lblNewLabel.setBounds(165, 99, 234, 88); layeredPane.add(lblNewLabel); }
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) { } } }); }