Hi every one,
I need ur help on this part of my project i cant know to solve it and i done what i can....
the problems are:
1- the time must be update with time of computer but i cant do it just I take the current time???
2- the second problem is the table I need it to be embedded in the search fram not on other fram Also it has some problem i cant to fixed it,
Please help me.

all the clas and datBase are attachment.

can u elaborate in detail

can u elaborate in detail

package lrc;



import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

import java.sql.*;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;




public class Search extends JFrame {

	private static final long serialVersionUID = 1L;
	
    private static JLabel wel_library;
    static String usname;
     String stat;
     int Copies;
	Db d=new Db();  //  @jve:decl-index=0:
	ShowCurrentTime tim =new ShowCurrentTime();  //  @jve:decl-index=0:
	private JLabel logo = null;
	private JLabel logo2 = null;
	ImageIcon college = new ImageIcon("sd1.JPG");
	ImageIcon college2 = new ImageIcon("sd.JPG");
	private JTabbedPane jp;
	private int user;
	private JLabel logo1;
	
///////////////////////////////////Search  component\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
	
    private JPanel search_pan;
    
	private JLabel lbSearch;
	private JButton btnFind;
	
	private JTextField txtSearch;
	private JRadioButton rb1,rb2,rb3,rb4;
	private int flag=0;

	private String bname,bauthor,bid,bcat,search;
	private int bmid,rows=0;
	private JTable table;
	private JScrollPane jsp;
	private Object data1[][];
 
   
    public Search() {
    	usrdetail();
        initComponents();
     
    }
    
   
    
    private void initComponents() {
    	
    	this.setSize(20000, 775);
    	 getContentPane().setLayout(null);
        jp = new JTabbedPane();
        logo1 = new JLabel(college2);
		logo1.setBounds(new Rectangle(2, 625, 1282, 192));
        
        wel_library = new JLabel();
        
        JLabel dateT = new JLabel();
        
        
      
        search_pan = new JPanel();
        

    
        //////////////////////////////Search component\\\\\\\\\\\\\\\\\\\\\\\\\
        
       
        
        wel_library.setFont(new java.awt.Font("Tahoma", 3, 15));
        wel_library.setHorizontalAlignment(SwingConstants.CENTER);
        wel_library.setText("Welcome"+":  "+ usname);
   
        wel_library.setBounds(0, 0, 200, 50);
       
       
        
    Calendar cal = new GregorianCalendar();
    String hour = String.valueOf(cal.get(Calendar.HOUR));
    String minute = String.valueOf(cal.get(Calendar.MINUTE));
    String second = String.valueOf(cal.get(Calendar.SECOND));
        
    dateT.setText(hour + ":" + minute + ":" + second);
    
    TimeZone timeZone = TimeZone.getTimeZone("CST");
       
        DateFormat formatter = DateFormat.getDateTimeInstance(
        		  DateFormat.FULL, DateFormat.FULL, Locale.US);

		formatter.setTimeZone(timeZone);


        dateT.setFont(new java.awt.Font("Tahoma", 3, 15));
        dateT.setHorizontalAlignment(SwingConstants.CENTER);
        
        GregorianCalendar calendar = new GregorianCalendar();

      
   
        dateT.setBounds(640, 0, 620, 50);
       
        lbSearch = new JLabel ("Search Field");
        lbSearch.setFont(new Font("Tahoma", 3, 18));
		lbSearch.setForeground (Color.black);
		lbSearch.setBounds (115, 95, 200, 20);
		
		txtSearch = new JTextField ();
		txtSearch.setFont(new Font("Tahoma", 3, 18));
		txtSearch.setBounds (260, 85, 340, 35);

		btnFind = new JButton ("Find Book");
		btnFind.setFont(new Font("Tahoma", 3, 18));
		btnFind.setBounds (260, 320, 225, 25);
	
		rb1=new JRadioButton("By Title");
		rb1.setFont(new Font("Tahoma", 3, 18));
		rb1.addActionListener(new ActionListener() {
		      public void actionPerformed(ActionEvent e) {
		         flag=0;
		        }
		      });

	
		rb1.setBounds (260, 155, 200, 20);
		rb2=new JRadioButton("By Author");
		rb2.setFont(new Font("Tahoma", 3, 18));
		rb2.addActionListener(new ActionListener() {
		      public void actionPerformed(ActionEvent e) {
		         flag=1;
		        }
		      });
		rb2.setBounds (260, 195, 200, 20);
		rb3=new JRadioButton("By Category");
		rb3.setFont(new Font("Tahoma", 3, 18));
		rb3.addActionListener(new ActionListener() {
		      public void actionPerformed(ActionEvent e) {
		         flag=2;
		        }
		      });
		rb3.setBounds (260, 235, 200, 20);
		rb4=new JRadioButton("By id");
		rb4.setFont(new Font("Tahoma", 3, 18));
		rb4.addActionListener(new ActionListener() {
		      public void actionPerformed(ActionEvent e) {
		         flag=3;
		        }
		      });
		rb4.setBounds(260,275,200,20);
		
		search_pan.setLayout (null);
	     search_pan.add(wel_library);
	     search_pan.add(dateT);
		search_pan.add(lbSearch);
		search_pan.add(txtSearch);
		search_pan.add(btnFind);
			
		TestTable tt= new TestTable();
		
					    
			     
		btnFind.addActionListener(new ActionListener(){
  			public void actionPerformed(ActionEvent evt)
			{
  				if (txtSearch.getText().equals ("")) {
  					JOptionPane.showMessageDialog((Component) null, "Search Field not Provided. ", " Error", JOptionPane.ERROR_MESSAGE);
  				
  					txtSearch.requestFocus ();
  				}
  				else 
  				{
  				
  				search();
  				}
			}
		 });
		//search_pan.add(btnCancel);
		rb1.setBackground( Color.white);
		rb2.setBackground( Color.white);
		rb3.setBackground( Color.white);
		rb4.setBackground( Color.white);
		ButtonGroup bg=new ButtonGroup();
		bg.add(rb1);
		bg.add(rb2);
		bg.add(rb3);
		bg.add(rb4);
		search_pan.add(rb1);
		search_pan.add(rb2);
		search_pan.add(rb3);
		search_pan.add(rb4);
		search_pan.setBackground( Color.white);
		
		rb1.setSelected(true);
		
		
		
		

        
        

    
        jp.addTab("SERCH BOOK",new ImageIcon("SEARCH.PNG") , search_pan);
      

        setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        jp.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
       
        logo = new JLabel(college);
		logo.setBounds(new Rectangle(2, 1, 1282, 172));
		getContentPane().add(logo);
		
		  logo2 = new JLabel(college2);
	
			logo2.setBounds(new Rectangle(2, 625, 1282, 192));
			getContentPane().add(logo2);

        
        
        getContentPane().add(jp);
        jp.setBounds(0, 170, 2000,600);
        getContentPane().setBackground( Color.WHITE);

      
		setTitle("Search Page");
		setVisible(true);
    }// 

    
    
    protected void search() {
    	String bname1,bauthor1,bcat1,bID;
		int num;
		boolean found = false;				//To Confirm the Book's Id Existance.
		d.ConnectionDB();
		  try
		  {
			  String q,bavl,bisr;
				num=d.stat.executeUpdate("Delete * from bksearch");
				ResultSet rs = d.stat.executeQuery ("SELECT * FROM BookT ");	 //Executing the Query.
				
				search=txtSearch.getText();
				search=search.toLowerCase();
				search=search.trim();
				
				while(rs.next())
				{
					
					bname=rs.getString(2);
					bauthor=rs.getString(3);
					bcat=rs.getString(7);
					bid=rs.getString(1);
					bmid=rs.getInt(6);
					if(bmid>0) bavl="Available";
					else bavl="Issued";
					
					
					
					if(flag==0)
					{
					
						bname1=bname.toLowerCase();
						if(bname1.equals(search))
						{
							System.out.println("Came Here2");
						    num=d.stat.executeUpdate("insert into bksearch values('"+bid+"', '"+bname+"','"+bcat+"','"+bauthor+"' , '"+bavl+"')");
							System.out.println("gg");
						    rows++;
						    found=true;
							System.out.println("bookname");
						}
					}
					else if(flag==1)
					{
						bauthor1=bauthor.toLowerCase();
						if(bauthor1.equals(search))
						{
							num=d.stat.executeUpdate("insert into bksearch values('"+bid+"', '"+bname+"' , '"+bcat+"' , '"+bauthor+"' , '"+bavl+"')");
							rows++;
							found=true;
							System.out.println("auther");
						}
					}
					else if(flag==2)
					{
						bcat1=bcat;
						if(bcat1.equals(search))
						{
							num=d.stat.executeUpdate("insert into bksearch values("+bid+", '"+bname+"' , '"+bcat+"' , '"+bauthor+"' , '"+bavl+"')");
							rows++;
							found=true;
							System.out.println("catagory");
						}
					}
					else if(flag==3)
					{
					
						bID=bid.toLowerCase();
						if(bid.equals(search))
						{
							System.out.println("ID");
					 
							num=d.stat.executeUpdate("insert into bksearch values("+bid+", '"+bname+"' , '"+bcat+"' , '"+bauthor+"' , '"+bavl+"')");
						      rows++;
							found=true;
							System.out.println("id");
						}
					}
					
				}
				
		  }
		  catch(SQLException ex)
		   {
		   if (found == false) {
					JOptionPane.showMessageDialog (this, "Record not Found.");
				}
		   }
		
		
			if(found==true){
			
			try{
			data1=new Object[rows][5];
			
			Object[] Colheads={"Book Id","Book Name","Category","Author","Availability"};
			ResultSet rs=d.stat.executeQuery("Select * from bksearch");
		
			for(int i1=0;i1<rows;i1++)
			{
					rs.next();
					for(int j1=0;j1<5;j1++)
					{
						data1[i1][j1]=rs.getString(j1+1);
					}
			}
			//rs.close();
				//	.close();
				//	con.close();
			table=new JTable(data1,Colheads);
			int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
			int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
			System.out.println("hai we came here");
			jsp=new JScrollPane(table,v,h);
			TableDisp td=new TableDisp(table);
		
			
			}
			catch(Exception sqlex) {
				if (found == false) {
					JOptionPane.showMessageDialog (this, "Some prob Found.");
				}
			}
		}
		

    

		
		
	}


                                                
    
    /**
     * @param args the command line arguments
     */
 
    
    // Variables declaration - do not modify
  
    
     void usrdetail(){
    	d.ConnectionDB();
			  try
			  {
				  int n =Login.id;
					
			   		
			   		//String s ="SELECT * FROM User WHERE User_Id = "+Login.id+" ";
			   		ResultSet rs=d.stat.executeQuery("SELECT * FROM User WHERE User_Id ="+n+" ");
			   	
					while(rs.next()){
					
						
						 usname = rs.getString(3);
						
					}
				    System.out.println(usname);
					
			  }catch(SQLException ex)
			
			  {
	               System.out.println("Exception22 raised is:"+ex);
	           
				  
			  }
		}
    
    
  
	

}

problems in details :
1- when i want to search about the book tital it'll appear to me one book if there are more than one book with same name .same problems with others choices ( author , category , etc .. )

2- assume that i did the first search and i want to do another search it will not give me any result .

3- the search result will appear in a new frame . i want to appear it in the same frame.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.