コード例 #1
0
 /** primary constructor */
 public BreadBoardMenu(VirtualBreadBoard main) {
   this.main = main;
   ledGreen = new LED(1);
   ledRed = new LED(2);
   ledBlue = new LED(3);
   and = new ANDChip();
   // sets JFrame's size, background color, and exit operation.
   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   board = new Board();
   setSize(1200, 562);
   setBackground(Color.DARK_GRAY);
   // instanitates all nesscary components
   area = new JPanel();
   run = new JButton("Run");
   back = new JButton("Back");
   wireTest = new JButton("Wire");
   snapper = new Snapper();
   // sets JPanel layout
   area.setLayout(null);
   // sets the buttons locations and size
   run.setBounds(1050, 400, 100, 30);
   back.setBounds(1050, 450, 100, 30);
   wireTest.setBounds(1050, 300, 100, 30);
   ledGreen.setBounds(850, 0, ledGreen.getWidth(), ledGreen.getHeight());
   ledRed.setBounds(875, 0, ledGreen.getWidth(), ledGreen.getHeight());
   ledBlue.setBounds(900, 0, ledGreen.getWidth(), ledGreen.getHeight());
   and.setBounds(850, 50, and.getWidth(), and.getHeight());
   // adds MouseListeners to compnents
   run.addMouseListener(runL);
   back.addMouseListener(backL);
   wireTest.addMouseListener(wireL);
   ledGreen.addMouseListener(ledL);
   ledRed.addMouseListener(ledL);
   ledBlue.addMouseListener(ledL);
   board.addMouseListener(boardL);
   and.addMouseListener(andL);
   // adds components to the JPanel
   setup();
   // adds JPanel area to this class
   add(area);
 }
コード例 #2
0
 @Override
 public void mouseClicked(MouseEvent e) {
   if (and.contains(e.getPoint())) {
     if (chipP == false) {
       ledP = false;
       chipP = true;
       wireP = false;
       wireStep2 = false;
     } else {
       chipP = false;
     }
   }
 }