Results 1 to 4 of 4

Thread: hellp

  1. #1
    assia is offline Member
    Join Date
    May 2013
    Posts
    3
    Rep Power
    0

    Default hellp

    hello
    i want a help, i begin to create a programm but i have some difficult, i want to use button next and previous, also i want when i press in button "nouvelle mission" "order mission" must be increment by one, this is my code is not complet:

    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;

    import javax.swing.JButton;

    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JTextField;





    public class vehicule extends JFrame implements ActionListener{

    private static final long serialVersionUID = 1L;
    final static String BUTTONPANEL = "Card with JButtons";
    JButton Back = new JButton("Back");
    JLabel lb=new JLabel(" Order de mission:");
    JButton Next = new JButton("Next");
    JTextField bb=new JTextField();
    JLabel bbb=new JLabel(" ");
    JLabel bbb1=new JLabel(" ");
    JLabel bbb2=new JLabel(" ");
    JLabel bbb3=new JLabel(" ");
    JLabel bbb4=new JLabel(" ");
    JLabel bbb5=new JLabel(" ");
    JLabel lbb=new JLabel(" depart:");
    JLabel lbb1=new JLabel(" ");

    JLabel lb1=new JLabel(" Vihecule:");
    JComboBox<String> cmb=new JComboBox<String>();
    JLabel lb2=new JLabel(" date de depart:");
    JTextField txt1=new JTextField();
    JLabel lb3=new JLabel(" heure de depart:");
    JTextField txt2=new JTextField();

    JLabel lb5=new JLabel(" Chauffeur:");
    JTextField txt3=new JTextField();
    JLabel lb7=new JLabel(" Lieu de mission:");
    JTextField txt5=new JTextField();
    JLabel lb8=new JLabel(" L'état en depart:");
    JTextField txt6=new JTextField();
    JLabel lb9=new JLabel(" Km: ");
    JLabel lb10=new JLabel(" depart: ");
    JLabel lb11=new JLabel(" retour: ");
    JTextField txt8=new JTextField();
    JTextField txt7=new JTextField();
    JLabel lb12=new JLabel(" ");
    JLabel lb13=new JLabel(" ");
    JLabel lb14=new JLabel(" ");
    JLabel lb15=new JLabel(" Carburant en depart: ");
    JTextField txt9=new JTextField();
    JLabel lb16=new JLabel(" Reclamation: ");
    JTextField txt10=new JTextField();
    JLabel lbb3=new JLabel(" retour:");
    JLabel lbb4=new JLabel(" ");
    JLabel lb22=new JLabel(" date de retour: ");
    JTextField txt11=new JTextField();
    JLabel lb33=new JLabel(" heure de retour: ");
    JTextField txt22=new JTextField();

    JLabel lb55=new JLabel(" L'etat en retour: ");
    JTextField txt33=new JTextField();
    JLabel lb77=new JLabel(" Carburant en retour: ");
    JTextField txt55=new JTextField();
    JLabel txt18=new JLabel(" ");
    JLabel lb25=new JLabel(" ");
    JLabel txt19=new JLabel(" ");
    JLabel lb26=new JLabel(" ");
    JLabel txt20=new JLabel(" ");
    JLabel lb27=new JLabel(" ");
    JLabel txt21=new JLabel(" ");
    JLabel LB28=new JLabel(" ");
    JLabel LB29=new JLabel(" ");



    JButton btn1=new JButton("enresitrer");
    JButton btn2=new JButton("nouvelle mission");
    JButton btn3=new JButton("annuler");
    JButton btn4=new JButton("imprimer");
    JFrame frm=this;

    public vehicule() {

    JPanel jp=(JPanel)this.getContentPane();
    JPanel j=(JPanel)this.getContentPane();
    this.setTitle("sortie de vihecule");
    JPanel p1=new JPanel();
    JPanel p2=new JPanel();
    JPanel p4=new JPanel();
    JPanel p11=new JPanel();
    JPanel p6=new JPanel();
    p11.setLayout(new GridLayout(2,3));
    p1.setLayout(new GridLayout(15,0));
    p2.setLayout(new GridLayout(15,2));
    p4.setLayout(new GridLayout(15,3));
    p6.setLayout(new GridLayout());

    Back.setActionCommand("Back");
    Next.setActionCommand("Next");


    lbb.setFont(new Font("Serif", Font.BOLD, 20));
    lbb.setForeground(Color.BLUE);
    lbb3.setFont(new Font("Serif", Font.BOLD, 20));
    lbb3.setForeground(Color.BLUE);
    lb1.setFont(new Font("", Font.BOLD, 15));
    lb2.setFont(new Font("", Font.BOLD, 15));
    lb3.setFont(new Font("", Font.BOLD, 15));
    lb5.setFont(new Font("", Font.BOLD, 15));
    lb7.setFont(new Font("", Font.BOLD, 15));
    lb8.setFont(new Font("", Font.BOLD, 15));
    lb9.setFont(new Font("", Font.BOLD, 15));
    lb10.setFont(new Font("", Font.BOLD, 15));
    lb11.setFont(new Font("", Font.BOLD, 15));
    lb12.setFont(new Font("", Font.BOLD, 15));
    lb13.setFont(new Font("", Font.BOLD, 15));
    lb14.setFont(new Font("", Font.BOLD, 15));
    lb15.setFont(new Font("", Font.BOLD, 15));
    lb16.setFont(new Font("", Font.BOLD, 15));
    lb22.setFont(new Font("", Font.BOLD, 15));
    lb33.setFont(new Font("", Font.BOLD, 15));
    lb55.setFont(new Font("", Font.BOLD, 15));
    lb77.setFont(new Font("", Font.BOLD, 15));

    p11.add(bbb);p11.add(bbb2);p11.add(lb);p11.add(bbb 1);p11.add(bbb3);
    p11.add(bbb4);p11.add(Back);p11.add(bb);p11.add(Ne xt);p11.add(bbb5);
    p1.add(lbb1);p2.add(lbb1);
    p1.add(lbb);p2.add(lbb1);
    p1.add(lb1); p2.add(cmb,BorderLayout.NORTH);
    cmb.addItem("PEUGEOT");
    cmb.addItem(".......");
    cmb.addItem("......");
    p1.add(lb2);
    p2.add(txt1);
    p1.add(lb3);p2.add(txt2);
    p1.add(lb5);p2.add(txt3);

    p1.add(lb7);p2.add(txt5);
    p1.add(lb8);p2.add(txt6);
    p1.add(lb14);
    p1.add(lb9);p2.add(lb10);p2.add(txt7);
    p2.add(lb11);p2.add(txt8);
    p1.add(lb12);p1.add(lb13);
    p1.add(lb15);p2.add(txt9);
    p1.add(lb16);p2.add(txt10);
    p4.add(lbb3);p4.add(lbb4);
    p4.add(lb25);p4.add(lb26);
    p4.add(lb22);p4.add(txt11);
    p4.add(lb33);p4.add(txt22);
    p4.add(lb55);p4.add(txt33);
    p4.add(lb77);p4.add(txt55);
    p4.add(txt18);p4.add(txt19);
    p4.add(txt20);p4.add(txt21);
    p4.add(txt18);p4.add(txt19);
    p4.add(lb27);
    p4.add(LB28);p4.add(LB29);



    JPanel p3=new JPanel();
    p3.setLayout(new GridLayout(1,4));
    p3.add(btn1);p3.add(btn2);p3.add(btn3);p3.add(btn4 );
    jp.setLayout(new BorderLayout());
    j.setLayout(new BorderLayout());

    jp.add(p11,BorderLayout.NORTH);
    jp.add(p1,BorderLayout.WEST);
    jp.add(p2,BorderLayout.CENTER);
    jp.add(p3,BorderLayout.SOUTH);
    jp.add(p4,BorderLayout.EAST);



    btn1.addActionListener(this);
    btn2.addActionListener(this);
    btn3.addActionListener(this);
    this.setSize(900,550);
    this.setVisible(true);
    this.setResizable(false);


    }
    public void actionPerformed1(ActionEvent e)
    {
    if(e.getSource()==btn1)
    {
    try{
    String vec="";
    String csex= cmb.getSelectedItem().toString();
    if(vec=="PEUGEOT"){

    csex="PEUGEOT";

    }

    if(vec==" "){csex=" ";}
    if(vec==" "){csex=" ";}
    Class.forName("com.mysql.jdbc.Driver");
    Connection con= (Connection) DriverManager.getConnection("jdbc:mysql://localhost/auo","root","");
    Statement cmd= (Statement) con.createStatement();
    cmd.execute(
    "insert into depart values('"+csex+"','"+txt1.getText()+"','"+txt2.get Text()+"','"+txt3.getText()+"','"+txt5.getText()+" ','"+txt6.getText()+"','"+txt7.getText()+"','"+txt 8.getText()+"','"+txt9.getText()+"','"+txt10.getTe xt()+"')");
    JOptionPane.showMessageDialog(frm,"bien enregistrer");
    }
    catch(Exception ex)
    {
    System.out.println(ex);
    }
    }
    if(e.getSource()==btn2)
    {

    // ORDRE DE MISSION
    txt1.setText(""); //DATE DE EPART
    txt1.repaint(); //DATE DE DEPART
    txt2.setText(""); //HEUR DE DEPART
    txt2.repaint(); //HEURE DE DEPART
    txt3.setText(""); //CHAFFEUR
    txt3.repaint(); //CHAUFFEUR
    txt5.setText(""); //LIEU DE MISSION
    txt5.repaint(); // LIEU DE MISSION
    txt6.setText(""); //L4ETAT EN DEPART
    txt6.repaint(); //L'ETAT EN DEPART
    txt7.setText(""); //KM DEPART
    txt7.repaint(); //KM DEPART
    txt8.setText(""); //KM RETOUR
    txt8.repaint(); //KM RETOUR
    txt9.setText(""); // CARBURANT DEPART
    txt9.repaint(); // CARBURANT DEPART
    txt10.setText(""); // RECLAMATION
    txt10.repaint(); // RECLAMATION
    txt11.setText(""); //DATE DE RETOUR
    txt11.repaint(); //DATE DE RETOUR
    txt22.setText(""); // HEURE DE RETOUR
    txt22.repaint(); // HEURE DE RETOUR
    txt33.setText(""); //L'ETAT EN RETOUR
    txt33.repaint(); //L'ETAT EN RETOUR
    txt55.setText(""); // CARBURANT EN RETOUR
    txt55.repaint(); //Carburant en retour
    }
    if(e.getSource()==btn3)
    {
    login obj=new login();
    obj.setVisible(true);
    obj.setSize(300,230);
    this.dispose();
    }
    if(e.getSource()==btn4)
    {

    }
    }




    @Override
    public void actionPerformed(ActionEvent e) {
    // TODO Auto-generated method stub

    }
    public static void main(String[] args) {
    new vehicule();

    }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default Re: hellp

    I'm going to move this to New To Java.
    Also, when posting code please wrap it in [code] tags [/code]. Many members won't bother reading unformatted code.

    What is your code doing now?
    What should it be doing?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    assia is offline Member
    Join Date
    May 2013
    Posts
    3
    Rep Power
    0

    Default Re: hellp

    this my code, is not full, i want when press in button "nouvelle mission" all text repaint just of "order mission" must be increment by 1 (this case is not text, is a number)

    Java Code:
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Font;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    
    import javax.swing.JButton;
    
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    
    
    
    
    
    public class vehicule extends JFrame implements ActionListener{
    
    	private static final long serialVersionUID = 1L;
    	final static String BUTTONPANEL = "Card with JButtons";
    	JButton Back = new JButton("Back");
    	 JLabel lb=new JLabel("       Order de mission:");
    	 JButton Next = new JButton("Next");
    	 JTextField bb=new JTextField();
    	 JLabel bbb=new JLabel("                  ");
    	 JLabel bbb1=new JLabel("                  ");
    	 JLabel bbb2=new JLabel("                  ");
    	 JLabel bbb3=new JLabel("                  ");
    	 JLabel bbb4=new JLabel("                                                  ");
    	 JLabel bbb5=new JLabel("                                                  ");
    	 JLabel lbb=new JLabel("              depart:");
    	 JLabel lbb1=new JLabel("  ");
    	 
    	 JLabel lb1=new JLabel("               Vihecule:");   
         JComboBox<String> cmb=new JComboBox<String>();
         JLabel lb2=new JLabel("               date de depart:");
         JTextField txt1=new JTextField();
         JLabel lb3=new JLabel("               heure de depart:");
         JTextField txt2=new JTextField();
        
         JLabel lb5=new JLabel("               Chauffeur:");
         JTextField txt3=new JTextField();
         JLabel lb7=new JLabel("               Lieu de mission:");
         JTextField txt5=new JTextField();
         JLabel lb8=new JLabel("               L'état en depart:");
         JTextField txt6=new JTextField();
         JLabel lb9=new JLabel("               Km:  ");
         JLabel lb10=new JLabel("       depart:  ");
         JLabel lb11=new JLabel("       retour:   ");
         JTextField txt8=new JTextField();
         JTextField txt7=new JTextField();
         JLabel lb12=new JLabel("         ");
         JLabel lb13=new JLabel("        ");
         JLabel lb14=new JLabel("     ");
         JLabel lb15=new JLabel("               Carburant en depart: ");
         JTextField txt9=new JTextField();
         JLabel lb16=new JLabel("               Reclamation: ");
         JTextField txt10=new JTextField();
         JLabel lbb3=new JLabel("              retour:");
    	 JLabel lbb4=new JLabel("                  ");
    	 JLabel lb22=new JLabel("               date de retour:                      ");
         JTextField txt11=new JTextField();
         JLabel lb33=new JLabel("               heure de retour:                     ");
         JTextField txt22=new JTextField();
        
         JLabel lb55=new JLabel("               L'etat en retour:                ");
         JTextField txt33=new JTextField();
         JLabel lb77=new JLabel("               Carburant en retour:             ");
         JTextField txt55=new JTextField();
         JLabel txt18=new JLabel("                             ");
         JLabel lb25=new JLabel("                               ");
         JLabel txt19=new JLabel("                              ");
         JLabel lb26=new JLabel("                                  ");
         JLabel txt20=new JLabel("                               ");
         JLabel lb27=new JLabel("                             ");
         JLabel txt21=new JLabel("                             ");
         JLabel LB28=new JLabel("      ");
         JLabel LB29=new JLabel("      ");
    	 
        
        
    	 JButton btn1=new JButton("enresitrer");   
         JButton btn2=new JButton("nouvelle mission");   
         JButton btn3=new JButton("annuler");
         JButton btn4=new JButton("imprimer");
         JFrame frm=this;
        
    	 public vehicule() {
         	
         	JPanel jp=(JPanel)this.getContentPane();   
         	JPanel j=(JPanel)this.getContentPane();  
             this.setTitle("sortie de vihecule");
             JPanel p1=new JPanel();
             JPanel p2=new JPanel();
             JPanel p4=new JPanel();
             JPanel p11=new JPanel();
             JPanel p6=new JPanel();
             p11.setLayout(new GridLayout(2,3));
             p1.setLayout(new GridLayout(15,0));
             p2.setLayout(new GridLayout(15,2));
             p4.setLayout(new GridLayout(15,3));
             p6.setLayout(new GridLayout()); 
             
             Back.setActionCommand("Back");
             Next.setActionCommand("Next");
             
             
             lbb.setFont(new Font("Serif", Font.BOLD, 20));
             lbb.setForeground(Color.BLUE);
             lbb3.setFont(new Font("Serif", Font.BOLD, 20));
             lbb3.setForeground(Color.BLUE);
             lb1.setFont(new Font("", Font.BOLD, 15));
             lb2.setFont(new Font("", Font.BOLD, 15));
             lb3.setFont(new Font("", Font.BOLD, 15));
             lb5.setFont(new Font("", Font.BOLD, 15));
             lb7.setFont(new Font("", Font.BOLD, 15));
             lb8.setFont(new Font("", Font.BOLD, 15));
             lb9.setFont(new Font("", Font.BOLD, 15));
             lb10.setFont(new Font("", Font.BOLD, 15));
             lb11.setFont(new Font("", Font.BOLD, 15));
             lb12.setFont(new Font("", Font.BOLD, 15));
             lb13.setFont(new Font("", Font.BOLD, 15));
             lb14.setFont(new Font("", Font.BOLD, 15));
             lb15.setFont(new Font("", Font.BOLD, 15));
             lb16.setFont(new Font("", Font.BOLD, 15));
             lb22.setFont(new Font("", Font.BOLD, 15));
             lb33.setFont(new Font("", Font.BOLD, 15));
             lb55.setFont(new Font("", Font.BOLD, 15));
             lb77.setFont(new Font("", Font.BOLD, 15));
             
             p11.add(bbb);p11.add(bbb2);p11.add(lb);p11.add(bbb1);p11.add(bbb3);
             p11.add(bbb4);p11.add(Back);p11.add(bb);p11.add(Next);p11.add(bbb5);
             p1.add(lbb1);p2.add(lbb1);
             p1.add(lbb);p2.add(lbb1);
             p1.add(lb1); p2.add(cmb,BorderLayout.NORTH); 
             cmb.addItem("PEUGEOT");   
             cmb.addItem(".......");
             cmb.addItem("......");
             p1.add(lb2);
             p2.add(txt1);
             p1.add(lb3);p2.add(txt2);
             p1.add(lb5);p2.add(txt3);
             
             p1.add(lb7);p2.add(txt5);
             p1.add(lb8);p2.add(txt6);
             p1.add(lb14);
             p1.add(lb9);p2.add(lb10);p2.add(txt7);
             p2.add(lb11);p2.add(txt8);
             p1.add(lb12);p1.add(lb13);
             p1.add(lb15);p2.add(txt9);
             p1.add(lb16);p2.add(txt10);
             p4.add(lbb3);p4.add(lbb4);
             p4.add(lb25);p4.add(lb26);
             p4.add(lb22);p4.add(txt11);
             p4.add(lb33);p4.add(txt22);
             p4.add(lb55);p4.add(txt33);
             p4.add(lb77);p4.add(txt55);
             p4.add(txt18);p4.add(txt19);
             p4.add(txt20);p4.add(txt21);
             p4.add(txt18);p4.add(txt19);
             p4.add(lb27);
             p4.add(LB28);p4.add(LB29);
             
             
             
             JPanel p3=new JPanel();   
             p3.setLayout(new GridLayout(1,4));   
             p3.add(btn1);p3.add(btn2);p3.add(btn3);p3.add(btn4); 
             jp.setLayout(new BorderLayout());  
             j.setLayout(new BorderLayout());
             
             jp.add(p11,BorderLayout.NORTH); 
             jp.add(p1,BorderLayout.WEST); 
             jp.add(p2,BorderLayout.CENTER); 
             jp.add(p3,BorderLayout.SOUTH);
             jp.add(p4,BorderLayout.EAST);
             
             
             
             btn1.addActionListener(this);   
             btn2.addActionListener(this);      
             btn3.addActionListener(this);
             this.setSize(900,550);   
             this.setVisible(true);
             this.setResizable(false); 
             
             
    	 }
    	 public void actionPerformed1(ActionEvent e)   
         {   
             if(e.getSource()==btn1)   
             {   
             try{   
                 String vec="";   
    				String csex= cmb.getSelectedItem().toString();   
                 if(vec=="PEUGEOT"){
                 	
                 	csex="PEUGEOT";   
                 	
                 } 
                 
                 if(vec==" "){csex=" ";}  
                 if(vec==" "){csex=" ";}
                 Class.forName("com.mysql.jdbc.Driver");   
                 Connection con= (Connection) DriverManager.getConnection("jdbc:mysql://localhost/auo","root","");   
                 Statement cmd= (Statement) con.createStatement();   
             cmd.execute(   
              "insert into  depart values('"+csex+"','"+txt1.getText()+"','"+txt2.getText()+"','"+txt3.getText()+"','"+txt5.getText()+"','"+txt6.getText()+"','"+txt7.getText()+"','"+txt8.getText()+"','"+txt9.getText()+"','"+txt10.getText()+"')");   
               JOptionPane.showMessageDialog(frm,"bien enregistrer");   
                 }   
                catch(Exception ex)   
                     {        
                         System.out.println(ex);   
                     }      
             }   
             if(e.getSource()==btn2)   
             {   
            	                     // ORDRE DE MISSION
                 
            	 txt1.setText("");  //DATE DE EPART 
                 txt1.repaint();    //DATE DE DEPART
                 txt2.setText("");   //HEUR DE DEPART
                 txt2.repaint();     //HEURE DE DEPART
                 txt3.setText("");   //CHAFFEUR
                 txt3.repaint();     //CHAUFFEUR
                 txt5.setText("");   //LIEU DE MISSION
                 txt5.repaint();     // LIEU DE MISSION
                 txt6.setText("");   //L4ETAT EN DEPART
                 txt6.repaint();    //L'ETAT EN DEPART
                 txt7.setText("");   //KM DEPART
                 txt7.repaint();     //KM DEPART
                 txt8.setText("");   //KM RETOUR
                 txt8.repaint();     //KM RETOUR
                 txt9.setText("");   // CARBURANT DEPART
                 txt9.repaint();    // CARBURANT DEPART
                 txt10.setText("");  // RECLAMATION 
                 txt10.repaint();   // RECLAMATION
                 txt11.setText("");   //DATE DE RETOUR
                 txt11.repaint();     //DATE DE RETOUR
                 txt22.setText("");   // HEURE DE RETOUR
                 txt22.repaint();    // HEURE DE RETOUR
                 txt33.setText("");   //L'ETAT EN RETOUR
                 txt33.repaint();     //L'ETAT EN RETOUR
                 txt55.setText("");   // CARBURANT EN RETOUR
                 txt55.repaint();    //Carburant en retour
             }   
             if(e.getSource()==btn3)   
             {   
                 login obj=new login();    
                 obj.setVisible(true);   
                 obj.setSize(300,230);   
                 this.dispose();   
             }  
             if(e.getSource()==btn4)   
             {   
                    
             } 
         }   
    	 
    	 
    	 
    	 
    	@Override
    	public void actionPerformed(ActionEvent e) {
    		// TODO Auto-generated method stub
    		
    	}
    	public static void main(String[] args) {
        	new vehicule();
        
        	}
    }

  4. #4
    assia is offline Member
    Join Date
    May 2013
    Posts
    3
    Rep Power
    0

    Default Re: hellp

    this program for:
    - when a vehicle want to out in mission, we must enter: mission order, as they depart ( name of vehicle,date and time, driver, place, the state car, fuel) and when the vehcle return to the garage we need to register that (date and time, state, and fuel)

Similar Threads

  1. hellp with loops required!!!
    By sr2000 in forum New To Java
    Replies: 1
    Last Post: 11-30-2009, 07:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •