View the step-by-step solution to:

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

package start; import java.awt.AWTException; import java.awt.BorderLayout; import java.awt.CheckboxMenuItem; import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.GridLayout; import java.awt.Image; import java.awt.Menu; import java.awt.MenuItem; import java.awt.PopupMenu; import java.awt.SystemTray; import java.awt.Toolkit; import java.awt.TrayIcon; import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.JToolBar; import 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 Tool0 = new JButton("Tool0"); JButton Tool1 = new JButton("Tool1"); JButton Tool2 = new JButton("Tool2"); JButton Tool3 = new JButton("Tool3"); JButton Tool4 = new JButton("Tool4"); JButton Tool5 = new JButton("Tool5"); JButton Tool6 = new JButton("Tool6"); JButton Tool7 = new JButton("Tool7"); JButton Tool8 = new JButton("Tool8");
Background image of page 1
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 button0 = new JButton("button0"); JButton button1 = new JButton("button1"); JButton button2 = new JButton("button2"); JButton button3 = new JButton("button3"); JButton button4 = new JButton("button4"); JButton button5 = new 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));
Background image of page 2
Show entire document

Recently Asked Questions

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.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    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