26.07.2013 Views

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

Java How to Program Fourth Edition - DCC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

778 Graphical User Interface Components: Part 2 Chapter 13<br />

92 // set constraints and add component<br />

93 layout.setConstraints( component, constraints );<br />

94 container.add( component );<br />

95 }<br />

96<br />

97 // execute application<br />

98 public static void main( String args[] )<br />

99 {<br />

100 GridBagDemo application = new GridBagDemo();<br />

101<br />

102 application.setDefaultCloseOperation(<br />

103 JFrame.EXIT_ON_CLOSE );<br />

104 }<br />

105<br />

106 } // end class GridBagDemo<br />

Fig. Fig. 13.20 13.20 13.20 Demonstrating the GridBagLayout layout manager (part 3 of 3).<br />

The GUI consists of three JBut<strong>to</strong>ns, two JTextAreas, a JComboBox and a<br />

JTextField. The layout manager for the content pane is GridBagLayout. Lines 22–<br />

23 instantiate the GridBagLayout object and set the layout manager for the content pane<br />

<strong>to</strong> layout. The GridBagConstraints object used <strong>to</strong> determine the location and size

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!