Coverage Report - net.miginfocom.examples.Example02
 
Classes in this File Line Coverage Branch Coverage Complexity
Example02
N/A
N/A
1.25
Example02$1
N/A
N/A
1.25
 
 1  
 package net.miginfocom.examples;
 2  
 
 3  
 import net.miginfocom.swing.MigLayout;
 4  
 
 5  
 import javax.swing.*;
 6  
 import javax.swing.border.CompoundBorder;
 7  
 import javax.swing.border.EmptyBorder;
 8  
 import javax.swing.border.EtchedBorder;
 9  
 /*
 10  
  * License (BSD):
 11  
  * ==============
 12  
  *
 13  
  * Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com)
 14  
  * All rights reserved.
 15  
  *
 16  
  * Redistribution and use in source and binary forms, with or without modification,
 17  
  * are permitted provided that the following conditions are met:
 18  
  * Redistributions of source code must retain the above copyright notice, this list
 19  
  * of conditions and the following disclaimer.
 20  
  * Redistributions in binary form must reproduce the above copyright notice, this
 21  
  * list of conditions and the following disclaimer in the documentation and/or other
 22  
  * materials provided with the distribution.
 23  
  * Neither the name of the MiG InfoCom AB nor the names of its contributors may be
 24  
  * used to endorse or promote products derived from this software without specific
 25  
  * prior written permission.
 26  
  *
 27  
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 28  
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 29  
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 30  
  * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 31  
  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 32  
  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 33  
  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 34  
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 35  
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 36  
  * OF SUCH DAMAGE.
 37  
  *
 38  
  * @version 1.0
 39  
  * @author Mikael Grev, MiG InfoCom AB
 40  
  *         Date: 2006-sep-08
 41  
  */
 42  
 public class Example02
 43  
 {
 44  
         private static JPanel createPanel()
 45  
         {
 46  
                 JPanel panel = new JPanel(new MigLayout());
 47  
 
 48  
                 panel.add(createLabel("West Panel"),    "dock west");
 49  
                 panel.add(createLabel("North 1 Panel"), "dock north");
 50  
                 panel.add(createLabel("North 2 Panel"), "dock north");
 51  
                 panel.add(createLabel("South Panel"),   "dock south");
 52  
                 panel.add(createLabel("East Panel"),    "dock east");
 53  
                 panel.add(createLabel("Center Panel"),  "grow, push"); // "dock center" from v3.0
 54  
 
 55  
                 return panel;
 56  
         }
 57  
 
 58  
         private static JLabel createLabel(String text)
 59  
         {
 60  
                 JLabel label = new JLabel(text);
 61  
                 label.setHorizontalAlignment(JLabel.CENTER);
 62  
                 label.setBorder(new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 10, 5, 10)));
 63  
                 return label;
 64  
         }
 65  
 
 66  
         public static void main(String[] args)
 67  
         {
 68  
                 SwingUtilities.invokeLater(new Runnable() {
 69  
                         public void run() {
 70  
                                 try {
 71  
                                         UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
 72  
                                 } catch (Exception ex) {
 73  
                                         ex.printStackTrace();
 74  
                                 }
 75  
 
 76  
                                 JFrame frame = new JFrame("Example 02");
 77  
                                 frame.getContentPane().add(createPanel());
 78  
                                 frame.pack();
 79  
                                 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 80  
                                 frame.setVisible(true);
 81  
                         }
 82  
                 });
 83  
         }
 84  
 
 85  
 }