public TaskbarPositionTest() {
    super("Use CTRL-down to show a JPopupMenu");
    setContentPane(panel = createContentPane());
    setJMenuBar(createMenuBar("1 - First Menu", true));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // CTRL-down will show the popup.
    panel
        .getInputMap()
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_MASK), "OPEN_POPUP");
    panel.getActionMap().put("OPEN_POPUP", new PopupHandler());

    pack();

    Toolkit toolkit = Toolkit.getDefaultToolkit();
    fullScreenBounds = new Rectangle(new Point(), toolkit.getScreenSize());
    screenBounds = new Rectangle(new Point(), toolkit.getScreenSize());

    // Place the frame near the bottom. This is a pretty wild guess.
    this.setLocation(0, (int) screenBounds.getHeight() - 2 * this.getHeight());

    // Reduce the screen bounds by the insets.
    GraphicsConfiguration gc = this.getGraphicsConfiguration();
    if (gc != null) {
      Insets screenInsets = toolkit.getScreenInsets(gc);
      screenBounds = gc.getBounds();
      screenBounds.width -= (screenInsets.left + screenInsets.right);
      screenBounds.height -= (screenInsets.top + screenInsets.bottom);
      screenBounds.x += screenInsets.left;
      screenBounds.y += screenInsets.top;
    }

    setVisible(true);
  }
  class plzwai extends JFrame {
    Toolkit tk = Toolkit.getDefaultToolkit();
    int w = (int) tk.getScreenSize().getWidth();
    int h = (int) tk.getScreenSize().getHeight();

    plzwai() {
      LookAndFeel lf = UIManager.getLookAndFeel();
      try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        // UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
      } catch (Exception e) {
      }
      fplz = new JFrame("Sending The Pay Slip. Please Wait....");
      fplz.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      final JProgressBar aJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL);
      // aJProgressBar.setStringPainted(true);
      aJProgressBar.setIndeterminate(true);
      fplz.add(new JPanel(), BorderLayout.NORTH);
      fplz.setIconImage(Toolkit.getDefaultToolkit().getImage("Bin\\img\\airindia.jpg"));
      fplz.add(new JPanel(), BorderLayout.WEST);
      fplz.add(new JPanel(), BorderLayout.EAST);
      fplz.add(new JPanel(), BorderLayout.SOUTH);
      fplz.add(aJProgressBar, BorderLayout.CENTER);
      fplz.setResizable(false);
      fplz.setLocation(h / 3, w / 4);
      fplz.setSize(700, 100);
      fplz.setVisible(true);
    }
  }
  public hostelStatus() {
    setTitle("Hostel");
    connect();
    updateRecord();

    JFrame fr = new JFrame();
    Toolkit tkt = fr.getToolkit();
    Dimension frsize = tkt.getScreenSize();
    setBounds(frsize.width / 4, frsize.height / 12, frsize.width / 2, frsize.height / 8);
    setLayout(null);

    cn = getContentPane();
    cn.setBackground(new Color(190, 180, 170));

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    tl = new JLabel("Current Hostels Status");
    tl.setFont(new Font("Engravers MT", 1, 25));
    tl.setForeground(new Color(247, 251, 249));

    p1 = new JPanel();
    p1.setBounds(0, 0, 600, 50);
    p1.add(tl);
    p1.setBackground(new Color(31, 88, 166));
    cn.add(p1);

    b1 = new JButton("LOAD");
    b1.setMnemonic('L');
    b1.addActionListener(new dispListener());
    b1.setBounds(230, 320, 120, 30);

    b2 = new JButton("EXIT");
    b2.setMnemonic('X');
    b2.addActionListener(new exitListener());
    b2.setBounds(350, 320, 100, 30);

    cn.add(b1);
    cn.add(b2);

    table = new JTable(data, col);
    table.setFont(new Font("Serif", Font.BOLD, 16));
    table.setBackground(new Color(250, 250, 250));
    table.setEnabled(false);

    JScrollPane jsp = new JScrollPane(table);
    jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    jsp.setBounds(5, 100, 590, 200);
    cn.add(jsp);

    screensize = Toolkit.getDefaultToolkit().getScreenSize();

    setSize(600, 400);
    setVisible(true);
    setVisible(true);
    setResizable(true);
    connect();
  }
  // Define method to return commands.
  private void buildFrame(int width, int height) {
    // Set JFrame title.
    setTitle("Communicator");

    // Initialize and set policies for JScrollPane(s).
    receiverScrollPane =
        setScrollPaneProperties(new JScrollPane(receiver = new JTextAreaPanel(COL, ROW)));
    senderScrollPane =
        setScrollPaneProperties(new JScrollPane(sender = new JTextAreaPanel(COL, ROW)));

    // Disable editability of receiver JTextAreaPanel.
    receiver.setEditable(false);

    // Initialize JButtonPanel.
    button = new JButtonPanel();

    // Define and initialize JButton(s).
    buildButtons();

    // Set panel size.
    setSize(width, height);

    // Set JPanel Layout.
    getContentPane().setLayout(new BorderLayout());

    // Add a JTextAreaPanel(s).
    getContentPane().add(receiverScrollPane, BorderLayout.NORTH);
    getContentPane().add(button, BorderLayout.CENTER);
    getContentPane().add(senderScrollPane, BorderLayout.SOUTH);

    // Build JMenuBar.
    buildMenu();

    // Build JButton action listeners.
    buildButtonActionListeners();

    // Set the screen and display dialog window in relation to screen size.
    dim = tk.getScreenSize();
    setLocation((dim.width / 100), (dim.height / 100));

    // --------------------- Begin Window ActionListener ---------------------/

    // Add window listener to the frame.
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent closingEvent) {
            // Exit on window frame close.
            System.exit(0);
          } // End of windowClosing() method.
        }); // End of addWindowListener() method for JFrame.

    // Set resizeable window off.
    setResizable(false);

    // Display the JFrame to the platform window manager.
    show();
  } // End of buildFrame() method.
  /**
   * Returns an point which has been adjusted to take into account of the desktop bounds, taskbar
   * and multi-monitor configuration.
   *
   * <p>This adustment may be cancelled by invoking the application with
   * -Djavax.swing.adjustPopupLocationToFit=false
   */
  Point adjustPopupLocationToFitScreen(int xPosition, int yPosition) {
    Point popupLocation = new Point(xPosition, yPosition);

    if (popupPostionFixDisabled == true || GraphicsEnvironment.isHeadless()) {
      return popupLocation;
    }

    // Get screen bounds
    Rectangle scrBounds;
    GraphicsConfiguration gc = getCurrentGraphicsConfiguration(popupLocation);
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    if (gc != null) {
      // If we have GraphicsConfiguration use it to get screen bounds
      scrBounds = gc.getBounds();
    } else {
      // If we don't have GraphicsConfiguration use primary screen
      scrBounds = new Rectangle(toolkit.getScreenSize());
    }

    // Calculate the screen size that popup should fit
    Dimension popupSize = JPopupMenu.this.getPreferredSize();
    long popupRightX = (long) popupLocation.x + (long) popupSize.width;
    long popupBottomY = (long) popupLocation.y + (long) popupSize.height;
    int scrWidth = scrBounds.width;
    int scrHeight = scrBounds.height;
    if (!canPopupOverlapTaskBar()) {
      // Insets include the task bar. Take them into account.
      Insets scrInsets = toolkit.getScreenInsets(gc);
      scrBounds.x += scrInsets.left;
      scrBounds.y += scrInsets.top;
      scrWidth -= scrInsets.left + scrInsets.right;
      scrHeight -= scrInsets.top + scrInsets.bottom;
    }
    int scrRightX = scrBounds.x + scrWidth;
    int scrBottomY = scrBounds.y + scrHeight;

    // Ensure that popup menu fits the screen
    if (popupRightX > (long) scrRightX) {
      popupLocation.x = scrRightX - popupSize.width;
      if (popupLocation.x < scrBounds.x) {
        popupLocation.x = scrBounds.x;
      }
    }
    if (popupBottomY > (long) scrBottomY) {
      popupLocation.y = scrBottomY - popupSize.height;
      if (popupLocation.y < scrBounds.y) {
        popupLocation.y = scrBounds.y;
      }
    }

    return popupLocation;
  }
  public AppFrame() {
    super();
    GlobalData.oFrame = this;
    this.setSize(this.width, this.height);
    this.toolkit = Toolkit.getDefaultToolkit();

    Dimension w = toolkit.getScreenSize();
    int fx = (int) w.getWidth();
    int fy = (int) w.getHeight();

    int wx = (fx - this.width) / 2;
    int wy = (fy - this.getHeight()) / 2;

    setLocation(wx, wy);

    this.tracker = new MediaTracker(this);
    String sHost = "";
    try {

      localAddr = InetAddress.getLocalHost();
      if (localAddr.isLoopbackAddress()) {
        localAddr = LinuxInetAddress.getLocalHost();
      }
      sHost = localAddr.getHostAddress();
    } catch (UnknownHostException ex) {
      sHost = "你的IP地址错误";
    }
    //
    this.textLines[0] = "服务器正在运行.";
    this.textLines[1] = "";
    this.textLines[2] = "你的IP地址: " + sHost;
    this.textLines[3] = "";
    this.textLines[4] = "请打开你的手机客户端";
    this.textLines[5] = "";
    this.textLines[6] = "输入屏幕上显示的IP地址.";
    //
    try {
      URL fileURL = this.getClass().getProtectionDomain().getCodeSource().getLocation();
      String sBase = fileURL.toString();
      if ("jar".equals(sBase.substring(sBase.length() - 3, sBase.length()))) {
        jar = new JarFile(new File(fileURL.toURI()));

      } else {
        basePath = System.getProperty("user.dir") + "\\res\\";
      }
    } catch (Exception ex) {
      this.textLines[1] = "exception: " + ex.toString();
    }
  }
Exemple #7
0
  public ArenaFrame(String title, Arena arena, String background, String battleBG, String cardBG) {
    setTitle(title);
    this.arena = arena;
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    width = (int) screenSize.getWidth();
    height = (int) screenSize.getHeight();
    posX = (width - Constant.BATTLEFIELD_WIDTH) / 2;
    posY = (height - Constant.BATTLEFIELD_HEIGHT - Constant.CARDPANEL_HEIGHT) / 2;
    skill_id = 0;
    addKeyListener(this);
    addMouseListener(this);
    addMouseMotionListener(this);

    setUndecorated(true);
    setExtendedState(JFrame.MAXIMIZED_BOTH);
    c = getContentPane();
    c.setPreferredSize(new Dimension(width, height));
    c.setLayout(null);

    battle_field =
        new BattleFieldPanel(Constant.BATTLEFIELD_WIDTH, Constant.BATTLEFIELD_HEIGHT, arena);
    battle_field.setBounds(posX, posY, Constant.BATTLEFIELD_WIDTH, Constant.BATTLEFIELD_HEIGHT);
    battle_field.setOpaque(false);
    c.add(battle_field);

    card_panel = new CardPanel(Constant.CARDPANEL_WIDTH, Constant.CARDPANEL_HEIGHT, arena);
    card_panel.setBounds(
        posX,
        posY + Constant.BATTLEFIELD_HEIGHT,
        Constant.CARDPANEL_WIDTH,
        Constant.CARDPANEL_HEIGHT);
    card_panel.setOpaque(false);
    c.add(card_panel);

    setSize(width, height);

    setBackground(background);
    setBattleFieldBackground(battleBG);
    setCardPanelBackground(cardBG);

    setResizable(false);
    setLocationRelativeTo(null);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    setVisible(true);
    setFocusable(true);
  }
  public LocalImageFrameTest() throws Exception {
    setTitle("Image display");
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension d = tk.getScreenSize();
    int width = 435;
    int height = 240;
    setBounds((int) (d.width - width) / 2, (int) (d.height - height) / 2, width, height);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    JPanel panel = new LocalImagePanel();
    add(panel);
  }
  /** Crea el JFrame, ajusta sus valores, y le agrega los componentes */
  public VentanaCarga(Listado lis) {
    listado = lis;
    jbAgregar = new JButton("Agregar");
    jtfNumero = new JTextField(60);
    jlMensaje = new JLabel("Ingrese un n�mero entero: ", SwingConstants.LEFT);

    jbAgregar.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            jbAgregarActionPerformed(evt);
          }
        });

    setTitle("Ventana de Carga");
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setBackground(new Color(153, 153, 255));

    Toolkit kit = Toolkit.getDefaultToolkit();
    Dimension dim = kit.getScreenSize();
    int alto = dim.height;
    int ancho = dim.width;

    // Fijamos el ancho, el alto y las coordenadas de arranque para mostrarla centrada
    int jfAncho = ancho / 2;
    int jfAlto = alto / 3;

    setSize(jfAncho, jfAlto);
    setLocation(ancho / 4, alto / 4);

    // Proveemos un �cono para la ventana
    Image img = kit.getImage("exclam.gif");
    setIconImage(img);

    getContentPane().setLayout(null);

    jlMensaje.setBounds(jfAncho / 2 - 110, jfAlto / 4, 160, 30);
    getContentPane().add(jlMensaje);

    jtfNumero.setBounds(jfAncho / 2 + 60, jfAlto / 4, 60, 30);
    getContentPane().add(jtfNumero);

    jbAgregar.setBounds(jfAncho / 2 - 40, jfAlto / 2, 80, 30);
    getContentPane().add(jbAgregar);
  }
Exemple #10
0
 /*
 	This could live in the desktop script.
 	However we'd like to get it on the screen as quickly as possible.
 */
 public static void startSplashScreen() {
   int width = 275, height = 148;
   Window win = new Window(new Frame());
   win.pack();
   BshCanvas can = new BshCanvas();
   can.setSize(width, height); // why is this necessary?
   Toolkit tk = Toolkit.getDefaultToolkit();
   Dimension dim = tk.getScreenSize();
   win.setBounds(dim.width / 2 - width / 2, dim.height / 2 - height / 2, width, height);
   win.add("Center", can);
   Image img = tk.getImage(Interpreter.class.getResource("/bsh/util/lib/splash.gif"));
   MediaTracker mt = new MediaTracker(can);
   mt.addImage(img, 0);
   try {
     mt.waitForAll();
   } catch (Exception e) {
   }
   Graphics gr = can.getBufferedGraphics();
   gr.drawImage(img, 0, 0, can);
   win.setVisible(true);
   win.toFront();
   splashScreen = win;
 }
Exemple #11
0
  public SignUpBO() {
    setTitle("Sign Up");
    setSize(320, 210);

    // get screen size and set the location of the frame
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension d = tk.getScreenSize();
    int screenHeight = d.height;
    int screenWidth = d.width;
    setLocation(screenWidth / 3, screenHeight / 4);

    addWindowListener(
        new WindowAdapter() // handle window event
        {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    Container contentPane = getContentPane(); // add a panel to a frame
    SU_Panel = new SignUpPanel();
    contentPane.add(SU_Panel);
    show();
  }
Exemple #12
0
  public EchoAWT() throws UnknownHostException {

    super("채팅 프로그램");

    // 각종 정의
    h = new JPanel(new GridLayout(2, 3));
    m = new JPanel(new BorderLayout());
    f = new JPanel(new BorderLayout());
    s = new JPanel(new BorderLayout());
    login = new JPanel(new BorderLayout());

    // name = new JLabel(" 사용자 이름 ");
    name = new JLabel(" 메세지 입력 ");

    jta = new JTextArea();
    // clientList = new JTextArea(0, 10);
    clientList = new JList();

    jsp = new JScrollPane(jta);
    list = new JScrollPane(clientList);

    jtf = new JTextField("입력하세요.");
    hi = new JTextField("HOST IP 입력");
    pi = new JTextField("PORT 입력");
    localport = new JTextField("원하는 PORT 입력");
    lid = new JTextField("ID를 입력하세요.");
    lpw = new JTextField("PW를 입력하세요.");

    serveropen = new JButton("서버 오픈");
    textin = new JButton("입력");
    clientin = new JButton("서버 접속");
    conf = new JButton("로그인");
    join = new JButton("회원가입");

    addr = InetAddress.getLocalHost();

    // 사용자 해상도 및 창 크기 설정 및 가져오기.
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();

    setSize(500, 500);
    Dimension d = getSize();

    // 각종 버튼 및 텍스트 필드 리스너
    jtf.addActionListener(this);
    hi.addActionListener(this);
    pi.addActionListener(this);
    localport.addActionListener(this);
    lid.addActionListener(this);
    lpw.addActionListener(this);
    conf.addActionListener(this);
    join.addActionListener(this);

    serveropen.addActionListener(this);
    clientin.addActionListener(this);
    textin.addActionListener(this);

    jtf.addFocusListener(this);
    hi.addFocusListener(this);
    pi.addFocusListener(this);
    localport.addFocusListener(this);
    lid.addFocusListener(this);
    lpw.addFocusListener(this);

    // 서버 접속
    h.add(hi);
    h.add(pi);
    h.add(clientin);

    // 서버 생성
    h.add(new JLabel("IP : " + addr.getHostAddress(), (int) CENTER_ALIGNMENT));
    h.add(localport);
    h.add(serveropen);

    // 채팅글창 글 작성 막기
    jta.setEditable(false);

    // 접속자 리스트 width 제한
    clientList.setFixedCellWidth(d.width / 3);

    // 입력 창
    f.add(name, "West");
    f.add(jtf, "Center");
    f.add(textin, "East");

    // 접속자 확인창
    s.add(new JLabel("접속자", (int) CENTER_ALIGNMENT), "North");
    s.add(list, "Center");
    // clientList.setEditable(false);

    // 메인 창
    m.add(jsp, "Center");
    m.add(s, "East");

    // 프레임 설정
    add(h, "North");
    add(m, "Center");
    add(f, "South");

    // 로그인 다이얼로그
    jd = new JDialog();
    jd.setTitle("채팅 로그인");
    jd.add(login);
    jd.setSize(200, 200);
    Dimension dd = jd.getSize();
    jd.setLocation(screenSize.width / 2 - (dd.width / 2), screenSize.height / 2 - (dd.height / 2));
    jd.setVisible(true);

    // 로그인창
    JPanel lm = new JPanel(new GridLayout(4, 1));
    lm.add(lid);
    lm.add(new Label());
    lm.add(lpw);
    lm.add(new Label());

    JPanel bt = new JPanel();
    bt.add(conf);
    bt.add(join);

    login.add(new Label(), "North");
    login.add(new Label(), "West");
    login.add(new Label(), "East");
    login.add(lm, "Center");
    login.add(bt, "South");

    // 창의 위치, 보임, EXIT 단추 활성화.
    setLocation(screenSize.width / 2 - (d.width / 2), screenSize.height / 2 - (d.height / 2));

    setVisible(false);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
  /** Class constructor - make the JFrame ready */
  public TestProgram() {
    // Set screen size
    Toolkit tk = Toolkit.getDefaultToolkit();
    int x = (int) tk.getScreenSize().getWidth() - 150;
    int y = (int) tk.getScreenSize().getHeight() - 100;
    this.setSize(x, y);

    // Some settings
    this.setTitle("Friends With Benefits - Test program");
    field = new Field();
    random = new Random(System.currentTimeMillis());

    // Set the panel
    c = this.getContentPane();
    c.setLayout(new BorderLayout());

    contentpanel = new ContentPanel();
    contentpanel.setField(field);
    c.add(contentpanel, BorderLayout.CENTER);

    // Menupanel
    menupanel = new JPanel();
    layout = new GroupLayout(menupanel);
    menupanel.setLayout(layout);
    c.add(menupanel, BorderLayout.EAST);

    progress = new JProgressBar(0, 99);
    progress.setValue(99);

    open = new JButton("Open");
    open.setFocusPainted(false);
    save = new JButton("Save");
    save.setFocusPainted(false);
    open.addActionListener(this);
    save.addActionListener(this);

    everywhere = new JRadioButton("Everywhere");
    everywhere.setFocusPainted(false);
    inRectangle = new JRadioButton("In bounding rectangle");
    inRectangle.setFocusPainted(false);
    inRectangle.setSelected(true);

    placeOfCluster = new ButtonGroup();
    placeOfCluster.add(everywhere);
    placeOfCluster.add(inRectangle);

    addnoise = new JButton("Add noise");
    addnoise.setFocusPainted(false);
    addnoise.addActionListener(this);

    circle = new JRadioButton("Circle");
    circle.setFocusPainted(false);
    square = new JRadioButton("Square");
    square.setFocusPainted(false);
    circle.setSelected(true);

    squarecircle = new ButtonGroup();
    squarecircle.add(circle);
    squarecircle.add(square);

    fillFactor = new JSlider();
    fillFactor.setMajorTickSpacing(20);
    fillFactor.setMinorTickSpacing(5);
    fillFactor.setPaintTicks(true);

    addacluster = new JButton("Add simple cluster");
    addacluster.setFocusPainted(false);
    addacluster.addActionListener(this);

    clear = new JButton("Clear field");
    clear.addActionListener(this);
    clear.setFocusPainted(false);

    center = new JButton("Center field");
    center.addActionListener(this);
    center.setFocusPainted(false);

    minAlgo = new JTextField();
    minAlgo.setText("0");
    maxAlgo = new JTextField();
    maxAlgo.setText("10");
    run = new JButton("Run algo");
    run.addActionListener(this);
    run.setFocusPainted(false);

    empty = new JPanel();
    empty.setLayout(new BorderLayout());

    JSeparator sep1 = new JSeparator();
    JSeparator sep2 = new JSeparator();
    JSeparator sep3 = new JSeparator();
    JSeparator sep4 = new JSeparator();
    JLabel runalgo = new JLabel("Run algorithm"), addcluster = new JLabel("Add simple cluster");
    JLabel addNoise = new JLabel("Add noise"), fillf = new JLabel("Fill factor:");
    JLabel minalgo = new JLabel("Min:"), maxalgo = new JLabel("Max:");
    addcluster.setFont(f);
    addNoise.setFont(f);
    runalgo.setFont(f);

    fillFactor.setPreferredSize(
        new Dimension(
            menupanel.getPreferredSize().width / 2, fillFactor.getPreferredSize().height));

    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.CENTER)
            .addGroup(
                layout.createSequentialGroup().addComponent(open).addGap(2).addComponent(save))
            .addComponent(sep1)
            .addComponent(addNoise)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(everywhere)
                    .addComponent(inRectangle))
            .addComponent(addnoise)
            .addComponent(sep2)
            .addComponent(addcluster)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(circle)
                    .addComponent(square))
            .addComponent(fillf)
            .addComponent(fillFactor)
            .addComponent(addacluster)
            .addComponent(sep3)
            .addComponent(center)
            .addComponent(clear)
            .addComponent(sep4)
            .addComponent(runalgo)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addComponent(minalgo)
                    .addGap(2)
                    .addComponent(minAlgo)
                    .addGap(10)
                    .addComponent(maxalgo)
                    .addGap(2)
                    .addComponent(maxAlgo))
            .addComponent(run)
            .addComponent(empty)
            .addComponent(progress));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(open)
                    .addComponent(save))
            .addGap(5)
            .addComponent(sep1)
            .addGap(5)
            .addComponent(addNoise)
            .addComponent(everywhere)
            .addComponent(inRectangle)
            .addGap(3)
            .addComponent(addnoise)
            .addGap(5)
            .addComponent(sep2)
            .addGap(5)
            .addComponent(addcluster)
            .addComponent(circle)
            .addComponent(square)
            .addGap(3)
            .addComponent(fillf)
            .addGap(3)
            .addComponent(fillFactor)
            .addGap(3)
            .addComponent(addacluster)
            .addGap(5)
            .addComponent(sep3)
            .addGap(5)
            .addComponent(center)
            .addGap(3)
            .addComponent(clear)
            .addGap(5)
            .addComponent(sep4)
            .addGap(5)
            .addComponent(runalgo)
            .addGap(3)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(minalgo)
                    .addComponent(minAlgo)
                    .addComponent(maxalgo)
                    .addComponent(maxAlgo))
            .addComponent(run)
            .addComponent(empty)
            .addComponent(progress));

    int width = menupanel.getPreferredSize().width;

    setSize(addNoise, width - 10);
    setSize(everywhere, width - 20);
    setSize(inRectangle, width - 20);
    setSize(addnoise, width);

    setSize(addcluster, width - 10);
    setSize(circle, width - 20);
    setSize(square, width - 20);
    setSize(addacluster, width);

    setSize(center, width);
    setSize(clear, width);

    setSize(runalgo, width - 10);
    setSize(minalgo, (int) Math.floor(width / 4) - 20);
    setMaxSize(minAlgo, (int) Math.ceil(width / 4));
    setSize(maxalgo, (int) Math.floor(width / 4) - 20);
    setMaxSize(maxAlgo, (int) Math.ceil(width / 4));
    setSize(run, width);

    empty.setPreferredSize(new Dimension(width, 1000));

    menupanel.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.BLACK),
            "Menu",
            TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION,
            f));
  }
  public UserEditing(int uid) {
    Container contentPane;
    JPanel comboPanel, okPanel;

    JButton okButton;
    JButton cancel;
    JTextField username;
    JTextField email;
    JTextField phone;
    String[] comboBoxItem = {"Trainees", "Trainers", "All Users"};

    // set the frame properties
    setSize(FRAME_WIDTH, FRAME_HEIGHT);
    setTitle("SSEM - User Editing");

    // set center
    final Toolkit toolkit = Toolkit.getDefaultToolkit();
    final Dimension screenSize = toolkit.getScreenSize();
    final int x = (screenSize.width - 300) / 2;
    final int y = (screenSize.height - 600) / 2;
    setLocation(x, y);

    contentPane = getContentPane();
    contentPane.setLayout(null);

    listID = Account.searchuserlistID(uid);

    // name
    JLabel userLabel = new JLabel("Name:");
    userLabel.setBounds(10, 10, 80, 25);
    username = new JTextField(20);
    username.setBounds(100, 10, 160, 25);
    username.setText(Account.userlist.get(listID).getUserName());

    // email
    JLabel emailLabel = new JLabel("Email:");
    emailLabel.setBounds(10, 50, 80, 25);
    email = new JTextField(20);
    email.setBounds(100, 50, 160, 25);
    email.setText(Account.userlist.get(listID).getUserEmail());

    // phone
    JLabel phoneLabel = new JLabel("Phone:");
    phoneLabel.setBounds(10, 90, 80, 25);
    phone = new JTextField(20);
    phone.setBounds(100, 90, 160, 25);
    phone.setText(Account.userlist.get(listID).getUserPhone());

    // create and place the OK button
    okButton = new JButton("OK");
    okButton.setBounds(10, 170, 80, 25);

    // create and place the Cancel button
    cancel = new JButton("Cancel");
    cancel.setBounds(100, 170, 80, 25);

    contentPane.add(userLabel);
    contentPane.add(username);
    contentPane.add(emailLabel);
    contentPane.add(email);
    contentPane.add(phoneLabel);
    contentPane.add(phone);
    contentPane.add(okButton);
    contentPane.add(cancel);

    ///// listener/////////////////////////////////////////////////
    // name////on ENTER key switch to password
    username.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (checkname(username.getText())) email.requestFocusInWindow();
          }
        });

    // email////on ENTER key switch to phone
    email.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (checkemail(email.getText())) phone.requestFocusInWindow();
          }
        });

    // phone////on ENTER key switch to  birth
    phone.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (checkphone(phone.getText())) okButton.doClick();
          }
        });

    // register 'Exit upon closing' as a default close operation
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });

    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (checkname(username.getText())
                && checkphone(phone.getText())
                && checkphone(phone.getText())) {
              if (JOptionPane.showConfirmDialog(
                      null, "Edit information ??", " ", JOptionPane.YES_NO_OPTION)
                  == JOptionPane.YES_OPTION) {
                Account.userlist.get(listID).setUserName(username.getText());
                Account.userlist.get(listID).setUserEmail(email.getText());
                Account.userlist.get(UserEditing.listID).setUserPhone(phone.getText());
                Account.listAll();
                dispose();
              } else {
                JOptionPane.showMessageDialog(
                    null, "Action Cancelled & SYSTEM END.", " ", JOptionPane.WARNING_MESSAGE);
              }
            }
          }
        });
  }
public class Option extends JFrame implements ActionListener, Runnable {
  Thread thread = new Thread(this);
  JFrame fplz;
  Toolkit tk = Toolkit.getDefaultToolkit();
  int w = (int) tk.getScreenSize().getWidth();
  int h = (int) tk.getScreenSize().getHeight();
  static String emp;
  String rav;

  public Option(String em, String prav) {
    rav = prav;
    emp = em;
    launch();
  }

  private void launch() {
    JRoundButton view;
    JRoundButton edit;
    JRoundButton print;
    JRoundButton mail;
    JLabel jLabel1;
    jLabel1 = new JLabel();
    view = new JRoundButton(null, new ImageIcon("Bin\\img\\view.png"));
    mail = new JRoundButton(null, new ImageIcon("Bin\\img\\mail.png"));
    print = new JRoundButton(null, new ImageIcon("Bin\\img\\viewcomp.png"));
    edit = new JRoundButton(null, new ImageIcon("Bin\\img\\edit.png"));

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle("Choose Options");
    setResizable(false);
    setIconImage(Toolkit.getDefaultToolkit().getImage("Bin\\img\\airindia.jpg"));
    jLabel1.setIcon(new ImageIcon("Bin\\img\\1960_Air_India.jpg"));
    edit.setToolTipText("Edit Account");
    mail.setToolTipText("Mail Pay Slip");
    view.setToolTipText("View Pay Slip without PLI");
    print.setActionCommand("Merge");
    edit.setActionCommand("Edit");
    mail.setActionCommand("Mail");
    view.setActionCommand("View");
    print.setToolTipText("View Pay Slip with PLI");
    print.addActionListener(this);
    edit.addActionListener(this);
    mail.addActionListener(this);
    view.addActionListener(this);
    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGroup(
                        layout
                            .createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGap(43, 43, 43) // 59,59,59
                                    .addComponent(jLabel1))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGap(24, 24, 24)
                                    .addComponent(print)
                                    .addGap(36, 36, 36)
                                    .addComponent(view)
                                    .addGap(35, 35, 35)
                                    .addComponent(mail)
                                    .addGap(29, 29, 29)
                                    .addComponent(edit)))
                    .addContainerGap(35, Short.MAX_VALUE)));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGap(41, 41, 41)
                    .addComponent(jLabel1)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE)
                    .addGroup(
                        layout
                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(print)
                            .addComponent(view)
                            .addComponent(mail)
                            .addComponent(edit))
                    .addContainerGap()));
    setLocation(h / 2, w / 14);
    pack();
  }

  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("merge")) {
      new checkmerge().setVisible(true);
    } else if (e.getActionCommand().equalsIgnoreCase("mail")) {
      mail();
    } else if (e.getActionCommand().equalsIgnoreCase("edit")) {
      new edit().setVisible(true);
    } else {
      new checkview().setVisible(true);
    }
  }

  public void mk(String strManyDirectories) {
    boolean success = (new File(strManyDirectories)).mkdirs();
    if (success) {}
  }

  public void run() {
    String t1[] = {new EmailQuery(emp).search(rav)};
    String aa[] = {
      new Dir().getdir()
          + "test/Temp2/Temp3/Temp4/Temp5/Temp6/Temp7/Temp8/Temp9/Temp10/Temp11/Temp12/Complete Pay Slip.pdf"
    };
    String messa =
        "Dear Employee,\n Here is your complete pay slip in PDF format .\n Please save it on your computer.\n This email is sent because you have requested for your complete Pay Slip to be mailed to you via Pay Roll Application."
            + "\n\n Note:Please do not reply to this email .\n Once downloaded your pay slip you can delete the mail.\n This Email is not Spam.\n\n Thank You.\n\n Rav Softs Presentation";
    sending1 s1 =
        new sending1("*****@*****.**", messa, "Pay Slip", t1, "airindia1960", aa);
    String result = s1.send();
    fplz.setVisible(false);
    if (result.equals("Your message is successfully mailed")) {
      JOptionPane.showMessageDialog(null, result, "Alert", JOptionPane.INFORMATION_MESSAGE);
    }
  }

  class plzwai extends JFrame {
    Toolkit tk = Toolkit.getDefaultToolkit();
    int w = (int) tk.getScreenSize().getWidth();
    int h = (int) tk.getScreenSize().getHeight();

    plzwai() {
      LookAndFeel lf = UIManager.getLookAndFeel();
      try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        // UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
      } catch (Exception e) {
      }
      fplz = new JFrame("Sending The Pay Slip. Please Wait....");
      fplz.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      final JProgressBar aJProgressBar = new JProgressBar(JProgressBar.HORIZONTAL);
      // aJProgressBar.setStringPainted(true);
      aJProgressBar.setIndeterminate(true);
      fplz.add(new JPanel(), BorderLayout.NORTH);
      fplz.setIconImage(Toolkit.getDefaultToolkit().getImage("Bin\\img\\airindia.jpg"));
      fplz.add(new JPanel(), BorderLayout.WEST);
      fplz.add(new JPanel(), BorderLayout.EAST);
      fplz.add(new JPanel(), BorderLayout.SOUTH);
      fplz.add(aJProgressBar, BorderLayout.CENTER);
      fplz.setResizable(false);
      fplz.setLocation(h / 3, w / 4);
      fplz.setSize(700, 100);
      fplz.setVisible(true);
    }
  }

  class checkview extends JFrame {
    JButton sub;
    JLabel head;
    JPasswordField pas;

    public checkview() {
      launch();
    }

    private void launch() {

      head = new JLabel();
      pas = new JPasswordField();
      JTextComponent.KeyBinding[] newBindings = {
        new JTextComponent.KeyBinding(
            KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK),
            DefaultEditorKit.beepAction),
        new JTextComponent.KeyBinding(
            KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK),
            DefaultEditorKit.beepAction),
        new JTextComponent.KeyBinding(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK),
            DefaultEditorKit.beepAction)
      };

      Keymap k = pas.getKeymap();
      JTextComponent.loadKeymap(k, newBindings, pas.getActions());
      XrButton sub = new XrButton(new ImageIcon("Bin\\img\\ok.png"));

      head.setFont(new Font("Verdana", 1, 16));
      head.setText("Employee ID: " + emp + " please enter the password");

      sub.setFont(new Font("Verdana", 1, 12));
      sub.setToolTipText("Submit");

      sub.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              String pwd = new CheckQuery(emp).search(rav);
              if ((pas.getText().equalsIgnoreCase(null)) || (pas.getText().equalsIgnoreCase(""))) {
                JOptionPane.showMessageDialog(
                    null, "Please Enter the Password", "Error", JOptionPane.ERROR_MESSAGE);
              } else if (pas.getText().equalsIgnoreCase(pwd)) {
                dispose();
                view();
              } else {
                JOptionPane.showMessageDialog(
                    null, "Oops Incorrect Password", "Error", JOptionPane.ERROR_MESSAGE);
              }
            }
          });

      GroupLayout layout = new GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
          layout
              .createParallelGroup(GroupLayout.Alignment.LEADING)
              .addGroup(
                  layout
                      .createSequentialGroup()
                      .addGroup(
                          layout
                              .createParallelGroup(GroupLayout.Alignment.LEADING)
                              .addGroup(
                                  layout
                                      .createSequentialGroup()
                                      .addGap(196, 196, 196)
                                      .addComponent(sub))
                              .addGroup(
                                  layout
                                      .createSequentialGroup()
                                      .addGap(31, 31, 31)
                                      .addComponent(head))
                              .addGroup(
                                  layout
                                      .createSequentialGroup()
                                      .addGap(126, 126, 126)
                                      .addComponent(
                                          pas,
                                          GroupLayout.PREFERRED_SIZE,
                                          216,
                                          GroupLayout.PREFERRED_SIZE)))
                      .addContainerGap(34, Short.MAX_VALUE)));
      layout.setVerticalGroup(
          layout
              .createParallelGroup(GroupLayout.Alignment.LEADING)
              .addGroup(
                  layout
                      .createSequentialGroup()
                      .addGap(33, 33, 33)
                      .addComponent(head)
                      .addGap(45, 45, 45)
                      .addComponent(
                          pas,
                          GroupLayout.PREFERRED_SIZE,
                          GroupLayout.DEFAULT_SIZE,
                          GroupLayout.PREFERRED_SIZE)
                      .addGap(56, 56, 56)
                      .addComponent(sub)
                      .addContainerGap(42, Short.MAX_VALUE)));
      addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              setVisible(false);
            }
          });
      setIconImage(Toolkit.getDefaultToolkit().getImage("Bin\\img\\airindia.jpg"));
      setLocation(h / 2, w / 7);
      setResizable(false);
      setTitle("Authentication");
      pack();
    }
  }

  public void view() {
    try {
      mk(
          new Dir().getdir()
              + "test/Temp2/Temp3/Temp4/Temp5/Temp6/Temp7/Temp8/Temp9/Temp10/Temp11/Temp12");

      new FirstPageOfPaySlip().launch(emp, rav);

      new SecondPageOfPaySlip().launch(emp, rav);
    } catch (Exception ex) {
    }
    String cmd1 =
        "rundll32"
            + " "
            + "url.dll,FileProtocolHandler"
            + " "
            + new Dir().getdir()
            + "test/Temp2/Temp3/Temp4/Temp5/Temp6/Temp7/Temp8/Temp9/Temp10/Temp11/Temp12/Salary_Slips.pdf";
    String cmd =
        "rundll32"
            + " "
            + "url.dll,FileProtocolHandler"
            + " "
            + new Dir().getdir()
            + "test/Temp2/Temp3/Temp4/Temp5/Temp6/Temp7/Temp8/Temp9/Temp10/Temp11/Temp12/PLI1.pdf";
    try {
      Runtime.getRuntime().exec(cmd1);
    } catch (Exception ex) {
    }
  }

  public void merge() {
    try {
      mk(
          new Dir().getdir()
              + "test/Temp2/Temp3/Temp4/Temp5/Temp6/Temp7/Temp8/Temp9/Temp10/Temp11/Temp12");
      new FirstPageOfPaySlip().launch(emp, rav);
      new SecondPageOfPaySlip().launch(emp, rav);
    } catch (Exception sd) {
    }
    try {
      new PDFMerger();
    } catch (Exception ex) {
    }

    String cmd1 =
        "rundll32"
            + " "
            + "url.dll,FileProtocolHandler"
            + " "
            + new Dir().getdir()
            + "test/Temp2/Temp3/Temp4/Temp5/Temp6/Temp7/Temp8/Temp9/Temp10/Temp11/Temp12/Merged.pdf";
    try {
      Process pro = Runtime.getRuntime().exec(cmd1);
    } catch (Exception cdz) {
    }
  }

  public void mail() {
    try {
      mk(
          new Dir().getdir()
              + "test/Temp2/Temp3/Temp4/Temp5/Temp6/Temp7/Temp8/Temp9/Temp10/Temp11/Temp12");

      new FirstPageOfPaySlip().launch(emp, rav);
      new SecondPageOfPaySlip().launch(emp, rav);
      new PDFMerger();
    } catch (Exception sd) {
    }
    new plzwai();
    thread.start();
  }

  class checkmerge extends JFrame {
    JButton sub;
    JLabel head;
    JPasswordField pas;

    public checkmerge() {
      launch();
    }

    private void launch() {

      head = new JLabel();
      pas = new JPasswordField();
      JTextComponent.KeyBinding[] newBindings = {
        new JTextComponent.KeyBinding(
            KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK),
            DefaultEditorKit.beepAction),
        new JTextComponent.KeyBinding(
            KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK),
            DefaultEditorKit.beepAction),
        new JTextComponent.KeyBinding(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK),
            DefaultEditorKit.beepAction)
      };

      Keymap k = pas.getKeymap();
      JTextComponent.loadKeymap(k, newBindings, pas.getActions());
      XrButton sub = new XrButton(new ImageIcon("Bin\\img\\ok.png"));

      head.setFont(new Font("Verdana", 1, 16));
      head.setText("Employee ID: " + emp + " please enter the password");

      sub.setFont(new Font("Verdana", 1, 12));
      sub.setToolTipText("Submit");

      sub.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              String pwd = new CheckQuery(emp).search(rav);
              if ((pas.getText().equalsIgnoreCase(null)) || (pas.getText().equalsIgnoreCase(""))) {
                JOptionPane.showMessageDialog(
                    null, "Please Enter the Password", "Error", JOptionPane.ERROR_MESSAGE);
              } else if (pas.getText().equalsIgnoreCase(pwd)) {
                dispose();
                merge();
              } else {
                JOptionPane.showMessageDialog(
                    null, "Oops Incorrect Password", "Error", JOptionPane.ERROR_MESSAGE);
              }
            }
          });

      GroupLayout layout = new GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
          layout
              .createParallelGroup(GroupLayout.Alignment.LEADING)
              .addGroup(
                  layout
                      .createSequentialGroup()
                      .addGroup(
                          layout
                              .createParallelGroup(GroupLayout.Alignment.LEADING)
                              .addGroup(
                                  layout
                                      .createSequentialGroup()
                                      .addGap(196, 196, 196)
                                      .addComponent(sub))
                              .addGroup(
                                  layout
                                      .createSequentialGroup()
                                      .addGap(31, 31, 31)
                                      .addComponent(head))
                              .addGroup(
                                  layout
                                      .createSequentialGroup()
                                      .addGap(126, 126, 126)
                                      .addComponent(
                                          pas,
                                          GroupLayout.PREFERRED_SIZE,
                                          216,
                                          GroupLayout.PREFERRED_SIZE)))
                      .addContainerGap(34, Short.MAX_VALUE)));
      layout.setVerticalGroup(
          layout
              .createParallelGroup(GroupLayout.Alignment.LEADING)
              .addGroup(
                  layout
                      .createSequentialGroup()
                      .addGap(33, 33, 33)
                      .addComponent(head)
                      .addGap(45, 45, 45)
                      .addComponent(
                          pas,
                          GroupLayout.PREFERRED_SIZE,
                          GroupLayout.DEFAULT_SIZE,
                          GroupLayout.PREFERRED_SIZE)
                      .addGap(56, 56, 56)
                      .addComponent(sub)
                      .addContainerGap(42, Short.MAX_VALUE)));
      addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              setVisible(false);
            }
          });
      setIconImage(Toolkit.getDefaultToolkit().getImage("Bin\\img\\airindia.jpg"));
      setLocation(h / 2, w / 7);
      setResizable(false);
      setTitle("Authentication");
      pack();
    }
  }

  class edit extends JFrame {
    JButton email;
    JButton pas;
    JLabel head;
    JLabel pass;
    JLabel id;

    public edit() {
      launch();
    }

    private void launch() {

      head = new JLabel();
      pass = new JLabel();
      id = new JLabel();
      email = new JRoundButton(null, new ImageIcon("Bin\\img\\changemail.png"));
      pas = new JRoundButton(null, new ImageIcon("Bin\\img\\changepass.png"));

      head.setFont(new Font("Verdana", 1, 18));
      head.setText("Edit User's Account");

      pass.setFont(new Font("Serif", 1, 14));
      pass.setText("Change Password");

      id.setFont(new Font("Serif", 1, 14));
      id.setText("Change Email ID");

      pas.setToolTipText("Change Password");

      email.setToolTipText("Change Email ID");

      email.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              dispose();
              new email().setVisible(true);
            }
          });

      pas.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              dispose();
              new pas().setVisible(true);
            }
          });

      GroupLayout layout = new GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
          layout
              .createParallelGroup(GroupLayout.Alignment.LEADING)
              .addGroup(
                  layout
                      .createSequentialGroup()
                      .addGroup(
                          layout
                              .createParallelGroup(GroupLayout.Alignment.LEADING)
                              .addGroup(
                                  layout
                                      .createSequentialGroup()
                                      .addGap(95, 95, 95)
                                      .addComponent(head))
                              .addGroup(
                                  layout
                                      .createSequentialGroup()
                                      .addGap(72, 72, 72)
                                      .addGroup(
                                          layout
                                              .createParallelGroup(
                                                  GroupLayout.Alignment.LEADING, false)
                                              .addGroup(
                                                  layout
                                                      .createSequentialGroup()
                                                      .addComponent(id)
                                                      .addPreferredGap(
                                                          javax.swing.LayoutStyle.ComponentPlacement
                                                              .RELATED,
                                                          javax.swing.GroupLayout.DEFAULT_SIZE,
                                                          Short.MAX_VALUE)
                                                      .addComponent(email))
                                              .addGroup(
                                                  layout
                                                      .createSequentialGroup()
                                                      .addComponent(pass)
                                                      .addGap(69, 69, 69)
                                                      .addComponent(pas)))))
                      .addContainerGap(79, Short.MAX_VALUE)));
      layout.setVerticalGroup(
          layout
              .createParallelGroup(GroupLayout.Alignment.LEADING)
              .addGroup(
                  layout
                      .createSequentialGroup()
                      .addGap(39, 39, 39)
                      .addComponent(head)
                      .addGap(50, 50, 50)
                      .addGroup(
                          layout
                              .createParallelGroup(GroupLayout.Alignment.TRAILING)
                              .addComponent(pass)
                              .addComponent(pas))
                      .addGap(42, 42, 42)
                      .addGroup(
                          layout
                              .createParallelGroup(GroupLayout.Alignment.TRAILING)
                              .addComponent(id)
                              .addComponent(email))
                      .addContainerGap(100, Short.MAX_VALUE)));
      addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              setVisible(false);
            }
          });
      setIconImage(Toolkit.getDefaultToolkit().getImage("Bin\\img\\airindia.jpg"));
      setLocation(h / 2, w / 7);
      setResizable(false);
      setTitle("Edit Account");
      pack();
    }
  }

  public class pas extends JFrame {
    String pwd = new CheckQuery(emp).search(rav);
    JButton sub;
    JLabel old;
    JLabel new1;
    JLabel new2;
    JLabel head;
    JPasswordField pas1;
    JPasswordField pas2;
    JPasswordField pas3;

    public pas() {
      launch();
    }

    private void launch() {

      head = new JLabel();
      old = new JLabel();
      new1 = new JLabel();
      new2 = new JLabel();
      pas1 = new JPasswordField();
      JTextComponent.KeyBinding[] newBindings = {
        new JTextComponent.KeyBinding(
            KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK),
            DefaultEditorKit.beepAction),
        new JTextComponent.KeyBinding(
            KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK),
            DefaultEditorKit.beepAction),
        new JTextComponent.KeyBinding(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK),
            DefaultEditorKit.beepAction)
      };

      Keymap k = pas1.getKeymap();
      JTextComponent.loadKeymap(k, newBindings, pas1.getActions());
      pas2 = new JPasswordField();

      Keymap k2 = pas2.getKeymap();
      JTextComponent.loadKeymap(k2, newBindings, pas2.getActions());
      pas3 = new JPasswordField();

      Keymap k3 = pas3.getKeymap();
      JTextComponent.loadKeymap(k3, newBindings, pas3.getActions());
      XrButton sub = new XrButton(new ImageIcon("Bin\\img\\ok.png"));

      sub.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              if (pas1.getText().equals(pwd)) {
                if ((pas1.getText().equalsIgnoreCase(""))
                    || (pas1.getText().equalsIgnoreCase(null))
                    || (pas2.getText().equalsIgnoreCase(""))
                    || (pas2.getText().equalsIgnoreCase(null))
                    || (pas3.getText().equalsIgnoreCase(""))
                    || (pas3.getText().equalsIgnoreCase(null))) {
                  JOptionPane.showMessageDialog(
                      null, "Please all the text fields", "Error", JOptionPane.ERROR_MESSAGE);
                } else {
                  if ((pas2.getText().equalsIgnoreCase(pas3.getText()))) {
                    String r = update(pas2.getText());
                    if (r.equalsIgnoreCase("ok")) {
                      JOptionPane.showMessageDialog(
                          null, "Updated....", "Alert", JOptionPane.INFORMATION_MESSAGE);
                    } else {
                      JOptionPane.showMessageDialog(
                          null,
                          "Encountered Error cant update..",
                          "Error",
                          JOptionPane.ERROR_MESSAGE);
                    }
                  } else {
                    JOptionPane.showMessageDialog(
                        null, "New password do not match", "Error", JOptionPane.ERROR_MESSAGE);
                  }
                }
              } else {
                JOptionPane.showMessageDialog(
                    null, "Incorrect old password", "Error", JOptionPane.ERROR_MESSAGE);
              }
              dispose();
            }
          });

      head.setFont(new Font("Verdana", 1, 16));
      head.setText("Change Password");

      old.setFont(new Font("Verdana", 0, 12));
      old.setText("Old Password");

      new1.setFont(new Font("Verdana", 0, 12));
      new1.setText("New Password");

      new2.setFont(new Font("Verdana", 0, 12));
      new2.setText("Confirm Password");

      sub.setToolTipText("Submit");

      GroupLayout layout = new GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
          layout
              .createParallelGroup(GroupLayout.Alignment.LEADING)
              .addGroup(
                  layout
                      .createSequentialGroup()
                      .addGap(57, 57, 57)
                      .addGroup(
                          layout
                              .createParallelGroup(GroupLayout.Alignment.LEADING)
                              .addComponent(old)
                              .addComponent(new1)
                              .addComponent(new2))
                      .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                      .addGroup(
                          layout
                              .createParallelGroup(GroupLayout.Alignment.LEADING)
                              .addComponent(
                                  pas1, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE)
                              .addComponent(
                                  pas2, GroupLayout.PREFERRED_SIZE, 123, GroupLayout.PREFERRED_SIZE)
                              .addComponent(
                                  pas3,
                                  GroupLayout.PREFERRED_SIZE,
                                  123,
                                  GroupLayout.PREFERRED_SIZE))
                      .addContainerGap(57, Short.MAX_VALUE))
              .addGroup(
                  GroupLayout.Alignment.TRAILING,
                  layout
                      .createSequentialGroup()
                      .addContainerGap(166, Short.MAX_VALUE)
                      .addComponent(sub)
                      .addGap(161, 161, 161))
              .addGroup(
                  GroupLayout.Alignment.TRAILING,
                  layout
                      .createSequentialGroup()
                      .addContainerGap(122, Short.MAX_VALUE)
                      .addComponent(head)
                      .addGap(119, 119, 119)));
      layout.setVerticalGroup(
          layout
              .createParallelGroup(GroupLayout.Alignment.LEADING)
              .addGroup(
                  layout
                      .createSequentialGroup()
                      .addGap(31, 31, 31)
                      .addComponent(head)
                      .addGap(50, 50, 50)
                      .addGroup(
                          layout
                              .createParallelGroup(GroupLayout.Alignment.TRAILING)
                              .addComponent(old)
                              .addComponent(
                                  pas1,
                                  GroupLayout.PREFERRED_SIZE,
                                  GroupLayout.DEFAULT_SIZE,
                                  GroupLayout.PREFERRED_SIZE))
                      .addGap(30, 30, 30)
                      .addGroup(
                          layout
                              .createParallelGroup(GroupLayout.Alignment.TRAILING)
                              .addComponent(new1)
                              .addComponent(
                                  pas2,
                                  GroupLayout.PREFERRED_SIZE,
                                  GroupLayout.DEFAULT_SIZE,
                                  GroupLayout.PREFERRED_SIZE))
                      .addGap(28, 28, 28)
                      .addGroup(
                          layout
                              .createParallelGroup(GroupLayout.Alignment.TRAILING)
                              .addComponent(new2)
                              .addComponent(
                                  pas3,
                                  GroupLayout.PREFERRED_SIZE,
                                  GroupLayout.DEFAULT_SIZE,
                                  GroupLayout.PREFERRED_SIZE))
                      .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
                      .addComponent(sub)
                      .addGap(22, 22, 22)));
      addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              setVisible(false);
            }
          });
      setIconImage(Toolkit.getDefaultToolkit().getImage("Bin\\img\\airindia.jpg"));
      setLocation(h / 2, w / 7);
      setResizable(false);
      setTitle("Change Password");
      pack();
    }

    public String update(String r1) {
      Connection con = null;
      try {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        String driver = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + rav;
        con = DriverManager.getConnection(driver, "", "");
        Statement sta = con.createStatement();
        sta.executeUpdate("UPDATE EnggDept SET PSWD='" + r1 + "' where EMPID=" + emp);
        System.out.println("Table updated");
        sta.close();
        con.close();
        return "ok";
      } catch (Exception e) {
        return e.toString();
      }
    }
  }

  class email extends JFrame {
    String pwd = new CheckQuery(emp).search(rav);
    JButton sub;
    JLabel head;
    JLabel email;
    JLabel pas;
    JPasswordField pass;
    JTextField mail;

    public email() {
      launch();
    }

    private void launch() {

      head = new JLabel();
      email = new JLabel();
      pas = new JLabel();
      pass = new JPasswordField();
      JTextComponent.KeyBinding[] newBindings = {
        new JTextComponent.KeyBinding(
            KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK),
            DefaultEditorKit.beepAction),
        new JTextComponent.KeyBinding(
            KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK),
            DefaultEditorKit.beepAction),
        new JTextComponent.KeyBinding(
            KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK),
            DefaultEditorKit.beepAction)
      };

      Keymap k = pass.getKeymap();
      JTextComponent.loadKeymap(k, newBindings, pass.getActions());
      mail = new JTextField();
      XrButton sub = new XrButton(new ImageIcon("Bin\\img\\ok.png"));

      head.setFont(new Font("Verdana", 1, 16));
      head.setText("Change Email ID");

      email.setFont(new Font("Verdana", 0, 12));
      email.setText("Enter New Email ID");

      pas.setFont(new Font("Verdana", 0, 12));
      pas.setText("Enter the Password");

      sub.setToolTipText("Submit");
      sub.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
              if (pass.getText().equals(pwd)) {
                if ((mail.getText().equalsIgnoreCase(null))
                    || (mail.getText().equalsIgnoreCase(""))) {
                  JOptionPane.showMessageDialog(
                      null, "Please Enter the new email id", "Error", JOptionPane.ERROR_MESSAGE);
                } else {
                  String r = update(mail.getText());
                  if (r.equalsIgnoreCase("ok")) {
                    JOptionPane.showMessageDialog(
                        null, "Updated....", "Alert", JOptionPane.INFORMATION_MESSAGE);
                  } else {
                    JOptionPane.showMessageDialog(
                        null,
                        "Encountered Error cant update..",
                        "Error",
                        JOptionPane.ERROR_MESSAGE);
                  }
                }
              } else {

                JOptionPane.showMessageDialog(
                    null, "Incorrect Password", "Error", JOptionPane.ERROR_MESSAGE);
              }
              dispose();
            }
          });

      GroupLayout layout = new GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
          layout
              .createParallelGroup(GroupLayout.Alignment.LEADING)
              .addGroup(
                  layout
                      .createSequentialGroup()
                      .addGroup(
                          layout
                              .createParallelGroup(GroupLayout.Alignment.LEADING)
                              .addGroup(
                                  layout
                                      .createSequentialGroup()
                                      .addGap(118, 118, 118)
                                      .addComponent(head))
                              .addGroup(
                                  layout
                                      .createSequentialGroup()
                                      .addGap(77, 77, 77)
                                      .addGroup(
                                          layout
                                              .createParallelGroup(GroupLayout.Alignment.LEADING)
                                              .addComponent(pas)
                                              .addComponent(email))
                                      .addGap(27, 27, 27)
                                      .addGroup(
                                          layout
                                              .createParallelGroup(
                                                  GroupLayout.Alignment.LEADING, false)
                                              .addComponent(mail)
                                              .addComponent(
                                                  pass,
                                                  GroupLayout.DEFAULT_SIZE,
                                                  140,
                                                  Short.MAX_VALUE))))
                      .addContainerGap(31, Short.MAX_VALUE))
              .addGroup(
                  GroupLayout.Alignment.TRAILING,
                  layout
                      .createSequentialGroup()
                      .addContainerGap(165, Short.MAX_VALUE)
                      .addComponent(sub)
                      .addGap(170, 170, 170)));
      layout.setVerticalGroup(
          layout
              .createParallelGroup(GroupLayout.Alignment.LEADING)
              .addGroup(
                  layout
                      .createSequentialGroup()
                      .addGap(38, 38, 38)
                      .addComponent(head)
                      .addGap(48, 48, 48)
                      .addGroup(
                          layout
                              .createParallelGroup(GroupLayout.Alignment.TRAILING)
                              .addComponent(email)
                              .addComponent(
                                  mail,
                                  GroupLayout.PREFERRED_SIZE,
                                  GroupLayout.DEFAULT_SIZE,
                                  GroupLayout.PREFERRED_SIZE))
                      .addGap(29, 29, 29)
                      .addGroup(
                          layout
                              .createParallelGroup(GroupLayout.Alignment.LEADING)
                              .addComponent(pas, GroupLayout.Alignment.TRAILING)
                              .addComponent(
                                  pass,
                                  GroupLayout.Alignment.TRAILING,
                                  GroupLayout.PREFERRED_SIZE,
                                  GroupLayout.DEFAULT_SIZE,
                                  GroupLayout.PREFERRED_SIZE))
                      .addGap(45, 45, 45)
                      .addComponent(sub)
                      .addContainerGap(56, Short.MAX_VALUE)));
      addWindowListener(
          new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              setVisible(false);
            }
          });
      setIconImage(Toolkit.getDefaultToolkit().getImage("Bin\\img\\airindia.jpg"));
      setLocation(h / 2, w / 7);
      setResizable(false);
      setTitle("Change Email");
      pack();
    }

    public String update(String r1) {
      Connection con = null;
      try {
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        String driver = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + rav;
        con = DriverManager.getConnection(driver, "", "");
        Statement sta = con.createStatement();
        sta.executeUpdate("UPDATE EnggDept SET EMAIL='" + r1 + "' where EMPID=" + emp);
        System.out.println("Table updated");
        sta.close();
        con.close();
        return "ok";
      } catch (Exception e) {
        return e.toString();
      }
    }
  }
}
Exemple #16
0
  Head() {
    setTitle("Head Office");
    setLocation(440, 80);
    f1.setLayout(null);

    Toolkit kit = Toolkit.getDefaultToolkit();
    Dimension screenSize = kit.getScreenSize();
    int screenHeight = screenSize.height - 30;
    // int screenWidth = screenSize.width;

    setSize(800, 738);
    // System.out.println(screenHeight);

    setResizable(false);

    //     setSize(800,800);

    lno = new JLabel("Head office Number :");
    lname = new JLabel("              Name :");
    contact = new JLabel("           Contact :");
    address = new JLabel("           Address :");
    state = new JLabel("             State :");
    startdate = new JLabel("        Start Date :");
    howmany = new JLabel(" Total Employee :");

    t1 = new JTextField(10);
    t2 = new JTextField(10);
    t3 = new JTextField(10);
    t4 = new JTextField(10);
    t5 = new JTextField(10);
    t6 = new JTextField(10);
    t7 = new JTextField(10);

    add = new JButton(" Add");
    ok = new JButton("OK");

    ok.addActionListener(this);
    add.addActionListener(this);

    taddress = new JTextArea(15, 20);

    scrpn = new JScrollPane(taddress);

    f1.add(lno);
    f1.add(t1);
    f1.add(lname);
    f1.add(t2);
    f1.add(contact);
    f1.add(t3);
    f1.add(t4);
    f1.add(add);
    f1.add(t5);
    f1.add(address);
    f1.add(scrpn);
    f1.add(state);
    f1.add(t6);
    f1.add(t7);
    f1.add(howmany);
    f1.add(startdate);

    b6 =
        new JButton(
            "Exit"); // , new ImageIcon(ClassLoader.getSystemResource("Images/update.png")));
    b7 = new JButton("View");
    b6.setBounds(180, 370, 100, 30);
    b7.setBounds(50, 370, 100, 30);
    add(b6);
    add(b7);
    b6.addActionListener(this);
    b7.addActionListener(this);

    lno.setBounds(10, 25, 150, 25);
    t1.setBounds(150, 23, 125, 25);

    lname.setBounds(10, 67, 150, 25);
    t2.setBounds(150, 67, 150, 25);

    contact.setBounds(10, 110, 150, 25);
    t3.setBounds(150, 110, 125, 25);

    state.setBounds(10, 153, 150, 25);
    t4.setBounds(150, 153, 125, 25);

    startdate.setBounds(10, 196, 150, 25);
    t5.setBounds(150, 196, 125, 25);

    address.setBounds(10, 239, 150, 25);
    t7.setBounds(150, 239, 250, 25);
    // scrpn.setBounds(150,239,200,50);
    howmany.setBounds(10, 310, 150, 25);
    t6.setBounds(150, 310, 125, 25);

    ok.setBounds(190, 420, 90, 25);
    setSize(445, 500);
    add(f1, BorderLayout.CENTER);
    setVisible(true);
    try {
      Class.forName("com.mysql.jdbc.Driver");
      System.out.println("Driver loaded Succesfull");
      cn = DriverManager.getConnection("jdbc:mysql://127.0.0.1/payroll", "root", "root");
      System.out.println("Connection Succesfull");
      st = cn.createStatement();
    } catch (Exception e) {
      JOptionPane.showMessageDialog(this, "Error is" + e);
    }
  }
Exemple #17
0
 void centerFrame() {
   Toolkit t = getToolkit();
   Dimension scr = t.getScreenSize();
   setSize(scr.width / 2, scr.height / 2);
   setLocation(new Point((scr.width - getSize().width) / 2, (scr.height - getSize().height) / 2));
 }
// Define class.
public class StackTraceDialog extends JDialog implements ActionListener {
  // Define and initialize a default Toolkit.
  private Toolkit tk = Toolkit.getDefaultToolkit();

  // Define and initialize screen Dimension(s).
  private Dimension dim = tk.getScreenSize();

  // Define and initialize Container(s).
  private Container c = getContentPane();

  // Define and intialize phsyical size dimensions.
  int left = 0;
  int top = 0;
  int buttonWidth = 50;
  int buttonHeight = 25;
  int displayAreaWidth = dim.width - 400;
  int displayAreaHeight = dim.height - 400;
  int offsetMargin = 20;

  // The dialog width and height are derived from base objects.
  int dialogWidth = displayAreaWidth + offsetMargin;
  int dialogHeight = displayAreaHeight + buttonHeight + (3 * offsetMargin);

  // Define String(s).
  private String eStackTrace;

  // ---------------------------------/
  // Define AWT and Swing objects.
  // ---------------------------------/

  // Define and initialize JButton(s).
  private JButton okButton = new JButton("OK");

  // Define and initialize JTextArea(s).
  private JTextArea displayArea = new JTextArea();

  // Define Box(s).
  private Box displayBox;

  // ---------------------------- Constructor --------------------------------/

  // The class requires an owning frame and cannot be called from a default
  // constructor because none is defined in the JDialog class.
  public StackTraceDialog(Frame owner, String title, boolean modal) {
    // Call the constructor for JDialog.
    super(owner, modal);

    // The title argument is treated as overloaded because the stack trace
    // String is passed into an instance of this class by using it.  Then,
    // the String is assigned to a class level variable.
    eStackTrace = new String(title);

    // Call the buildDialogBox() method.
    buildDialogBox();
  } // End of StackTraceDialog constructor.

  // --------------------------- Begin Methods -------------------------------/

  // Method to build the dialog box for help.
  private void buildDialogBox() {
    // Set the JDialog window properties.
    setTitle("Stack Trace Detail");
    setResizable(false);
    setSize(dialogWidth, dialogHeight);

    // Append the stack trace output to the display area.
    displayArea.append(eStackTrace);

    // Create horizontal and vertical scrollbars for box.
    displayBox = Box.createHorizontalBox();
    displayBox = Box.createVerticalBox();

    // Add a JScrollPane to the Box.
    displayBox.add(new JScrollPane(displayArea));

    // Define behaviors of container.
    c.setLayout(null);
    c.add(displayBox);
    c.add(okButton);

    // Set scroll pane bounds.
    displayBox.setBounds(
        (dialogWidth / 2) - ((displayAreaWidth / 2) + 2),
        (top + (offsetMargin / 2)),
        displayAreaWidth,
        displayAreaHeight);

    // Set the behaviors, bounds and action listener for the button.
    okButton.setBounds(
        (dialogWidth / 2) - (buttonWidth / 2),
        (displayAreaHeight + offsetMargin),
        buttonWidth,
        buttonHeight);

    // Set the font to the platform default Font for the object with the
    // properties of bold and font size of 11.
    okButton.setFont(new Font(okButton.getFont().getName(), Font.BOLD, 11));

    // The class implements the ActionListener interface and therefore
    // provides an implementation of the actionPerformed() method.  When a
    // class implements ActionListener, the instance handler returns an
    // ActionListener.  The ActionListener then performs actionPerformed()
    // method on an ActionEvent.
    okButton.addActionListener(this);

    // Set the screen and display dialog window in relation to screen size.
    setLocation((dim.width / 2) - (dialogWidth / 2), (dim.height / 2) - (dialogHeight / 2));

    // Display JDialog.
    show();
  } // End of buildDialogBox method.

  // Class listener based on implementing ActionListener.
  public void actionPerformed(ActionEvent e) {

    this.setVisible(false);
    this.dispose();
  } // End of actionPerformed method.

  // ---------------------------- End Methods --------------------------------/

} // End of StackTraceDialog class.