yiann_is's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
16 (0.02 per day)
Joined:
25-December 12
Profile Views:
310
Last Active:
User is offline Aug 02 2013 02:34 PM
Currently:
Offline

Previous Fields

Country:
GR
OS Preference:
Who Cares
Favorite Browser:
Chrome
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Playstation
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   yiann_is has not set their status

Posts I've Made

  1. In Topic: Retreive data from a database, java

    Posted 2 Aug 2013

    View Postg00se, on 02 August 2013 - 12:32 PM, said:

    Quote

    Is there another way to compare the stored data (registered username)with the input data (login)
    Is that your use case? If so, why are you querying for every username instead of just the one entered?


    you are right!i did like you said. Now i want to get the pass from the specific user and compare it. I thought to write it like that, but i get an error Illegal operation on empty result set
    if(puname.equals(username)) {
    					System.out.println(puname);
    					String queryPass= "select password from userdata where username='puname'";
    					rs2 = st.executeQuery(queryPass);
    					String passdb=rs2.getString("password");
    					System.out.println("pass"+passdb);
    
  2. In Topic: Retreive data from a database, java

    Posted 2 Aug 2013

    View Postg00se, on 01 August 2013 - 02:34 PM, said:

    Try
    http://technojeeves....-to-nested-list

    In your case, nesting might not be necessary, so adapt


    i can't adapt it, or i can't understand what and how it works. Is there another way to compare the stored data (registered username)with the input data (login)
  3. In Topic: multiple jlabels in a loop, java

    Posted 29 Jul 2013

    Thanks Martyr2, it works fine!Just had to do some changes to run the new program.
  4. In Topic: multiple jlabels in a loop, java

    Posted 29 Jul 2013

    ok,this code shows the names of my files but it shows the label on top of another. For example, i have two files and it creates 10 labels with its label the names of the two files. Probably 10 labels, to fill all the space of panel?
  5. In Topic: multiple jlabels in a loop, java

    Posted 28 Jul 2013

    Ok, here is my code
    import javax.swing.*;
    
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.font.TextAttribute;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Map;
    
    public class searchFrame extends JFrame {
    
    JLabel bsearch= new JLabel ("Search by name: ");
    JTextField txsearch = new JTextField(25);
    JButton bgo = new JButton("Go");
    JLabel allsearch= new JLabel ("All files");
    JLabel result=new JLabel ();
    JPanel panel = new JPanel();
    
    searchFrame(){
    super("Search frame");
    setSize(260,400);
    setLocation(500,280);
    panel.setLayout (null); 
    
    bsearch.setBounds(10,40,100,20);
    txsearch.setBounds(120,40,70,20);
    bgo.setBounds(195,40,55,20);
    allsearch.setBounds(10,70,80,20);
    result.setBounds(10,100,80,20);
    
    panel.add(bsearch);
    panel.add(txsearch);
    panel.add(bgo);
    panel.add(allsearch);
    panel.add(result);
    
    getContentPane().add(panel);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
    actionsearch();
    mouseactionlabel();
    }
    
    public void actionsearch(){
    bgo.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    	String path1="C:/Documents and Settings/giannis/Desktop/Server/";
    	String fileName = "";
    	        try{
    			fileName = txsearch.getText();
    			File directory = new File(path1);
                            File[] listOfFiles = directory.listFiles();
                            int c=0;
                            for (File file : listOfFiles ) {
                                    String name = file.getName();
                                    
    								    if (name.equals(fileName)) {
                                        result.setText(fileName);
    									long size=file.length();
    									long modified=file.lastModified();									
    									 c=1;
    										System.out.println("File found..");
    										System.out.println("File size"+size);
    										System.out.println("File modified"+modified);
    									}
    								    
    								    }if (c!=1){
    								    	System.out.println("File not found..");
    								    	result.setText("Not found");
    								    }}
    		catch(Exception e){
                e.printStackTrace();
            }                                       
                            	
    }
    });
    }
    
    void mouseactionlabel(){
    allsearch.addMouseListener(new MouseListener() {
    public void mouseClicked(MouseEvent arg0) {
    	String path1="C:/Documents and Settings/giannis/Desktop/Server/";
    	
    	        try{
    	        	
    	        	File directory = new File(path1);
    	        	File[] listOfFiles = directory.listFiles();
                    int c1 = directory.listFiles().length;
                    System.out.println(c1);
                    JLabel[] labels = new JLabel[c1];
                    
                    for (File file : listOfFiles ) {
                        
                    for (int i = 0 ;i < c1; i++)
                    {     
                    	for(int v = 120; v <= 300; v += 20){
                    		String name = file.getName();
                    		labels[i] = new JLabel();
                    		labels[i].setBounds(10,v,80,20);
                    		labels[i].setText(name);                		
                    		panel.add(labels[i]);
                    		
                   	
                    }}
    									}
    								    
    								    }
    		catch(Exception e){
                e.printStackTrace();
            }
    }
    public void mouseEntered(MouseEvent arg0) {
    }
    public void mouseExited(MouseEvent arg0) {
    }
    public void mousePressed(MouseEvent arg0) {
    }
    public void mouseReleased(MouseEvent arg0) {
    }
    });
    }
    }
    
    

My Information

Member Title:
New D.I.C Head
Age:
25 years old
Birthday:
December 23, 1988
Gender:
Location:
Athens

Contact Information

E-mail:
Click here to e-mail me

Friends

yiann_is hasn't added any friends yet.

Comments

yiann_is has no profile comments yet. Why not say hello?