Hi
My problem is that ,
The Jframe window does not remember it's position after minimizing ....suppose I minimize at co'ordiates (45,89)..but after maximizing it again open at (37,28)..means at different co-ordinates ..i want that jframe should open at the same position...after maximizing..like remeber it's position..

please help

yes ..i set
setlocation(new point(10,20));

but i also used this..

int x = this.getLocation().x;
int y = this.getLocation().y;

this.setLocation(new Point(x,y));

i do not want it to have fixed position ....i would like that the frame should remember it's position after minimizing and after maximizing it should open at the same position ,it was previously minimized...

Does your code set the location between the minimize and the restore?

after maximizing..like remeber it's position..

I'm confused here how about the position of a mazimized frame. Does a max frame have a position?

no..
ok..I want to do like after dragging to the specified point ...i minimize it ...after that i again click in below to restore it's position ..but it opens always at the top left corner ..

below is the code ...when i clicked on the minimize button ..this action is performed..

private void jButtonMinimize_actionPerformed(ActionEvent e){
        this.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
        this.setExtendedState(JFrame.MAXIMIZED_BOTH);  //Maximizing the frame
        this.setExtendedState(JFrame.ICONIFIED | this.getExtendedState());
}

i tried this code also but it does not work...

int x = this.getLocation().x;
int y = this.getLocation().y;

this.setLocation(new Point(x,y));

Edited 3 Years Ago by mike_2000_17: Fixed formatting

below is the whole code....

package com.softidsolutions.sb.gui;



import java.awt.Color;
import java.awt.geom.*;
import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Shape;
import java.awt.Toolkit;
import java.awt.event.AWTEventListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.RoundRectangle2D;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRootPane;
import javax.swing.JSeparator;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.WindowConstants;
import javax.swing.border.Border;
import javax.swing.*;

import com.softidsolutions.sb.model.AuthenticationModel;
import com.softidsolutions.sb.model.ChnagePassPhraseModel;
import com.softidsolutions.sb.util.ConstantVariables;
import com.softidsolutions.sb.util.SerialNumber;
import com.sun.awt.AWTUtilities;

/**
 * @author hp
 *
 */
/**
 * @author hp
 *
 */
public class ChnagePassPhraseScreen extends JFrame implements ConstantVariables {

    private String serialNumber;
    private JLabel jLabelSerialNo;
    private JLabel jLabelSerialNoValue;
    private JLabel jLabelUserId1;
    private JLabel jLabelUserId1Value;
    private JLabel jLabelUserId2;
    private JLabel jLabelCurrentPassPhrase;
    private JLabel jLabelCurrentPassPhraseTag;
    private JLabel jLabelNewPassPhrase;
    private JLabel jLabelReEnterNewPassPhrase;
    private JLabel jLabelMessage;
    private JLabel title;

    private JTextField jTxtFieldUserId;
    private JPasswordField jTxtFieldCurrentPassPhrase;
    private JPasswordField jTxtFieldNewPassPhrase;
    private JPasswordField jTxtFieldReEnterNewPassPhrase;
    private JTextField jTxtFieldMessage;
    private JButton jButtonOk;
    private JButton jButtonExit;
    private JButton jButtonClose;
    private JButton jButtonMinimize;
    private JPanel contentPane;
    private JMenuBar menubar;
    private JMenu toolMenu;
    private JMenu helpmenu;
    private JMenuItem toolMenuItem1;
    private JMenuItem toolMenuItem2;
    private JMenuItem toolMenuItem3;

    private String userId;

    public String getUserId() {
        return userId;
    }
    public void setUserId(String userId) {
        this.userId = userId;
    }

    // End of variables declaration

    public ChnagePassPhraseScreen() {

        super();

        this.setUndecorated(true);
        this.pack();
        create(this.userId);


        Shape shape = new RoundRectangle2D.Float(0, 0,432,270,50,50);
        //this.setIconImage(Toolkit.getDefaultToolkit().getImage("addthis_button.gif"));

        AWTUtilities.setWindowShape(this, shape); 


        this.setVisible(true);
    }







    public ChnagePassPhraseScreen(String userId) {

        super();
        //this.setIconImage(Toolkit.getDefaultToolkit().getImage("addthis_button.gif"));

        this.setUndecorated(true);
        this.pack();
        create(userId);
        Shape shape = new RoundRectangle2D.Float(0, 0,432,270,50,50);
        AWTUtilities.setWindowShape(this, shape); 
        AWTUtilities.setWindowOpaque(this, true);
        //int x = this.getLocation().x;
        //int y = this.getLocation().y;

        //this.setLocation(new Point(x, y));

        this.setVisible(true);


    }

    private void create(String userId) {
        title=new JLabel();
        jLabelSerialNo = new JLabel();
        jLabelSerialNoValue = new JLabel();
        jLabelUserId1 = new JLabel();
        jLabelUserId1Value = new JLabel();
        jLabelUserId2 = new JLabel();
        jLabelCurrentPassPhrase = new JLabel();
        jLabelCurrentPassPhraseTag = new JLabel();
        jLabelNewPassPhrase = new JLabel();
        jLabelReEnterNewPassPhrase = new JLabel();
        jLabelMessage = new JLabel();

        jTxtFieldUserId = new JTextField();
        jTxtFieldCurrentPassPhrase = new JPasswordField();
        jTxtFieldNewPassPhrase = new JPasswordField();
        jTxtFieldReEnterNewPassPhrase = new JPasswordField();
        jTxtFieldMessage = new JTextField();
        Icon closeIcon = new ImageIcon("button_close.jpg");
        jButtonClose = new JButton("X");
        jButtonClose.setVisible(true);
        jButtonMinimize = new JButton("--");
        jButtonMinimize.setVisible(true);
        jButtonOk = new JButton();
        jButtonExit = new JButton();

        contentPane = (JPanel) this.getContentPane();
        SerialNumber sn = new SerialNumber();
        this.userId=userId;

        //code for title
        title.setHorizontalAlignment(SwingConstants.LEFT);
        title.setForeground(new Color(255,255,255));
        title.setText("<html> ChangePassphraseScreen </html>");

        serialNumber=sn.get_serial_no();
        //
        // jLabelSerialNo
        //

        jLabelSerialNo.setHorizontalAlignment(SwingConstants.LEFT);
        jLabelSerialNo.setForeground(new Color(255,255,255));
        jLabelSerialNo.setText("<html> Serial No: </html>");

        //
        // jLabelUserId1
        //

        //jLabelUserId1.setHorizontalAlignment(SwingConstants.LEFT);
        //jLabelUserId1.setForeground(new Color(255,255,255));
        //jLabelUserId1.setText("<html> UserID: </html>");

        //
        // jLabelUserId2
        //

        jLabelUserId2.setHorizontalAlignment(SwingConstants.LEFT);
        jLabelUserId2.setForeground(new Color(255,255,255));
        jLabelUserId2.setText("<html> UserID</html>");

        //
        // jLabelCurrentPassPhrase
        //

        jLabelCurrentPassPhrase.setHorizontalAlignment(SwingConstants.LEFT);
        jLabelCurrentPassPhrase.setForeground(new Color(255,255,255));
        jLabelCurrentPassPhrase.setText("<html> Enter current Passphrase</font></html>");

        //
        // jLabelCurrentPassPhraseTag
        //
        jLabelCurrentPassPhraseTag.setHorizontalAlignment(SwingConstants.LEFT);
        jLabelCurrentPassPhraseTag.setForeground(new Color(255,255,255));
        jLabelCurrentPassPhraseTag.setText("<html><font size=\"2\">(Data protection password on your PC)</html>");

        //
        // jLabelNewPassPhrase
        //

        jLabelNewPassPhrase.setHorizontalAlignment(SwingConstants.LEFT);
        jLabelNewPassPhrase.setForeground(new Color(255,255,255));
        jLabelNewPassPhrase.setText("<html> Enter new Passphrase </html>");

        //
        // jLabelReEnterNewPassPhrase
        //

        jLabelReEnterNewPassPhrase.setHorizontalAlignment(SwingConstants.LEFT);
        jLabelReEnterNewPassPhrase.setForeground(new Color(255,255,255));
        jLabelReEnterNewPassPhrase.setText("<html> Re-Enter new Passphrase</html>");

        //
        // jLabelMessage
        //

        jLabelMessage.setHorizontalAlignment(SwingConstants.LEFT);
        jLabelMessage.setForeground(new Color(255,255,255));
        jLabelMessage.setText("<html> Message </html>");

        //
        // jLabelSerialNoValue
        //

        jLabelSerialNoValue.setHorizontalAlignment(SwingConstants.LEFT);
        jLabelSerialNoValue.setForeground(new Color(255,255,255));
        jLabelSerialNoValue.setText(sn.get_serial_no());

        //
        // jLabelUserId1Value
        //

        jLabelUserId1Value.setHorizontalAlignment(SwingConstants.LEFT);
        jLabelUserId1Value.setForeground(new Color(255,255,255));
        jLabelUserId1Value.setText(this.userId);

        //
        // jTxtFieldUserId
        //

        jTxtFieldUserId.setForeground(new Color(0, 0, 0));
        jTxtFieldUserId.setSelectedTextColor(new Color(0, 0, 0));
        jTxtFieldUserId.setToolTipText("Enter your UserID");
        jTxtFieldUserId.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                jTextField1_actionPerformed(e);
            }
        });

        //
        // jTxtFieldCurrentPassPhrase
        //

        jTxtFieldCurrentPassPhrase.setForeground(new Color(0, 0, 0));
        jTxtFieldCurrentPassPhrase.setSelectedTextColor(new Color(0, 0, 0));
        jTxtFieldCurrentPassPhrase.setToolTipText("Enter your current Passphrase");
        // jTxtFieldNewPassPhrase
        //

        jTxtFieldNewPassPhrase.setForeground(new Color(0, 0, 0));
        jTxtFieldNewPassPhrase.setSelectedTextColor(new Color(0, 0, 0));
        jTxtFieldNewPassPhrase.setToolTipText("Enter your Passphrase");
        // jTxtFieldReEnterNewPassPhrase
        //

        jTxtFieldReEnterNewPassPhrase.setForeground(new Color(0, 0, 0));
        jTxtFieldReEnterNewPassPhrase.setSelectedTextColor(new Color(0, 0, 0));
        jTxtFieldReEnterNewPassPhrase.setToolTipText("Enter your Passphrase again");

        //jTxtFieldReEnterNewPassPhrase
        //

        jTxtFieldMessage.setForeground(new Color(0, 0, 0));
        jTxtFieldMessage.setSelectedTextColor(new Color(0, 0, 0));
        jTxtFieldMessage.setEditable(false);        

        // JMenuBar
        menubar = new JMenuBar();

        // JMenu

        toolMenu = new JMenu("Tools");
        toolMenu.setBackground(new Color(255, 255, 255));
        toolMenu.add(new JSeparator());

        helpmenu = new JMenu("Help");
        JMenuItem helpcontent=new JMenuItem("Help content");
        helpmenu.add(helpcontent);
        helpcontent.setBackground(new Color(255, 255, 255));
        helpcontent.addActionListener(new ActionListener()
        {
            public void actionPerformed(ActionEvent e)
            {
                JTextArea ta = new JTextArea(10, 35);
                JScrollPane jscrollpane = new JScrollPane(ta);

                  JFrame f = new JFrame("JScrollPane");
                  f.setUndecorated(false);
                  f.setLocation(new Point(700, 182));
                  f.getContentPane().add(jscrollpane);
                  f.setBackground(Color.gray);
                  Shape shape = new RoundRectangle2D.Float(0, 0,432,270,50,50);
                    AWTUtilities.setWindowShape(f, shape); 
                    AWTUtilities.setWindowOpaque(f, true);




                  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  f.setSize(250, 300);
                  f.setVisible(true);
            }
        });


        helpmenu.add(new JSeparator());

        // JMenuItem

        toolMenuItem1 = new JMenuItem("Codeword Recovery");
        toolMenuItem1.setBackground(new Color(255, 255, 255));
        toolMenuItem1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e)
            {
                toolItem1_actionPerformed(e);
            }
        });
        toolMenuItem2 = new JMenuItem("Passphrase Recovery");
        toolMenuItem2.setBackground(new Color(255, 255, 255));
        toolMenuItem2.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e)
            {
                toolItem2_actionPerformed(e);
            }
        });
        toolMenuItem3 = new JMenuItem("Change Passphrase");
        toolMenuItem3.setBackground(new Color(255, 255, 255));
        toolMenuItem3.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e)
            {
                toolItem3_actionPerformed(e);
            }
        });
        // adding the menu items to menu
        toolMenu.add(toolMenuItem1);
        toolMenu.add(toolMenuItem2);
        toolMenu.add(toolMenuItem3);

        // adding menu to MenuBar
        menubar.add(toolMenu);
        menubar.add(helpmenu);
        menubar.add( Box.createHorizontalGlue());
        menubar.add(jButtonMinimize);
        menubar.add(jButtonClose);
        menubar.setBackground(new Color(255, 255, 255));

        jButtonClose.setBackground(new Color(255, 255, 255));
        jButtonClose.setForeground(new Color(0, 0, 0));
        jButtonClose.setToolTipText("Close");
        jButtonClose.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                jButtonClose_actionPerformed(e);
            }
        });
        jButtonMinimize.setBackground(new Color(255, 255, 255));
        jButtonMinimize.setForeground(new Color(0, 0, 0));
        jButtonMinimize.setToolTipText("Minimize");
        jButtonMinimize.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                jButtonMinimize_actionPerformed(e);
            }
        });

        //
        // jButtonOk
        //

        jButtonOk.setBackground(new Color(255, 255, 255));
        jButtonOk.setForeground(new Color(0, 0, 0));
        jButtonExit.setHorizontalTextPosition(SwingConstants.CENTER);
        jButtonOk.setText("<html>OK</html>");
        jButtonOk.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ok_actionPerformed(e);
            }
        });

        //
        // jButtonExit
        //

        jButtonExit.setBackground(new Color(255, 255, 255));
        jButtonExit.setForeground(new Color(0, 0, 0));
        jButtonExit.setHorizontalTextPosition(SwingConstants.CENTER);
        jButtonExit.setText("<html>Exit</html>");

        jButtonExit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                jButton3_actionPerformed(e);
            }
        });

        //
        // contentPane
        //

        contentPane.setLayout(null);
        contentPane.setBorder(new RoundedBorder(50));
        contentPane.setBackground(Color.gray);
        addComponent(contentPane, title, 19, -8,200, 25);


        //1st row
        addComponent(contentPane, menubar,8,13,415,18);
        //addComponent(contentPane, jButtonClose, 400,10,16,16);

        // ***** 1st row ******* ////
        addComponent(contentPane, new JSeparator(), 10,20,410,1);

        //// ******* 2nd row ******* ////
        addComponent(contentPane, jLabelSerialNo, 10,30,56,12);
        addComponent(contentPane, jLabelSerialNoValue, 65,30,120,12);

        addComponent(contentPane, jLabelUserId1, 195,30,45,12);
        addComponent(contentPane, jLabelUserId1Value, 245,30,120,12);

        //3rd row
        addComponent(contentPane, new JSeparator(), 10,45,410,2);

        // 4th row

        addComponent(contentPane, jLabelUserId2, 10, 55, 70, 25);
        addComponent(contentPane, jTxtFieldUserId, 165, 55, 150, 25);

        // 5th row

        addComponent(contentPane, jLabelCurrentPassPhrase, 10, 90, 150, 25);
        addComponent(contentPane, jTxtFieldCurrentPassPhrase, 165, 90,150,25);

        addComponent(contentPane, jLabelCurrentPassPhraseTag, 10, 110,200, 25);

        addComponent(contentPane, jLabelNewPassPhrase, 10,145,75,30);
        addComponent(contentPane, jTxtFieldNewPassPhrase, 95,145,80,25);

        addComponent(contentPane, jLabelReEnterNewPassPhrase, 185,145,90,30);
        addComponent(contentPane, jTxtFieldReEnterNewPassPhrase,  270,145,80,25);

        // 7th row
        addComponent(contentPane, jLabelMessage, 10, 180,70, 25);
        addComponent(contentPane, jTxtFieldMessage,85, 180, 300, 25);

        addComponent(contentPane, jButtonOk, 175, 215, 55, 18);
        addComponent(contentPane, jButtonExit, 235, 215, 55, 18);

        // login
        //
        //this.setLocation(new Point(76, 182));
        this.setSize(new Dimension(432, 252));
        this.setBackground(Color.gray);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.setResizable(false);
    }

    /** Add Component Without a Layout Manager (Absolute Positioning) */

    private void addComponent(Container container, Component c, int x, int y,
            int width, int height)
    {

        c.setBounds(x, y, width, height);
        container.add(c);
    }

    private void ok_actionPerformed(ActionEvent e)
    {
        ChnagePassPhraseModel chnagePassPhraseModel=new ChnagePassPhraseModel();

        boolean result=false;
        boolean changePasswordResult=false;
        String userName=jTxtFieldUserId.getText();

        String c_password=jTxtFieldCurrentPassPhrase.getText();
        String n_password=jTxtFieldNewPassPhrase.getText();
        String recheckPassPhrase=jTxtFieldReEnterNewPassPhrase.getText();
        if((jTxtFieldNewPassPhrase.getText()).length()<8 ) {
            jTxtFieldMessage.setText("Passphrase must be more than 8 charecters.Please Re-Enter.");
        }else if((jTxtFieldNewPassPhrase.getText()).length()>=24){
            jTxtFieldMessage.setText("Passphrase is more than 24 charecters.Please Re-Enter.");
        }else if((jTxtFieldReEnterNewPassPhrase.getText()).length()<8 ) {
            jTxtFieldMessage.setText("repassPharseField must be more than 8 charecters.Please Re-Enter.");
        }else if((jTxtFieldReEnterNewPassPhrase.getText()).length()>=24){
            jTxtFieldMessage.setText("repassPharseField is more than 24 charecters.Please Re-Enter.");
        }
        else if (userName!=null && c_password!=null){
            result=chnagePassPhraseModel.verify_current_passphrase(userName, c_password);

        if(result){
            if((c_password!=null && !c_password.equals(""))&& (n_password!=null && !n_password.equals(""))){
                if(n_password.equals(recheckPassPhrase)){
                    changePasswordResult=chnagePassPhraseModel.change_passphrase(userName, c_password, n_password);
                    if(changePasswordResult){
                        jTxtFieldMessage.setText("Change passPhrase successfully");
                    }
                }else{
                    jTxtFieldMessage.setText("New password is not matched \nwith Re-Enter New password.");
                }
            }else{
                jTxtFieldMessage.setText("New password and Re-Enter password\n should not left blank.");
            }
        }else{
            jTxtFieldMessage.setText("Not a valid User.");
        }
        }


    }

    private void jTextField1_actionPerformed(ActionEvent e)
    {

    }

    private void jPasswordField1_actionPerformed(ActionEvent e)

    {

    }

    private void jButtonMinimize_actionPerformed(ActionEvent e){
        this.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
        this.setExtendedState(JFrame.MAXIMIZED_BOTH);  //Maximizing the frame
        this.setExtendedState(JFrame.ICONIFIED | this.getExtendedState());
        //int x = this.getLocation().x;
        //int y = this.getLocation().y;

        //this.setLocation(new Point(x,y));
    }


    private void jButton3_actionPerformed(ActionEvent e) {
        jButtonExit.setEnabled(false);
        this.dispose();
        TokenScreen tokenScreen=new TokenScreen(this.userId);
        MoveTokenScreen mml = new MoveTokenScreen(tokenScreen);
        tokenScreen.addMouseListener(mml);
        tokenScreen.addMouseMotionListener(mml);
        jButtonExit.setEnabled(true);
    }

    private void jButtonClose_actionPerformed(ActionEvent e) {
        dispose();
        System.exit(0);
    }

    private void jButton2_actionPerformed(ActionEvent e) {
        System.out.println("\njButton2_actionPerformed(ActionEvent e) called.");
        String username = new String("");
    }

    private static class RoundedBorder implements Border {

        private int radius;

        RoundedBorder(int radius) {
            this.radius = radius;
        }
        public Insets getBorderInsets(Component c) {
            return new Insets(this.radius+1, this.radius+1, this.radius+2, this.radius);
        }

        public boolean isBorderOpaque() {
            return true;
        }

        public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
            g.drawRoundRect(x,y,width-1,height-1,radius,radius);
        }
    }
    private void toolItem1_actionPerformed(ActionEvent e)

    {

        System.out.println("\ntoolItem1_actionPerformed(ActionEvent e) called.");
        this.dispose();
        CodeWordRecovery cwr=new CodeWordRecovery(this.userId);
        MoveCodeWordRecovery mml = new MoveCodeWordRecovery(cwr);
        cwr.addMouseListener(mml);
        cwr.addMouseMotionListener(mml);


    }

    private void toolItem2_actionPerformed(ActionEvent e)

    {

        System.out.println("\ntoolItem2_actionPerformed(ActionEvent e) called.");
        this.dispose();
        PassphraseRecovery cwr=new PassphraseRecovery(this.userId);
        MovePassphraseRecovery mml = new MovePassphraseRecovery(cwr);
        cwr.addMouseListener(mml);
        cwr.addMouseMotionListener(mml);


    }

    private void toolItem3_actionPerformed(ActionEvent e)

    {

        System.out.println("\ntoolItem3_actionPerformed(ActionEvent e) called.");
        this.dispose();
        ChnagePassPhraseScreen cpps=new ChnagePassPhraseScreen(this.userId);
        MoveChnagePassPhraseScreen mml = new MoveChnagePassPhraseScreen(cpps);
        cpps.addMouseListener(mml);
        cpps.addMouseMotionListener(mml);


    }
    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(GTK_CLASS);
        } catch (Exception ex) {
            System.out.println("Failed loading L&F: ");
            System.out.println(ex);
        }

        ChnagePassPhraseScreen chnagePassPhraseScreen=new ChnagePassPhraseScreen("");
        MoveChnagePassPhraseScreen mml = new MoveChnagePassPhraseScreen(chnagePassPhraseScreen);
        chnagePassPhraseScreen.addMouseListener(mml);
        chnagePassPhraseScreen.addMouseMotionListener(mml);


    }
}
class MoveChnagePassPhraseScreen implements MouseListener, MouseMotionListener {
    ChnagePassPhraseScreen target;
    //Register target1;
    Point start_drag;
    Point start_loc;

    public MoveChnagePassPhraseScreen(ChnagePassPhraseScreen target) {
        this.target = target;
    }

    public static JFrame getFrame(Container target) {
        if (target instanceof JFrame) {
            return (JFrame) target;
        }
        return getFrame(target.getParent());
    }

    Point getScreenLocation(MouseEvent e) {
        Point cursor = e.getPoint();
        Point target_location = this.target.getLocationOnScreen();
        return new Point((int) (target_location.getX() + cursor.getX()),
                (int) (target_location.getY() + cursor.getY()));
    }

    public void mouseClicked(MouseEvent e) {
    }

    public void mouseEntered(MouseEvent e) {
    }

    public void mouseExited(MouseEvent e) {
    }

    public void mousePressed(MouseEvent e) {
        this.start_drag = this.getScreenLocation(e);
        this.start_loc = this.getFrame(this.target).getLocation();
    }

    public void mouseReleased(MouseEvent e) {
    }

    public void mouseDragged(MouseEvent e) {
        Point current = this.getScreenLocation(e);
        Point offset = new Point(
                (int) current.getX() - (int) start_drag.getX(), (int) current
                        .getY()
                        - (int) start_drag.getY());
        JFrame frame = this.getFrame(target);
        Point new_location = new Point((int) (this.start_loc.getX() + offset
                .getX()), (int) (this.start_loc.getY() + offset.getY()));
        frame.setLocation(new_location);
    }

    public void mouseMoved(MouseEvent e) {
    }
}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Sorry that was a waste of time. I do not have the packages your program imports.
Trim out/remove the non standard packages and try again.

hi can I send you the code via email ..could you please give me your..email..

hi ...
Thanks Norm ..i resolve the issue .....

private void jButtonMinimize_actionPerformed(ActionEvent e){
        this.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
        //this.setExtendedState(JFrame.MAXIMIZED_BOTH);  //Maximizing the frame
        this.setExtendedState(JFrame.ICONIFIED | this.getExtendedState() );

made PLAIN_DIALOG TO NONE
and commented //this.setExtendedState(JFrame.MAXIMIZED_BOTH);

well thanks...
I have another problem ..if help it will be great ..

When i clicked on JMenuitem ..it opens a new window ..but when i close this window the parent window also closes...

is there any method to resolve ..i don't want to close the parent window only the new window..

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.