简体   繁体   中英

Jframe resize on right

I have a little problem with JFrame resize. I need to resize a frame when I push a button but I need to take visible the right side of frame.

For default when I resize some JFrame ho show me the left size.

    JButton btnX = new JButton("");
    btnX.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int x = ((Toolkit.getDefaultToolkit().getScreenSize().width/2)-221);
            int y = (0);
            if(contr==0){
                //frmAsda.setBounds(x, y, 442, 45);
                frmAsda.setBounds(x, y, 100, 170);
                contr=1;
                frmAsda.setBackground(new Color(1.0f,1.0f,1.0f,0.0f));

            } else if (contr==1){
                //frmAsda.setBounds(x, y, 442, 216);
                 frmAsda.setBounds(x, y, 442, 170);
                contr=0;
                frmAsda.setBackground(new Color(0.0f,0.0f,0.0f,0.7f));

            }
        }
    });

from this frame

在此处输入图片说明

to this:

在此处输入图片说明

Put your Panel into JScrollPane and make ScrollBars not visible. On resize just scroll right.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM