├── AuctionLogo2.jpg ├── trendingLogo.png ├── ClientController.java ├── Images ├── LoginPage.png ├── Registration Page.png ├── Sell Product Confirmation.png ├── Sell Panel Confirmed Product.png └── TopBidderProcedure.txt ├── navigation-drawer-icon.jpg ├── README.md ├── AuctionBackend1.java ├── Client.java ├── LoginFrame.java ├── BidSettings.java ├── RegistrationFrame.java └── AuctionGui.java /AuctionLogo2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yash-ai/Java-Auction-System/HEAD/AuctionLogo2.jpg -------------------------------------------------------------------------------- /trendingLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yash-ai/Java-Auction-System/HEAD/trendingLogo.png -------------------------------------------------------------------------------- /ClientController.java: -------------------------------------------------------------------------------- 1 | package package_1; 2 | 3 | public class ClientController { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /Images/LoginPage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yash-ai/Java-Auction-System/HEAD/Images/LoginPage.png -------------------------------------------------------------------------------- /navigation-drawer-icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yash-ai/Java-Auction-System/HEAD/navigation-drawer-icon.jpg -------------------------------------------------------------------------------- /Images/Registration Page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yash-ai/Java-Auction-System/HEAD/Images/Registration Page.png -------------------------------------------------------------------------------- /Images/Sell Product Confirmation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yash-ai/Java-Auction-System/HEAD/Images/Sell Product Confirmation.png -------------------------------------------------------------------------------- /Images/Sell Panel Confirmed Product.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Yash-ai/Java-Auction-System/HEAD/Images/Sell Panel Confirmed Product.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java-Auction-System 2 | 3 | Java based Auction System Project with a Front-End Gui using Swing and Awt Java Libraries. Any user can display their products along with 4 | its Price and description as well as place a bid for the products displayed on the main window. The bidding on the Product automatically 5 | terminates after 24 hrs and a closed bidding starts for the top 5 Bidders of the Product.The bidder with the Highest bid wins the Product. 6 | -------------------------------------------------------------------------------- /AuctionBackend1.java: -------------------------------------------------------------------------------- 1 | package package_1; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.SQLException; 6 | 7 | public class AuctionBackend1 { 8 | 9 | public static String url = "jdbc:mysql://localhost:3306/dbauction"; 10 | public static String driver = "com.mysql.cj.jdbc.Driver"; 11 | public static String user = "root"; 12 | public static String pass = "yashshete"; 13 | 14 | public static void main(String[] args) { 15 | 16 | LoginFrame lf = new LoginFrame(); 17 | lf.setVisible(true); 18 | } 19 | static Connection connection() throws ClassNotFoundException, SQLException{ 20 | Class.forName(driver); 21 | Connection con = DriverManager.getConnection(url,user,pass); 22 | return con; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Images/TopBidderProcedure.txt: -------------------------------------------------------------------------------- 1 | delimiter $ 2 | create procedure topBids(in ProdId varchar(40),in tbUsername varchar(40)) 3 | begin 4 | declare tb1 varchar(40) default null; 5 | declare tb2 varchar(40) default null; 6 | declare tb3 varchar(40) default null; 7 | declare continue handler for not found set finished=1; 8 | select TB1 into tb1 from topbidders where ProID=ProdId; 9 | if finished=0 then 10 | update topbidders set TB1=tbUsername where ProID=ProdId; 11 | select TB2 into tb2 from topbidders where ProID=ProdId; 12 | update topbidders set TB2=tb1 where ProID=ProdId; 13 | select TB3 into tb1 from topbidders where ProID=ProdId; 14 | update topbidders set TB3=tb2 where ProID=ProdId; 15 | select TB4 into tb2 from topbidders where ProID=ProdId; 16 | update topbidders set TB4=tb1 where ProID=ProdId; 17 | select TB5 into tb3 from topbidders where ProID=ProdId; 18 | update topbidders set TB5=tb2 where ProID=ProdId; 19 | end if; 20 | end $ 21 | delimiter ; -------------------------------------------------------------------------------- /Client.java: -------------------------------------------------------------------------------- 1 | package package_1; 2 | import java.io.Serializable; 3 | 4 | public class Client implements Serializable { 5 | 6 | 7 | private static final long serialVersionUID = 1L; 8 | String firstName; 9 | String lastName; 10 | String gender; 11 | String email; 12 | String userName; 13 | String password; 14 | String address; 15 | String ProductID; 16 | 17 | public String getFirstName() { 18 | return firstName; 19 | } 20 | public void setFirstName(String firstName) { 21 | this.firstName = firstName; 22 | } 23 | public String getLastName() { 24 | return lastName; 25 | } 26 | public void setLastName(String lastName) { 27 | this.lastName = lastName; 28 | } 29 | public String getGender() { 30 | return gender; 31 | } 32 | public void setGender(String gender) { 33 | this.gender = gender; 34 | } 35 | public String getEmail() { 36 | return email; 37 | } 38 | public void setEmail(String email) { 39 | this.email = email; 40 | } 41 | public String getUserName() { 42 | return userName; 43 | } 44 | public void setUserName(String userName) { 45 | this.userName = userName; 46 | } 47 | public String getPassword() { 48 | return password; 49 | } 50 | public void setPassword(String password) { 51 | this.password = password; 52 | } 53 | public String getAddress() { 54 | return address; 55 | } 56 | public void setAddress(String address) { 57 | this.address = address; 58 | } 59 | } -------------------------------------------------------------------------------- /LoginFrame.java: -------------------------------------------------------------------------------- 1 | package package_1; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.Color; 5 | import java.awt.Component; 6 | import java.awt.Cursor; 7 | import java.awt.EventQueue; 8 | import java.awt.Font; 9 | import java.awt.event.ActionEvent; 10 | import java.awt.event.ActionListener; 11 | import java.sql.Connection; 12 | import java.sql.PreparedStatement; 13 | import java.sql.ResultSet; 14 | 15 | import javax.swing.JButton; 16 | import javax.swing.JFrame; 17 | import javax.swing.JLabel; 18 | import javax.swing.JOptionPane; 19 | import javax.swing.JPanel; 20 | import javax.swing.JPasswordField; 21 | import javax.swing.JSeparator; 22 | import javax.swing.JTextField; 23 | import javax.swing.SwingConstants; 24 | import javax.swing.border.EmptyBorder; 25 | import javax.swing.border.LineBorder; 26 | 27 | import package_1.Client; 28 | import package_1.ClientController; 29 | import package_1.RegistrationFrame; 30 | 31 | public class LoginFrame extends JFrame { 32 | 33 | private static final long serialVersionUID = 1L; 34 | private JPanel contentPane; 35 | private JLabel username; 36 | private JLabel Password; 37 | private JTextField txtUsername; 38 | private JPasswordField passwordField; 39 | public int LoggedIn=0; 40 | public String userName; 41 | public String passWord; 42 | private JButton btnLogin,btnCancel,lblRegister; 43 | boolean authResult; 44 | ClientController cc; 45 | RegistrationFrame rf; 46 | 47 | Client c; 48 | String fname; 49 | String lname; 50 | 51 | private Connection con ; 52 | private PreparedStatement ps; 53 | private ResultSet rs; 54 | 55 | /** 56 | * Launch the application. 57 | */ 58 | 59 | public LoginFrame() { 60 | LoggedIn=0; 61 | c=new Client(); 62 | try{ 63 | con = AuctionBackend1.connection(); 64 | }catch(Exception e){ 65 | e.printStackTrace(); 66 | } 67 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 68 | setBounds(100, 100, 430, 350); 69 | contentPane = new JPanel(); 70 | contentPane.setBackground(new Color(47, 79, 79)); 71 | contentPane.setBounds(100, 100, 430, 350); 72 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 73 | contentPane.setLayout(new BorderLayout(0, 0)); 74 | setContentPane(contentPane); 75 | contentPane.setLayout(null); 76 | 77 | JPanel panel = new JPanel(); 78 | panel.setBounds(0, 0, 414, 38); 79 | panel.setBackground(new Color(255, 165, 0)); 80 | contentPane.add(panel); 81 | 82 | JLabel lblLoginForm = new JLabel("Login Form"); 83 | lblLoginForm.setHorizontalTextPosition(SwingConstants.LEFT); 84 | lblLoginForm.setHorizontalAlignment(SwingConstants.LEFT); 85 | panel.add(lblLoginForm); 86 | lblLoginForm.setForeground(new Color(255, 255, 255)); 87 | lblLoginForm.setFont(new Font("Tahoma", Font.BOLD, 18)); 88 | 89 | username = new JLabel("Username:"); 90 | username.setFont(new Font("Tahoma", Font.BOLD, 16)); 91 | username.setBounds(60, 80, 90, 22); 92 | username.setForeground(Color.WHITE); 93 | contentPane.add(username); 94 | username.setVisible(true); 95 | 96 | Password = new JLabel("Password:"); 97 | Password.setFont(new Font("Tahoma", Font.BOLD, 16)); 98 | Password.setBounds(60, 138, 90, 22); 99 | Password.setForeground(Color.WHITE); 100 | contentPane.add(Password); 101 | Password.setVisible(true); 102 | 103 | txtUsername = new JTextField(); 104 | txtUsername.setFont(new Font("Tahoma", Font.BOLD, 12)); 105 | txtUsername.setForeground(new Color(0, 0, 0)); 106 | txtUsername.setBackground(new Color(112, 128, 144)); 107 | txtUsername.setBounds(156, 80, 156, 22); 108 | contentPane.add(txtUsername); 109 | txtUsername.setVisible(true); 110 | 111 | passwordField = new JPasswordField(); 112 | passwordField.setFont(new Font("Tahoma", Font.BOLD, 12)); 113 | passwordField.setForeground(new Color(0, 0, 0)); 114 | passwordField.setToolTipText(""); 115 | passwordField.setBackground(new Color(112, 128, 144)); 116 | passwordField.setBounds(156, 138, 156, 22); 117 | contentPane.add(passwordField); 118 | passwordField.setVisible(true); 119 | 120 | btnLogin = new JButton("Login"); 121 | btnLogin.setInheritsPopupMenu(true); 122 | btnLogin.setRequestFocusEnabled(true); 123 | btnLogin.setRolloverEnabled(false); 124 | btnLogin.setForeground(new Color(30, 144, 255)); 125 | btnLogin.setAlignmentY(Component.BOTTOM_ALIGNMENT); 126 | btnLogin.setBorder(new LineBorder(new Color(0, 0, 0))); 127 | btnLogin.setBackground(new Color(47, 79, 79)); 128 | btnLogin.setFont(new Font("Tahoma", Font.BOLD, 16)); 129 | btnLogin.setBounds(96, 209, 89, 38); 130 | contentPane.add(btnLogin); 131 | btnLogin.setVisible(true); 132 | btnLogin.addActionListener(new ActionListener() { 133 | public void actionPerformed(ActionEvent ae) { 134 | if(LoginData()) 135 | { 136 | 137 | int login=0; 138 | try { 139 | //Check for the UserName and Password in the Database. 140 | //If() the UserName and Password Matches Open the Respective Users Account and The Auction Frame. 141 | 142 | ps = con.prepareStatement("select UserName,Password from registrationtable where UserName=? AND Password=?"); 143 | ps.setString(1,userName); 144 | ps.setString(2,passWord); 145 | rs=ps.executeQuery(); 146 | if(rs.next()) 147 | login=1; 148 | if(login==1) 149 | { 150 | //c.setUserName(userName); 151 | AuctionGui AG=new AuctionGui(); 152 | AG.setVisible(true); 153 | rege(ae); 154 | ps.close(); 155 | } 156 | else 157 | { 158 | JOptionPane.showMessageDialog(null,"Invalid Username or Password!!"); 159 | } 160 | } catch (Exception e) { 161 | System.out.println("Exception Handled during Authenticating User Input in Login Frame."); 162 | e.printStackTrace(); 163 | } 164 | } 165 | } 166 | 167 | 168 | }); 169 | 170 | 171 | btnCancel = new JButton("Cancel"); 172 | btnCancel.setInheritsPopupMenu(true); 173 | btnCancel.setRolloverEnabled(false); 174 | btnCancel.setRequestFocusEnabled(true); 175 | btnCancel.setBorder(new LineBorder(new Color(0, 0, 0))); 176 | btnCancel.setForeground(new Color(255, 0, 0)); 177 | btnCancel.setFont(new Font("Tahoma", Font.BOLD, 14)); 178 | btnCancel.setBackground(new Color(47, 79, 79)); 179 | btnCancel.setBounds(242, 209, 99, 38); 180 | contentPane.add(btnCancel); 181 | btnCancel.setVisible(true); 182 | 183 | 184 | lblRegister = new JButton("Click Here to Regiser "); 185 | lblRegister.addActionListener(new ActionListener() { 186 | public void actionPerformed(ActionEvent e) { 187 | //RegistrationFrame rf=new RegistrationFrame(); 188 | rf.setVisible(true); 189 | reg(e); 190 | 191 | 192 | } 193 | }); 194 | lblRegister.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 195 | lblRegister.setFocusTraversalPolicyProvider(true); 196 | lblRegister.setVisible(true); 197 | 198 | lblRegister.setFont(new Font("Tahoma", Font.BOLD, 13)); 199 | lblRegister.setForeground(new Color(240, 248, 255)); 200 | lblRegister.setBackground(new Color(47, 79, 79)); 201 | lblRegister.setBounds(131, 274, 192, 20); 202 | contentPane.add(lblRegister); 203 | 204 | JSeparator separator = new JSeparator(); 205 | separator.setBackground(new Color(0, 0, 255)); 206 | separator.setBounds(10, 59, 394, 2); 207 | contentPane.add(separator); 208 | 209 | JSeparator separator_1 = new JSeparator(); 210 | separator_1.setBackground(new Color(0, 0, 205)); 211 | separator_1.setBounds(10, 189, 394, 2); 212 | contentPane.add(separator_1); 213 | 214 | rf = new RegistrationFrame(); 215 | } 216 | 217 | 218 | private void reg(ActionEvent e) { 219 | this.setVisible(false); 220 | 221 | } 222 | 223 | private void rege(ActionEvent e) { 224 | this.setVisible(false); 225 | 226 | } 227 | 228 | /*String setUserName() 229 | {return userName;} 230 | 231 | String setPassword() 232 | {return password;} 233 | 234 | void getUserName(String us) 235 | {userName=us;} 236 | 237 | void getPassword(String pw) 238 | {password=pw;}*/ 239 | 240 | //Validate the Entered Username and Password. 241 | @SuppressWarnings("deprecation") 242 | boolean LoginData() 243 | { 244 | userName=txtUsername.getText(); 245 | c.userName=userName; 246 | if(userName.equalsIgnoreCase("")) 247 | { 248 | JOptionPane.showMessageDialog(null,"Invalid Username!!"); 249 | txtUsername.requestFocusInWindow(); 250 | txtUsername.setText(""); 251 | userName=""; 252 | return false; 253 | } 254 | passWord=passwordField.getText(); 255 | c.password=passWord; 256 | if(passWord.equalsIgnoreCase("")) 257 | { 258 | JOptionPane.showMessageDialog(null,"Invalid Password!!"); 259 | passwordField.requestFocusInWindow(); 260 | passwordField.setText(""); 261 | passWord=""; 262 | return false; 263 | } 264 | return true; 265 | } 266 | 267 | } 268 | -------------------------------------------------------------------------------- /BidSettings.java: -------------------------------------------------------------------------------- 1 | package package_1; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.Color; 5 | import java.awt.Font; 6 | import java.awt.Image; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | import java.awt.event.MouseAdapter; 10 | import java.awt.event.MouseEvent; 11 | import java.sql.Connection; 12 | import java.sql.PreparedStatement; 13 | import java.sql.ResultSet; 14 | import java.sql.SQLException; 15 | 16 | import javax.swing.ImageIcon; 17 | import javax.swing.JButton; 18 | import javax.swing.JFrame; 19 | import javax.swing.JLabel; 20 | import javax.swing.JOptionPane; 21 | import javax.swing.JPanel; 22 | import javax.swing.JTextField; 23 | import javax.swing.SwingConstants; 24 | import javax.swing.UIManager; 25 | import javax.swing.border.EmptyBorder; 26 | import java.math.*; 27 | 28 | public class BidSettings extends JFrame { 29 | 30 | /** 31 | * 32 | */ 33 | AuctionGui ag; 34 | Client c; 35 | private static final int noOfBids=0; 36 | private static final long serialVersionUID = 1L; 37 | private JPanel contentPane; 38 | private JLabel txtAmount; 39 | String textAmount; 40 | double bidAmount; 41 | double dCurrentPrice; 42 | PreparedStatement ps; 43 | ResultSet rs; 44 | /** 45 | * Create the frame. 46 | * @throws SQLException 47 | * @throws ClassNotFoundException 48 | */ 49 | public BidSettings() throws ClassNotFoundException, SQLException { 50 | 51 | Connection con = AuctionBackend1.connection(); 52 | ag = new AuctionGui(); 53 | 54 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 55 | setBounds(100, 100, 450, 310); 56 | contentPane = new JPanel(); 57 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 58 | contentPane.setLayout(new BorderLayout(0, 0)); 59 | setContentPane(contentPane); 60 | 61 | JPanel placeBidPanel = new JPanel(); 62 | placeBidPanel.setBackground(new Color(255, 255, 255)); 63 | placeBidPanel.setBounds(100,100,450,300); 64 | contentPane.add(placeBidPanel); 65 | placeBidPanel.setLayout(null); 66 | 67 | 68 | JLabel lblBidSettings = new JLabel(" Bid Settings "); 69 | lblBidSettings.setHorizontalAlignment(SwingConstants.CENTER); 70 | lblBidSettings.setFont(new Font("Open Sans Semibold", Font.BOLD, 16)); 71 | lblBidSettings.setBounds(160, 10, 90, 30); 72 | placeBidPanel.add(lblBidSettings); 73 | 74 | 75 | JLabel lblNotice_1 = new JLabel(" Enter the Amount you want to Bid. "); 76 | lblNotice_1.setFont(new Font("Open Sans Semibold", Font.PLAIN, 11)); 77 | lblBidSettings.setHorizontalAlignment(SwingConstants.CENTER); 78 | lblBidSettings.setFont(new Font("Myanmar Text", Font.BOLD, 12)); 79 | lblNotice_1.setBounds(125, 45, 200, 20); 80 | placeBidPanel.add(lblNotice_1); 81 | 82 | JLabel lblNotice_2 = new JLabel("1000 will be used to Bid"); 83 | lblNotice_2.setFont(new Font("Open Sans Semibold", Font.PLAIN, 11)); 84 | lblNotice_2.setBounds(160, 70, 130, 20); 85 | placeBidPanel.add(lblNotice_2); 86 | 87 | JPanel moneyPanel = new JPanel(); 88 | moneyPanel.setBackground(UIManager.getColor("Button.foreground")); 89 | moneyPanel.setForeground(new Color(80, 80, 80)); 90 | moneyPanel.setBounds(20, 115, 385, 100); 91 | moneyPanel.setLayout(null); 92 | placeBidPanel.add(moneyPanel); 93 | 94 | JLabel Plus_Icon = new JLabel(); 95 | Plus_Icon.setLayout(null); 96 | JLabel Minus_Icon = new JLabel(); 97 | txtAmount = new JLabel(); 98 | 99 | Image img8=new ImageIcon(this.getClass().getResource("/icon-add.png")).getImage(); 100 | Image img9=new ImageIcon(this.getClass().getResource("/icon-minus.png")).getImage(); 101 | Image img10=new ImageIcon(this.getClass().getResource("/icon-minus-32-grey.png")).getImage(); 102 | 103 | /*System.out.println("ag.getProdId():"+ag.getProdId()); 104 | ps = con.prepareStatement("select CurrentPrice from bidtable where ProID=?"); 105 | ps.setString(1, ag.getProdId()); 106 | rs = ps.executeQuery(); 107 | if(rs.next()) 108 | { 109 | dCurrentPrice = rs.getDouble("CurrentPrice"); 110 | } 111 | */ 112 | //Code to Determine the Number of Digits in Base Price. 113 | int n=(int) dCurrentPrice; 114 | int i=0; 115 | while(n>0) 116 | { 117 | n=n/10; 118 | i++; 119 | } 120 | double basePrice = dCurrentPrice + Math.pow(10,i-1); 121 | String strCurrentPrice = Double.toString(basePrice); 122 | dCurrentPrice=basePrice; 123 | txtAmount.setText(strCurrentPrice); 124 | Plus_Icon.addMouseListener(new MouseAdapter() { 125 | @Override 126 | public void mouseClicked(MouseEvent e) { 127 | 128 | //Retrieve the Current Value From The Database. 129 | //value in the textField = Current value + 1000; 130 | //if(value in textField == current value + 1000) 131 | int n=(int) dCurrentPrice; 132 | int i=0; 133 | while(n>0) 134 | { 135 | n=n/10; 136 | i++; 137 | } 138 | dCurrentPrice = dCurrentPrice + Math.pow(10,i-1); 139 | String strCurrentPrice = Double.toString(dCurrentPrice); 140 | txtAmount.setText(strCurrentPrice); 141 | Minus_Icon.setBackground(new Color(255,0,0)); 142 | Minus_Icon.setIcon(new ImageIcon(img9)); 143 | } 144 | }); 145 | Plus_Icon.setBackground(new Color(0,255,0)); 146 | Plus_Icon.setOpaque(true); 147 | Plus_Icon.setIcon(new ImageIcon(img8)); 148 | Plus_Icon.setBounds(340, 5, 40, 40); 149 | moneyPanel.add(Plus_Icon); 150 | 151 | Minus_Icon.setBackground(Color.WHITE); 152 | Minus_Icon.setIcon(new ImageIcon(img10)); 153 | Minus_Icon.addMouseListener(new MouseAdapter() { 154 | @Override 155 | public void mouseClicked(MouseEvent e) { 156 | int n=(int) dCurrentPrice; 157 | int i=0; 158 | while(n>0) 159 | { 160 | n=n/10; 161 | i++; 162 | } 163 | dCurrentPrice = dCurrentPrice - Math.pow(10,i-1); 164 | String strCurrentPrice = Double.toString(dCurrentPrice); 165 | txtAmount.setText(strCurrentPrice); 166 | if(dCurrentPrice==basePrice) 167 | { 168 | Minus_Icon.setBackground(new Color(255,255,255)); 169 | Minus_Icon.setIcon(new ImageIcon(img10)); 170 | } 171 | 172 | } 173 | }); 174 | Minus_Icon.setOpaque(true); 175 | Minus_Icon.setBounds(340, 50, 40, 40); 176 | moneyPanel.add(Minus_Icon); 177 | 178 | 179 | txtAmount.setBackground(new Color(112, 128, 144)); 180 | txtAmount.setFont(new Font("Tahoma", Font.BOLD, 18)); 181 | txtAmount.setBounds(132, 22, 187, 56); 182 | moneyPanel.add(txtAmount); 183 | 184 | JButton btnPlaceBidCancel = new JButton("Cancel"); 185 | btnPlaceBidCancel.addActionListener(new ActionListener() { 186 | public void actionPerformed(ActionEvent arg0) { 187 | contentPane.setVisible(false); 188 | //Redirect To the MoreInfo Panel. 189 | } 190 | }); 191 | btnPlaceBidCancel.setBounds(45,225,110,30); 192 | btnPlaceBidCancel.setForeground(new Color(255, 0, 0)); 193 | btnPlaceBidCancel.setFont(new Font("Tahoma", Font.BOLD, 15)); 194 | btnPlaceBidCancel.setBackground(new Color(70, 130, 180)); 195 | placeBidPanel.add(btnPlaceBidCancel); 196 | 197 | JButton btnPlaceBidPlaceBid = new JButton(); 198 | btnPlaceBidPlaceBid.setText(" Place Bid "); 199 | btnPlaceBidPlaceBid.setForeground(new Color(0, 0, 255)); 200 | btnPlaceBidPlaceBid.setFont(new Font("Tahoma", Font.BOLD, 15)); 201 | btnPlaceBidPlaceBid.setBackground(new Color(70, 130, 180)); 202 | btnPlaceBidPlaceBid.addActionListener(new ActionListener() { 203 | int yesOrNo; 204 | public void actionPerformed(ActionEvent arg0) { 205 | 206 | //Add the ProductId to the Usernames table who clicked the "Place Bid" Button and show the Details in the user's MyBids Panel. 207 | 208 | bidAmount=Double.parseDouble(txtAmount.getText()); 209 | yesOrNo = JOptionPane.showConfirmDialog(null, " Place the Bid at "+bidAmount+"?", "Confirmation Message", JOptionPane.YES_NO_OPTION); 210 | if(yesOrNo==0) 211 | { 212 | int bids=0; 213 | int flag=0; 214 | int exFlag=0; 215 | //User Clicked Yes. 216 | try { 217 | 218 | //code to first check if the User has bid Before if so then Update the Current Bid Value. 219 | ps = con .prepareStatement("select Username from buyertable where ProID=? AND Username=?"); 220 | ps.setString(1, ag.getProdId()); 221 | ps.setString(2, c.userName); 222 | rs=ps.executeQuery(); 223 | if(rs.next()) //For existing Bidder. 224 | { 225 | exFlag=1; 226 | ps = con.prepareStatement("update buyertable set MyBidPrice=? where UserName=? AND ProID=?"); 227 | ps.setDouble(1, bidAmount); 228 | ps.setString(2, c.userName); 229 | ps.setString(3, ag.getProdId()); 230 | ps.executeUpdate(); 231 | ps=con.prepareStatement("Update bidtable set CurrentPrice=?,UserName=? where ProID=?");//remaining:-to update username. 232 | ps.setDouble(1, bidAmount); 233 | ps.setString(2, c.userName); 234 | ps.setString(3, ag.getProdId()); 235 | ps.executeUpdate(); 236 | 237 | ps.close(); 238 | } 239 | else if(exFlag==0) 240 | { 241 | //For First Time Bidder.Check if any one has Bid on the Same Product in Past. 242 | ps=con.prepareStatement("select ProID from buyertable where UserName = ?"); 243 | ps.setString(1, ag.getProdId()); 244 | rs=ps.executeQuery(); 245 | if(rs.next()) //If Someone has Bid in Past then just Update the bidtable. 246 | { 247 | flag=1; 248 | ps = con.prepareStatement("insert into buyertable values (?,?,?)"); 249 | ps.setString(1, ag.getProdId()); 250 | ps.setString(2, c.userName); 251 | ps.setDouble(3, bidAmount); 252 | ps.executeUpdate(); 253 | ps=con.prepareStatement("update bidtable set CurrentPrice=? where ProID=? AND UserName=?"); 254 | ps.setDouble(1, bidAmount); 255 | ps.setString(2, ag.getProdId()); 256 | ps.setString(3, c.userName); 257 | ps.close(); 258 | } 259 | else if(flag==0) //If NoOne has Bid on the Product in Past then insert new Values in the bidtable as well. 260 | { 261 | ps = con.prepareStatement("insert into buyertable values (?,?,?)"); 262 | ps.setString(1, ag.getProdId()); 263 | ps.setString(2, c.userName); 264 | ps.setDouble(3, bidAmount); 265 | ps.executeUpdate(); 266 | ps = con.prepareStatement("insert into bidtable(ProID,BasePrice,CurrentPrice,userName) values(?,?,?,?)"); 267 | ps.setString(1, ag.getProdId()); 268 | ps.setDouble(2, Double.parseDouble(ag.getProdBasePrice())); 269 | ps.setDouble(3, bidAmount); 270 | ps.setString(4, c.userName); 271 | ps.executeUpdate(); 272 | ps = con.prepareStatement("select NoOfBids from bidtable where ProID=?"); 273 | ps.setString(1, ag.getProdId()); 274 | rs=ps.executeQuery(); 275 | if(rs.next()) 276 | { 277 | bids=rs.getInt("NoOfBids"); 278 | bids++; 279 | } 280 | ps = con.prepareStatement("insert into bidtable (NoOfBids) values(?) where ProID=?"); 281 | ps.setInt(1,bids); 282 | ps.setString(2, ag.getProdId()); 283 | ps.executeUpdate(); 284 | 285 | ps.close(); 286 | rs.close(); 287 | } 288 | } 289 | } catch (SQLException e) { 290 | System.out.println("SQLException in PlaceBid button in Bid settings."); 291 | e.printStackTrace(); 292 | } 293 | 294 | JOptionPane.showMessageDialog(null, " Thank You for Placing the Bid!!. This Product has been Added to your My Bids Drawer."); 295 | } 296 | else 297 | { 298 | JOptionPane.showMessageDialog(null, " Bidding Cancelled!!",null,JOptionPane.ERROR_MESSAGE); 299 | } 300 | } 301 | }); 302 | btnPlaceBidPlaceBid.setBounds(225, 225, 125, 30); 303 | placeBidPanel.add(btnPlaceBidPlaceBid); 304 | 305 | } 306 | } 307 | -------------------------------------------------------------------------------- /RegistrationFrame.java: -------------------------------------------------------------------------------- 1 | package package_1; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.Color; 5 | import java.awt.Cursor; 6 | 7 | import java.awt.Font; 8 | import java.awt.event.ActionEvent; 9 | import java.awt.event.ActionListener; 10 | import java.sql.Connection; 11 | import java.sql.PreparedStatement; 12 | import java.sql.ResultSet; 13 | import java.util.regex.Matcher; 14 | import java.util.regex.Pattern; 15 | 16 | import javax.swing.ButtonGroup; 17 | import javax.swing.JButton; 18 | import javax.swing.JFrame; 19 | import javax.swing.JLabel; 20 | import javax.swing.JOptionPane; 21 | import javax.swing.JPanel; 22 | import javax.swing.JPasswordField; 23 | import javax.swing.JRadioButton; 24 | import javax.swing.JSeparator; 25 | import javax.swing.JTextArea; 26 | import javax.swing.JTextField; 27 | import javax.swing.border.EmptyBorder; 28 | 29 | import package_1.Client; 30 | import package_1.ClientController; 31 | import package_1.LoginFrame; 32 | 33 | public class RegistrationFrame extends JFrame { 34 | 35 | private static final long serialVersionUID = 1L; 36 | private JPanel contentPane; 37 | private JTextField txtFN; 38 | private JTextField txtLN; 39 | private JTextField txtEmail; 40 | private JTextField txtUsername; 41 | private JPasswordField passwordField; 42 | private JPasswordField CpasswordField; 43 | private JRadioButton rdbtnMale,rdbtnFemale; 44 | private JTextArea txtArAddress; 45 | private JLabel lblRegistrationForm,lblFirstName,lblLastName,lblEmail,lblUsername,lblPassword,lblConfirmPassword,lblAddress, lblGender; 46 | private JButton btnCancel,btnRegister; 47 | ButtonGroup group; 48 | String Gender; 49 | public int Registered; 50 | 51 | Client c2; 52 | 53 | String firstName; 54 | String lastName; 55 | boolean gender; 56 | String email; 57 | String username; 58 | String password; 59 | String cPassword; 60 | String address; 61 | 62 | Pattern p; 63 | Matcher m; 64 | boolean b; 65 | 66 | private Connection con ; 67 | private PreparedStatement ps; 68 | private ResultSet rs; 69 | 70 | 71 | /** 72 | * Create the frame. 73 | */ 74 | public RegistrationFrame() { 75 | Registered=0; 76 | 77 | try{ 78 | con = AuctionBackend1.connection(); 79 | }catch(Exception e){ 80 | e.printStackTrace(); 81 | } 82 | 83 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 84 | setBounds(100, 100, 450, 580); 85 | contentPane = new JPanel(); 86 | contentPane.setBackground(new Color(47, 79, 79)); 87 | contentPane.setBounds(100, 100, 450, 590); 88 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 89 | contentPane.setLayout(new BorderLayout(0, 0)); 90 | setContentPane(contentPane); 91 | contentPane.setLayout(null); 92 | 93 | JPanel panel = new JPanel(); 94 | panel.setForeground(new Color(240, 255, 240)); 95 | panel.setBackground(new Color(255, 140, 0)); 96 | panel.setBounds(0, 0, 434, 45); 97 | contentPane.add(panel); 98 | 99 | lblRegistrationForm = new JLabel("Registration Form"); 100 | lblRegistrationForm.setForeground(new Color(245, 245, 245)); 101 | lblRegistrationForm.setFont(new Font("Tahoma", Font.BOLD, 18)); 102 | panel.add(lblRegistrationForm); 103 | 104 | lblFirstName = new JLabel("First Name:"); 105 | lblFirstName.setFont(new Font("Tahoma", Font.BOLD, 16)); 106 | lblFirstName.setForeground(new Color(255, 255, 255)); 107 | lblFirstName.setBounds(38, 76, 107, 20); 108 | contentPane.add(lblFirstName); 109 | 110 | lblLastName = new JLabel("Last Name:"); 111 | lblLastName.setForeground(new Color(255, 255, 255)); 112 | lblLastName.setFont(new Font("Tahoma", Font.BOLD, 16)); 113 | lblLastName.setBounds(38, 107, 107, 20); 114 | contentPane.add(lblLastName); 115 | 116 | lblEmail = new JLabel("Email:"); 117 | lblEmail.setForeground(new Color(255, 255, 255)); 118 | lblEmail.setFont(new Font("Tahoma", Font.BOLD, 16)); 119 | lblEmail.setBounds(80, 196, 65, 20); 120 | contentPane.add(lblEmail); 121 | 122 | lblUsername = new JLabel("Username:"); 123 | lblUsername.setFont(new Font("Tahoma", Font.BOLD, 16)); 124 | lblUsername.setForeground(new Color(255, 255, 255)); 125 | lblUsername.setBounds(44, 227, 101, 20); 126 | contentPane.add(lblUsername); 127 | 128 | lblPassword = new JLabel("Password:"); 129 | lblPassword.setFont(new Font("Tahoma", Font.BOLD, 16)); 130 | lblPassword.setForeground(new Color(255, 255, 255)); 131 | lblPassword.setBounds(50, 258, 95, 20); 132 | contentPane.add(lblPassword); 133 | 134 | lblConfirmPassword = new JLabel("Confirm Password:"); 135 | lblConfirmPassword.setForeground(new Color(255, 255, 255)); 136 | lblConfirmPassword.setFont(new Font("Tahoma", Font.BOLD, 16)); 137 | lblConfirmPassword.setBounds(0, 291, 166, 20); 138 | contentPane.add(lblConfirmPassword); 139 | 140 | lblAddress = new JLabel("Address:"); 141 | lblAddress.setFont(new Font("Tahoma", Font.BOLD, 16)); 142 | lblAddress.setForeground(Color.WHITE); 143 | lblAddress.setBounds(38, 333, 73, 23); 144 | contentPane.add(lblAddress); 145 | 146 | txtArAddress = new JTextArea(); 147 | txtArAddress.setLineWrap(true); 148 | txtArAddress.setFocusTraversalPolicyProvider(true); 149 | txtArAddress.setFont(new Font("Tahoma", Font.BOLD, 14)); 150 | txtArAddress.setForeground(new Color(255, 255, 255)); 151 | txtArAddress.setBackground(new Color(112, 128, 144)); 152 | txtArAddress.setBounds(123, 353, 221, 95); 153 | contentPane.add(txtArAddress); 154 | 155 | 156 | btnCancel = new JButton("Back"); 157 | btnCancel.addActionListener(new ActionListener() { 158 | public void actionPerformed(ActionEvent e) { 159 | LoginFrame lf=new LoginFrame(); 160 | lf.setVisible(true); 161 | visible(e); 162 | 163 | } 164 | }); 165 | btnCancel.setRolloverEnabled(false); 166 | btnCancel.setRequestFocusEnabled(false); 167 | btnCancel.setForeground(new Color(255, 0, 0)); 168 | btnCancel.setBackground(new Color(47, 79, 79)); 169 | btnCancel.setFont(new Font("Tahoma", Font.BOLD, 16)); 170 | btnCancel.setBounds(96, 475, 89, 36); 171 | contentPane.add(btnCancel); 172 | 173 | txtFN = new JTextField(); 174 | txtFN.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); 175 | txtFN.setFont(new Font("Tahoma", Font.BOLD, 14)); 176 | txtFN.setBackground(new Color(112, 128, 144)); 177 | txtFN.setBounds(155, 74, 146, 22); 178 | txtFN.setColumns(10); 179 | contentPane.add(txtFN); 180 | 181 | 182 | txtLN = new JTextField(); 183 | txtLN.setFont(new Font("Tahoma", Font.BOLD, 14)); 184 | txtLN.setBackground(new Color(112, 128, 144)); 185 | txtLN.setBounds(155, 106, 146, 23); 186 | txtLN.setColumns(10); 187 | contentPane.add(txtLN); 188 | 189 | 190 | txtEmail = new JTextField(); 191 | txtEmail.setFont(new Font("Tahoma", Font.BOLD, 14)); 192 | txtEmail.setBackground(new Color(112, 128, 144)); 193 | txtEmail.setBounds(153, 195, 189, 23); 194 | txtEmail.setColumns(10); 195 | contentPane.add(txtEmail); 196 | 197 | 198 | txtUsername = new JTextField(); 199 | txtUsername.setFont(new Font("Tahoma", Font.BOLD, 14)); 200 | txtUsername.setBackground(new Color(112, 128, 144)); 201 | txtUsername.setBounds(153, 226, 189, 23); 202 | txtUsername.setColumns(10); 203 | contentPane.add(txtUsername); 204 | 205 | 206 | passwordField = new JPasswordField(); 207 | passwordField.setFont(new Font("Tahoma", Font.BOLD, 14)); 208 | passwordField.setBackground(new Color(112, 128, 144)); 209 | passwordField.setBounds(153, 258, 189, 23); 210 | contentPane.add(passwordField, BorderLayout.CENTER); 211 | 212 | 213 | CpasswordField = new JPasswordField(); 214 | CpasswordField.setBackground(new Color(112, 128, 144)); 215 | CpasswordField.setFont(new Font("Tahoma", Font.BOLD, 14)); 216 | CpasswordField.setBounds(155, 290, 189, 23); 217 | contentPane.add(CpasswordField, BorderLayout.CENTER); 218 | 219 | lblGender = new JLabel("Gender:"); 220 | lblGender.setFont(new Font("Tahoma", Font.BOLD, 16)); 221 | lblGender.setForeground(new Color(255, 255, 255)); 222 | lblGender.setBackground(new Color(47, 79, 79)); 223 | lblGender.setBounds(62, 156, 73, 14); 224 | contentPane.add(lblGender); 225 | 226 | rdbtnMale = new JRadioButton("Male"); 227 | rdbtnMale.setRequestFocusEnabled(false); 228 | rdbtnMale.setRolloverEnabled(false); 229 | rdbtnMale.setFont(new Font("Tahoma", Font.BOLD, 14)); 230 | rdbtnMale.setForeground(new Color(255, 255, 255)); 231 | rdbtnMale.setBackground(new Color(47, 79, 79)); 232 | rdbtnMale.setBounds(156, 153, 65, 23); 233 | contentPane.add(rdbtnMale); 234 | 235 | rdbtnFemale = new JRadioButton("Female",false); 236 | rdbtnFemale.setRolloverEnabled(false); 237 | rdbtnFemale.setRequestFocusEnabled(false); 238 | rdbtnFemale.setForeground(new Color(255, 255, 255)); 239 | rdbtnFemale.setBackground(new Color(47, 79, 79)); 240 | rdbtnFemale.setFont(new Font("Tahoma", Font.BOLD, 14)); 241 | rdbtnFemale.setBounds(237, 153, 80, 23); 242 | contentPane.add(rdbtnFemale); 243 | 244 | group=new ButtonGroup(); 245 | group.add(rdbtnMale); 246 | group.add(rdbtnFemale); 247 | 248 | 249 | btnRegister = new JButton("Register\r\n"); 250 | btnRegister.setRolloverEnabled(false); 251 | btnRegister.setRequestFocusEnabled(true); 252 | btnRegister.setForeground(new Color(30, 144, 255)); 253 | btnRegister.setFont(new Font("Tahoma", Font.BOLD, 16)); 254 | btnRegister.setBackground(new Color(47, 79, 79)); 255 | btnRegister.setBounds(237, 474, 107, 38); 256 | contentPane.add(btnRegister); 257 | 258 | JSeparator separator = new JSeparator(); 259 | separator.setBackground(new Color(0, 0, 255)); 260 | separator.setBounds(10, 459, 414, 6); 261 | contentPane.add(separator); 262 | btnRegister.addActionListener(new ActionListener() { 263 | 264 | 265 | @Override 266 | public void actionPerformed(ActionEvent e) { 267 | 268 | try { 269 | if(RegisterData()){ 270 | Registered=1; 271 | ps = con.prepareStatement("insert into registrationtable values(?,?,?,?,?,?,?)"); 272 | ps.setString(1,firstName); 273 | ps.setString(2,lastName); 274 | ps.setString(3,Gender); 275 | ps.setString(4,email); 276 | ps.setString(5,address); 277 | ps.setString(6,username); 278 | ps.setString(7,password); 279 | ps.executeUpdate(); 280 | ps.close(); 281 | JOptionPane.showMessageDialog(null, 282 | "Data Registered Successfully."); 283 | 284 | /* try { 285 | sendDataToController(Registered); 286 | } catch (FileNotFoundException e1) { 287 | System.out.println("Exception Handled during Authenticating User Input in Registration Frame on Register Button Click."+e1); 288 | e1.printStackTrace(); 289 | } 290 | */ 291 | //Store the Data in the Database. 292 | } 293 | } catch (Exception e1) { 294 | System.out.println("Exception Caught in Register Button."); 295 | e1.printStackTrace(); 296 | } 297 | } 298 | }); 299 | 300 | } 301 | void visible(ActionEvent e) 302 | { 303 | this.setVisible(false); 304 | } 305 | 306 | //Function To Validate All the Input. 307 | 308 | 309 | @SuppressWarnings("deprecation") 310 | boolean RegisterData() throws Exception{ 311 | firstName=txtFN.getText(); 312 | p = Pattern.compile("[^a-z]", Pattern.CASE_INSENSITIVE); 313 | m = p.matcher(firstName); 314 | b = m.find(); 315 | if(b || firstName.equalsIgnoreCase("")) 316 | { 317 | JOptionPane.showMessageDialog(null,"Invalid First Name!!"); 318 | txtFN.requestFocusInWindow(); 319 | txtFN.setText(""); 320 | firstName=""; 321 | return false; 322 | } 323 | System.out.println(firstName); 324 | 325 | lastName=txtLN.getText(); 326 | p = Pattern.compile("[^a-z]", Pattern.CASE_INSENSITIVE); 327 | m = p.matcher(lastName); 328 | b = m.find(); 329 | if(lastName.equalsIgnoreCase("") || b) 330 | { 331 | JOptionPane.showMessageDialog(null,"Invalid Last Name!!"); 332 | txtLN.requestFocusInWindow(); 333 | txtLN.setText(""); 334 | lastName=""; 335 | return false; 336 | } 337 | System.out.println(lastName); 338 | 339 | gender = false; 340 | try{ 341 | gender=rdbtnMale.isSelected(); 342 | }catch(Exception e) 343 | { 344 | System.out.println("Exception Caught in Gender."); 345 | return false; 346 | } 347 | if(gender==true) 348 | Gender="M"; 349 | else 350 | Gender="F"; 351 | System.out.println(Gender); 352 | 353 | 354 | email=txtEmail.getText(); 355 | if(email.equalsIgnoreCase("") || email.equals("@gmail.com")|| email.equals("@yahoo")) 356 | { 357 | JOptionPane.showMessageDialog(null,"Invalid Email ID!!"); 358 | txtEmail.requestFocusInWindow(); 359 | txtEmail.setText(""); 360 | email=""; 361 | return false; 362 | } 363 | System.out.println(email); 364 | 365 | username=txtUsername.getText(); 366 | boolean test=false; 367 | //boolean test = To check in the Database If any User is Present with The same UserName. 368 | ps = con.prepareStatement("select UserName from registrationtable where UserName=?"); 369 | ps.setString(1, username); 370 | rs= ps.executeQuery(); 371 | if(rs.next()) 372 | { 373 | test=true; 374 | } 375 | 376 | if(test) 377 | { 378 | JOptionPane.showMessageDialog(null,"This Username Already Exists."); 379 | txtUsername.requestFocusInWindow(); 380 | txtUsername.setText(""); 381 | username=""; 382 | return false; 383 | } 384 | if(username.equalsIgnoreCase("")) 385 | { 386 | JOptionPane.showMessageDialog(null,"Invalid Email ID!!"); 387 | txtUsername.requestFocusInWindow(); 388 | txtUsername.setText(""); 389 | username=""; 390 | return false; 391 | } 392 | System.out.println(username); 393 | password=passwordField.getText(); 394 | cPassword=CpasswordField.getText(); 395 | 396 | if(!(cPassword.equals(password))) 397 | { 398 | JOptionPane.showMessageDialog(null,"Password did'nt Match!!"); 399 | CpasswordField.requestFocusInWindow(); 400 | CpasswordField.setText(""); 401 | 402 | return false; 403 | } 404 | System.out.println(password); 405 | 406 | address=txtArAddress.getText(); 407 | System.out.println(address); 408 | 409 | return true; 410 | } 411 | } 412 | 413 | -------------------------------------------------------------------------------- /AuctionGui.java: -------------------------------------------------------------------------------- 1 | package package_1; 2 | 3 | import java.awt.Image; 4 | 5 | import javax.swing.ImageIcon; 6 | import javax.swing.JFrame; 7 | import javax.swing.JPanel; 8 | import javax.swing.border.EmptyBorder; 9 | import javax.swing.JLabel; 10 | import javax.swing.JMenuItem; 11 | import javax.swing.JOptionPane; 12 | import javax.swing.SwingConstants; 13 | import javax.swing.Timer; 14 | 15 | import java.awt.BorderLayout; 16 | import java.awt.Color; 17 | import java.awt.Cursor; 18 | 19 | import javax.swing.JTabbedPane; 20 | import javax.swing.JScrollPane; 21 | import javax.swing.JSeparator; 22 | import javax.swing.JTable; 23 | import javax.swing.JTextArea; 24 | 25 | import java.nio.file.*; 26 | import java.sql.Blob; 27 | import java.sql.Connection; 28 | import java.sql.PreparedStatement; 29 | import java.sql.ResultSet; 30 | import java.sql.SQLException; 31 | import java.util.Random; 32 | import java.util.TimerTask; 33 | import java.util.Vector; 34 | import java.util.regex.Matcher; 35 | import java.util.regex.Pattern; 36 | import java.awt.event.ActionEvent; 37 | import java.awt.event.ActionListener; 38 | import java.awt.event.MouseAdapter; 39 | import java.awt.event.MouseEvent; 40 | import java.io.File; 41 | import java.io.FileInputStream; 42 | import java.io.FileNotFoundException; 43 | import java.io.FileOutputStream; 44 | import java.io.InputStream; 45 | 46 | import javax.swing.JButton; 47 | import javax.swing.JComboBox; 48 | import javax.swing.JDialog; 49 | import javax.swing.JFileChooser; 50 | import javax.swing.border.LineBorder; 51 | import javax.swing.border.MatteBorder; 52 | import javax.swing.event.ListSelectionEvent; 53 | import javax.swing.event.ListSelectionListener; 54 | import javax.swing.filechooser.FileNameExtensionFilter; 55 | import javax.swing.table.DefaultTableModel; 56 | import java.awt.Font; 57 | import javax.swing.JTextField; 58 | import java.awt.event.FocusAdapter; 59 | import java.awt.event.FocusEvent; 60 | import net.proteanit.sql.*; 61 | 62 | public class AuctionGui extends JFrame{ 63 | 64 | //Initialization. 65 | Integer pl1=50,pl2=700; 66 | Timer t1 ,t2; 67 | 68 | private static final long serialVersionUID = 1L; 69 | public static String finalTimer; 70 | private JTabbedPane tabbedPane; 71 | private JButton btnSearch; 72 | private JPanel homeTab,trendingBidsTab; 73 | private JLabel drawerIconMenu,drawerIconArrowTop; 74 | 75 | private JPanel navigationPanel; 76 | private JLabel lblHome,lblAccount,lblSell,lblMyBids,lblCategory,lblSavedBids,lblLogout; 77 | 78 | private JPanel contentPane; 79 | private JTextField searchTextField; 80 | private JPanel accountPanel,sellPanel,myBidsPanel,savedBidsPanel,moreInfoPanel,myProdPanel; 81 | private JLabel lblFirstName,lblLastName,lblEmail,lblUsername,lblPassword,lblAddress, lblGender; 82 | 83 | private JLabel txtFN, txtLN, txtEmail, txtUsername, passwordField; 84 | private JTextArea txtAddress; 85 | private JLabel txtGender; 86 | private JLabel lblAccountDetails; 87 | private JButton btnChangePassword; 88 | private JLabel lblNewPassword,lblNewCPassword; 89 | private JTextField txtNewPassword,txtNewCPassword; 90 | private JButton btnSaveChanges; 91 | private JButton btnCancel; 92 | 93 | private JLabel lblSellProduct,lblProductName,lblProductDetails,lblProductImage,lblBasePrice,lblSPCategory,lblTimeLeft,txtProductImage,lblPath,txtPath; 94 | private JLabel lblspecifyCategory,txtTimeLeft,lblProductId,txtProductId,lblMyBidsTitle,lblSavedBidsTitle; 95 | private JLabel lblCurrentPrice,txtCurrentPrice; 96 | private JTextField txtProductName,txtBasePrice,txtspecifyCategory; 97 | private JTextArea txtArProductDetails; 98 | private String[] options; 99 | private JComboBox comboBoxCategory; 100 | private JMenuItem categoryCar,categoryElectronics,categoryPainting,categoryStatue,categoryWatch,categoryOthers,empty; 101 | private String Path,selectCategory; 102 | private JButton btnBrowse,btnSell,btnSave,btnPlaceBid; 103 | private JTable myBidsTable,homeHomeTable,homeTrendingTable,savedBidsTable,myProdTable; 104 | private JScrollPane myBidsScrollPane,savedBidsScrollPane,homeHomeScrollPane,homeTrendingScrollPane,myProdScrollPane; 105 | private DefaultTableModel myBidsmodel,savedBidsmodel,homeHomemodel,homeTrendingmodel,myProdmodel; 106 | 107 | private JLabel lblMoreProductInfo,lblInfoProductName,lblInfoProductDetails,lblInfoProductImage,lblInfoBasePrice,lblInfoSPCategory,txtInfoProductImage,lblInfoPath,txtInfoPath; 108 | private JLabel txtInfoProductName,txtInfoBasePrice,lblInfoUsername,txtInfoUsername,lblInfoCurrentPrice,txtInfoCurrentPrice,txtInfoSPCategory,lblInfoTimeLeft,txtInfoTimeLeft; 109 | private JLabel lblInfoProductID,txtInfoProductID; 110 | private JTextArea txtInfoArProductDetails; 111 | private JButton btnInfoBrowse,btnInfoSave,btnInfoPlaceBid; 112 | private String InfoPath; 113 | private JLabel lblMyProd,lblMyProdTitle; 114 | 115 | Object myBidsrows[][]; 116 | Object savedBidsrows[][]; 117 | Object myProdrows[][]; 118 | 119 | Pattern p; 120 | Matcher m; 121 | boolean b; 122 | 123 | private Connection con ; 124 | private PreparedStatement ps; 125 | private ResultSet rs; 126 | FileOutputStream fos; 127 | Blob blob; 128 | byte[] bImg; 129 | 130 | 131 | String productName; 132 | String productBasePrice; 133 | String specifyCategory; 134 | String productDescription; 135 | String getProID; 136 | 137 | 138 | String selectCategoryHeader; 139 | Vector vectorMyBidsHeader; 140 | Vector> vectorMyBidsTable; 141 | 142 | Vector vectorSaveBidsHeader; 143 | Vector> vectorSaveBidsTable; 144 | 145 | Vector vectorMyProdHeader; 146 | Vector> vectorMyProdTable; 147 | 148 | static int interval=10*60; 149 | static int timeleft; 150 | static int seconds,minutes=9; 151 | static int delay = 1000; 152 | static int period = 1000; 153 | java.util.Timer timer; 154 | Client c; 155 | /** 156 | * Launch the application. 157 | */ 158 | /* 159 | public static void main(String[] args) { 160 | EventQueue.invokeLater(new Runnable() { 161 | public void run() { 162 | try { 163 | AuctionGui auctionFrame = new AuctionGui(); 164 | auctionFrame.setVisible(true); 165 | } catch (Exception e) { 166 | e.printStackTrace(); 167 | } 168 | } 169 | }); 170 | } 171 | */ 172 | 173 | /** 174 | * Create the frame. 175 | * @throws SQLException 176 | */ 177 | public AuctionGui() throws SQLException { 178 | 179 | try{ 180 | con = AuctionBackend1.connection(); 181 | }catch(Exception e){ 182 | e.printStackTrace(); 183 | } 184 | Client c = new Client(); 185 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 186 | setBounds(100, 100, 1386, 742); 187 | contentPane = new JPanel(); 188 | //contentPane.setBackground(new Color(67, 67, 67)); 189 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 190 | contentPane.setPreferredSize(getMaximumSize()); 191 | setContentPane(contentPane); 192 | contentPane.setLayout(null); 193 | 194 | JPanel headerpanel = new JPanel(); 195 | headerpanel.setBounds(0, 0, 1370, 143); 196 | headerpanel.setBackground(new Color(38, 33, 99)); 197 | contentPane.add(headerpanel); 198 | headerpanel.setLayout(null); 199 | 200 | /*JLabel lblAuctionSystem = new JLabel(""); 201 | lblAuctionSystem.setBounds(387, 0, 493, 143); 202 | headerpanel.add(lblAuctionSystem); 203 | lblAuctionSystem.setHorizontalAlignment(SwingConstants.CENTER); 204 | Image img=new ImageIcon(this.getClass().getResource("/AuctionLogo2.1.jpg")).getImage(); 205 | lblAuctionSystem.setIcon(new ImageIcon(img)); 206 | lblAuctionSystem.setVisible(false); 207 | */ 208 | 209 | //DropDown Menu for Category Search. 210 | //--------------------------JTabbed Pane.----------------------------------------- 211 | 212 | 213 | tabbedPane = new JTabbedPane(JTabbedPane.TOP); 214 | tabbedPane.setBounds(0, 143, 1365, 560); 215 | //tabbedPane.setEnabledAt(132, true); 216 | //tabbedPane.setBackgroundAt(132, new Color(67, 67, 67)); 217 | tabbedPane.setVisible(true); 218 | contentPane.add(tabbedPane); 219 | 220 | //-------------------Home Tab---------------------------------------- 221 | 222 | 223 | homeTab= new JPanel(); 224 | homeTab.setBorder(null); 225 | tabbedPane.addTab(" Home ", new ImageIcon("G:\\homelogo.png"), homeTab, null); 226 | JLabel lblBackground = new JLabel(""); 227 | lblBackground.setBounds(0, 0, 1360, 503); 228 | Image img2=new ImageIcon(this.getClass().getResource("/black_background_wood-wallpaper.jpg")).getImage(); 229 | lblBackground.setIcon(new ImageIcon(img2)); 230 | homeTab.setLayout(null); 231 | //homeTab.add(lblBackground); 232 | 233 | String homeTabcolumns[]={"ProductId","Product Name","Base Price","Category","Maximum Bidder","Current Bid Price","No Of Bids","Image"}; 234 | 235 | homeHomeTable = new JTable(); 236 | homeHomeTable.setBounds(0, 44, 1365, 516); 237 | 238 | homeHomemodel = new DefaultTableModel(); 239 | homeHomemodel.setColumnIdentifiers(homeTabcolumns); 240 | homeHomeTable =new JTable(homeHomemodel); 241 | homeHomeTable.setShowVerticalLines(true); 242 | homeHomeTable.setShowHorizontalLines(true); 243 | homeHomeTable.setRowHeight(120); 244 | 245 | homeHomeTable.getColumnModel().getColumn(0); 246 | homeHomeTable.getColumnModel().getColumn(1); 247 | homeHomeTable.getColumnModel().getColumn(2); 248 | homeHomeTable.getColumnModel().getColumn(3); 249 | homeHomeTable.getColumnModel().getColumn(4); 250 | homeHomeTable.getColumnModel().getColumn(5); 251 | homeHomeTable.getColumnModel().getColumn(6); 252 | homeHomeTable.getColumnModel().getColumn(7).setPreferredWidth(150); 253 | 254 | homeHomeScrollPane = new JScrollPane(homeHomeTable,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 255 | homeHomeScrollPane.setBounds(0, 44, 1365, 516); 256 | homeHomeScrollPane.setVisible(true); 257 | homeTab.add(homeHomeScrollPane,BorderLayout.CENTER); 258 | 259 | 260 | 261 | //---------------------------------Trending Bids-------------------------------------- 262 | 263 | trendingBidsTab = new JPanel(); 264 | trendingBidsTab.setBorder(new LineBorder(new Color(0, 0, 0))); 265 | tabbedPane.addTab(" Trending Bids ", new ImageIcon("G:\\SmalltrendingLogo.jpg"), trendingBidsTab, null); 266 | trendingBidsTab.setLayout(null); 267 | JLabel lblBackground1 = new JLabel(""); 268 | lblBackground1.setBounds(0, 0, 1360, 503); 269 | Image img3=new ImageIcon(this.getClass().getResource("/black_background_wood-wallpaper.jpg")).getImage(); 270 | lblBackground1.setIcon(new ImageIcon(img3)); 271 | //trendingBidsTab.add(lblBackground1); 272 | 273 | String trendingTabcolumns[]={"ProductId","Product Name","Base Price","Category","Maximum Bidder","Current Bid Price","No Of Bids","Image"}; 274 | 275 | homeTrendingTable = new JTable(); 276 | homeTrendingTable.setBounds(0, 44, 1365, 516); 277 | 278 | homeTrendingmodel = new DefaultTableModel(); 279 | homeTrendingmodel.setColumnIdentifiers(trendingTabcolumns); 280 | homeTrendingTable =new JTable(homeTrendingmodel); 281 | homeTrendingTable.setShowVerticalLines(true); 282 | homeTrendingTable.setShowHorizontalLines(true); 283 | homeTrendingTable.setRowHeight(120); 284 | 285 | homeTrendingTable.getColumnModel().getColumn(0); 286 | homeTrendingTable.getColumnModel().getColumn(1); 287 | homeTrendingTable.getColumnModel().getColumn(2); 288 | homeTrendingTable.getColumnModel().getColumn(3); 289 | homeTrendingTable.getColumnModel().getColumn(4); 290 | homeTrendingTable.getColumnModel().getColumn(5); 291 | homeTrendingTable.getColumnModel().getColumn(6); 292 | homeTrendingTable.getColumnModel().getColumn(7).setPreferredWidth(150); 293 | 294 | homeTrendingScrollPane = new JScrollPane(homeTrendingTable,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 295 | homeTrendingScrollPane.setBounds(0, 44, 1365, 516); 296 | homeTrendingScrollPane.setVisible(true); 297 | trendingBidsTab.add(homeTrendingScrollPane,BorderLayout.CENTER); 298 | 299 | //-----------------------------------JtabbedPane Ends------------------------------------------ 300 | 301 | //Search Icon and Search Code 302 | searchTextField = new JTextField(); 303 | searchTextField.setText("Enter Product ID"); 304 | searchTextField.addFocusListener(new FocusAdapter() { 305 | @Override 306 | public void focusGained(FocusEvent arg0) { 307 | if(searchTextField.getText().equals("Enter Product ID")) 308 | searchTextField.setText(""); 309 | } 310 | public void focusLost(FocusEvent e) { 311 | if(searchTextField.getText().equals("")) 312 | searchTextField.setText("Enter Product ID"); 313 | } 314 | }); 315 | searchTextField.setHorizontalAlignment(SwingConstants.LEFT); 316 | searchTextField.setFont(new Font("Times New Roman", Font.BOLD, 16)); 317 | searchTextField.setBounds(890, 81, 196, 34); 318 | searchTextField.setBackground(new Color(112, 128, 144)); 319 | searchTextField.setColumns(10); 320 | headerpanel.add(searchTextField); 321 | 322 | 323 | //Search Button 324 | btnSearch = new JButton(""); 325 | 326 | btnSearch.setIcon(new ImageIcon("G:\\Navigation-Drawer-Icons\\google-web-search-50.png")); 327 | btnSearch.setBounds(1086, 81, 35, 34); 328 | headerpanel.add(btnSearch); 329 | 330 | JComboBox comboBox = new JComboBox(); 331 | options = new String[7]; 332 | options[0]=""; 333 | options[1]=" Car "; 334 | options[2]=" Watch "; 335 | options[3]=" Statue "; 336 | options[4]=" Painting "; 337 | options[5]=" Electronics "; 338 | options[6]=" Others "; 339 | for(int i=0;i<=6;i++) 340 | { 341 | comboBox.addItem(options[i]); 342 | } 343 | comboBox.setBackground(new Color(112, 128, 144)); 344 | comboBox.setForeground(new Color(255, 255, 255)); 345 | comboBox.setFont(new Font("Tahoma", Font.BOLD, 14)); 346 | comboBox.setBounds(1146, 81, 190, 34); 347 | headerpanel.add(comboBox); 348 | 349 | empty=new JMenuItem(""); 350 | comboBox.add(empty); 351 | 352 | categoryCar=new JMenuItem(" Car "); 353 | categoryCar.setRequestFocusEnabled(false); 354 | categoryCar.setFont(new Font("Tahoma", Font.PLAIN, 14)); 355 | categoryCar.setBackground(new Color(112, 128, 144)); 356 | categoryCar.setForeground(new Color(65, 131, 215)); 357 | comboBox.add(categoryCar); 358 | 359 | categoryWatch=new JMenuItem(" Watch "); 360 | categoryWatch.setRequestFocusEnabled(false); 361 | categoryWatch.setFont(new Font("Tahoma", Font.PLAIN, 14)); 362 | categoryWatch.setBackground(new Color(112, 128, 144)); 363 | categoryWatch.setForeground(new Color(65, 131, 215)); 364 | comboBox.add(categoryWatch); 365 | 366 | categoryStatue=new JMenuItem(" Statue "); 367 | categoryStatue.setRequestFocusEnabled(false); 368 | categoryStatue.setFont(new Font("Tahoma", Font.PLAIN, 14)); 369 | categoryStatue.setBackground(new Color(112, 128, 144)); 370 | categoryStatue.setForeground(new Color(65, 131, 215)); 371 | comboBox.add(categoryStatue); 372 | 373 | categoryPainting=new JMenuItem(" Painting "); 374 | categoryPainting.setRequestFocusEnabled(false); 375 | categoryPainting.setFont(new Font("Tahoma", Font.PLAIN, 14)); 376 | categoryPainting.setBackground(new Color(112, 128, 144)); 377 | categoryPainting.setForeground(new Color(65, 131, 215)); 378 | comboBox.add(categoryPainting); 379 | 380 | categoryElectronics=new JMenuItem(" Electronics "); 381 | categoryElectronics.setRequestFocusEnabled(false); 382 | categoryElectronics.setFont(new Font("Tahoma", Font.PLAIN, 14)); 383 | categoryElectronics.setBackground(new Color(112, 128, 144)); 384 | categoryElectronics.setForeground(new Color(65, 131, 215)); 385 | comboBox.add(categoryElectronics); 386 | 387 | categoryOthers=new JMenuItem(" Others "); 388 | categoryOthers.setRequestFocusEnabled(false); 389 | categoryOthers.setFont(new Font("Tahoma", Font.PLAIN, 14)); 390 | categoryOthers.setBackground(new Color(112, 128, 144)); 391 | categoryOthers.setForeground(new Color(65, 131, 215)); 392 | comboBox.add(categoryOthers); 393 | 394 | comboBox.addActionListener(new ActionListener() { 395 | 396 | @Override 397 | public void actionPerformed(ActionEvent e) { 398 | 399 | btnSearch.addMouseListener(new MouseAdapter() { 400 | @Override 401 | public void mouseClicked(MouseEvent arg0) { 402 | 403 | int flag=0; 404 | System.out.println("In Search Action Listener"); 405 | Vector vectorCombo1 = new Vector(); //5 Columns. 406 | Vector vectorCombo2 = new Vector(); //3 Columns. 407 | Vector vectorFinalCombo = new Vector(); 408 | if(comboBox.getSelectedItem().equals("")) 409 | { 410 | try { 411 | System.out.println("text"+searchTextField.getText()); 412 | ps = con.prepareStatement("select ProID,ProName,BasePrice,ProCategory from selltable where ProID=?"); 413 | ps.setString(1, searchTextField.getText()); 414 | rs = ps.executeQuery(); 415 | if(rs.next()) //Only One Product becoz Search with ProID is Unique. 416 | { 417 | vectorCombo1.add(0,rs.getString("ProID")); 418 | vectorCombo1.add(1,rs.getString("ProName")); 419 | vectorCombo1.add(2,rs.getString("BasePrice")); 420 | vectorCombo1.add(3,rs.getString("ProCategory")); 421 | 422 | //blob=rs.getBlob("Image"); 423 | //bImg=blob.getBytes(1, (int)blob.length()); 424 | //ImageIcon imgTemp = new ImageIcon(new ImageIcon().getImage(bImg));//Remaining:-retrieving Image from Database. 425 | //vectorCombo1.add(4,imgTemp); 426 | System.out.println("In 1st if"); 427 | } 428 | 429 | ps = con.prepareStatement("select UserName,CurrentPrice,NoOfBids from bidtable where ProID=?"); 430 | ps.setString(1, searchTextField.getText()); 431 | rs=ps.executeQuery(); 432 | if(rs.next()) 433 | { 434 | vectorCombo2.add(0,rs.getString("UserName")); 435 | vectorCombo2.add(1,rs.getString("CurrentPrice")); 436 | vectorCombo2.add(2,rs.getString("NoOfBids")); 437 | System.out.println("In 2nd if"); 438 | } 439 | vectorFinalCombo.add(0, vectorCombo1.get(0)); //ProID. 440 | vectorFinalCombo.add(1, vectorCombo1.get(1)); //Prodname. 441 | vectorFinalCombo.add(2, vectorCombo1.get(2)); //Base Price. 442 | vectorFinalCombo.add(3, vectorCombo1.get(3)); //Pro Category. 443 | vectorFinalCombo.add(4, vectorCombo2.get(0)); //MaxBidderName. 444 | vectorFinalCombo.add(5, vectorCombo2.get(1)); //MaxBidderPrice. 445 | vectorFinalCombo.add(6, vectorCombo2.get(2)); //NoOfBids. 446 | //vectorFinalCombo.add(7, vectorCombo1.get(4)); //Image. 447 | System.out.println("In before add"); 448 | homeHomemodel.addRow(new Object[]{vectorFinalCombo.get(0),vectorFinalCombo.get(1),vectorFinalCombo.get(2),vectorFinalCombo.get(3),vectorFinalCombo.get(4),vectorFinalCombo.get(5),vectorFinalCombo.get(6)}); 449 | flag=1; 450 | 451 | 452 | } catch (Exception e2) { 453 | System.out.println("Exception found in Search Combobox"); 454 | e2.printStackTrace(); 455 | } 456 | 457 | } 458 | else if(comboBox.getSelectedItem().equals(" Car ")) 459 | { 460 | selectCategoryHeader=" Car "; 461 | } 462 | else if(comboBox.getSelectedItem().equals(" Watch ")) 463 | { 464 | selectCategoryHeader=" Watch "; 465 | } 466 | else if(comboBox.getSelectedItem().equals(" Statue ")) 467 | { 468 | selectCategoryHeader=" Statue "; 469 | } 470 | else if(comboBox.getSelectedItem().equals(" Statue ")) 471 | { 472 | selectCategoryHeader=" Statue "; 473 | } 474 | else if(comboBox.getSelectedItem().equals(" Electronics ")) 475 | { 476 | selectCategoryHeader=" Electronics "; 477 | } 478 | else if(comboBox.getSelectedItem().equals(" Others ")) 479 | { 480 | selectCategoryHeader=" Others "; 481 | } 482 | if(flag==0) 483 | { 484 | int prodCount=0; 485 | 486 | try { 487 | 488 | ps = con.prepareStatement("select ProID,ProName,BasePrice,ProCategory from selltable where ProCategory=?"); 489 | ps.setString(1, selectCategoryHeader); 490 | rs = ps.executeQuery(); 491 | while(rs.next()) //Multiple Products will be Selected. 492 | { 493 | 494 | vectorCombo1.add(0,rs.getString("ProID")); 495 | vectorCombo1.add(1,rs.getString("ProName")); 496 | vectorCombo1.add(2,rs.getString("BasePrice")); 497 | vectorCombo1.add(3,rs.getString("ProCategory")); 498 | 499 | // blob=rs.getBlob("Image"); 500 | //bImg=blob.getBytes(1, (int)blob.length()); 501 | // ImageIcon imgTemp = new ImageIcon(new ImageIcon().getImage(bImg));//Remaining:-retrieving Image from Database. 502 | //vectorCombo1.add(4,imgTemp); 503 | prodCount++; 504 | } 505 | 506 | int i=prodCount-1; 507 | int index=0; 508 | while(i>=0) 509 | { 510 | index=4*(i); 511 | 512 | ps = con.prepareStatement("select UserName,CurrentPrice,NoOfBids from bidtable where ProID=?"); 513 | ps.setString(1, vectorCombo1.get(index)); 514 | rs=ps.executeQuery(); 515 | if(rs.next()) 516 | { 517 | vectorCombo2.add(0,rs.getString("UserName")); 518 | vectorCombo2.add(1,rs.getString("CurrentPrice")); 519 | vectorCombo2.add(2,rs.getString("NoOfBids")); 520 | i--; 521 | } 522 | } 523 | int k=0,x=0; 524 | while(prodCount>k) 525 | { 526 | vectorFinalCombo.add(x++, vectorCombo1.get(k)); //ProID 527 | vectorFinalCombo.add(x++, vectorCombo1.get(k+1)); //ProName 528 | vectorFinalCombo.add(x++, vectorCombo1.get(k+2)); //Base Price 529 | vectorFinalCombo.add(x++, vectorCombo1.get(k+3)); //ProdCategory. 530 | vectorFinalCombo.add(x++, vectorCombo2.get(k+1)); //Max Bidder. 531 | vectorFinalCombo.add(x++, vectorCombo2.get(k)); //CurrentPrice[Max Bid]. 532 | vectorFinalCombo.add(x++, vectorCombo2.get(k+2)); //No Of Bids. 533 | //vectorFinalCombo.add(x++, vectorCombo1.get(k+4)); //Image. 534 | homeHomemodel.addRow(new Object[]{vectorFinalCombo.get(x-7),vectorFinalCombo.get(x-6),vectorFinalCombo.get(x-5),vectorFinalCombo.get(x-4),vectorFinalCombo.get(x-3),vectorFinalCombo.get(x-2),vectorFinalCombo.get(x-1)}); 535 | k++; 536 | 537 | } 538 | 539 | } catch (Exception e2) { 540 | System.out.println("Exception found in Search Combobox"); 541 | e2.printStackTrace(); 542 | } 543 | } 544 | } 545 | }); 546 | } 547 | }); 548 | 549 | //------------------------Navigation Drawer Starts.------------------------------------- 550 | 551 | 552 | navigationPanel = new JPanel(); 553 | navigationPanel.setBounds(0, 40, 135, 80); 554 | navigationPanel.setBackground(new Color(38, 33, 99)); 555 | navigationPanel.setLayout(null); 556 | headerpanel.add(navigationPanel); 557 | //getRootPane().setGlassPane(navigationPanel); 558 | //getRootPane().setBounds(0, 40, 135, 660); 559 | //getRootPane().getGlassPane().setVisible(true); 560 | 561 | 562 | lblHome = new JLabel("Home"); 563 | lblHome.setHorizontalTextPosition(SwingConstants.CENTER); 564 | lblHome.setFocusTraversalPolicyProvider(true); 565 | lblHome.setOpaque(true); 566 | lblHome.setBorder(new MatteBorder(3, 3, 3, 3, (Color) new Color(65, 105, 225))); 567 | lblHome.setBackground(new Color(38, 33, 99 )); 568 | lblHome.setForeground(Color.WHITE); 569 | lblHome.setFont(new Font("Myanmar Text", Font.BOLD, 14)); 570 | lblHome.setHorizontalAlignment(SwingConstants.CENTER); 571 | lblHome.setBounds(140, 10, 80, 50); 572 | navigationPanel.add(lblHome); 573 | 574 | 575 | lblAccount = new JLabel("Account"); 576 | lblAccount.setOpaque(true); 577 | lblAccount.setBorder(new MatteBorder(3, 3, 3, 3, (Color) new Color(65, 105, 225))); 578 | lblAccount.setBackground(new Color(38, 33, 99)); 579 | lblAccount.setForeground(Color.WHITE); 580 | lblAccount.setFont(new Font("Myanmar Text", Font.BOLD, 14)); 581 | lblAccount.setHorizontalAlignment(SwingConstants.CENTER); 582 | lblAccount.setBounds(230, 10, 80, 50); 583 | navigationPanel.add(lblAccount); 584 | 585 | 586 | lblSell = new JLabel("Sell"); 587 | lblSell.setOpaque(true); 588 | lblSell.setBorder(new MatteBorder(3, 3, 3, 3, (Color) new Color(65, 105, 225))); 589 | lblSell.setBackground(new Color(38, 33, 99)); 590 | lblSell.setForeground(Color.WHITE); 591 | lblSell.setFont(new Font("Myanmar Text", Font.BOLD, 14)); 592 | lblSell.setHorizontalAlignment(SwingConstants.CENTER); 593 | lblSell.setBounds(320, 10, 80, 50); 594 | navigationPanel.add(lblSell); 595 | 596 | lblMyProd = new JLabel("My Prod"); 597 | lblMyProd.setOpaque(true); 598 | lblMyProd.setBorder(new MatteBorder(3, 3, 3, 3, (Color) new Color(65, 105, 225))); 599 | lblMyProd.setForeground(Color.WHITE); 600 | lblMyProd.setBackground(new Color(38, 33, 99)); 601 | lblMyProd.setFont(new Font("Myanmar Text", Font.BOLD, 14)); 602 | lblMyProd.setHorizontalAlignment(SwingConstants.CENTER); 603 | lblMyProd.setBounds(410, 10, 80, 50); 604 | navigationPanel.add(lblMyProd); 605 | 606 | lblMyBids = new JLabel("My Bids"); 607 | lblMyBids.setOpaque(true); 608 | lblMyBids.setBorder(new MatteBorder(3, 3, 3, 3, (Color) new Color(65, 105, 225))); 609 | lblMyBids.setForeground(Color.WHITE); 610 | lblMyBids.setBackground(new Color(38, 33, 99)); 611 | lblMyBids.setFont(new Font("Myanmar Text", Font.BOLD, 14)); 612 | lblMyBids.setHorizontalAlignment(SwingConstants.CENTER); 613 | lblMyBids.setBounds(500, 10, 80, 50); 614 | navigationPanel.add(lblMyBids); 615 | 616 | lblSavedBids = new JLabel("Saved Bids"); 617 | lblSavedBids.setOpaque(true); 618 | lblSavedBids.setBorder(new MatteBorder(3, 3, 3, 3, (Color) new Color(65, 105, 225))); 619 | lblSavedBids.setForeground(Color.WHITE); 620 | lblSavedBids.setBackground(new Color(38, 33, 99)); 621 | lblSavedBids.setFont(new Font("Myanmar Text", Font.BOLD, 14)); 622 | lblSavedBids.setHorizontalAlignment(SwingConstants.CENTER); 623 | lblSavedBids.setBounds(590, 10, 80, 50); 624 | navigationPanel.add(lblSavedBids); 625 | 626 | lblLogout = new JLabel("Logout"); 627 | lblLogout.setOpaque(true); 628 | lblLogout.setBorder(new MatteBorder(3, 3, 3, 3, (Color) new Color(65, 105, 225))); 629 | lblLogout.setForeground(Color.WHITE); 630 | lblLogout.setBackground(new Color(38, 33, 99)); 631 | lblLogout.setFont(new Font("Myanmar Text", Font.BOLD, 14)); 632 | lblLogout.setHorizontalAlignment(SwingConstants.CENTER); 633 | lblLogout.setBounds(680, 10, 80, 50); 634 | navigationPanel.add(lblLogout); 635 | 636 | 637 | 638 | //Code to Open the Navigation Drawer Effect. 639 | t1= new Timer(50,new ActionListener() { 640 | @Override 641 | public void actionPerformed(ActionEvent e) { 642 | 643 | if(pl1 > 900){ 644 | t1.stop(); 645 | } 646 | else{ 647 | navigationPanel.setSize(pl1,navigationPanel.getHeight()); 648 | pl1+=50; 649 | } 650 | 651 | } 652 | }); 653 | 654 | //Code to Close the Navigation Drawer Effect. 655 | t2= new Timer(50,new ActionListener() { 656 | @Override 657 | public void actionPerformed(ActionEvent e) { 658 | 659 | if(pl2 < 100){ 660 | t2.stop(); 661 | } 662 | else{ 663 | navigationPanel.setSize(pl2,navigationPanel.getHeight()); 664 | pl2-=50; 665 | } 666 | 667 | } 668 | }); 669 | 670 | //Drawer Icon 671 | drawerIconMenu = new JLabel(); 672 | drawerIconArrowTop = new JLabel(); 673 | drawerIconArrowTop.setHorizontalAlignment(SwingConstants.CENTER); 674 | drawerIconArrowTop.setOpaque(true); 675 | drawerIconArrowTop.setBackground(new Color(65, 105, 225)); 676 | drawerIconArrowTop.setBounds(0, 0, 135, 70); 677 | drawerIconArrowTop.setVisible(false); 678 | drawerIconMenu.setBounds(0, 0, 135, 70); 679 | navigationPanel.add(drawerIconArrowTop); 680 | navigationPanel.add(drawerIconMenu); 681 | Image img5=new ImageIcon(this.getClass().getResource("/if_Menu3.png")).getImage(); 682 | drawerIconMenu.setIcon(new ImageIcon(img5)); 683 | drawerIconMenu.setHorizontalAlignment(SwingConstants.CENTER); 684 | 685 | 686 | Image img6=new ImageIcon(this.getClass().getResource("/double_arrow_top.png")).getImage(); 687 | 688 | drawerIconMenu.addMouseListener(new MouseAdapter() { 689 | @Override 690 | public void mouseClicked(MouseEvent arg0) { 691 | 692 | t1.start(); 693 | pl1=50; 694 | // t2.stop(); 695 | drawerIconArrowTop.setIcon(new ImageIcon(img6)); 696 | drawerIconArrowTop.setVisible(true); 697 | drawerIconMenu.setVisible(false); 698 | } 699 | }); 700 | 701 | drawerIconArrowTop.addMouseListener(new MouseAdapter() { 702 | @Override 703 | public void mouseClicked(MouseEvent e) { 704 | 705 | //t1.stop(); 706 | t2.start(); 707 | pl2=900; 708 | drawerIconMenu.setIcon(new ImageIcon(img5)); 709 | drawerIconMenu.setVisible(true); 710 | drawerIconArrowTop.setVisible(false); 711 | } 712 | }); 713 | 714 | 715 | 716 | //------------------------Navigation Drawer Ends.-------------------------------- 717 | 718 | 719 | 720 | 721 | //---------Creating Different Panels for Each Navigation Label------------ 722 | 723 | moreInfoPanel = new JPanel(); 724 | moreInfoPanel.setBounds(0, 143, 1365, 560); 725 | //moreInfoPanel.setBackground(new Color(67, 67, 67)); 726 | moreInfoPanel.setLayout(null); 727 | contentPane.add(moreInfoPanel); 728 | moreInfoPanel.setVisible(false); 729 | 730 | accountPanel = new JPanel(); 731 | accountPanel.setBounds(0, 143, 1365, 560); 732 | //accountPanel.setBackground(new Color(0, 0, 0)); 733 | accountPanel.setLayout(null); 734 | contentPane.add(accountPanel); 735 | accountPanel.setVisible(false); 736 | 737 | sellPanel = new JPanel(); 738 | sellPanel.setBounds(0, 143, 1365, 560); 739 | //sellPanel.setBackground(new Color(67, 67, 67)); 740 | sellPanel.setLayout(null); 741 | contentPane.add(sellPanel); 742 | sellPanel.setVisible(false); 743 | 744 | myProdPanel = new JPanel(); 745 | myProdPanel.setBounds(0, 190, 1365, 560); 746 | //myProdPanel.setBackground(new Color(67, 67, 67)); 747 | myProdPanel.setLayout(new BorderLayout(0, 0)); 748 | contentPane.add(myProdPanel); 749 | myProdPanel.setVisible(false); 750 | 751 | myBidsPanel = new JPanel(); 752 | myBidsPanel.setBounds(0, 190, 1365, 560); 753 | //myBidsPanel.setBackground(new Color(67, 67, 67)); 754 | myBidsPanel.setLayout(new BorderLayout(0, 0)); 755 | contentPane.add(myBidsPanel); 756 | myBidsPanel.setVisible(false); 757 | 758 | savedBidsPanel = new JPanel(); 759 | savedBidsPanel.setBounds(0, 190, 1365, 560); 760 | //savedBidsPanel.setBackground(new Color(67, 67, 67)); 761 | savedBidsPanel.setLayout(null); 762 | contentPane.add(savedBidsPanel); 763 | savedBidsPanel.setVisible(false); 764 | 765 | 766 | 767 | //-----------------------------Contents for Account Panel------------------------- 768 | 769 | 770 | lblAccountDetails = new JLabel("Account Details"); 771 | lblAccountDetails.setHorizontalAlignment(SwingConstants.CENTER); 772 | lblAccountDetails.setFont(new Font("Myanmar Text", Font.BOLD, 18)); 773 | lblAccountDetails.setBounds(560, 5, 150, 30); 774 | accountPanel.add(lblAccountDetails); 775 | 776 | JSeparator separatorAP_1 = new JSeparator(); 777 | separatorAP_1.setBackground(new Color(0, 0, 205)); 778 | separatorAP_1.setBounds(15, 45, 1300, 3); 779 | accountPanel.add(separatorAP_1); 780 | 781 | 782 | //Retrieve The Info from the Database to Display all the Info of the Logged in User. 783 | //String firstName = null,lastName= null,gender= null,email= null,address= null,userName= null,password = null; 784 | ps = con.prepareStatement("select * from registrationtable"); 785 | rs=ps.executeQuery(); 786 | while(rs.next()) 787 | { 788 | c.firstName=rs.getString("FirstName"); 789 | c.lastName=rs.getString("LastName"); 790 | c.gender=rs.getString("Gender"); 791 | c.email=rs.getString("Email"); 792 | c.address=rs.getString("Address"); 793 | c.userName=rs.getString("UserName"); 794 | c.password=rs.getString("Password"); 795 | } 796 | 797 | lblFirstName = new JLabel("First Name:"); 798 | lblFirstName.setFont(new Font("Tahoma", Font.BOLD, 16)); 799 | lblFirstName.setForeground(new Color(0, 0, 0)); 800 | lblFirstName.setBounds(35, 75, 110, 25); 801 | accountPanel.add(lblFirstName); 802 | 803 | txtFN = new JLabel(); 804 | txtFN.setText(c.firstName); 805 | txtFN.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); 806 | txtFN.setFont(new Font("Tahoma", Font.BOLD, 14)); 807 | txtFN.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 808 | txtFN.setBackground(new Color(112, 128, 144)); 809 | txtFN.setBounds(155, 75, 150, 25); 810 | accountPanel.add(txtFN); 811 | 812 | lblLastName = new JLabel("Last Name:"); 813 | lblLastName.setForeground(new Color(0, 0, 0)); 814 | lblLastName.setFont(new Font("Tahoma", Font.BOLD, 16)); 815 | lblLastName.setBounds(455, 75, 110, 25); 816 | accountPanel.add(lblLastName); 817 | 818 | txtLN = new JLabel(); 819 | txtLN.setText(c.lastName); 820 | txtLN.setFont(new Font("Tahoma", Font.BOLD, 14)); 821 | txtLN.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 822 | txtLN.setBackground(new Color(112, 128, 144)); 823 | txtLN.setBounds(575, 75, 150, 25); 824 | accountPanel.add(txtLN); 825 | 826 | lblGender = new JLabel("Gender:"); 827 | lblGender.setFont(new Font("Tahoma", Font.BOLD, 16)); 828 | lblGender.setForeground(new Color(0, 0, 0)); 829 | lblGender.setBackground(new Color(47, 79, 79)); 830 | lblGender.setBounds(825, 75, 110, 25); 831 | accountPanel.add(lblGender); 832 | 833 | txtGender = new JLabel(); 834 | txtGender.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 835 | txtGender.setText(c.gender); 836 | txtGender.setFont(new Font("Tahoma", Font.BOLD, 14)); 837 | txtGender.setBackground(new Color(112, 128, 144)); 838 | txtGender.setBounds(935, 75, 150, 25); 839 | accountPanel.add(txtGender); 840 | 841 | lblEmail = new JLabel("Email:"); 842 | lblEmail.setForeground(new Color(0, 0, 0)); 843 | lblEmail.setFont(new Font("Tahoma", Font.BOLD, 16)); 844 | lblEmail.setBounds(35, 150, 110, 25); 845 | accountPanel.add(lblEmail); 846 | 847 | txtEmail = new JLabel(); 848 | txtEmail.setText(c.email); 849 | txtEmail.setFont(new Font("Tahoma", Font.BOLD, 14)); 850 | txtEmail.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 851 | txtEmail.setBackground(new Color(112, 128, 144)); 852 | txtEmail.setBounds(155, 150, 150, 25); 853 | accountPanel.add(txtEmail); 854 | 855 | lblUsername = new JLabel("Username:"); 856 | lblUsername.setFont(new Font("Tahoma", Font.BOLD, 16)); 857 | lblUsername.setForeground(new Color(0, 0, 0)); 858 | lblUsername.setBounds(455, 150, 110, 25); 859 | accountPanel.add(lblUsername); 860 | 861 | txtUsername = new JLabel(); 862 | txtUsername.setText(c.userName); 863 | txtUsername.setFont(new Font("Tahoma", Font.BOLD, 14)); 864 | txtUsername.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 865 | txtUsername.setBackground(new Color(112, 128, 144)); 866 | txtUsername.setBounds(575, 150, 150, 25); 867 | accountPanel.add(txtUsername); 868 | 869 | lblPassword = new JLabel("Password:"); 870 | lblPassword.setFont(new Font("Tahoma", Font.BOLD, 16)); 871 | lblPassword.setForeground(new Color(0, 0, 0)); 872 | lblPassword.setBounds(825, 150, 110, 25); 873 | accountPanel.add(lblPassword); 874 | 875 | passwordField = new JLabel(); 876 | passwordField.setText(c.password); 877 | passwordField.setFont(new Font("Tahoma", Font.BOLD, 14)); 878 | passwordField.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 879 | passwordField.setBackground(new Color(112, 128, 144)); 880 | passwordField.setBounds(935, 150, 150, 25); 881 | accountPanel.add(passwordField, BorderLayout.CENTER); 882 | 883 | lblAddress = new JLabel("Address:"); 884 | lblAddress.setFont(new Font("Tahoma", Font.BOLD, 16)); 885 | lblAddress.setForeground(Color.BLACK); 886 | lblAddress.setBounds(455, 225, 110, 25); 887 | accountPanel.add(lblAddress); 888 | 889 | txtAddress = new JTextArea(); 890 | txtAddress.setText(c.address); 891 | txtAddress.setLineWrap(true); 892 | txtAddress.setFocusTraversalPolicyProvider(true); 893 | txtAddress.setFont(new Font("Tahoma", Font.BOLD, 15)); 894 | txtAddress.setForeground(new Color(255, 255, 255)); 895 | txtAddress.setBackground(new Color(112, 128, 144)); 896 | txtAddress.setBounds(575, 225, 350, 75); 897 | accountPanel.add(txtAddress); 898 | 899 | btnChangePassword = new JButton("Change Password"); 900 | btnChangePassword.setForeground(new Color(30, 144, 255)); 901 | btnChangePassword.setFont(new Font("Tahoma", Font.BOLD, 16)); 902 | btnChangePassword.setBackground(new Color(112, 128, 144)); 903 | btnChangePassword.setBounds(575, 325, 200, 30); 904 | accountPanel.add(btnChangePassword); 905 | 906 | 907 | JSeparator separatorAP_2 = new JSeparator(); 908 | separatorAP_2.setBackground(new Color(0, 0, 205)); 909 | separatorAP_2.setBounds(15, 360, 1300, 3); 910 | accountPanel.add(separatorAP_2); 911 | 912 | 913 | lblNewPassword = new JLabel("Enter New Password:"); 914 | lblNewPassword.setFont(new Font("Tahoma", Font.BOLD, 16)); 915 | lblNewPassword.setForeground(Color.BLACK); 916 | lblNewPassword.setBounds(155, 375, 185, 30); 917 | accountPanel.add(lblNewPassword); 918 | 919 | lblNewCPassword = new JLabel("Confirm Password:"); 920 | lblNewCPassword.setFont(new Font("Tahoma", Font.BOLD, 16)); 921 | lblNewCPassword.setForeground(Color.black); 922 | lblNewCPassword.setBounds(650, 375, 185, 30); 923 | accountPanel.add(lblNewCPassword); 924 | 925 | 926 | txtNewPassword = new JTextField(); 927 | txtNewPassword.setFont(new Font("Tahoma", Font.BOLD, 14)); 928 | txtNewPassword.setBackground(new Color(112, 128, 144)); 929 | txtNewPassword.setBounds(350, 375, 150, 30); 930 | accountPanel.add(txtNewPassword); 931 | 932 | txtNewCPassword = new JTextField(); 933 | txtNewCPassword.setFont(new Font("Tahoma", Font.BOLD, 14)); 934 | txtNewCPassword.setBackground(new Color(112, 128, 144)); 935 | txtNewCPassword.setBounds(845, 375, 150, 30); 936 | accountPanel.add(txtNewCPassword); 937 | 938 | btnSaveChanges = new JButton("Save Changes"); 939 | btnSaveChanges.setForeground(new Color(30, 144, 255)); 940 | btnSaveChanges.setFont(new Font("Tahoma", Font.BOLD, 16)); 941 | btnSaveChanges.setBackground(new Color(47, 79, 79)); 942 | btnSaveChanges.setBounds(350, 450, 150, 40); 943 | accountPanel.add(btnSaveChanges); 944 | 945 | btnCancel = new JButton("Cancel"); 946 | btnCancel.setForeground(new Color(255, 0, 0)); 947 | btnCancel.setFont(new Font("Tahoma", Font.BOLD, 16)); 948 | btnCancel.setBackground(new Color(47, 79, 79)); 949 | btnCancel.setBounds(650, 450, 100, 40); 950 | accountPanel.add(btnCancel); 951 | 952 | lblNewPassword.setVisible(false); 953 | lblNewCPassword.setVisible(false); 954 | txtNewPassword.setVisible(false); 955 | txtNewCPassword.setVisible(false); 956 | btnSaveChanges.setVisible(false); 957 | btnCancel.setVisible(false); 958 | 959 | //--------Internal Account Panel Mouse Listeners------------- 960 | 961 | 962 | btnChangePassword.addMouseListener(new MouseAdapter() { 963 | @Override 964 | public void mouseClicked(MouseEvent arg0) { 965 | 966 | lblNewPassword.setVisible(true); 967 | lblNewCPassword.setVisible(true); 968 | txtNewPassword.setVisible(true); 969 | txtNewCPassword.setVisible(true); 970 | String pass = txtNewPassword.getText().toString(); 971 | btnSaveChanges.setVisible(true); 972 | btnSaveChanges.addMouseListener(new MouseAdapter() { 973 | //Database Connectivity to Change the Password of the Current User. 974 | @Override 975 | public void mouseClicked(MouseEvent e) { 976 | try { 977 | ps = con.prepareStatement("Update registrationtable set Password=? where UserName=?"); 978 | ps.setString(1,pass); 979 | ps.setString(2, c.userName); 980 | ps.executeUpdate(); 981 | ps.close(); 982 | JOptionPane.showMessageDialog(null,"Your Password has been Successfully Updated!!"+"Username:"+c.userName+" Password:"+pass); 983 | } catch (SQLException e1) { 984 | System.out.println("SQLException in save button of Account Panel"); 985 | e1.printStackTrace(); 986 | } 987 | 988 | } 989 | }); 990 | btnCancel.setVisible(true); 991 | btnCancel.addMouseListener(new MouseAdapter() { 992 | 993 | //Shuts the Password Label. 994 | @Override 995 | public void mouseClicked(MouseEvent e) { 996 | lblNewPassword.setVisible(false); 997 | lblNewCPassword.setVisible(false); 998 | txtNewPassword.setVisible(false); 999 | txtNewCPassword.setVisible(false); 1000 | btnSaveChanges.setVisible(false); 1001 | btnCancel.setVisible(false); 1002 | } 1003 | }); 1004 | 1005 | } 1006 | }); 1007 | 1008 | 1009 | //-----------------------------Contents for Selling Panel------------------ 1010 | 1011 | 1012 | lblSellProduct = new JLabel("Sell Product"); 1013 | lblSellProduct.setHorizontalAlignment(SwingConstants.CENTER); 1014 | lblSellProduct.setFont(new Font("Myanmar Text", Font.BOLD, 16)); 1015 | lblSellProduct.setBounds(560, 5, 150, 30); 1016 | sellPanel.add(lblSellProduct); 1017 | 1018 | JSeparator separatorSP_1 = new JSeparator(); 1019 | separatorSP_1.setBackground(new Color(0, 0, 205)); 1020 | separatorSP_1.setBounds(15, 45, 1300, 3); 1021 | sellPanel.add(separatorSP_1); 1022 | 1023 | lblProductName = new JLabel(); 1024 | lblProductName.setText(" Product Name: "); 1025 | lblProductName.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); 1026 | lblProductName.setFont(new Font("Tahoma", Font.BOLD, 16)); 1027 | lblProductName.setBounds(50, 75, 135, 25); 1028 | sellPanel.add(lblProductName); 1029 | 1030 | txtProductName = new JTextField(); 1031 | txtProductName.setFont(new Font("Tahoma", Font.BOLD, 14)); 1032 | txtProductName.setForeground(Color.WHITE); 1033 | txtProductName.setBackground(new Color(112, 128, 144)); 1034 | txtProductName.setBounds(195, 75, 150, 25); 1035 | sellPanel.add(txtProductName); 1036 | 1037 | lblBasePrice = new JLabel(); 1038 | lblBasePrice.setText(" Base Price: "); 1039 | lblBasePrice.setFont(new Font("Tahoma", Font.BOLD, 16)); 1040 | lblBasePrice.setBounds(50, 200, 110, 25); 1041 | sellPanel.add(lblBasePrice); 1042 | 1043 | txtBasePrice = new JTextField(); 1044 | txtBasePrice.setFont(new Font("Tahoma", Font.BOLD, 14)); 1045 | txtBasePrice.setForeground(Color.WHITE); 1046 | txtBasePrice.setBackground(new Color(112, 128, 144)); 1047 | txtBasePrice.setBounds(170, 200, 130, 25); 1048 | sellPanel.add(txtBasePrice); 1049 | 1050 | lblSPCategory = new JLabel(); 1051 | lblSPCategory.setText(" Category :"); 1052 | lblSPCategory.setFont(new Font("Tahoma", Font.BOLD, 16)); 1053 | lblSPCategory.setBounds(50, 300, 110, 25); 1054 | sellPanel.add(lblSPCategory); 1055 | 1056 | lblProductDetails =new JLabel(); 1057 | lblProductDetails.setText(" Product Details: "); 1058 | lblProductDetails.setFont(new Font("Tahoma", Font.BOLD, 16)); 1059 | lblProductDetails.setBounds(400, 75, 150, 25); 1060 | sellPanel.add(lblProductDetails); 1061 | 1062 | txtArProductDetails = new JTextArea(); 1063 | txtArProductDetails.setLineWrap(true); 1064 | txtArProductDetails.setFocusTraversalPolicyProvider(true); 1065 | txtArProductDetails.setFont(new Font("Tahoma", Font.BOLD, 15)); 1066 | txtArProductDetails.setForeground(Color.WHITE); 1067 | txtArProductDetails.setBackground(new Color(112, 128, 144)); 1068 | txtArProductDetails.setBounds(400, 110, 200, 200); 1069 | sellPanel.add(txtArProductDetails); 1070 | 1071 | lblProductImage = new JLabel(); 1072 | lblProductImage.setText(" Product Image "); 1073 | lblProductImage.setFont(new Font("Tahoma", Font.BOLD, 16)); 1074 | lblProductImage.setBounds(650, 75, 150, 25); 1075 | sellPanel.add(lblProductImage); 1076 | 1077 | txtProductImage = new JLabel(); 1078 | txtProductImage.setBounds(650, 110, 700, 365); 1079 | txtProductImage.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 1080 | sellPanel.add(txtProductImage); 1081 | 1082 | lblPath = new JLabel(); 1083 | lblPath.setText(" PATH: "); 1084 | lblPath.setFont(new Font("Tahoma", Font.BOLD, 16)); 1085 | lblPath.setBounds(528, 510, 75, 25); 1086 | sellPanel.add(lblPath); 1087 | 1088 | txtPath = new JLabel(); 1089 | txtPath.setFont(new Font("Tahoma", Font.BOLD, 14)); 1090 | txtPath.setBackground(new Color(112, 128, 144)); 1091 | txtPath.setForeground(Color.BLACK); 1092 | txtPath.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 1093 | txtPath.setBounds(600, 510, 450, 25); 1094 | sellPanel.add(txtPath); 1095 | 1096 | 1097 | //--------Code for Selecting Image from the Directory. 1098 | 1099 | 1100 | btnBrowse = new JButton(); 1101 | btnBrowse.setText(" Browse "); 1102 | btnBrowse.setForeground(new Color(30, 144, 255)); 1103 | btnBrowse.setFont(new Font("Tahoma", Font.BOLD, 16)); 1104 | btnBrowse.setBackground(new Color(47, 79, 79)); 1105 | btnBrowse.setBounds(1200, 475, 150, 40); 1106 | sellPanel.add(btnBrowse); 1107 | btnBrowse.addMouseListener(new MouseAdapter() { 1108 | @Override 1109 | public void mouseClicked(MouseEvent arg0) { 1110 | JFileChooser file = new JFileChooser(); 1111 | FileNameExtensionFilter filter = new FileNameExtensionFilter("*.Images", "jpg","png","jpeg"); 1112 | file.addChoosableFileFilter(filter); 1113 | int result = file.showSaveDialog(null); 1114 | if(result==JFileChooser.APPROVE_OPTION) 1115 | { 1116 | File selectedFile= file.getSelectedFile(); 1117 | Path = selectedFile.getAbsolutePath(); 1118 | System.out.println("Path: "+Path); 1119 | txtPath.setText(Path); 1120 | ImageIcon icon = new ImageIcon(Path); 1121 | txtProductImage.setIcon(icon); 1122 | } 1123 | else if(result == JFileChooser.CANCEL_OPTION) 1124 | { 1125 | JOptionPane.showMessageDialog(null, " No Path Found "); 1126 | } 1127 | } 1128 | }); 1129 | 1130 | //---------Adding Items to ComboBox 1131 | 1132 | 1133 | comboBoxCategory = new JComboBox(); 1134 | options[0]=" "; 1135 | options[1]=" Car "; 1136 | options[2]=" Watch "; 1137 | options[3]=" Statue "; 1138 | options[4]=" Painting "; 1139 | options[5]=" Electronics "; 1140 | options[6]=" Others "; 1141 | for(int i=0;i<=6;i++) 1142 | { 1143 | comboBoxCategory.addItem(options[i]); 1144 | } 1145 | 1146 | comboBoxCategory.setBackground(new Color(112, 128, 144)); 1147 | comboBoxCategory.setForeground(new Color(255, 255, 255)); 1148 | comboBoxCategory.setFont(new Font("Tahoma", Font.BOLD, 14)); 1149 | comboBoxCategory.setBounds(170, 300, 140, 25); 1150 | sellPanel.add(comboBoxCategory); 1151 | 1152 | empty=new JMenuItem(""); 1153 | comboBoxCategory.add(empty); 1154 | 1155 | categoryCar=new JMenuItem(" Car "); 1156 | categoryCar.setRequestFocusEnabled(false); 1157 | categoryCar.setFont(new Font("Tahoma", Font.PLAIN, 14)); 1158 | categoryCar.setBackground(new Color(112, 128, 144)); 1159 | categoryCar.setForeground(new Color(65, 131, 215)); 1160 | comboBoxCategory.add(categoryCar); 1161 | 1162 | categoryWatch=new JMenuItem(" Watch "); 1163 | categoryWatch.setRequestFocusEnabled(false); 1164 | categoryWatch.setFont(new Font("Tahoma", Font.PLAIN, 14)); 1165 | categoryWatch.setBackground(new Color(112, 128, 144)); 1166 | categoryWatch.setForeground(new Color(65, 131, 215)); 1167 | comboBoxCategory.add(categoryWatch); 1168 | 1169 | categoryStatue=new JMenuItem(" Statue "); 1170 | categoryStatue.setRequestFocusEnabled(false); 1171 | categoryStatue.setFont(new Font("Tahoma", Font.PLAIN, 14)); 1172 | categoryStatue.setBackground(new Color(112, 128, 144)); 1173 | categoryStatue.setForeground(new Color(65, 131, 215)); 1174 | comboBoxCategory.add(categoryStatue); 1175 | 1176 | categoryPainting=new JMenuItem(" Painting "); 1177 | categoryPainting.setRequestFocusEnabled(false); 1178 | categoryPainting.setFont(new Font("Tahoma", Font.PLAIN, 14)); 1179 | categoryPainting.setBackground(new Color(112, 128, 144)); 1180 | categoryPainting.setForeground(new Color(65, 131, 215)); 1181 | comboBoxCategory.add(categoryPainting); 1182 | 1183 | categoryElectronics=new JMenuItem(" Electronics "); 1184 | categoryElectronics.setRequestFocusEnabled(false); 1185 | categoryElectronics.setFont(new Font("Tahoma", Font.PLAIN, 14)); 1186 | categoryElectronics.setBackground(new Color(112, 128, 144)); 1187 | categoryElectronics.setForeground(new Color(65, 131, 215)); 1188 | comboBoxCategory.add(categoryElectronics); 1189 | 1190 | categoryOthers=new JMenuItem(" Others "); 1191 | categoryOthers.setRequestFocusEnabled(false); 1192 | categoryOthers.setFont(new Font("Tahoma", Font.PLAIN, 14)); 1193 | categoryOthers.setBackground(new Color(112, 128, 144)); 1194 | categoryOthers.setForeground(new Color(65, 131, 215)); 1195 | comboBoxCategory.add(categoryOthers); 1196 | 1197 | lblspecifyCategory = new JLabel(); 1198 | lblspecifyCategory.setText("Specify Your Category:"); 1199 | lblspecifyCategory.setFont(new Font("Tahoma", Font.BOLD, 16)); 1200 | lblspecifyCategory.setBounds(300, 75, 110, 25); 1201 | lblspecifyCategory.setVisible(false); 1202 | sellPanel.add(lblspecifyCategory); 1203 | 1204 | txtspecifyCategory = new JTextField(); 1205 | txtspecifyCategory.setFont(new Font("Tahoma", Font.BOLD, 14)); 1206 | txtspecifyCategory.setBackground(new Color(112, 128, 144)); 1207 | txtspecifyCategory.setBounds(420, 75, 150, 25); 1208 | txtspecifyCategory.setVisible(false); 1209 | sellPanel.add(txtspecifyCategory); 1210 | 1211 | 1212 | comboBoxCategory.addActionListener(new ActionListener() { 1213 | 1214 | @Override 1215 | public void actionPerformed(ActionEvent e) { 1216 | if(comboBoxCategory.getSelectedItem().equals(" Car ")) 1217 | { 1218 | selectCategory=" Car "; 1219 | } 1220 | else if(comboBoxCategory.getSelectedItem().equals(" Watch ")) 1221 | { 1222 | selectCategory=" Watch "; 1223 | } 1224 | else if(comboBoxCategory.getSelectedItem().equals(" Statue ")) 1225 | { 1226 | selectCategory=" Statue "; 1227 | } 1228 | else if(comboBoxCategory.getSelectedItem().equals(" Statue ")) 1229 | { 1230 | selectCategory=" Statue "; 1231 | } 1232 | else if(comboBoxCategory.getSelectedItem().equals(" Electronics ")) 1233 | { 1234 | selectCategory=" Electronics "; 1235 | } 1236 | else if(comboBoxCategory.getSelectedItem().equals(" Others ")) 1237 | { 1238 | lblspecifyCategory.setVisible(true); 1239 | txtspecifyCategory.setVisible(true); 1240 | selectCategory = txtspecifyCategory.getText(); 1241 | } 1242 | else{ 1243 | JOptionPane.showMessageDialog(null, "Please Select a Category",null, JOptionPane.ERROR_MESSAGE); 1244 | } 1245 | } 1246 | }); 1247 | 1248 | btnSell = new JButton(); 1249 | btnSell.setText(" Sell "); 1250 | btnSell.setForeground(new Color(30, 144, 255)); 1251 | btnSell.setFont(new Font("Tahoma", Font.BOLD, 16)); 1252 | btnSell.setBackground(new Color(47, 79, 79)); 1253 | btnSell.setBounds(300, 450, 150, 40); 1254 | sellPanel.add(btnSell); 1255 | 1256 | btnSell.addMouseListener(new MouseAdapter() { 1257 | @Override 1258 | public void mouseClicked(MouseEvent arg0) { 1259 | if(ValidateInfo()) 1260 | { 1261 | int yesOrNo=JOptionPane.showConfirmDialog(null, " Are you Sure you want to Place the Product for Bidding ?", "Confirmation Message", JOptionPane.YES_NO_OPTION); 1262 | if(yesOrNo==0){ 1263 | 1264 | //If User Clicks Yes Option. 1265 | 1266 | lblProductId = new JLabel(); 1267 | lblProductId.setText("Product Id (AutoGenerated):"); 1268 | 1269 | Random rand = new Random(); 1270 | int value = rand.nextInt(5000); 1271 | txtProductId = new JLabel(); 1272 | String str=Integer.toString(value); 1273 | txtProductId.setText(str); 1274 | 1275 | lblTimeLeft= new JLabel(); 1276 | txtTimeLeft = new JLabel(); 1277 | lblTimeLeft.setText("Time Left (For Closed Bidding): "); 1278 | 1279 | timer = new java.util.Timer(); 1280 | timer.scheduleAtFixedRate(new TimerTask() { 1281 | 1282 | public void run() { 1283 | timeleft=setInterval(); 1284 | seconds = timeleft%60; 1285 | if(seconds == 0) 1286 | minutes--; 1287 | if((seconds/10)==0) 1288 | { finalTimer=String.format("0%d:0%d", minutes,seconds); 1289 | txtTimeLeft.setText("0"+Integer.toString(minutes) + " : 0"+Integer.toString(seconds) ); 1290 | 1291 | } 1292 | else 1293 | { finalTimer=String.format("0%d:%d", minutes,seconds); 1294 | txtTimeLeft.setText("0"+Integer.toString(minutes) + " : "+Integer.toString(seconds) ); 1295 | } 1296 | } 1297 | }, delay, period); 1298 | 1299 | 1300 | Object complexMsg[] = { lblProductId, txtProductId, lblTimeLeft,txtTimeLeft}; 1301 | 1302 | JOptionPane optionPane = new JOptionPane(); 1303 | optionPane.setMessage(complexMsg); 1304 | optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); 1305 | JDialog dialog = optionPane.createDialog(null, " Note: "); 1306 | dialog.setVisible(true); 1307 | 1308 | //Store the ProductId and the TimeLeft in the Database. 1309 | //Add the Rest info to the database. 1310 | //Add selectCategory String to the Database. 1311 | //Add image Path in the Database. 1312 | File imgfile = new File(txtPath.getText()); 1313 | FileInputStream fis = null; 1314 | try { 1315 | fis = new FileInputStream(imgfile); 1316 | } catch (FileNotFoundException e1) { 1317 | System.out.println("Excecption in File Input Stream "); 1318 | e1.printStackTrace(); 1319 | } 1320 | try { 1321 | ps= con.prepareStatement("insert into selltable values (?,?,?,?,?,?,?)"); 1322 | ps.setString(1,txtProductName.getText()); 1323 | ps.setString(2, txtArProductDetails.getText()); 1324 | ps.setString(3, txtProductId.getText()); 1325 | ps.setDouble(4, Double.parseDouble(txtBasePrice.getText())); 1326 | ps.setString(5, selectCategory); 1327 | ps.setString(6, c.userName); 1328 | ps.setBinaryStream(7, (InputStream)fis , (int)imgfile.length() ); 1329 | ps.executeUpdate(); 1330 | ps = con.prepareStatement(" insert into bidtable (ProID,BasePrice,CurrentPrice,NoOfBids) values (?,?,?,?)"); 1331 | ps.setString(1, txtProductId.getText()); 1332 | ps.setDouble(2, Double.parseDouble(txtBasePrice.getText())); 1333 | ps.setDouble(3, Double.parseDouble(txtBasePrice.getText())); 1334 | ps.setInt(4, 0); 1335 | ps.executeUpdate(); 1336 | ps.close(); 1337 | 1338 | } catch (SQLException e) { 1339 | System.out.println("SQLException in sell button of Sell Panel"); 1340 | e.printStackTrace(); 1341 | } 1342 | 1343 | } 1344 | else{ 1345 | txtProductName.setText(""); 1346 | txtBasePrice.setText(""); 1347 | txtArProductDetails.setText(""); 1348 | txtProductImage.setText(""); 1349 | selectCategory=""; 1350 | txtspecifyCategory.setText(""); 1351 | txtPath.setText(""); 1352 | } 1353 | } 1354 | } 1355 | }); 1356 | 1357 | 1358 | 1359 | //-----------------------------Contents for MyBids Panel------------------ 1360 | 1361 | lblMyBidsTitle = new JLabel(" My Bids "); 1362 | lblMyBidsTitle.setHorizontalAlignment(SwingConstants.CENTER); 1363 | lblMyBidsTitle.setFont(new Font("Myanmar Text", Font.BOLD, 16)); 1364 | lblMyBidsTitle.setBounds(560, 150, 150, 30); 1365 | contentPane.add(lblMyBidsTitle); 1366 | lblMyBidsTitle.setVisible(false); 1367 | 1368 | 1369 | //Database Connectivity to Retrieve the User Bidding Info from the Database. 1370 | 1371 | //-----------------------------Contents for SavedBids Panel------------------ 1372 | 1373 | lblSavedBidsTitle = new JLabel(" Saved Bids "); 1374 | lblSavedBidsTitle.setHorizontalAlignment(SwingConstants.CENTER); 1375 | lblSavedBidsTitle.setFont(new Font("Myanmar Text", Font.BOLD, 16)); 1376 | lblSavedBidsTitle.setBounds(560, 150, 150, 30); 1377 | contentPane.add(lblSavedBidsTitle); 1378 | lblSavedBidsTitle.setVisible(false); 1379 | 1380 | //Database Connectivity to Retrieve the User Saved Bidding Info from the Database. 1381 | 1382 | //Database Connectivity to Retrieve the User Bidding Info from the Database. 1383 | 1384 | //-----------------------------Contents for MyProducts Panel------------------ 1385 | 1386 | lblMyProdTitle = new JLabel(" My Products "); 1387 | lblMyProdTitle.setHorizontalAlignment(SwingConstants.CENTER); 1388 | lblMyProdTitle.setFont(new Font("Myanmar Text", Font.BOLD, 16)); 1389 | lblMyProdTitle.setBounds(560, 150, 150, 30); 1390 | contentPane.add(lblMyProdTitle); 1391 | lblMyProdTitle.setVisible(false); 1392 | 1393 | //Database Connectivity to Retrieve the Users Product Bidding Info from the Database. 1394 | 1395 | 1396 | //-----------------------------Contents for More Info Panel-------------------- 1397 | 1398 | //Opens when A particular Row from the table is Clicked. 1399 | 1400 | 1401 | lblMoreProductInfo = new JLabel("Product Details"); 1402 | lblMoreProductInfo.setBounds(560, 5, 150, 30); 1403 | lblMoreProductInfo.setHorizontalAlignment(SwingConstants.CENTER); 1404 | lblMoreProductInfo.setFont(new Font("Myanmar Text", Font.BOLD, 16)); 1405 | moreInfoPanel.add(lblMoreProductInfo); 1406 | 1407 | JSeparator separatorSP_2 = new JSeparator(); 1408 | separatorSP_2.setBackground(new Color(0, 0, 205)); 1409 | separatorSP_2.setBounds(15, 45, 1300, 3); 1410 | moreInfoPanel.add(separatorSP_2); 1411 | 1412 | lblInfoProductName = new JLabel(); 1413 | lblInfoProductName.setText(" Product Name: "); 1414 | lblInfoProductName.setBounds(50, 75, 135, 25); 1415 | lblInfoProductName.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); 1416 | lblInfoProductName.setFont(new Font("Tahoma", Font.BOLD, 16)); 1417 | moreInfoPanel.add(lblInfoProductName); 1418 | 1419 | txtInfoProductName = new JLabel(); 1420 | txtInfoProductName.setBounds(195, 75, 140, 25); 1421 | txtInfoProductName.setFont(new Font("Tahoma", Font.BOLD, 14)); 1422 | txtInfoProductName.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 1423 | txtInfoProductName.setBackground(new Color(112, 128, 144)); 1424 | moreInfoPanel.add(txtInfoProductName); 1425 | 1426 | lblInfoProductID = new JLabel(); 1427 | lblInfoProductID.setText(" Product ID: "); 1428 | lblInfoProductID.setBounds(50, 130, 135, 25); 1429 | lblInfoProductID.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); 1430 | lblInfoProductID.setFont(new Font("Tahoma", Font.BOLD, 16)); 1431 | moreInfoPanel.add(lblInfoProductID); 1432 | 1433 | txtInfoProductID = new JLabel(); 1434 | txtInfoProductID.setBounds(195, 130, 140, 25); 1435 | txtInfoProductID.setFont(new Font("Tahoma", Font.BOLD, 14)); 1436 | txtInfoProductID.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 1437 | txtInfoProductID.setBackground(new Color(112, 128, 144)); 1438 | moreInfoPanel.add(txtInfoProductID); 1439 | 1440 | 1441 | lblInfoBasePrice = new JLabel(); 1442 | lblInfoBasePrice.setText(" Base Price: "); 1443 | lblInfoBasePrice.setBounds(50, 185, 110, 25); 1444 | lblInfoBasePrice.setFont(new Font("Tahoma", Font.BOLD, 16)); 1445 | moreInfoPanel.add(lblInfoBasePrice); 1446 | 1447 | txtInfoBasePrice = new JLabel(); 1448 | txtInfoBasePrice.setBounds(170, 185, 130, 25); 1449 | txtInfoBasePrice.setFont(new Font("Tahoma", Font.BOLD, 14)); 1450 | txtInfoBasePrice.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 1451 | txtInfoBasePrice.setBackground(new Color(112, 128, 144)); 1452 | moreInfoPanel.add(txtInfoBasePrice); 1453 | 1454 | lblInfoCurrentPrice = new JLabel(); 1455 | lblInfoCurrentPrice.setText(" Current Bid Price: "); 1456 | lblInfoCurrentPrice.setBounds(10, 240, 175, 25); 1457 | lblInfoCurrentPrice.setFont(new Font("Tahoma", Font.BOLD, 16)); 1458 | moreInfoPanel.add(lblInfoCurrentPrice); 1459 | 1460 | txtInfoCurrentPrice = new JLabel(); 1461 | txtInfoCurrentPrice.setBounds(195, 240, 130, 25); 1462 | txtInfoCurrentPrice.setFont(new Font("Tahoma", Font.BOLD, 14)); 1463 | txtInfoCurrentPrice.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 1464 | txtInfoCurrentPrice.setBackground(new Color(112, 128, 144)); 1465 | moreInfoPanel.add(txtInfoCurrentPrice); 1466 | 1467 | lblInfoSPCategory = new JLabel(); 1468 | lblInfoSPCategory.setText(" Category : "); 1469 | lblInfoSPCategory.setBounds(50, 300, 110, 25); 1470 | lblInfoSPCategory.setFont(new Font("Tahoma", Font.BOLD, 16)); 1471 | moreInfoPanel.add(lblInfoSPCategory); 1472 | 1473 | txtInfoSPCategory = new JLabel(); 1474 | txtInfoSPCategory.setBounds(170, 300, 140, 25); 1475 | txtInfoSPCategory.setFont(new Font("Tahoma", Font.BOLD, 14)); 1476 | txtInfoSPCategory.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 1477 | moreInfoPanel.add(txtInfoSPCategory); 1478 | 1479 | lblInfoUsername = new JLabel(); 1480 | lblInfoUsername.setText(" Username : "); 1481 | lblInfoUsername.setBounds(50, 375, 110, 25); 1482 | lblInfoUsername.setFont(new Font("Tahoma", Font.BOLD, 16)); 1483 | moreInfoPanel.add(lblInfoUsername); 1484 | 1485 | txtInfoUsername = new JLabel(); 1486 | txtInfoUsername.setBounds(170, 375, 130, 25); 1487 | txtInfoUsername.setFont(new Font("Tahoma", Font.BOLD, 14)); 1488 | txtInfoUsername.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 1489 | txtInfoUsername.setBackground(new Color(112, 128, 144)); 1490 | moreInfoPanel.add(txtInfoUsername); 1491 | 1492 | 1493 | lblInfoProductDetails = new JLabel(); 1494 | lblInfoProductDetails.setBounds(350, 75, 150, 25); 1495 | lblInfoProductDetails.setText(" Product Info."); 1496 | lblInfoProductDetails.setFont(new Font("Tahoma", Font.BOLD, 16)); 1497 | moreInfoPanel.add(lblInfoProductDetails); 1498 | 1499 | txtInfoArProductDetails = new JTextArea(); 1500 | txtInfoArProductDetails.setLineWrap(true); 1501 | txtInfoArProductDetails.setFocusTraversalPolicyProvider(true); 1502 | txtInfoArProductDetails.setFont(new Font("Tahoma", Font.ROMAN_BASELINE, 14)); 1503 | txtInfoArProductDetails.setForeground(new Color(255, 255, 255)); 1504 | txtInfoArProductDetails.setBackground(new Color(112, 128, 144)); 1505 | txtInfoArProductDetails.setBounds(350, 110, 200, 200); 1506 | moreInfoPanel.add(txtInfoArProductDetails); 1507 | 1508 | lblInfoProductImage = new JLabel(); 1509 | lblInfoProductImage.setText(" Product Image "); 1510 | lblInfoProductImage.setFont(new Font("Tahoma", Font.BOLD, 16)); 1511 | lblInfoProductImage.setBounds(720, 75, 150, 25); 1512 | moreInfoPanel.add(lblInfoProductImage); 1513 | 1514 | txtInfoProductImage = new JLabel(); 1515 | txtInfoProductImage.setBounds(600, 110, 700, 365); 1516 | txtInfoProductImage.setBackground(new Color(112, 128, 144)); 1517 | txtInfoProductImage.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 1518 | moreInfoPanel.add(txtInfoProductImage); 1519 | 1520 | lblInfoPath = new JLabel(); 1521 | lblInfoPath.setText(" PATH: "); 1522 | lblInfoPath.setFont(new Font("Tahoma", Font.BOLD, 16)); 1523 | lblInfoPath.setBounds(528, 510, 75, 25); 1524 | moreInfoPanel.add(lblInfoPath); 1525 | 1526 | txtInfoPath = new JLabel(); 1527 | txtInfoPath.setFont(new Font("Tahoma", Font.BOLD, 14)); 1528 | txtInfoPath.setBackground(new Color(112, 128, 144)); 1529 | txtInfoPath.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 1530 | txtInfoPath.setBounds(600, 510, 450, 25); 1531 | moreInfoPanel.add(txtInfoPath); 1532 | 1533 | 1534 | lblInfoTimeLeft = new JLabel(" Time Left(For Closed Bidding) "); 1535 | lblInfoTimeLeft.setFont(new Font("Tahoma", Font.BOLD, 14)); 1536 | lblInfoTimeLeft.setBounds(340, 320, 220, 25); 1537 | moreInfoPanel.add(lblInfoTimeLeft); 1538 | 1539 | txtInfoTimeLeft = new JLabel(); 1540 | txtInfoTimeLeft.setFont(new Font("Tahoma", Font.BOLD, 14)); 1541 | txtInfoTimeLeft.setBackground(new Color(112, 128, 144)); 1542 | txtInfoTimeLeft.setBorder(new LineBorder(new Color(0, 0, 0), 2)); 1543 | txtInfoTimeLeft.setBounds(350, 355, 150, 25); 1544 | moreInfoPanel.add(txtInfoTimeLeft); 1545 | 1546 | 1547 | btnInfoSave = new JButton(); 1548 | btnInfoSave.addMouseListener(new MouseAdapter() { 1549 | @Override 1550 | public void mouseClicked(MouseEvent arg0) { 1551 | 1552 | //Add the ProductId to the Username Table who clicked the "Save" Button and then Show the Details of the Product in that user's MySavedBids Panel. 1553 | try { 1554 | ps = con.prepareStatement("insert into savebidstable values (?,?) "); 1555 | ps.setString(1,txtInfoProductID.getText()); 1556 | ps.setString(2,c.userName); 1557 | ps.executeUpdate(); 1558 | JOptionPane.showMessageDialog(null, "This Product has been Added to your Saved Bids Drawer."); 1559 | } catch (SQLException e) { 1560 | System.out.println("Exception in btnInfoSave"); 1561 | e.printStackTrace(); 1562 | } 1563 | 1564 | } 1565 | }); 1566 | btnInfoSave.setBounds(250, 445, 110, 30); 1567 | btnInfoSave.setText(" Save "); 1568 | btnInfoSave.setForeground(new Color(0, 0, 0)); 1569 | btnInfoSave.setFont(new Font("Tahoma", Font.BOLD, 16)); 1570 | btnInfoSave.setBackground(new Color(255, 140, 0)); 1571 | moreInfoPanel.add(btnInfoSave); 1572 | 1573 | 1574 | //A separate JFrame for User to Place the Bid. 1575 | 1576 | btnInfoPlaceBid = new JButton(); 1577 | btnInfoPlaceBid.addMouseListener(new MouseAdapter() { 1578 | @Override 1579 | public void mouseClicked(MouseEvent e) { 1580 | 1581 | try { 1582 | BidSettings bs = new BidSettings(); 1583 | bs.setVisible(true); 1584 | } catch (Exception e1) { 1585 | System.out.println("Exception in btnInfoPlaceBid"); //Open the Bidding Frame. 1586 | e1.printStackTrace(); 1587 | } 1588 | } 1589 | }); 1590 | btnInfoPlaceBid.setBounds(430, 445, 140, 30); 1591 | btnInfoPlaceBid.setText(" Place Bid "); 1592 | btnInfoPlaceBid.setForeground(new Color(192, 192, 192)); 1593 | btnInfoPlaceBid.setFont(new Font("Tahoma", Font.BOLD, 16)); 1594 | btnInfoPlaceBid.setBackground(new Color(65, 105, 225)); 1595 | moreInfoPanel.add(btnInfoPlaceBid); 1596 | 1597 | 1598 | 1599 | //-----------------------------------All Mouse Listeners-------------------------------------- 1600 | 1601 | 1602 | lblHome.addMouseListener(new MouseAdapter() { 1603 | @Override 1604 | //---------Home Panel [JTabbedPane]------------- 1605 | public void mouseClicked(MouseEvent arg0) { 1606 | 1607 | tabbedPane.setVisible(true); 1608 | homeTab.setVisible(true); 1609 | trendingBidsTab.setVisible(true); 1610 | savedBidsPanel.setVisible(false); 1611 | sellPanel.setVisible(false); 1612 | myProdPanel.setVisible(false); 1613 | myBidsPanel.setVisible(false); 1614 | accountPanel.setVisible(false); 1615 | lblMyBidsTitle.setVisible(false); 1616 | lblMyProdTitle.setVisible(false); 1617 | moreInfoPanel.setVisible(false); 1618 | lblSavedBidsTitle.setVisible(false); 1619 | 1620 | homeFetchData( c); 1621 | } 1622 | }); 1623 | 1624 | lblAccount.addMouseListener(new MouseAdapter() { 1625 | @Override 1626 | 1627 | //---------Account Panel--------------- 1628 | public void mouseClicked(MouseEvent e) { 1629 | 1630 | tabbedPane.setVisible(false); 1631 | homeTab.setVisible(false); 1632 | trendingBidsTab.setVisible(false); 1633 | savedBidsPanel.setVisible(false); 1634 | sellPanel.setVisible(false); 1635 | myProdPanel.setVisible(false); 1636 | myBidsPanel.setVisible(false); 1637 | accountPanel.setVisible(true); 1638 | lblMyBidsTitle.setVisible(false); 1639 | lblMyProdTitle.setVisible(false); 1640 | moreInfoPanel.setVisible(false); 1641 | lblSavedBidsTitle.setVisible(false); 1642 | } 1643 | }); 1644 | 1645 | lblSell.addMouseListener(new MouseAdapter() { 1646 | @Override 1647 | //----------Sell Panel----------------- 1648 | public void mouseClicked(MouseEvent e) { 1649 | 1650 | tabbedPane.setVisible(false); 1651 | homeTab.setVisible(false); 1652 | trendingBidsTab.setVisible(false); 1653 | accountPanel.setVisible(false); 1654 | savedBidsPanel.setVisible(false); 1655 | myProdPanel.setVisible(false); 1656 | myBidsPanel.setVisible(false); 1657 | sellPanel.setVisible(true); 1658 | lblMyBidsTitle.setVisible(false); 1659 | lblMyProdTitle.setVisible(false); 1660 | moreInfoPanel.setVisible(false); 1661 | lblSavedBidsTitle.setVisible(false); 1662 | 1663 | } 1664 | }); 1665 | lblMyProd.addMouseListener(new MouseAdapter() { 1666 | @Override 1667 | //----------MyBids Panel----------------- 1668 | public void mouseClicked(MouseEvent e) { 1669 | 1670 | tabbedPane.setVisible(false); 1671 | homeTab.setVisible(false); 1672 | trendingBidsTab.setVisible(false); 1673 | accountPanel.setVisible(false); 1674 | savedBidsPanel.setVisible(false); 1675 | sellPanel.setVisible(false); 1676 | myBidsPanel.setVisible(false); 1677 | myProdPanel.setVisible(true); 1678 | lblMyBidsTitle.setVisible(false); 1679 | lblMyProdTitle.setVisible(true); 1680 | moreInfoPanel.setVisible(false); 1681 | lblSavedBidsTitle.setVisible(false); 1682 | 1683 | String myProdcolumns[]={"ProductId","Product Name","Base Price","Maximum Bidder","Current Bid Price","Image"}; 1684 | 1685 | myProdTable = new JTable(); 1686 | myProdTable.setBounds(0, 45, 1365, 516); 1687 | 1688 | myProdmodel = new DefaultTableModel(); 1689 | myProdmodel.setColumnIdentifiers(myProdcolumns); 1690 | 1691 | myProdTable = new JTable(myProdmodel); 1692 | myProdTable.setShowVerticalLines(true); 1693 | myProdTable.setShowHorizontalLines(true); 1694 | myProdTable.setRowHeight(120); 1695 | 1696 | myProdTable.getColumnModel().getColumn(0).setPreferredWidth(50); 1697 | myProdTable.getColumnModel().getColumn(1).setPreferredWidth(50); 1698 | myProdTable.getColumnModel().getColumn(2).setPreferredWidth(50); 1699 | myProdTable.getColumnModel().getColumn(3).setPreferredWidth(50); 1700 | myProdTable.getColumnModel().getColumn(4).setPreferredWidth(50); 1701 | myProdTable.getColumnModel().getColumn(5).setPreferredWidth(150); 1702 | 1703 | myProdScrollPane = new JScrollPane(myProdTable,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 1704 | myProdScrollPane.setBounds(0, 44, 1365, 516); 1705 | myProdScrollPane.setVisible(true); 1706 | myProdPanel.add(myProdScrollPane,BorderLayout.CENTER); 1707 | 1708 | myProdFetchData(c); //To constantly Update the Data in the MyBidsTable. 1709 | 1710 | } 1711 | }); 1712 | lblMyBids.addMouseListener(new MouseAdapter() { 1713 | @Override 1714 | //----------MyBids Panel----------------- 1715 | public void mouseClicked(MouseEvent e) { 1716 | 1717 | tabbedPane.setVisible(false); 1718 | homeTab.setVisible(false); 1719 | trendingBidsTab.setVisible(false); 1720 | accountPanel.setVisible(false); 1721 | savedBidsPanel.setVisible(false); 1722 | sellPanel.setVisible(false); 1723 | myBidsPanel.setVisible(true); 1724 | myProdPanel.setVisible(false); 1725 | lblMyBidsTitle.setVisible(true); 1726 | lblMyProdTitle.setVisible(false); 1727 | moreInfoPanel.setVisible(false); 1728 | lblSavedBidsTitle.setVisible(false); 1729 | 1730 | myBidsTable = new JTable(); 1731 | myBidsTable.setBounds(0, 44, 1365, 516); 1732 | 1733 | String myBidscolumns[]={"ProductId","Product Name","Your Bid Price","Maximum Bidder","Current Bid Price","Image"}; 1734 | 1735 | myBidsmodel = new DefaultTableModel(); 1736 | myBidsmodel.setColumnIdentifiers(myBidscolumns); 1737 | myBidsTable =new JTable(myBidsmodel); 1738 | myBidsTable.setShowVerticalLines(true); 1739 | myBidsTable.setShowHorizontalLines(true); 1740 | myBidsTable.setRowHeight(120); 1741 | 1742 | myBidsTable.getColumnModel().getColumn(0).setPreferredWidth(50); 1743 | myBidsTable.getColumnModel().getColumn(1).setPreferredWidth(50); 1744 | myBidsTable.getColumnModel().getColumn(2).setPreferredWidth(50); 1745 | myBidsTable.getColumnModel().getColumn(3).setPreferredWidth(50); 1746 | myBidsTable.getColumnModel().getColumn(4).setPreferredWidth(50); 1747 | myBidsTable.getColumnModel().getColumn(5).setPreferredWidth(150); 1748 | 1749 | 1750 | myBidsScrollPane = new JScrollPane(myBidsTable,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 1751 | myBidsScrollPane.setBounds(0, 44, 1365, 516); 1752 | myBidsScrollPane.setVisible(true); 1753 | myBidsPanel.add(myBidsScrollPane,BorderLayout.CENTER); 1754 | 1755 | myBidsFetchData(c); //To constantly Update the Data in the MyBidsTable. 1756 | } 1757 | }); 1758 | 1759 | lblSavedBids.addMouseListener(new MouseAdapter() { 1760 | @Override 1761 | //----------SavedBids Panel----------------- 1762 | public void mouseClicked(MouseEvent e) { 1763 | 1764 | tabbedPane.setVisible(false); 1765 | homeTab.setVisible(false); 1766 | trendingBidsTab.setVisible(false); 1767 | accountPanel.setVisible(false); 1768 | sellPanel.setVisible(false); 1769 | myBidsPanel.setVisible(false); 1770 | savedBidsPanel.setVisible(true); 1771 | myProdPanel.setVisible(false); 1772 | lblMyBidsTitle.setVisible(false); 1773 | lblMyProdTitle.setVisible(false); 1774 | moreInfoPanel.setVisible(false); 1775 | lblSavedBidsTitle.setVisible(true); 1776 | 1777 | String savedBidscolumns[]={"ProductId","Product Name","Seller Username","Maximum Bidder","Current Bid Price","Image"}; 1778 | 1779 | savedBidsTable = new JTable(); 1780 | savedBidsTable.setBounds(0, 44, 1365, 516); 1781 | 1782 | savedBidsmodel = new DefaultTableModel(); 1783 | savedBidsmodel.setColumnIdentifiers(savedBidscolumns); 1784 | savedBidsTable =new JTable(savedBidsmodel); 1785 | savedBidsTable.setShowVerticalLines(true); 1786 | savedBidsTable.setShowHorizontalLines(true); 1787 | savedBidsTable.setRowHeight(120); 1788 | savedBidsTable.getColumnModel().getColumn(5).setPreferredWidth(150); 1789 | 1790 | savedBidsTable.getColumnModel().getColumn(0).setPreferredWidth(50); 1791 | savedBidsTable.getColumnModel().getColumn(1).setPreferredWidth(50); 1792 | savedBidsTable.getColumnModel().getColumn(2).setPreferredWidth(50); 1793 | savedBidsTable.getColumnModel().getColumn(3).setPreferredWidth(50); 1794 | savedBidsTable.getColumnModel().getColumn(4).setPreferredWidth(50); 1795 | savedBidsTable.getColumnModel().getColumn(5).setPreferredWidth(150); 1796 | 1797 | savedBidsScrollPane = new JScrollPane(savedBidsTable,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 1798 | savedBidsScrollPane.setBounds(0, 44, 1365, 516); 1799 | savedBidsScrollPane.setVisible(true); 1800 | savedBidsPanel.add(savedBidsScrollPane,BorderLayout.CENTER); 1801 | 1802 | savedBidsFetchData(c); //To constantly Update the Data in the SavedBidsTable. 1803 | } 1804 | }); 1805 | 1806 | lblLogout.addMouseListener(new MouseAdapter() { 1807 | @Override 1808 | //-------------Logout Panel------------ 1809 | public void mouseClicked(MouseEvent e) { 1810 | 1811 | tabbedPane.setVisible(false); 1812 | homeTab.setVisible(false); 1813 | trendingBidsTab.setVisible(false); 1814 | accountPanel.setVisible(false); 1815 | sellPanel.setVisible(false); 1816 | myBidsPanel.setVisible(false); 1817 | savedBidsPanel.setVisible(false); 1818 | myProdPanel.setVisible(false); 1819 | lblMyBidsTitle.setVisible(false); 1820 | lblMyProdTitle.setVisible(false); 1821 | lblSavedBidsTitle.setVisible(false); 1822 | 1823 | int yesOrNo = JOptionPane.showConfirmDialog(null, " Are you sure you want to Logout?", "Logout Screen", JOptionPane.YES_NO_OPTION); 1824 | if(yesOrNo==0) 1825 | { 1826 | //User Clicked Yes redirect to Login page. 1827 | LoginFrame lf = new LoginFrame(); 1828 | lf.setVisible(true); 1829 | reg(); 1830 | } 1831 | 1832 | } 1833 | }); 1834 | } 1835 | 1836 | public void reg() 1837 | { 1838 | this.setVisible(false); 1839 | } 1840 | 1841 | public String getProdId() 1842 | { 1843 | System.out.println("txtProductId.getText():"+txtProductId.getText()); 1844 | return txtProductId.getText(); 1845 | } 1846 | public String getProdBasePrice() 1847 | { 1848 | return txtBasePrice.getText(); 1849 | } 1850 | 1851 | //-------------------------Fetch Data constantly from the Database to HomeTable .------------- 1852 | 1853 | public void homeFetchData(Client c) 1854 | { 1855 | try { 1856 | /* 1857 | myBidsTable.setModel(DbUtils.resultSetToTableModel(rs)); 1858 | */ 1859 | String mbtProID=null; 1860 | int prodCount=0; 1861 | Vector temp = new Vector(); //contains 4 Columns. Image Column is Not Added. 1862 | tabbedPane.setVisible(true); 1863 | trendingBidsTab.setVisible(true); 1864 | homeTab.setVisible(true); 1865 | ps = con.prepareStatement("select ProID,ProName,BasePrice,ProCategory,Image from selltable"); 1866 | rs=ps.executeQuery(); 1867 | 1868 | while(rs.next()) 1869 | { 1870 | mbtProID = rs.getString("ProID"); 1871 | temp.add(mbtProID); 1872 | temp.add(rs.getString("ProName")); 1873 | temp.add(rs.getString("BasePrice")); 1874 | temp.add(rs.getString("ProCategory")); 1875 | blob=rs.getBlob("Image"); 1876 | bImg=blob.getBytes(1, (int)blob.length()); 1877 | //ImageIcon imgTemp = new ImageIcon(new ImageIcon().getImage(bImg));//Remaining:-retrieving Image from Database. 1878 | //temp2.addElement(imgTemp); 1879 | prodCount++; 1880 | System.out.println("Inside 1st while:"+prodCount); 1881 | } 1882 | Vector temp1 = new Vector(); 1883 | 1884 | for(int z=prodCount-1,y=0;z>=0;z--) 1885 | { 1886 | temp1.add(y++, temp.get(z*4)); 1887 | temp1.add(y++,temp.get(z*4+1)); 1888 | temp1.add(y++, temp.get(z*4+2)); 1889 | temp1.add(y++, temp.get(z*4+3)); 1890 | //temp1.add(y++, temp.get(y)); for Image 1891 | } 1892 | Vector temp2 = new Vector(); //contains 3 Columns. 1893 | int i=prodCount-1; 1894 | 1895 | while(i>=0) 1896 | { 1897 | int index=4*i; 1898 | ps = con.prepareStatement("select UserName,CurrentPrice,NoOfBids from bidtable where ProID=?"); 1899 | ps.setString(1, temp.get(index)); 1900 | rs=ps.executeQuery(); 1901 | while(rs.next()) 1902 | { 1903 | temp2.add(rs.getString("UserName")); 1904 | temp2.add(rs.getString("CurrentPrice")); 1905 | temp2.add(rs.getString("NoOfBids")); 1906 | } 1907 | i--; 1908 | } 1909 | 1910 | Vector finalhomeTable = new Vector(); 1911 | int k=0,x=0; 1912 | while(prodCount>k) 1913 | { 1914 | finalhomeTable.add(x++, temp1.get(k)); //ProID 1915 | finalhomeTable.add(x++, temp1.get(k+1)); //ProName 1916 | finalhomeTable.add(x++, temp1.get(k+2)); //BasePrice 1917 | finalhomeTable.add(x++, temp1.get(k+3)); //Category. 1918 | finalhomeTable.add(x++, temp2.get(k)); //Max Bidder Username. 1919 | finalhomeTable.add(x++, temp2.get(k+1)); //CurrentPrice. 1920 | finalhomeTable.add(x++, temp2.get(k+2)); //NoOfBids. 1921 | // finalhomeTable.add(x++, temp1.get(k+4)); //Image . 1922 | homeHomemodel.addRow(new Object[]{finalhomeTable.get(x-7),finalhomeTable.get(x-6),finalhomeTable.get(x-5),finalhomeTable.get(x-4),finalhomeTable.get(x-3),finalhomeTable.get(x-2),finalhomeTable.get(x-1)}); 1923 | k++; 1924 | 1925 | } 1926 | }catch(Exception e) 1927 | { 1928 | System.out.println("Exception Caught is homeFetchData Function."); 1929 | e.printStackTrace(); 1930 | } 1931 | } 1932 | 1933 | //-------------------------Fetch Data constantly from the Database to MyBidsTable .------------- 1934 | 1935 | public void myBidsFetchData(Client c) 1936 | { 1937 | //Remaining:-If user Clicks on a particular row , show MoreInfo panel without save or Sell Button. 1938 | try { 1939 | /* 1940 | myBidsTable.setModel(DbUtils.resultSetToTableModel(rs)); 1941 | */ 1942 | String mbtProID=null; 1943 | vectorMyBidsTable = new Vector>(); 1944 | int prodCount=0; 1945 | ps = con.prepareStatement("select ProID,MyBidPrice from buyertable where Username=?"); 1946 | ps.setString(1, c.userName); 1947 | rs=ps.executeQuery(); 1948 | Vector temp = new Vector(); 1949 | if(!rs.next()) 1950 | { 1951 | myBidsPanel.setVisible(false); 1952 | JOptionPane.showMessageDialog(null, "Your My Bids Table is Empty!!"); 1953 | } 1954 | else 1955 | { 1956 | myBidsPanel.setVisible(true); 1957 | while(rs.next()) 1958 | { 1959 | mbtProID = rs.getString("ProID"); 1960 | temp.add(mbtProID); 1961 | temp.add(Double.toString(rs.getDouble("MyBidPrice"))); 1962 | prodCount++; 1963 | } 1964 | Vector temp1 = new Vector(); 1965 | for(int z=prodCount-1,y=0;z>=0;z--) 1966 | { 1967 | temp1.add(y++, temp.get(z*2)); 1968 | temp1.add(y++,temp.get(z*2+1)); 1969 | } 1970 | Vector temp2 = new Vector(); 1971 | 1972 | int i=prodCount-1; 1973 | 1974 | while(i>=0) 1975 | { 1976 | int index=2*(i-1); 1977 | 1978 | ps = con.prepareStatement("select ProName,Image from selltable where ProID=?"); 1979 | ps.setString(1, temp.get(index)); 1980 | rs=ps.executeQuery(); 1981 | if(rs.next()) //Will Only get 1 Value. 1982 | { 1983 | temp2.add(rs.getString("ProName")); 1984 | blob=rs.getBlob("Image"); 1985 | bImg=blob.getBytes(1, (int)blob.length()); 1986 | //ImageIcon imgTemp = new ImageIcon(new ImageIcon().getImage(bImg));//Remaining:-retrieving Image from Database. 1987 | //temp2.addElement(imgTemp); 1988 | } 1989 | i--; 1990 | } 1991 | Vector temp3 = new Vector(); 1992 | int j=prodCount-1; 1993 | 1994 | while(j>=0) 1995 | { 1996 | int index=2*(i-1); 1997 | 1998 | ps = con.prepareStatement("select CurrentPrice,UserName from bidtable where ProID=?"); 1999 | ps.setString(1, temp.get(index)); 2000 | rs=ps.executeQuery(); 2001 | if(rs.next()) 2002 | { 2003 | temp3.add(rs.getString("UserName")); 2004 | temp3.add(Double.toString(rs.getDouble("CurrentPrice"))); 2005 | } 2006 | j--; 2007 | } 2008 | Vector finalMyBidsTable = new Vector(); 2009 | int k=0,x=0; 2010 | while(prodCount>k) 2011 | { 2012 | finalMyBidsTable.add(x++, temp1.get(k)); //ProID 2013 | finalMyBidsTable.add(x++, temp2.get(k)); //ProName 2014 | finalMyBidsTable.add(x++, temp1.get(k+1)); //MyBidPrice 2015 | finalMyBidsTable.add(x++, temp3.get(k+1)); //CurrentPrice[Max Bid]. 2016 | finalMyBidsTable.add(x++, temp3.get(k)); //Max Bidder Username. 2017 | // finalMyBidsTable.add(x++, temp2.get(k+1)); //Image . 2018 | myBidsmodel.addRow(new Object[]{finalMyBidsTable.get(x-5),finalMyBidsTable.get(x-4),finalMyBidsTable.get(x-3),finalMyBidsTable.get(x-2),finalMyBidsTable.get(x-1)}); 2019 | k++; 2020 | 2021 | } 2022 | } 2023 | 2024 | 2025 | } catch (SQLException e) { 2026 | System.out.println("SQLException in MyBids fetch Method."); 2027 | e.printStackTrace(); 2028 | } 2029 | 2030 | } 2031 | 2032 | //-------------------------Fetch Data constantly from the Database to SavedBidsTable .------------- 2033 | 2034 | 2035 | public void savedBidsFetchData(Client c) 2036 | { 2037 | //Remaining:-If user Clicks on a particular row , show MoreInfo panel without save or Sell Button. 2038 | try { 2039 | /* 2040 | myBidsTable.setModel(DbUtils.resultSetToTableModel(rs)); 2041 | */ 2042 | System.out.println("Inside Try Block"); 2043 | String mbtProID=null; 2044 | int prodCount=0; 2045 | Vector temp = new Vector(); //contains only ProductId. 2046 | savedBidsPanel.setVisible(true); 2047 | ps = con.prepareStatement("select ProID from savebidstable where Username=?"); 2048 | ps.setString(1, c.userName); 2049 | rs=ps.executeQuery(); 2050 | 2051 | while(rs.next()) 2052 | { 2053 | mbtProID = rs.getString("ProID"); 2054 | temp.add(mbtProID); 2055 | prodCount++; 2056 | System.out.println("Inside 1st while:"+prodCount); 2057 | } 2058 | Vector temp1 = new Vector(); //Storing the Product Id in the Descending Order. 2059 | for(int z=prodCount-1,y=0;z>=0;z--) 2060 | { 2061 | temp1.add(y++, temp.get(z)); 2062 | } 2063 | Vector temp2 = new Vector(); //Has 3 columns 2064 | 2065 | int i=prodCount-1; 2066 | 2067 | while(i>=0) 2068 | { 2069 | ps = con.prepareStatement("select ProName,UserName,Image from selltable where ProID=?"); 2070 | ps.setString(1, temp.get(i)); 2071 | rs=ps.executeQuery(); 2072 | if(rs.next()) //Will Only get 1 Value. 2073 | { 2074 | temp2.add(rs.getString("ProName")); 2075 | temp2.add(rs.getString("UserName")); 2076 | blob=rs.getBlob("Image"); 2077 | bImg=blob.getBytes(1, (int)blob.length()); 2078 | //ImageIcon imgTemp = new ImageIcon(new ImageIcon().getImage(bImg));//Remaining:-retrieving Image from Database. 2079 | //temp2.add(imgTemp); 2080 | System.out.println("Inside 2nd if"+i); 2081 | } 2082 | i--; 2083 | } 2084 | 2085 | Vector temp3 = new Vector(); //Has 2 Columns. 2086 | int j=prodCount-1; 2087 | 2088 | while(j>=0) 2089 | { 2090 | ps = con.prepareStatement("select CurrentPrice,UserName from bidtable where ProID=?"); 2091 | ps.setString(1, temp.get(j)); 2092 | rs=ps.executeQuery(); 2093 | if(rs.next()) 2094 | { 2095 | temp3.add(rs.getString("UserName")); 2096 | temp3.add(Double.toString(rs.getDouble("CurrentPrice"))); 2097 | System.out.println("Inside 3rd while:"+j); 2098 | } 2099 | j--; 2100 | } 2101 | Vector finalSavedBidsTable = new Vector(); 2102 | int k=0,x=0; 2103 | while(prodCount>k) 2104 | { 2105 | finalSavedBidsTable.add(x++, temp1.get(k)); //ProID 2106 | finalSavedBidsTable.add(x++, temp2.get(k)); //ProName 2107 | finalSavedBidsTable.add(x++, temp2.get(k+1)); //Seller UserName 2108 | finalSavedBidsTable.add(x++, temp3.get(k)); //Max Bidder Username. 2109 | finalSavedBidsTable.add(x++, temp3.get(k+1)); //CurrentPrice[Max Bid]. 2110 | //finalSavedBidsTable.add(x++, temp2.get(k+2)); //Image . 2111 | savedBidsmodel.addRow(new Object[]{finalSavedBidsTable.get(x-5),finalSavedBidsTable.get(x-4),finalSavedBidsTable.get(x-3),finalSavedBidsTable.get(x-2),finalSavedBidsTable.get(x-1)}); 2112 | k++; 2113 | System.out.println("Inside 4th While:"+k); 2114 | } 2115 | 2116 | } catch (SQLException e) { 2117 | System.out.println("SQLException in Saved Bids fetch Method."); 2118 | e.printStackTrace(); 2119 | } 2120 | 2121 | } 2122 | 2123 | 2124 | 2125 | //-------------------------Fetch Data constantly from the Database to MyProductBidsTable .------------- 2126 | 2127 | 2128 | public void myProdFetchData(Client c) 2129 | { 2130 | System.out.println("In myProductFetchData"); 2131 | 2132 | //Remaining:-If user Clicks on a particular row , show MoreInfo panel without save or Sell Button. 2133 | try { 2134 | /* 2135 | myBidsTable.setModel(DbUtils.resultSetToTableModel(rs)); 2136 | */ 2137 | String mbtProID=null; 2138 | vectorMyProdTable = new Vector>(); 2139 | int prodCount=0; 2140 | ps = con.prepareStatement("select ProID from selltable where UserName=?"); 2141 | ps.setString(1, c.userName); 2142 | rs=ps.executeQuery(); 2143 | Vector temp = new Vector(); //contains only ProductId. 2144 | 2145 | 2146 | myProdPanel.setVisible(true); 2147 | System.out.println("in Else"); 2148 | System.out.println("before While"); 2149 | while(rs.next()) 2150 | { 2151 | mbtProID = rs.getString("ProID"); 2152 | temp.add(mbtProID); 2153 | prodCount++; 2154 | System.out.println("In first While: "+prodCount); 2155 | } 2156 | System.out.println("After While"); 2157 | Vector temp1 = new Vector(); //Storing the Product Id in the Descending Order. 2158 | for(int z=prodCount-1,y=0;z>=0;z--) 2159 | { 2160 | temp1.add(y++, temp.get(z)); 2161 | System.out.println("In 2nd While: "+y); 2162 | } 2163 | Vector temp2 = new Vector(); //Has 3 columns 2164 | int i=prodCount-1; 2165 | 2166 | while(i>=0) 2167 | { 2168 | ps = con.prepareStatement("select ProName,BasePrice,Image from selltable where ProID=?"); 2169 | ps.setString(1, temp.get(i)); 2170 | rs=ps.executeQuery(); 2171 | if(rs.next()) //Will Only get 1 Value. 2172 | { 2173 | temp2.add(rs.getString("ProName")); 2174 | temp2.add(Double.toString(rs.getDouble("BasePrice"))); 2175 | blob=rs.getBlob("Image"); 2176 | bImg=blob.getBytes(1, (int)blob.length()); 2177 | //ImageIcon imgTemp = new ImageIcon(new ImageIcon().getImage(bImg));//Remaining:-retrieving Image from Database. 2178 | // temp2.add(imgTemp); 2179 | System.out.println("In 3rd While: "+i); 2180 | } 2181 | i--; 2182 | } 2183 | 2184 | Vector temp3 = new Vector(); //Has 2 Columns. 2185 | i=prodCount-1; 2186 | int j=prodCount-1; 2187 | 2188 | while(j>=0) 2189 | { 2190 | ps = con.prepareStatement("select CurrentPrice,UserName from bidtable where ProID=?"); 2191 | ps.setString(1, temp.get(i)); 2192 | rs=ps.executeQuery(); 2193 | if(rs.next()) 2194 | { 2195 | temp3.add(rs.getString("UserName")); 2196 | temp3.add(Double.toString(rs.getDouble("CurrentPrice"))); 2197 | System.out.println("In 4th While: "+j); 2198 | } 2199 | j--; 2200 | } 2201 | Vector finalmyProdTable = new Vector(); 2202 | int k=0,x=0; 2203 | while(prodCount>k) 2204 | { 2205 | finalmyProdTable.add(x++, temp1.get(k)); //ProID 2206 | finalmyProdTable.add(x++, temp2.get(k)); //ProName 2207 | finalmyProdTable.add(x++, temp2.get(k+1)); //Base Price 2208 | finalmyProdTable.add(x++, temp3.get(k)); //Max Bidder Username. 2209 | finalmyProdTable.add(x++, temp3.get(k+1)); //CurrentPrice[Max Bid]. 2210 | //finalmyProdTable.add(x++, temp2.get(k+2)); //Image . 2211 | myProdmodel.addRow(new Object[]{finalmyProdTable.get(x-5),finalmyProdTable.get(x-4),finalmyProdTable.get(x-3),finalmyProdTable.get(x-2),finalmyProdTable.get(x-1)}); 2212 | k++; 2213 | System.out.println("In add row: " +k); 2214 | 2215 | } 2216 | myProdTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){ 2217 | public void valueChanged(ListSelectionEvent event) { 2218 | // do some actions here, for example 2219 | // print first column value from selected row 2220 | getProID=myProdTable.getValueAt(myProdTable.getSelectedRow(), 0).toString(); 2221 | System.out.println(getProID); 2222 | if(getProID!=null) 2223 | { 2224 | System.out.println("Inside More Info Panel"); 2225 | moreInfoPanel.setVisible(true); 2226 | myProdPanel.setVisible(false); 2227 | try { 2228 | ps=con.prepareStatement("select * from selltable where ProID=?"); 2229 | ps.setString(1, getProID); 2230 | rs=ps.executeQuery(); 2231 | if(rs.next()) 2232 | { 2233 | txtInfoProductName.setText(rs.getString("ProName")); 2234 | txtInfoProductID.setText(rs.getString("ProID")); 2235 | txtInfoBasePrice.setText(rs.getString("BasePrice")); 2236 | txtInfoArProductDetails.setText(rs.getString("ProDetails")); 2237 | txtInfoSPCategory.setText(rs.getString("ProCategory")); 2238 | txtInfoUsername.setText(rs.getString("UserName")); 2239 | blob=rs.getBlob("Image"); 2240 | bImg=blob.getBytes(1, (int)blob.length()); 2241 | //ImageIcon imgTemp = new ImageIcon(new ImageIcon().getImage(bImg));//Remaining:-retrieving Image from Database. 2242 | // txtInfoProductImage.add(imgTemp); 2243 | 2244 | } 2245 | ps=con.prepareStatement("select CurrentPrice from bidtable where ProID=?"); 2246 | ps.setString(1, getProID); 2247 | rs=ps.executeQuery(); 2248 | if(rs.next()) 2249 | { 2250 | txtInfoCurrentPrice.setText(rs.getString("CurrentPrice")); 2251 | } 2252 | } catch (Exception e) { 2253 | System.out.println("Exception in MyProductTable ListSelectionListener."); 2254 | e.printStackTrace(); 2255 | } 2256 | 2257 | } 2258 | } 2259 | }); 2260 | 2261 | System.out.println("Outside ListListener"); 2262 | 2263 | //-------------------Enable the MoreInfoPanel for that Specific ProductId--------------------; 2264 | 2265 | 2266 | 2267 | 2268 | } catch (SQLException e) { 2269 | System.out.println("SQLException in My Product fetch Method."); 2270 | e.printStackTrace(); 2271 | } 2272 | 2273 | } 2274 | 2275 | public int getMyBidsRowCount() 2276 | { 2277 | return myBidsrows.length; 2278 | } 2279 | public int getSavedBidsRowCount() 2280 | { 2281 | return savedBidsrows.length; 2282 | } 2283 | private int setInterval() { 2284 | if (interval == 0) 2285 | timer.cancel(); 2286 | return --interval; 2287 | } 2288 | //------------------------------Validate Info Functions------------------- 2289 | 2290 | public boolean ValidateInfo() 2291 | { 2292 | productName=txtProductName.getText(); 2293 | p = Pattern.compile("[^a-z]", Pattern.CASE_INSENSITIVE); 2294 | m = p.matcher(productName); 2295 | b = m.find(); 2296 | if(b || productName.equalsIgnoreCase("")) 2297 | { 2298 | JOptionPane.showMessageDialog(null,"Invalid Product Name!!",null, JOptionPane.ERROR_MESSAGE); 2299 | txtProductName.requestFocusInWindow(); 2300 | txtProductName.setText(""); 2301 | productName=""; 2302 | return false; 2303 | } 2304 | System.out.println(productName); 2305 | 2306 | productBasePrice=txtBasePrice.getText(); 2307 | p = Pattern.compile("[^0-9]", Pattern.CASE_INSENSITIVE); 2308 | m = p.matcher(productBasePrice); 2309 | b = m.find(); 2310 | if(b || productBasePrice.equalsIgnoreCase("")) 2311 | { 2312 | JOptionPane.showMessageDialog(null,"Invalid Base Price Name!!",null, JOptionPane.ERROR_MESSAGE); 2313 | txtBasePrice.requestFocusInWindow(); 2314 | txtBasePrice.setText(""); 2315 | productBasePrice=""; 2316 | return false; 2317 | } 2318 | System.out.println(productName); 2319 | 2320 | return true; 2321 | } 2322 | } 2323 | --------------------------------------------------------------------------------