Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import java.awt.*;
- public class EMULATOR {
- public static void main(String[] args){
- JFrame frame = new JFrame();
- Container west = new JPanel(new BorderLayout());
- JPanel p =new JPanel();
- JPanel p2 = new JPanel();
- JPanel p3 = new JPanel();
- west.add(p,BorderLayout.WEST);
- west.add(p2,BorderLayout.EAST);
- west.add(p3,BorderLayout.CENTER);
- frame.getContentPane().add(west);
- /*teclas de direção*/
- JButton botão = new JButton("A");
- botão.setBackground(Color.gray);
- JButton botão2 = new JButton("V");
- botão2.setBackground(Color.red);
- JButton botão3 = new JButton("<");
- botão3.setBackground(Color.blue);
- JButton botão4 = new JButton(">");
- botão4.setBackground(Color.green);
- /*##########################################*/
- /*outras teclas*/
- JButton botão5 = new JButton("X");
- botão5.setBackground(Color.red);
- JButton botão6 = new JButton("O");
- botão6.setBackground(Color.green);
- JButton botão7 = new JButton("H");
- botão7.setBackground(Color.gray);
- JButton botão8 = new JButton("A");
- botão8.setBackground(Color.blue);
- /*adicionando os de direção*/
- p.setLayout(new BorderLayout());
- p.add(botão,BorderLayout.NORTH);
- p.add(botão2,BorderLayout.SOUTH);
- p.add(botão3,BorderLayout.WEST);
- p.add(botão4,BorderLayout.EAST);
- /*novos botões*/
- p2.setLayout(new BorderLayout());
- p2.add(botão5,BorderLayout.NORTH);
- p2.add(botão6,BorderLayout.SOUTH);
- p2.add(botão7,BorderLayout.WEST);
- p2.add(botão8,BorderLayout.EAST);
- frame.pack();
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment