Coverage Report - net.miginfocom.examples.JavaOneShrink
 
Classes in this File Line Coverage Branch Coverage Complexity
JavaOneShrink
N/A
N/A
1.25
JavaOneShrink$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.LineBorder;
 7  
 import java.awt.*;
 8  
 /*
 9  
  * License (BSD):
 10  
  * ==============
 11  
  *
 12  
  * Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com)
 13  
  * All rights reserved.
 14  
  *
 15  
  * Redistribution and use in source and binary forms, with or without modification,
 16  
  * are permitted provided that the following conditions are met:
 17  
  * Redistributions of source code must retain the above copyright notice, this list
 18  
  * of conditions and the following disclaimer.
 19  
  * Redistributions in binary form must reproduce the above copyright notice, this
 20  
  * list of conditions and the following disclaimer in the documentation and/or other
 21  
  * materials provided with the distribution.
 22  
  * Neither the name of the MiG InfoCom AB nor the names of its contributors may be
 23  
  * used to endorse or promote products derived from this software without specific
 24  
  * prior written permission.
 25  
  *
 26  
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 27  
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 28  
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 29  
  * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 30  
  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 31  
  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 32  
  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 33  
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 34  
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 35  
  * OF SUCH DAMAGE.
 36  
  *
 37  
  * @version 1.0
 38  
  * @author Mikael Grev, MiG InfoCom AB
 39  
  *         Date: 2006-sep-08
 40  
  */
 41  
 
 42  
 /**
 43  
  * @author Mikael Grev, MiG InfoCom AB
 44  
  *         Date: Apr 20, 2008
 45  
  *         Time: 10:32:58 PM
 46  
  */
 47  
 public class JavaOneShrink
 48  
 {
 49  
         private static JComponent createPanel(String ... args)
 50  
         {
 51  
                 JPanel panel = new JPanel(new MigLayout("nogrid"));
 52  
 
 53  
                 panel.add(createTextArea(args[0].replace(", ", "\n    ")), args[0] + ", w 200");
 54  
                 panel.add(createTextArea(args[1].replace(", ", "\n    ")), args[1] + ", w 200");
 55  
                 panel.add(createTextArea(args[2].replace(", ", "\n    ")), args[2] + ", w 200");
 56  
                 panel.add(createTextArea(args[3].replace(", ", "\n    ")), args[3] + ", w 200");
 57  
 
 58  
                 JSplitPane gSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, panel, new JPanel());
 59  
                 gSplitPane.setOpaque(true);
 60  
                 gSplitPane.setBorder(null);
 61  
 
 62  
                 return gSplitPane;
 63  
         }
 64  
 
 65  
         private static JComponent createTextArea(String s)
 66  
         {
 67  
                 JTextArea ta = new JTextArea("\n\n    " + s, 6, 20);
 68  
                 ta.setBorder(new LineBorder(new Color(200, 200, 200)));
 69  
                 ta.setFont(new Font("Helvetica", Font.BOLD, 20));
 70  
                 ta.setMinimumSize(new Dimension(20, 20));
 71  
                 ta.setFocusable(false);
 72  
                 return ta;
 73  
         }
 74  
 
 75  
         public static void main(String[] args)
 76  
         {
 77  
                 SwingUtilities.invokeLater(new Runnable() {
 78  
                         public void run() {
 79  
                                 try {
 80  
                                         UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
 81  
                                 } catch (Exception ex) {
 82  
                                         ex.printStackTrace();
 83  
                                 }
 84  
 
 85  
                                 JFrame frame = new JFrame("JavaOne Shrink Demo");
 86  
                                 Container cp = frame.getContentPane();
 87  
                                 cp.setLayout(new MigLayout("wrap 1"));
 88  
 
 89  
                                 cp.add(createPanel("", "", "", ""));
 90  
                                 cp.add(createPanel("shrinkprio 1", "shrinkprio 1", "shrinkprio 2", "shrinkprio 3"));
 91  
                                 cp.add(createPanel("shrink 25", "shrink 50", "shrink 75", "shrink 100"));
 92  
                                 cp.add(createPanel("shrinkprio 1, shrink 50", "shrinkprio 1, shrink 100", "shrinkprio 2, shrink 50", "shrinkprio 2, shrink 100"));
 93  
 
 94  
                                 frame.pack();
 95  
                                 frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 96  
                                 frame.setLocationRelativeTo(null);
 97  
                                 frame.setVisible(true);
 98  
                         }
 99  
                 });
 100  
         }
 101  
 
 102  
 }