View the step-by-step solution to: package

ertyhj
ertyhj
LayoutMngr.java

package start;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import

java.awt.AWTException;
java.awt.BorderLayout;
java.awt.CheckboxMenuItem;
java.awt.Component;
java.awt.Container;
java.awt.Dimension;
java.awt.FlowLayout;
java.awt.GridBagConstraints;
java.awt.GridBagLayout;
java.awt.GridLayout;
java.awt.Image;
java.awt.Menu;
java.awt.MenuItem;
java.awt.PopupMenu;
java.awt.SystemTray;
java.awt.Toolkit;
java.awt.TrayIcon;
java.awt.Window;
java.awt.event.ActionEvent;
java.awt.event.ActionListener;

import
import
import
import
import
import
import
import
import
import
import
import
import
import

javax.swing.BorderFactory;
javax.swing.Box;
javax.swing.BoxLayout;
javax.swing.ImageIcon;
javax.swing.JButton;
javax.swing.JFrame;
javax.swing.JLabel;
javax.swing.JOptionPane;
javax.swing.JPanel;
javax.swing.JScrollPane;
javax.swing.JTextArea;
javax.swing.JTextField;
javax.swing.JToolBar;
javax.swing.border.EmptyBorder;

public class LayoutMngr {
/**
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
*/
private static void createAndShowGUI() {
JFrame frame = new JFrame("Layout Manager");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(9, 1));
Container contentPane = frame.getContentPane();
//contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS));
JButton
JButton
JButton
JButton
JButton
JButton
JButton
JButton
JButton

Tool0
Tool1
Tool2
Tool3
Tool4
Tool5
Tool6
Tool7
Tool8

=
=
=
=
=
=
=
=
=

new
new
new
new
new
new
new
new
new

JButton("Tool0");
JButton("Tool1");
JButton("Tool2");
JButton("Tool3");
JButton("Tool4");
JButton("Tool5");
JButton("Tool6");
JButton("Tool7");
JButton("Tool8");

panel.add(Tool0);
panel.add(Tool1);
panel.add(Tool2);
panel.add(Tool3);
panel.add(Tool4);
panel.add(Tool5);
panel.add(Tool6);
panel.add(Tool7);
panel.add(Tool8);
panel.setAlignmentX(Component.LEFT_ALIGNMENT);
contentPane.add(panel, BorderLayout.WEST);
JPanel panel1 = new JPanel();
panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS));
JToolBar toolbar = new JToolBar();
toolbar.addSeparator();
JButton
JButton
JButton
JButton
JButton
JButton

button0
button1
button2
button3
button4
button5

=
=
=
=
=
=

new
new
new
new
new
new

JButton("button0");
JButton("button1");
JButton("button2");
JButton("button3");
JButton("button4");
JButton("button5");

toolbar.add(button0);
toolbar.add(button1);
toolbar.add(button2);
toolbar.add(button3);
toolbar.add(button4);
toolbar.add(button5);
JTextArea textArea = new JTextArea("Lorem ipsum dolor sit amet,
consectetur " +
"adipisicing " + "elit, sed do eiusmod tempor"
+
"incididunt ut labore et dolore magna
aliqua." +
"Ut enim ad minim veniam, quis nostrud
exercitation" +
"ullamco laboris nisi ut aliquip ex ea
commodo" +
"consequat. Duis aute irure dolor in
reprehenderit" +
"in voluptate velit esse cillum dolore eu
fugiat nulla" +
"pariatur. Excepteur sint occaecat cupidatat
non proident," +
"sunt in culpa qui officia deserunt mollit
anim id est laborum.");
//JScrollPane pane = new JScrollPane(textArea);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
textArea.setEditable(false);
panel1.add(toolbar);
//contentPane.add(Box.createRigidArea(new Dimension(5,0)));
panel1.add(textArea);
//panel1.add(Box.createRigidArea(new Dimension(5,0)));
JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.TRAILING));

JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.TRAILING));
JLabel label1 = new JLabel("Property 1");
JTextField tf1 = new JTextField();
tf1.setColumns(5);
JButton b1 = new JButton("Set Property 1");
JLabel label2 = new JLabel("Property 1");
JTextField tf2 = new JTextField();
tf2.setColumns(5);
JButton b2 = new JButton("Set Property 2");
panel2.add(label1);
panel2.add(tf1);
panel2.add(b1);
panel3.add(label2);
panel3.add(tf2);
panel3.add(b2);
panel1.add(panel2);
panel1.add(panel3);
panel.setBorder( new EmptyBorder(6, 6, 6, 6) );
contentPane.add(panel1, BorderLayout.CENTER);
//contentPane.add(panel2, BorderLayout.SOUTH);
frame.pack();
frame.setSize(465, 300);
frame.setVisible(true);
}

}

public static void main(String args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors and customizable flashcards—available anywhere, anytime.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access or to earn money with our Marketplace.

    Browse Documents
  • 890,990,898

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
  • 890,990,898

    Flashcards

    Browse existing sets or create your own using our digital flashcard system. A simple yet effective studying tool to help you earn the grade that you want!

    Browse Flashcards