Package user

Source Code of user.User

package user;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Timer;
import java.util.TimerTask;

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import main.ILanguage;
import menu.MainMenu;
import database.DbwDBConnection;

public class User extends JFrame implements IUser, ILanguage{
  /**
   *
   */
  private static final long serialVersionUID = -4133129596263369617L;
  private String       userName;
  private DbwDBConnection dataBaseConnection;
  Timer t;
  @SuppressWarnings("unused")
  private Container     pane;
  public User(String userName, String title){
    super(TOP_TITLE + " " +title);
    this.userName=userName;
    pane = this.getContentPane();
    dataBaseConnection=new DbwDBConnection();

    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent e) {
        int retour = JOptionPane.showConfirmDialog(User.this,EXIT_MESSAGE, EXIT_CONFIRMATION,JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
        if (retour == JOptionPane.YES_OPTION){
          dataBaseConnection.disconnectUser(User.this.userName);
          System.exit(0);

        }
      }

    });

    createComponents();
   
    this.setSize(700, 300);
    //this.setLocation(300, 300);
    this.pack();
    this.setVisible(true);
  }

  public void createComponents(){

    this.setJMenuBar(new MainMenu(userName));

    this.setLayout(new BorderLayout());
    //this.RepetAction();
    this.add(new PanelTop(userName),BorderLayout.NORTH);
    this.add(new PanelBottom(userName),BorderLayout.SOUTH);
  }
  public void RepetAction() {
    t = new Timer();
    t.schedule(new MonAction(), 0, 5*1000);
  }

  class MonAction extends TimerTask {
    int nbrRepetitions = 5;

    public void run() {
      if (nbrRepetitions > 0) {
        System.out.println("Ca bosse dur!");
       
        User.this.repaint();
        //User.this.validate();
        User.this.add(new PanelTop(userName),BorderLayout.NORTH);
        User.this.add(new PanelBottom(userName),BorderLayout.SOUTH);
       
        User.this.validate();
        User.this.repaint();
       
        nbrRepetitions--;
      } else {
        System.out.println("Terminé!");
        t.cancel();
      }
    }
  }
  public static void main (String [] args){
  //  new User("imad");


  }

}
TOP

Related Classes of user.User

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.
ga('create', 'UA-20639858-1', 'auto'); ga('send', 'pageview');