ScholarMatic | 24/7 Homework Help

ScholarMatic Will Help You Write Your Essays and Term Papers

Answered » You can buy a ready-made answer or pick a professional tutor to order an original one.

More Java Graphics – Layouts What will you learn How to organize graphical elements on a Panel Recommended reading From the Java textbook, Sams…

by | Nov 28, 2023 | engineering

Before you start Lab 5, Layouts, take a look at the code below. Play with is, for instance,

  • commenting the setLayout() lines and checking the result
  • change background colors
  • experiment with other layouts
  • add a couple of buttons to some of the panels
  • make some changes myJPanel12 (p12)

public class app

{

    public static void main(String args[])

{

myJFrame mjf = new myJFrame();

}

}

import java.awt.*;

import javax.swing.*;

{

myJPanel p1;

public myJFrame ()

{

super (“My First Frame”);

//————————————————

// Create components

p1 = new myJPanel();

//————————————————

// Choose a Layout for JFrame and

// add Jpanel to JFrame according to layout

getContentPane().setLayout(new BorderLayout());

getContentPane().add(p1,”Center”);

//———————————————–

setDefaultCloseOperation(EXIT_ON_CLOSE);

setSize (640, 480);

setVisible(true);

}

}

import java.awt.*;

import javax.swing.*;

public class myJPanel1 extends JPanel

{

myJPanel11 p11;

myJPanel12 p12;

public myJPanel1()

{

setBackground(Color.pink);

p11 = new myJPanel11();

p12 = new myJPanel12();

setLayout(new GridLayout(1,2));

add(p11);

add(p12);

}

}

import java.awt.*;

import javax.swing.*;

public class myJPanel11 extends JPanel

{

myJPanel111 p111;

myJPanel112 p112;

myJPanel113 p113;

public myJPanel11()

{

setBackground(Color.green);

p111 = new myJPanel111();

p112 = new myJPanel112();

p113 = new myJPanel113();

//———————————————–

// Choose a Layout for JPanel1 and

// add components to Jpanel according to layout

setLayout(new GridLayout(3,1));

add(p111);

add(p112);

add(p113);

}

}

import java.awt.*;

import javax.swing.*;

public class myJPanel12 extends JPanel

{

public myJPanel12()

{

setBackground(Color.yellow);

}

}

import java.awt.*;

import javax.swing.*;

public class myJPanel111 extends JPanel

{

public myJPanel111()

{

setBackground(Color.orange);

}

}

import java.awt.*;

import javax.swing.*;

public class myJPanel112 extends JPanel

{

public myJPanel112()

{

setBackground(Color.red);

}

}

import java.awt.*;

import javax.swing.*;

public class myJPanel113 extends JPanel

{

public myJPanel113()

{

setBackground(Color.pink);

}

}

ScholarMatic: Explanation & Answer

Your ready answer from a verified tutor is just a click away for as little as $14.99


  

Click Order Now to get 100% Original Answer Customized to your instructions!

HOME TO CERTIFIED WRITERS

Why Place An Order With Us?

  • Certified Editors
  • 24/7 Customer Support
  • Profesional Research
  • Easy to Use System Interface
  • Student Friendly Pricing

Have a similar question?

PLAGIRAISM FREE PAPERS

All papers we provide are well-researched, properly formatted and cited.

TOP QUALITY

All papers we provide are well-researched, properly formatted and cited.

HIGHLY SECURED

All papers we provide are well-researched, properly formatted and cited.

ScholarMatic: Get Started

Assignment Writing Service

Feel safe and secure when placing an order on our portal!
Fruitful cooperation begins with solid guarantees, and we are professional enough to promise perfect results. Let’s get it started!