import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; public class GUI extends JFrame{ private JLabel pic; private JButton up,down,right,left; private int a = 10; private int b = 10; public GUI(){ super("AWESOME"); setLayout(null); Icon xbox = new ImageIcon(getClass().getResource("xbox.png")); pic = new JLabel(xbox); pic.setBounds(a, b,50,50); pic.setVisible(true); up = new JButton(""); up.setBounds(40, 200, 20, 20); up.setVisible(true); up.addActionListener( new ActionListener(){ public void actionPerformed(ActionEvent event){ b+=5; } } ); add(up); add(pic); public class bro { public static void main(String args[]) { GUI fr = new GUI(); fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fr.setSize(300, 300); fr.setVisible(true); } }
b+=5
pic.setBounds(a, b,50,50);
a
b
setBounds
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)