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