AdminMain() { l = new JLabel(); l.setBounds(10, 20, 1340, 1000); l.setBackground(Color.black); Font ft = new Font("Arial", Font.BOLD, 30); Font ft1 = new Font("Arial", Font.BOLD, 14); Font ft2 = new Font("Arial", Font.BOLD, 20); f1 = new Frame("Soft Test Management (Beta)"); f1.setLayout(null); l1 = new Label("Test Instructions", l1.CENTER); l1.setBounds(10, 20, 1300, 60); l1.setForeground(Color.blue); l1.setBackground(Color.white); l1.setFont(ft); l2 = new JLabel("Deletion of Faculty/Students"); l2.setBounds(20, 30, 1000, 500); l2.setBackground(Color.blue); l2.setFont(ft2); l3 = new JLabel("Test Pattern"); l3.setBounds(20, 90, 1300, 500); l3.setBackground(Color.green); l3.setFont(ft2); b1 = new JButton("Go !"); b1.setBounds(300, 220, 120, 30); b1.setBackground(Color.white); b1.setForeground(Color.blue); b1.setFont(ft2); b2 = new JButton("Go"); b2.setBounds(300, 240, 120, 30); b2.setBackground(Color.white); b2.setForeground(Color.blue); b2.setFont(ft2); f1.add(l); l.add(l1); l2.add(b1); l.add(l2); l3.add(b2); l.add(l3); b1.addActionListener(this); b2.addActionListener(this); f1.setVisible(true); f1.setSize(1800, 800); }
public void view(String data1, String data2, String identity) throws RemoteException, MalformedURLException, NotBoundException { JTextField data11 = new JTextField(); data11.setEditable(false); data11.setBounds(135, 180, 250, 20); j.add(data11); data11.setBorder(new EmptyBorder(0, 0, 0, 0)); data11.setText("从" + data1 + "到" + data2 + "的收款单列表如下:"); DateRange dr = new DateRange(data1, data2); dr.divide(); ArrayList<String> dateRange = dr.getDateRange(); ReceiptListService bl = new ReceiptList(); ArrayList<ReceiptListVO> vos = bl.find(dateRange); String[][] playerInfore = new String[64][5]; double num = 0; if (vos != null) { for (int i = 0; i < vos.size(); i++) { ReceiptListVO vo = vos.get(i); playerInfore[i][0] = vo.getOrderNumber(); playerInfore[i][1] = vo.getDate(); playerInfore[i][2] = vo.getMoney(); playerInfore[i][3] = vo.getPostman(); double money = Double.parseDouble(vo.getMoney()); num += money; } } JTextField labelx = new JTextField(); labelx.setEditable(false); labelx.setBounds(135, 200, 250, 20); j.add(labelx); labelx.setBorder(new EmptyBorder(0, 0, 0, 0)); labelx.setText("总计" + num + "元"); String[] Names = {"订单条形码号", "收款日期", "收款金额", "收款快递员"}; DefaultTableModel tableModel = new DefaultTableModel(playerInfore, Names); JTable table = new JTable(tableModel); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.getColumnModel().getColumn(0).setPreferredWidth(150); table.getColumnModel().getColumn(1).setPreferredWidth(100); table.getColumnModel().getColumn(2).setPreferredWidth(100); table.getColumnModel().getColumn(2).setPreferredWidth(100); scrollPane = new JScrollPane(table); scrollPane.setBounds(30, 230, 445, 330); j.add(scrollPane); // p500.add(j); }
public Abschluss(String wahl, Sudoku s, Sudoku2 s2) { super("Sudoku-Abschluss"); this.setSize(270, 135); this.setLocation(250, 300); this.setLayout(null); this.setAlwaysOnTop(true); this.setResizable(false); this.setUndecorated(true); if (s == null) this.setLocationRelativeTo(s2); else this.setLocationRelativeTo(s); su = s; su2 = s2; w = wahl; ImageIcon icon = new ImageIcon("files/minigames/Sudoku/beispiel2.jpg"); icon.setImage(icon.getImage().getScaledInstance(290, 135, Image.SCALE_DEFAULT)); lab = new JLabel(icon); lab.setSize(270, 135); lab.setLocation(0, 0); this.add(lab); text = new JLabel(); text.setSize(250, 20); text.setLocation(10, 10); text.setForeground(Color.white); text.setHorizontalAlignment(0); lab.add(text); text2 = new JLabel(); text2.setSize(270, 20); text2.setLocation(10, 30); text2.setForeground(Color.white); lab.add(text2); ok = new JButton("OK"); ok.setSize(90, 30); ok.setLocation(80, 50); ok.setBorderPainted(false); ok.setBackground(Color.lightGray); ok.setForeground(Color.lightGray); ok.setOpaque(false); ok.setFont(new Font("Arial Black", 4, 20)); ok.setContentAreaFilled(false); ok.setFocusPainted(false); ok.addActionListener(this); ok.addMouseListener(this); lab.add(ok); textWahl(wahl); this.setVisible(true); }
public void addString(String msg) { JTextField txtF = new JTextField(); txtF.setText(msg); txtF.setVisible(true); txtF.setBounds(new Rectangle(10, mYPos, X_WINDOW_SIZE * 5, Y_HEIGHT)); txtF.setBackground(mMainColor); txtF.setBorder(BorderFactory.createEmptyBorder()); txtF.setForeground(Color.WHITE); mJMain.add(txtF); mYPos += Y_STEP; }
public JanelaDoJogo() { setTitle("Space War"); setSize(600, 700); setLocationRelativeTo(null); setResizable(false); ImageIcon imageI = new ImageIcon(getClass().getResource("/Imagens/14bis.png")); final JLabel label = new JLabel(imageI); label.setBounds(0, 0, 600, 700); ImageIcon start = new ImageIcon(getClass().getResource("/Imagens/start.png")); final JPanel painel = new JPanel(); add(painel); painel.add(label); JButton botao = new JButton("", start); botao.setRolloverIcon(start); botao.setPressedIcon(start); botao.setBorderPainted(false); botao.setContentAreaFilled(false); botao.setFocusPainted(false); botao.setBounds(30, 560, 80, 80); botao.setVisible(true); label.add(botao); painel.setVisible(true); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); botao.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { add(new Cenario()); Image cursorImage = Toolkit.getDefaultToolkit().getImage(""); Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImage, new Point(0, 0), ""); setCursor(blankCursor); thread.stop(); painel.setVisible(false); } }); }
public static void drawPoint(Rectangle r, JLabel map) { ImageIcon imageIcon = new ImageIcon("map//point.jpg"); JLabel label = new JLabel(imageIcon); // buttonStart.setLayout(null); /*label.setLocation(1, 1); label.setSize(600, 450);*/ label.setBounds(r); label.setVisible(true); map.add(label); map.repaint(); }
Jf() { j.setBounds(500, 40, 500, 500); j.setVisible(true); j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); j.setLayout(null); ImageIcon image = new ImageIcon("im1.jpg"); JLabel l = new JLabel(image); int m = image.getIconWidth(); int m1 = image.getIconHeight(); j.setResizable(false); // frame resize nahi hoga l.setBounds(0, 0, m, m1); j.add(l); l.add(linfo); l.add(lid); l.add(fid); l.add(lpass); l.add(fpass); fpass.setEchoChar('*'); l.add(blogin); l.add(bnewaccount); l.add(bforget); ImageIcon image1 = new ImageIcon("logo1.png"); JLabel limage = new JLabel(image1); l.add(limage); limage.setBounds(10, 50, 190, 130); Font f = new Font("ALGERIAN", Font.BOLD, 20); linfo.setFont(f); linfo.setBounds(40, 10, 420, 30); lid.setBounds(210, 50, 70, 30); fid.setBounds(290, 50, 150, 30); lpass.setBounds(210, 90, 70, 30); fpass.setBounds(290, 90, 150, 30); blogin.setBounds(210, 130, 100, 50); bnewaccount.setBounds(320, 130, 160, 20); bforget.setBounds(320, 160, 160, 20); blogin.setBackground(Color.green); bnewaccount.setBackground(Color.cyan); bforget.setBackground(Color.pink); blogin.addActionListener(new Login()); bnewaccount.addActionListener(new Account()); bforget.addActionListener(new Forget()); }
public Frame(boolean isStar) { super("2048"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new BorderLayout()); this.isStar = isStar; background = new JLabel(new ImageIcon("Images\\background.png")); this.setResizable(false); add(background); background.setLayout(new FlowLayout()); newGameButton = new JButton(new ImageIcon("Images\\newGame.png")); recordTableButton = new JButton(new ImageIcon("Images\\recordTableButton.png")); designButton = new JButton(new ImageIcon("Images\\changeDesign.png")); newGameButton.setBorder(BorderFactory.createEmptyBorder()); newGameButton.setContentAreaFilled(false); recordTableButton.setBorder(BorderFactory.createEmptyBorder()); recordTableButton.setContentAreaFilled(false); designButton.setBorder(BorderFactory.createEmptyBorder()); designButton.setContentAreaFilled(false); background.add(newGameButton); background.add(recordTableButton); background.add(designButton); newGameButton.addActionListener(this); recordTableButton.addActionListener(this); designButton.addActionListener(this); this.addKeyListener(this); board = new Board(highscores, this); this.pack(); nextImage = new JLabel(new ImageIcon("images\\next2.png")); background.add(board.getBoard()); background.add(nextImage); background.add(board.getScoreLabel()); if (isStar != this.board.getChangedDesign()) { this.board.ChaneDesign(); background.setIcon(new ImageIcon("Images\\Background2.png")); newGameButton.setIcon(new ImageIcon("Images\\newGameStar.png")); recordTableButton.setIcon(new ImageIcon("Images\\recordTableStarButton.png")); designButton.setIcon(new ImageIcon("Images\\changeDesignStar.png")); nextImage.setIcon(new ImageIcon("Images\\next2Star.png")); this.board.getScoreLabel().setText("Stars collected:" + this.board.getScore().getScore()); } // board.ChaneDesign(); this.setSize(476, 570); this.pack(); this.setVisible(true); this.requestFocusInWindow(); }
public Mainmenu() { getContentPane().setPreferredSize(new Dimension(500, 400)); getContentPane().setSize(new Dimension(500, 400)); getContentPane().setLayout(new BorderLayout()); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); try { lbg.setIcon(new ImageIcon(ImageIO.read(getClass().getResource("/other/pic/mainmenu_1.png")))); } catch (IOException ex) { Logger.getLogger(Mainmenu.class.getName()).log(Level.SEVERE, null, ex); } getContentPane().add(lbg, BorderLayout.CENTER); ltitle.setFont(new Font("Courier New", Font.BOLD, 80)); lNamaKelompok.setFont(new Font(lNamaKelompok.getFont().getFontName(), Font.PLAIN, 14)); // meletakkan komponen pada panel lbg.add(lRing); lbg.add(ring); lbg.add(nPlay); lbg.add(nExit); lbg.add(nSimulator); lbg.add(nHighScore); lbg.add(ltitle); lbg.add(lNamaKelompok); // memberi listener pada button nPlay.addActionListener(this); nExit.addActionListener(this); nSimulator.addActionListener(this); nHighScore.addActionListener(this); // mengatur posisi & ukuran komponen ltitle.setBounds(143, 30, 500, 200); lNamaKelompok.setBounds(334, 330, 500, 100); lRing.setBounds(130, 250, 100, 50); ring.setBounds(230, 260, 150, 25); nPlay.setBounds(50, 300, 100, 30); nSimulator.setBounds(150, 300, 100, 30); nHighScore.setBounds(250, 300, 100, 30); nExit.setBounds(350, 300, 100, 30); pack(); setVisible(true); }
/*Set the master panel that will hold all swing components in the frame for the main page*/ private void initializeMasterPanel(JFrame frame, JLabel label) { this.masterPanel = new JPanel(); this.masterPanel.setLayout(new BoxLayout(this.masterPanel, BoxLayout.Y_AXIS)); this.masterPanel.setBackground(new Color(0, 0, 0, 150)); this.masterPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 243, 0)); // border /*add components to the masterPanel*/ JPanel spacer = new JPanel(); spacer.setOpaque(false); spacer.setPreferredSize(new Dimension(50, 30)); addLogo(this.masterPanel); this.masterPanel.add(spacer); addSummonerLabel(this.masterPanel); addSummonerTextField(this.masterPanel); addHistoryButton(frame, this.masterPanel); addRankedStatsButton(frame, this.masterPanel); addRegionsComboBox(this.masterPanel); addErrorPanel(); label.add(this.masterPanel); }
private void initRound() { SpringLayout mainLayout = new SpringLayout(); setLayout(mainLayout); resultButton.setEnabled(false); betButton.setEnabled(true); inputImage.add(betInput); controlPanel.add(betLabel); controlPanel.add(inputImage); controlPanel.add(betButton); add(recordLabel); add(record); add(dealerPanel); add(playerPanel); add(controlPanel); add(moneyLabel); add(money); add(resultButton); mainLayout.putConstraint(SpringLayout.WEST, recordLabel, 154, SpringLayout.WEST, this); mainLayout.putConstraint(SpringLayout.NORTH, recordLabel, 20, SpringLayout.NORTH, this); mainLayout.putConstraint(SpringLayout.NORTH, record, 15, SpringLayout.NORTH, this); mainLayout.putConstraint(SpringLayout.WEST, record, 20, SpringLayout.EAST, recordLabel); mainLayout.putConstraint(SpringLayout.WEST, dealerPanel, 180, SpringLayout.WEST, this); mainLayout.putConstraint(SpringLayout.NORTH, dealerPanel, 70, SpringLayout.NORTH, this); mainLayout.putConstraint(SpringLayout.WEST, playerPanel, 180, SpringLayout.WEST, this); mainLayout.putConstraint(SpringLayout.NORTH, playerPanel, 10, SpringLayout.SOUTH, dealerPanel); mainLayout.putConstraint(SpringLayout.SOUTH, moneyLabel, -20, SpringLayout.SOUTH, this); mainLayout.putConstraint(SpringLayout.WEST, moneyLabel, 5, SpringLayout.WEST, this); mainLayout.putConstraint(SpringLayout.WEST, money, 20, SpringLayout.EAST, moneyLabel); mainLayout.putConstraint(SpringLayout.SOUTH, money, -15, SpringLayout.SOUTH, this); mainLayout.putConstraint(SpringLayout.SOUTH, resultButton, -13, SpringLayout.SOUTH, this); mainLayout.putConstraint(SpringLayout.EAST, resultButton, -70, SpringLayout.EAST, this); mainLayout.putConstraint( SpringLayout.SOUTH, controlPanel, -5, SpringLayout.NORTH, resultButton); assignCards(); numReplaced = 0; betInput.setText(null); betInput.requestFocusInWindow(); }
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); }
public void mainview() { scrollPane.setVisible(false); // p500.setVisible(true); // p510.setVisible(false); ImageIcon icon = new ImageIcon("src/frameM 成本、经营表.png"); // 定义图片并初始化,写上图片的绝对路径 j = new JLabel(); // 把图片放在标签上 j.setIcon(icon); p500.add(j); j.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight()); p500.setOpaque(false); // 让他透明 p500.setBounds(235, 0, 510, 560); p500.setLayout(null); // 输入起始日期 final JTextField num0 = new JTextField(); num0.setBounds(123, 80, 250, 25); num0.setOpaque(false); num0.setBorder(new EmptyBorder(0, 0, 0, 0)); j.add(num0); // 输入结束日期 final JTextField num10 = new JTextField(); num10.setBounds(123, 122, 250, 25); num10.setOpaque(false); num10.setBorder(new EmptyBorder(0, 0, 0, 0)); j.add(num10); // 查询 JButton change = new JButton(); change.setBounds(390, 97, 80, 33); change.setContentAreaFilled(false); change.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); change.setBorder(null); j.add(change); change.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String data1 = num0.getText(); String data2 = num10.getText(); JudgeStart_End se = new JudgeStart_End(data1, data2); String message = se.getMessage(); if (!message.equals("保存成功")) { JOptionPane.showMessageDialog(null, message, "", JOptionPane.ERROR_MESSAGE); return; } try { view(data1, data2, "财务人员"); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (NotBoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); j.add(change); p500.setVisible(true); jFrame.add(p500); }
public Design() throws Exception { super.setBackground(Color.BLACK); this.setTitle(""); con = getContentPane(); con.setLayout(null); dim = tk.getDefaultToolkit().getScreenSize(); this.setTitle("Customer Peer Login"); l1 = new JLabel(new ImageIcon("plain.jpg")); l1.setBounds(0, 0, 400, 400); con.add(l1); l1.setBorder(BorderFactory.createEtchedBorder(5, Color.black, Color.black)); title = new JLabel("CUSTOMER PEER LOGIN "); title.setFont(new Font("Bookman Old Style", Font.ROMAN_BASELINE, 20)); title.setForeground(Color.red); title.setBounds(80, 30, 300, 30); l1.add(title); l4 = new JLabel("CMACHINE NAME"); l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l4.setForeground(Color.BLUE); l4.setBounds(70, 100, 160, 20); // l4.setBorder(BorderFactory.createEtchedBorder(5,Color.green,Color.green)); l1.add(l4); jtf2 = new JTextField(); jtf2.setBounds(250, 100, 100, 20); jtf2.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jtf2); l2 = new JLabel("CUSER LOGIN"); l2.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l2.setForeground(Color.blue); l2.setBounds(70, 150, 120, 20); l1.add(l2); jtf1 = new JTextField(); jtf1.setBounds(250, 150, 100, 20); jtf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jtf1); l3 = new JLabel("CPASSWORD"); l3.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l3.setForeground(Color.blue); l3.setBounds(70, 200, 120, 20); l1.add(l3); jptf1 = new JPasswordField(); jptf1.setBounds(250, 200, 100, 20); jptf1.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(jptf1); JLabel l4 = new JLabel("DAgent"); l4.setFont(new Font("Bookman Old Style", Font.BOLD, 16)); l4.setForeground(Color.blue); l4.setBounds(70, 250, 120, 20); l1.add(l4); box = new JComboBox(); box.setBounds(250, 250, 100, 20); box.setBorder(BorderFactory.createEtchedBorder(5, Color.green, Color.green)); l1.add(box); b2 = new JButton("Register"); b2.setBounds(50, 300, 100, 20); l1.add(b2); b2.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); b3 = new JButton("Login"); b3.setBounds(150, 300, 100, 20); b3.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); l1.add(b3); b1 = new JButton("Cancel"); b1.setBounds(250, 300, 100, 20); b1.setBorder(BorderFactory.createEtchedBorder(10, Color.BLUE, Color.BLUE)); l1.add(b1); b1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { dispose(); } }); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); conn = DriverManager.getConnection("jdbc:odbc:agent"); } catch (Exception exp) { } try { Statement satem = conn.createStatement(); ResultSet rsatem = satem.executeQuery("select * from Dagent"); while (rsatem.next()) { String namem = rsatem.getString("uname"); box.addItem(namem); } } catch (Exception expo1) { } b2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { String username = jtf1.getText().trim(); String password = jptf1.getText().trim(); String mechine = jtf2.getText().trim(); String dname = box.getSelectedItem().toString(); int porte = 0; try { Statement sate = conn.createStatement(); ResultSet rsate = sate.executeQuery("select * from Dagent where uname='" + dname + "'"); if (rsate.next()) { servermachine = rsate.getString("umechine"); porte = rsate.getInt("ulistport"); System.out.println(servermachine); } System.out.println(servermachine); } catch (Exception exp) { exp.printStackTrace(); } try { packet p = new packet(); p.setaction("Creg"); p.setCuser(username); p.setCpass(password); p.setCmname(mechine); p.setCDpeer(dname); Socket soc = new Socket(servermachine, porte); ObjectOutputStream out = new ObjectOutputStream(soc.getOutputStream()); out.writeObject(p); ObjectInputStream in = new ObjectInputStream(soc.getInputStream()); packet rpac = (packet) in.readObject(); if (rpac.getaction().equals("ok")) { JOptionPane.showMessageDialog(null, "Sucessfully Registered"); jtf2.setText(""); jtf1.setText(""); jptf1.setText(""); } else { JOptionPane.showMessageDialog(null, "Already Registered"); jtf2.setText(""); jtf1.setText(""); jptf1.setText(""); } } catch (Exception exp) { } } }); b3.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent we) { String username = jtf1.getText().trim(); String password = jptf1.getText().trim(); String mechine = jtf2.getText().trim(); String Dname = box.getSelectedItem().toString(); int porte = 0; try { Statement sate = conn.createStatement(); ResultSet rsate = sate.executeQuery("select * from Dagent where uname='" + Dname + "'"); if (rsate.next()) { servermachine = rsate.getString("umechine"); porte = rsate.getInt("ulistport"); System.out.println(servermachine); } System.out.println(servermachine); } catch (Exception exp) { } try { packet p1 = new packet(); p1.setaction("clogin"); p1.setCuser(username); p1.setCpass(password); p1.setCmname(mechine); p1.setCDpeer(Dname); Socket soc1 = new Socket(servermachine, porte); ObjectOutputStream out1 = new ObjectOutputStream(soc1.getOutputStream()); out1.writeObject(p1); ObjectInputStream in1 = new ObjectInputStream(soc1.getInputStream()); packet rpac1 = (packet) in1.readObject(); if (rpac1.getaction().equals("ok")) { int port1 = 0; try { int portm = rpac1.getCport(); System.out.println("XXXXXXX" + portm); // JOptionPane.showMessageDialog(null,"Sucessfully Started"); new Listen(portm); new process(username, portm); dispose(); } catch (Exception exp) { } } else { JOptionPane.showMessageDialog( null, "Enter valid username and password", "Server reply", 2); jtf1.setText(""); jtf2.setText(""); jptf1.setText(""); } } catch (Exception exp) { } } }); setSize(400, 400); show(); setLocation(150, 100); setResizable(false); }
CarRace() { f = new JFrame("Car Race"); f.setSize(600, 700); f.setLayout(null); f.setBounds(250, 10, 600, 700); background = new JLabel(new ImageIcon("road.jpg")); background.setBounds(0, 0, 600, 700); f.add(background); car = new JLabel(new ImageIcon("red.png")); car.setBounds(120, 500, 120, 70); background.add(car); position = 1; one = new JLabel(new ImageIcon("pink.png")); one.setBounds(120, 100, 120, 70); background.add(one); two = new JLabel(new ImageIcon("yellow.png")); two.setBounds(240, 100, 120, 70); background.add(two); three = new JLabel(new ImageIcon("blue.png")); three.setBounds(360, 100, 120, 70); background.add(three); one.setVisible(false); two.setVisible(false); three.setVisible(false); start = new JButton("Start"); start.setBounds(240, 600, 100, 25); background.add(start); start.addKeyListener(this); start.addActionListener(this); score = new JLabel("score " + scoreValue); score.setBounds(430, 20, 130, 35); background.add(score); score.setFont(new Font("", Font.BOLD, 25)); score.setForeground(Color.WHITE); speed = new JLabel("speed"); speed.setBounds(40, 20, 160, 35); background.add(speed); speed.setFont(new Font("", Font.BOLD, 25)); speed.setForeground(Color.WHITE); result = new JLabel(); result.setBounds(180, 250, 400, 40); result.setVisible(false); result.setForeground(Color.WHITE); result.setFont(new Font(" ", Font.BOLD, 40)); background.add(result); x = 120; t = new Timer(x, this); f.setVisible(true); }
GUI() { jf = new JFrame("Intelligent Trafic Management System"); i1 = new ImageIcon("ab.png"); i2 = new ImageIcon("em.png"); jl1 = new JLabel(i1); jl1.setBounds(0, -50, 800, 20); jb[0] = new JButton("set"); jb[0].setBounds(100, 150, 70, 25); // for left side setter jb[1] = new JButton("set"); jb[1].setBounds(700, 150, 70, 25); // for right side setter jb[2] = new JButton("set"); jb[2].setBounds(100, 570, 70, 25); // for left bottom setter jb[3] = new JButton("set"); jb[3].setBounds(700, 570, 70, 25); // for right bottom setter jb[4] = new JButton("start"); // for starting jb[4].setBounds(200, 50, 70, 25); jb[5] = new JButton("Emergency"); // for emergency for left side setter jb[5].setBounds(350, 150, 100, 25); jb[6] = new JButton(i2); // for emergency for right side setter jb[6].setBounds(695, 240, 25, 130); jb[7] = new JButton(i2); // for emergency for left bottom side setter jb[7].setBounds(275, 400, 25, 130); jb[8] = new JButton("Emergency"); jb[8].setBounds(520, 570, 100, 25); // emergency for right bottom side setter jb[9] = new JButton("DataBase"); // For taking value from data base jb[9].setBounds(80, 50, 90, 25); jt[0] = new JTextField(20); jt[0].setBounds(200, 150, 70, 25); // for left side setter jt[1] = new JTextField(20); jt[1].setBounds(800, 150, 70, 25); // for right side setter jt[2] = new JTextField(20); jt[2].setBounds(200, 570, 70, 25); // for left bottom side setter jt[3] = new JTextField(20); jt[3].setBounds(800, 570, 70, 25); // for right bottom setter for (int i = 4; i < 8; i++) { jt[i] = new JTextField(20); jt[i].setBackground(Color.red); } jt[4].setBounds(220, 270, 70, 25); // left side setter jt[5].setBounds(550, 150, 70, 25); // right side setter jt[7].setBounds(370, 570, 70, 25); // left bottom side setter jt[6].setBounds(700, 450, 70, 25); // right bottom side setter // adding listener to all buttons jb[0].addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if (e.getSource() == jb[0]) { text = jt[0].getText(); // taking values from textfield int_text = Integer.parseInt(text); vech_freq.Set_freq(int_text, 0); } } }); jb[1].addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if (e.getSource() == jb[1]) { text = jt[1].getText(); // taking values from textfield int_text = Integer.parseInt(text); vech_freq.Set_freq(int_text, 1); } } }); jb[2].addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if (e.getSource() == jb[2]) { text = jt[2].getText(); // taking values from textfield int_text = Integer.parseInt(text); vech_freq.Set_freq(int_text, 2); } } }); jb[3].addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if (e.getSource() == jb[3]) { text = jt[3].getText(); // taking values from textfield int_text = Integer.parseInt(text); vech_freq.Set_freq(int_text, 3); } } }); jb[5].addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if (e.getSource() == jb[5]) { flag = 5; } } }); jb[6].addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if (e.getSource() == jb[6]) { flag = 6; } } }); jb[7].addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if (e.getSource() == jb[6]) { flag = 7; } } }); jb[8].addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if (e.getSource() == jb[8]) { flag = 8; } } }); jb[9].addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub if (e.getSource() == jb[9]) { text = data(0); jt[0].setText(text); int_text = Integer.parseInt(text); vech_freq.Set_freq(int_text, 0); text = data(1); jt[1].setText(text); int_text = Integer.parseInt(text); vech_freq.Set_freq(int_text, 1); text = data(2); jt[2].setText(text); int_text = Integer.parseInt(text); vech_freq.Set_freq(int_text, 2); text = data(3); jt[3].setText(text); int_text = Integer.parseInt(text); vech_freq.Set_freq(int_text, 3); } } }); jf.setSize(1000, 800); for (int i1 = 0; i1 <= 9; i1++) { jl1.add(jb[i1]); if (i1 < 8) jl1.add(jt[i1]); } jf.add(jl1); jf.setResizable(false); jf.setVisible(true); jf.setLocationRelativeTo(null); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public void addnew() { p40.setVisible(false); p41 = new JPanel(); ImageIcon icon = new ImageIcon("src/frameB receive add.png"); // 定义图片并初始化,写上图片的绝对路径 JLabel j = new JLabel(); // 把图片放在标签上 j.setIcon(icon); p41.add(j); j.setBounds(0, 0, 500, 600); p41.setOpaque(false); // 让他透明 p41.setBounds(235, 20, 520, 560); p41.setLayout(null); // 订单条形码号 final JTextField orderNumberField = new JTextField(); orderNumberField.setBounds(140, 80, 330, 25); orderNumberField.setOpaque(false); orderNumberField.setBorder(new EmptyBorder(0, 0, 0, 0)); j.add(orderNumberField); // 到达日期 final JTextField dateField = new JTextField(); dateField.setBounds(140, 123, 330, 25); dateField.setOpaque(false); dateField.setBorder(new EmptyBorder(0, 0, 0, 0)); j.add(dateField); GetDate dt = new GetDate(); String d = dt.getDate2(); dateField.setText(d); // 中转单编号 final JTextField transitNumberField = new JTextField(); transitNumberField.setBounds(140, 168, 330, 25); transitNumberField.setOpaque(false); transitNumberField.setBorder(new EmptyBorder(0, 0, 0, 0)); TransitNumber tn = new TransitNumber(operator); String t = tn.getCarNumber(); j.add(transitNumberField); transitNumberField.setText(t); // 出发地 final JTextField departPlaceField = new JTextField(); departPlaceField.setBounds(140, 215, 330, 25); departPlaceField.setOpaque(false); departPlaceField.setBorder(new EmptyBorder(0, 0, 0, 0)); City ci = new City(operator); String c = ci.getCarNumber(); j.add(departPlaceField); departPlaceField.setText(c); // 到达状态 final JTextField arrivalStateField = new JTextField(); arrivalStateField.setBounds(140, 256, 330, 25); arrivalStateField.setOpaque(false); arrivalStateField.setBorder(new EmptyBorder(0, 0, 0, 0)); j.add(arrivalStateField); // 清空 JButton clear = new JButton(); clear.setBounds(65, 325, 80, 35); clear.setContentAreaFilled(false); clear.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); clear.setBorder(null); clear.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { orderNumberField.setText(""); dateField.setText(""); transitNumberField.setText(""); departPlaceField.setText(""); arrivalStateField.setText(""); } }); // 保存并提交 JButton save = new JButton(); save.setBounds(210, 325, 80, 35); save.setContentAreaFilled(false); save.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); save.setBorder(null); save.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String orderNumber = orderNumberField.getText(); String date = dateField.getText(); String transitNumber = transitNumberField.getText(); String departPlace = departPlaceField.getText(); String arrivalState = arrivalStateField.getText(); JudgeHallPackageReceive j = new JudgeHallPackageReceive( orderNumber, date, transitNumber, departPlace, arrivalState, "未核对"); String message = j.getMessage(); if (message.equals("保存成功")) { JOptionPane.showMessageDialog(null, message, "", JOptionPane.INFORMATION_MESSAGE); HallPackageReceiveVO item = bl.addItem(orderNumber, date, transitNumber, departPlace, arrivalState, "未核对"); try { bl.submit(item); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (NotBoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // 清空输入框 orderNumberField.setText(""); dateField.setText(""); transitNumberField.setText(""); departPlaceField.setText(""); arrivalStateField.setText(""); // 物流信息更新 GetState getState = new GetState(operator); GetDate getDate = new GetDate(); String number = orderNumber; String add_time = getDate.getDate(); String place = getState.GetPlace(); String note = "快递已被营业厅接收"; LogisticsListVO vo = new LogisticsListVO(number, add_time, place, note); try { bl.updateLogistics(vo); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (NotBoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // 单据列表更新 GetDate geda = new GetDate(); String type0 = "C"; String date0 = geda.getDate(); String orderNumber0 = orderNumber; JudgeListVO vv = new JudgeListVO(type0, date0, orderNumber0); JudgeList jl = new JudgeList(); try { jl.updateJudge(vv); } catch (RemoteException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (NotBoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else { JOptionPane.showMessageDialog(null, message, "", JOptionPane.ERROR_MESSAGE); } } }); // 返回 JButton retur = new JButton(); retur.setBounds(360, 325, 80, 35); retur.setContentAreaFilled(false); retur.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); retur.setBorder(null); retur.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { p40 = new JPanel(); HallPackageReceiveView h = new HallPackageReceiveView(operator); try { h.view(); } catch (RemoteException | MalformedURLException | NotBoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } p41.setVisible(false); } }); j.add(clear); j.add(save); j.add(retur); jFrame.add(p41); }
public void view() throws RemoteException, MalformedURLException, NotBoundException { ImageIcon icon = new ImageIcon("src/frameB receive.png"); // 定义图片并初始化,写上图片的绝对路径 JLabel j = new JLabel(); // 把图片放在标签上 j.setIcon(icon); p40.add(j); j.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight()); p40.setOpaque(false); // 让他透明 p40.setBounds(235, 20, 510, 560); p40.setLayout(null); // 从txt读二维数组到playerInfore // 营业厅收件信息 ArrayList<HallPackageReceiveVO> vos = bl.show(); String[][] playerInfo = new String[64][6]; if (vos != null) { for (int i = 0; i < vos.size(); i++) { HallPackageReceiveVO vo = vos.get(i); playerInfo[i][0] = vo.getOrderNumber(); playerInfo[i][1] = vo.getDate(); playerInfo[i][2] = vo.getTransitNumber(); playerInfo[i][3] = vo.getDepartPlace(); playerInfo[i][4] = vo.getArrivalState(); playerInfo[i][5] = vo.getCheckState(); } } String[] Names = {"订单条形码", "到达日期", "中转单编号", "出发地", "到达状态", "核对状态"}; DefaultTableModel tableModel = new DefaultTableModel(playerInfo, Names); JTable table = new JTable(tableModel); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.getColumnModel().getColumn(0).setPreferredWidth(80); table.getColumnModel().getColumn(1).setPreferredWidth(80); table.getColumnModel().getColumn(2).setPreferredWidth(80); table.getColumnModel().getColumn(3).setPreferredWidth(80); table.getColumnModel().getColumn(4).setPreferredWidth(80); table.getColumnModel().getColumn(5).setPreferredWidth(80); JScrollPane scrollPane = new JScrollPane(table); scrollPane.setBounds(23, 50, 470, 400); j.add(scrollPane); JButton add = new JButton(); add.setBounds(68, 468, 125, 30); add.setContentAreaFilled(false); add.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); add.setBorder(null); j.add(add); add.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addnew(); } }); // 页面刷新 JButton reflesh = new JButton(); reflesh.setBounds(300, 465, 130, 30); reflesh.setContentAreaFilled(false); reflesh.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); reflesh.setBorder(null); j.add(reflesh); reflesh.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) {} }); p40.setVisible(true); jFrame.add(p40); }
public static void run(Main args) throws SQLException, InterruptedException { JFrame main = new JFrame("GolfTracker"); main.setSize(1200, 580); main.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label1 = new JLabel(); label1.setSize(210, 250); label1.setLocation(10, 80); JLabel im = new JLabel(new ImageIcon("golflog.jpg")); im.setSize(960, 550); im.setLocation(220, 0); JLabel logo = new JLabel(new ImageIcon("logo.png")); logo.setSize(210, 150); logo.setLocation(5, 25); main.add(im); main.add(logo); main.add(label1); main.setVisible(true); label1.setVisible(true); im.setVisible(true); logo.setVisible(true); for (int i = 0; i < 8; i++) { JButton btn = new JButton(); btn.setSize(200, 40); if (i == 0) { btn.setText("Initialize"); btn.addActionListener(new InitializeListener()); btn.setLocation(10, 5); label1.add(btn); btn.setVisible(false); } if (i == 1) { btn.setText("Display All Rounds"); btn.addActionListener(new AllScoresListener()); btn.setLocation(10, 170); label1.add(btn); } if (i == 2) { btn.setText("Add/Modify Round"); btn.addActionListener(new AddRoundListener()); btn.setLocation(10, 220); label1.add(btn); } if (i == 3) { btn.setText("Add/Modify Golfer"); btn.addActionListener(new AddGolferListener()); btn.setLocation(10, 270); label1.add(btn); } if (i == 4) { btn.setText("Display Rounds by Course"); btn.addActionListener(new ByCourseListener()); btn.setLocation(10, 320); label1.add(btn); } if (i == 5) { btn.setText("View Golfers"); btn.addActionListener(new AllGolfersListener()); btn.setLocation(10, 370); label1.add(btn); } if (i == 6) { btn.setText("Search"); btn.addActionListener(new SearchListener()); btn.setLocation(10, 420); label1.add(btn); } if (i == 7) { btn.setText("Quit"); btn.addActionListener(new QuitListener()); btn.setLocation(10, 470); label1.add(btn); } label1.repaint(); label1.revalidate(); } } // End of run method
public p2() throws Exception { // setBorder(BorderFactory.createEtchedBorder(Color.lightGray, Color.DARK_GRAY)); p = new JPanel(); // setBackground(Color.white); p.setLayout(new GridLayout(11, 3)); p.setBounds(0, 20, 309, 130); un = new JLabel("* Username"); ps1 = new JLabel("* Password"); ps2 = new JLabel("* Confirm Password"); fn = new JLabel("* First Name"); ln = new JLabel(" Last Name"); eid = new JLabel("* Email ID"); mb = new JLabel("* Mobile"); cct = new JLabel("* Current City"); hquali = new JLabel("* Highest Qualification"); dob = new JLabel(" DOB"); dober = new JLabel(); dd = new JLabel("DD"); mm = new JLabel("MM"); yy = new JLabel("YY"); member = new Label(" already a member?"); member.addMouseListener(this); er1 = new Label(""); er2 = new Label(""); er3 = new Label(""); er4 = new Label(""); er5 = new Label(""); er6 = new Label(""); er7 = new Label(""); er8 = new Label(""); er9 = new Label(""); er10 = new Label(""); un1 = new JTextField(15); ps11 = new JPasswordField(15); ps21 = new JPasswordField(15); fn1 = new JTextField(15); ln1 = new JTextField(15); eid1 = new JTextField(15); mb1 = new JTextField(15); cct1 = new JTextField(15); hquali1 = new JTextField(15); dober1 = new JTextField(2); dober2 = new JTextField(2); dober3 = new JTextField(2); sub = new JButton("Sign up"); sub.setBorderPainted(false); sub.setFocusable(true); sub.addActionListener(this); dober.setLayout(new FlowLayout()); dober.add(dober1); dober.add(dd); dober.add(dober2); dober.add(mm); dober.add(dober3); dober.add(yy); p.add(fn); p.add(fn1); p.add(er1); p.add(ln); p.add(ln1); p.add(er2); p.add(un); p.add(un1); p.add(er3); p.add(ps1); p.add(ps11); p.add(er4); p.add(ps2); p.add(ps21); p.add(er5); p.add(eid); p.add(eid1); p.add(er6); p.add(mb); p.add(mb1); p.add(er7); p.add(cct); p.add(cct1); p.add(er8); p.add(hquali); p.add(hquali1); p.add(er9); p.add(dob); p.add(dober); p.add(er10); p.add(sub); p.add(member); add(p); }
Options() { Main.initDataDir(); if (!settingsFile.isFile()) { createDefaultSettings(); } try { BufferedReader br = new BufferedReader(new FileReader(settingsFile)); try { defaultNoteColor = br.readLine(); br.close(); } catch (IOException e1) { e1.printStackTrace(); } } catch (FileNotFoundException e1) { e1.printStackTrace(); } final JButton btnClosePreferences = new JButton(); btnClosePreferences.setBounds(480, 300, 80, 25); btnClosePreferences.setText("Close"); btnClosePreferences.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { closeMe(); } }); final JButton btnCloseNetworkSettings = new JButton(); btnCloseNetworkSettings.setBounds(480, 300, 80, 25); btnCloseNetworkSettings.setText("Close"); btnCloseNetworkSettings.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { closeMe(); } }); final JLabel lbl1 = new JLabel(); lbl1.setText("Default color for new notes:"); lbl1.setBounds(20, 20, 400, 20); final JButton btnColor = new JButton(); btnColor.setBounds(230, 20, 120, 20); btnColor.setBackground(Color.decode(defaultNoteColor)); btnColor.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Color selectedColor = JColorChooser.showDialog(null, "Pick a Color", Color.YELLOW); if (selectedColor != null) { btnColor.setBackground(selectedColor); int newColor = btnColor.getBackground().getRGB(); defaultNoteColor = Integer.toString(newColor); saveSettings(); } } }); JPanel panelPreferences = new JPanel(); JLabel fillerPreferences = new JLabel(); tabbedPane.addTab("Preferences", preferences_icon, panelPreferences); fillerPreferences.setHorizontalAlignment(JLabel.CENTER); panelPreferences.setLayout(new GridLayout(1, 1)); panelPreferences.add(fillerPreferences); fillerPreferences.add(btnClosePreferences); fillerPreferences.add(lbl1); fillerPreferences.add(btnColor); JPanel panelNetworkSettings = new JPanel(); JLabel fillerNetworkSettings = new JLabel(); tabbedPane.addTab("Network settings", network_icon, panelNetworkSettings); fillerNetworkSettings.setHorizontalAlignment(JLabel.CENTER); panelNetworkSettings.setLayout(new GridLayout(1, 1)); panelNetworkSettings.add(fillerNetworkSettings); fillerNetworkSettings.add(btnCloseNetworkSettings); this.add(tabbedPane); this.setIconImage(optionsIcon.img); this.setTitle("JNotes Options:"); this.setSize(600, 400); this.setResizable(false); this.setLocationRelativeTo(null); }
public void gold() throws Exception { frm = new JFrame(); frm.setTitle("Background Color for JFrame"); // frm.setSize(400, 400); frm.setLocationRelativeTo(null); // frm.setDefaultCloseOperation(EXIT_ON_CLOSE); frm.setVisible(true); frm.setLayout(new BorderLayout()); JLabel background = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\Untitled.jpg")); frm.add(background); // background.setLayout(new FlowLayout()); background.setLayout(null); lh2 = (int) (((((Math.random()) * 5) * 5) * 5) * 7); lh3 = (int) (((((Math.random()) * 5) * 5) * 5) * 7); lh4 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); lh5 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); lh6 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); lh7 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); lh8 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); lh9 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); lh0 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); // JLabel l1=new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\images.gif")); JLabel l1 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\images.gif")); JLabel l2 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l3 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l4 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l5 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l6 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l7 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l8 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l9 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); JLabel l0 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif")); txter = new JTextField(100); txter.setBounds(3, 4, 0, 35); txter.addKeyListener(this); txter.getCursor(); txter.setText(strgr); row += 10; for (int it = 1; it > 0; it += 7) { // Rectangle r=compu l1.setBounds(300 + my_car.row, 400 + my_car.col, 90, 190); l2.setBounds(lh2, -250 + chg, 90, 190); l3.setBounds(lh3, -750 + chg, 90, 190); l4.setBounds(lh4, -1200 + chg, 90, 190); l5.setBounds(lh5, -1750 + chg, 90, 190); l6.setBounds(lh6, -2250 + chg, 90, 190); l7.setBounds(lh7, -2700 + chg, 90, 190); l8.setBounds(lh8, -3250 + chg, 90, 190); l9.setBounds(lh9, -3800 + chg, 90, 190); l0.setBounds(lh0, -4250 + chg, 90, 190); chg += 20; if (chg >= (5000)) { chg = 0; lh2 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh3 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh4 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh5 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh6 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh7 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh8 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh9 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); Thread.sleep(7); lh0 = (int) (((((Math.random()) * 5) * 5) * 5) * 5); } txter.requestDefaultFocus(); { } Thread.sleep(50); System.out.println(my_car.row); l1.repaint(); l2.repaint(); // b1=new JButton("I am a button"); background.add(l1); background.add(l2); background.add(l3); background.add(l4); background.add(l5); background.add(l6); background.add(l7); background.add(l8); background.add(l9); background.add(l0); background.add(txter); // background.add(b1); // frm.setSize(799, 699); frm.setBounds(0, 0, 800, 700); frm.setResizable(false); } }
private void initJP1() { yearleft = new JLabel(" <<", JLabel.CENTER); yearleft.setToolTipText("上一年"); yearright = new JLabel(">> ", JLabel.CENTER); yearright.setToolTipText("下一年"); yearleft.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); yearright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0)); monthleft = new JLabel(" <", JLabel.RIGHT); monthleft.setToolTipText("上一月"); monthright = new JLabel("> ", JLabel.LEFT); monthright.setToolTipText("下一月"); monthleft.setBorder(BorderFactory.createEmptyBorder(2, 30, 0, 0)); monthright.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 30)); centercontainer = new JLabel("", JLabel.CENTER); centercontainer.setLayout(new BorderLayout()); center = new JLabel("", JLabel.CENTER); centercontainer.add(monthleft, BorderLayout.WEST); centercontainer.add(center, BorderLayout.CENTER); centercontainer.add(monthright, BorderLayout.EAST); this.add(yearleft, BorderLayout.WEST); this.add(centercontainer, BorderLayout.CENTER); this.add(yearright, BorderLayout.EAST); this.setPreferredSize(new Dimension(380, 25)); updateDate(); yearleft.addMouseListener( new MouseAdapter() { public void mouseEntered(MouseEvent me) { yearleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); yearleft.setForeground(Color.RED); } public void mouseExited(MouseEvent me) { yearleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); yearleft.setForeground(Color.BLACK); } public void mousePressed(MouseEvent me) { select.add(Calendar.YEAR, -1); yearleft.setForeground(Color.WHITE); refresh(); } public void mouseReleased(MouseEvent me) { yearleft.setForeground(Color.BLACK); } }); yearright.addMouseListener( new MouseAdapter() { public void mouseEntered(MouseEvent me) { yearright.setCursor(new Cursor(Cursor.HAND_CURSOR)); yearright.setForeground(Color.RED); } public void mouseExited(MouseEvent me) { yearright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); yearright.setForeground(Color.BLACK); } public void mousePressed(MouseEvent me) { select.add(Calendar.YEAR, 1); yearright.setForeground(Color.WHITE); refresh(); } public void mouseReleased(MouseEvent me) { yearright.setForeground(Color.BLACK); } }); monthleft.addMouseListener( new MouseAdapter() { public void mouseEntered(MouseEvent me) { monthleft.setCursor(new Cursor(Cursor.HAND_CURSOR)); monthleft.setForeground(Color.RED); } public void mouseExited(MouseEvent me) { monthleft.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); monthleft.setForeground(Color.BLACK); } public void mousePressed(MouseEvent me) { select.add(Calendar.MONTH, -1); monthleft.setForeground(Color.WHITE); refresh(); } public void mouseReleased(MouseEvent me) { monthleft.setForeground(Color.BLACK); } }); monthright.addMouseListener( new MouseAdapter() { public void mouseEntered(MouseEvent me) { monthright.setCursor(new Cursor(Cursor.HAND_CURSOR)); monthright.setForeground(Color.RED); } public void mouseExited(MouseEvent me) { monthright.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); monthright.setForeground(Color.BLACK); } public void mousePressed(MouseEvent me) { select.add(Calendar.MONTH, 1); monthright.setForeground(Color.WHITE); refresh(); } public void mouseReleased(MouseEvent me) { monthright.setForeground(Color.BLACK); } }); }
/** Create the frame. */ public aplicacionGUI() { setTitle("App"); this.setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 540, 380); contentPane = new JLabel(); ImageIcon imga = new ImageIcon(this.getClass().getResource("images/simp.jpg")); contentPane.setIcon( new ImageIcon( imga.getImage().getScaledInstance(getWidth(), getHeight(), Image.SCALE_SMOOTH))); contentPane.setBackground(Color.WHITE); contentPane.setBorder( new BevelBorder( BevelBorder.LOWERED, SystemColor.activeCaptionBorder, SystemColor.activeCaptionBorder, SystemColor.activeCaptionBorder, SystemColor.activeCaptionBorder)); setContentPane(contentPane); contentPane.setLayout(null); JButton btnHablar = new JButton("Click..."); btnHablar.setFont(new Font("OCR A Extended", Font.BOLD, 16)); btnHablar.setBackground(Color.yellow); btnHablar.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { textArea.setVisible(true); String s = "\"Woohoo!\" \n -Homero."; textArea.setBackground(Color.orange); textArea.setFont(new Font("OCR A Extended", Font.BOLD, 18)); textArea.setText(s); ImageIcon img = new ImageIcon(this.getClass().getResource("images/woohoo.png")); label.setIcon( new ImageIcon(img.getImage().getScaledInstance(257, 225, Image.SCALE_SMOOTH))); AudioInputStream audioInputStream; try { audioInputStream = AudioSystem.getAudioInputStream( this.getClass().getResource("sounds/Woohoo!.wav")); Clip clip = AudioSystem.getClip(); clip.open(audioInputStream); clip.start(); } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) { e.printStackTrace(); } label.setVisible(true); } }); btnHablar.setBounds(272, 31, 89, 23); contentPane.add(btnHablar); label = new JLabel(""); label.addMouseListener( new MouseAdapter() { @Override public void mouseEntered(MouseEvent arg0) { if (label.isVisible()) { textArea.setBackground(Color.RED); String s = "\"DOH!\" \n -Homero."; textArea.setText(s); ImageIcon img = new ImageIcon(this.getClass().getResource("images/hdoh.png")); label.setIcon( new ImageIcon(img.getImage().getScaledInstance(257, 225, Image.SCALE_SMOOTH))); AudioInputStream audioInputStream; try { audioInputStream = AudioSystem.getAudioInputStream(this.getClass().getResource("sounds/doh.wav")); Clip clip = AudioSystem.getClip(); clip.open(audioInputStream); clip.start(); } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) { e.printStackTrace(); } } } @Override public void mouseExited(MouseEvent e) { if (label.isVisible()) { textArea.setBackground(Color.blue); String s = "\"DOH!\" \n -Homero."; textArea.setText(s); ImageIcon img = new ImageIcon(this.getClass().getResource("images/hdohh.png")); label.setIcon( new ImageIcon(img.getImage().getScaledInstance(257, 225, Image.SCALE_SMOOTH))); AudioInputStream audioInputStream; try { audioInputStream = AudioSystem.getAudioInputStream(this.getClass().getResource("sounds/doh.wav")); Clip clip = AudioSystem.getClip(); clip.open(audioInputStream); clip.start(); } catch (UnsupportedAudioFileException | IOException | LineUnavailableException ee) { ee.printStackTrace(); } } } }); label.setIcon( new ImageIcon( "C:\\Users\\Mica\\git\\Proyecto0\\Proyecto0\\src\\simpsons\\images\\woohoo.jpg")); label.setVerticalAlignment(SwingConstants.TOP); label.setBounds(5, 5, 257, 225); label.setVisible(false); contentPane.add(label); textArea = new JTextArea(); textArea.setVisible(false); // textArea.setBackground(Color.grey)); textArea.setForeground(Color.BLACK); textArea.setFont(new Font("OCR A Extended", Font.PLAIN, 15)); textArea.setEditable(false); textArea.setBounds(272, 65, 184, 51); contentPane.add(textArea); }
void jbInit() throws Exception { panel1.setLayout(borderLayout1); jPanel1.setBorder(BorderFactory.createEtchedBorder()); jPanel1.setPreferredSize(new Dimension(14, 100)); jPanel1.setLayout(borderLayout2); jPanel2.setBorder(BorderFactory.createEtchedBorder()); jPanel2.setPreferredSize(new Dimension(10, 40)); jPanel2.setLayout(gridBagLayout1); jLabel2.setText("Oznaka banke:"); bPronadji.setPreferredSize(new java.awt.Dimension(80, 27)); bPronadji.setText("Pronadji "); bPronadji.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { bPronadji_actionPerformed(e); } }); bIzlaz.setPreferredSize(new Dimension(80, 27)); bIzlaz.setText("Izlaz"); bIzlaz.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { bIzlaz_actionPerformed(e); } }); txtOznakaBanke.setPreferredSize(new Dimension(120, 21)); getContentPane().add(panel1); panel1.add(jPanel1, BorderLayout.NORTH); { jLabel1 = new JLabel(); jPanel1.add(jLabel1, BorderLayout.CENTER); jLabel1.setText("PREGLED FILIJALA BANKE"); jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 18)); jLabel1.setPreferredSize(new java.awt.Dimension(588, 96)); jLabel1.setHorizontalTextPosition(SwingConstants.CENTER); jLabel1.setHorizontalAlignment(SwingConstants.CENTER); jLabel1.setVerticalAlignment(SwingConstants.TOP); { jLabel3 = new JLabel(); jLabel1.add(jLabel3); jLabel3.setText("NAZIV:"); jLabel3.setBounds(7, 49, 42, 28); jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 12)); } { jLabel4 = new JLabel(); jLabel1.add(jLabel4); jLabel4.setText("ADRESA:"); jLabel4.setBounds(280, 49, 63, 28); jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 12)); } { jLnazivBanke = new JLabel(); jLabel1.add(jLnazivBanke); jLnazivBanke.setBounds(56, 49, 203, 28); } { jLadresaBanke = new JLabel(); jLabel1.add(jLadresaBanke); jLadresaBanke.setBounds(336, 49, 238, 28); } } panel1.add(jPanel2, BorderLayout.SOUTH); jPanel2.add( jLabel2, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); jPanel2.add( txtOznakaBanke, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); jPanel2.add( bPronadji, new GridBagConstraints( 5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 10, 0, 0), 0, 0)); jPanel2.add( bIzlaz, new GridBagConstraints( 5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 200, 0, 0), 0, 0)); panel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.getViewport().add(tabBanke, null); TModelPrijave tMP = new TModelPrijave(tabBanke); tabBanke.setModel(tMP); ((TModelPrijave) tabBanke.getModel()).initColumns(); }