I want to create a program that if you click the up button, the window goes 50pixel up and so on. I am almost finished now, I want that the window cant go outside the current screen size. I want to do that in the Inner class.
`
class Listener extends WindowAdapter implements ActionListener{
@Override
public void windowOpened(WindowEvent e) {
}
@Override
public void actionPerformed(ActionEvent e) {
Dimension hHeight = Toolkit.getDefaultToolkit().getScreenSize();
Dimension wWidth = Toolkit.getDefaultToolkit().getScreenSize();
setLocation(wWidth.width - getSize().width / 2, (hHeight.height - getSize().height) / 2);
double width= wWidth.getWidth();
if (e.getActionCommand().equals("UP") & yPosition > 0) {
yPosition -= 10;
}
if (e.getActionCommand().equals("RIGHT") & xPosition <= width) {
xPosition += 100;
}
if (e.getActionCommand().equals("DOWN")) {
yPosition += 10;
}
if (e.getActionCommand().equals("LEFT") & xPosition > 0) {
xPosition -= 10;
}
setLocation(xPosition,yPosition);
}
}
`
I make it for UP and LEFT for RIGHT and DOWN i don't manage it.