1. Engineering
  2. Computer Science
  3. package labbuilding import javaawtgraphics import javaxswingjpanel suppresswarningsquotserialquot public class building...

Question: package labbuilding import javaawtgraphics import javaxswingjpanel suppresswarningsquotserialquot public class building...

Question details

package labBuilding;

import java.awt.Graphics;

import javax.swing.JPanel;

@SuppressWarnings("serial")
public class Building extends JPanel {
  
   @Override
   protected void paintComponent(Graphics g) {
       super.paintComponent(g);
      
       // TODO: write code to draw the building
      
   }

}

package labBuilding;

import javax.swing.JFrame;

@SuppressWarnings("serial")
public class BuildingApp extends JFrame {

   public static void main(String[] args) {
       new BuildingApp().run();
   }
  
   public void run() {
       setBounds(100, 10, 400, 500);
   setDefaultCloseOperation(EXIT_ON_CLOSE);
   add(new Building());
   setVisible(true);
   }

}

Lab Building CSIS-1410 Learning Outcome: Formulating Algorithms Review Review for loops Review random numbens Practice drawing Getting Started: Download labBuilding.zip from Canvas and unzip it. Import the extracted ( unzipped ) code files into Eclipse: Right-click the src folder that should include the new package 기mport., the Import dialog opens Select General> File System and click Next the Import from directory dialog opens -Use the Browse button to navigate to the folder labBuilding and click OK Select the checkbox next to the folder labBuilding IMPORTANT: Select the checkbox next to Create to-level folder Click Finish Run the application to make sure that the file import worked as expected. Description: Implement the overridden method paintComponent so that it paints a tall building with multiple rows of windows Requirements: 1. Use for loops to draw the windows 2. Use random colors (every time the building is repainted some of the colors change randomly. Which of the areas change is up to you.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution