Package net.miginfocom.swing

Examples of net.miginfocom.swing.MigLayout


    LC layC = new LC().fill().wrap();
    AC colC = new AC().align("right", 1).fill(2, 4).grow(100, 2, 4).align("right", 3).gap("15", 2);
    AC rowC = new AC().align("top", 7).gap("15!", 6).grow(100, 8);

    JPanel panel = createTabPanel(new MigLayout(layC, colC, rowC));    // Makes the background gradient

    // References to text fields not stored to reduce code clutter.

    JScrollPane list2 = new JScrollPane(new JList(new String[] {"Mouse, Mickey"}));
    panel.add(list2,                     new CC().spanY().growY().minWidth("150").gapX(null, "10"));
View Full Code Here


    LC layC = new LC().fill().wrap();
    AC colC = new AC().align("right", 0).fill(1, 3).grow(100, 1, 3).align("right", 2).gap("15", 1);
    AC rowC = new AC().index(6).gap("15!").align("top").grow(100, 8);

    JPanel panel = createTabPanel(new MigLayout(layC, colC, rowC));    // Makes the background gradient

    // References to text fields not stored to reduce code clutter.

    panel.add(new JLabel("Last Name"));
    panel.add(new JTextField());
View Full Code Here

  public JComponent createLayout_Showdown()
  {
    JTabbedPane tabbedPane = new JTabbedPane();

    JPanel p = createTabPanel(new MigLayout("", "[]15[][grow,fill]15[grow]"));

    JScrollPane list1 = new JScrollPane(new JList(new String[] {"Mouse, Mickey"}));

    p.add(list1,                     "spany, growy, wmin 150");
    p.add(new JLabel("Last Name"));
    p.add(new JTextField());
    p.add(new JLabel("First Name")"split")// split divides the cell
    p.add(new JTextField(),          "growx, wrap");
    p.add(new JLabel("Phone"));
    p.add(new JTextField());
    p.add(new JLabel("Email"),       "split");
    p.add(new JTextField(),          "growx, wrap");
    p.add(new JLabel("Address 1"));
    p.add(new JTextField(),          "span, growx"); // span merges cells
    p.add(new JLabel("Address 2"));
    p.add(new JTextField(),          "span, growx");
    p.add(new JLabel("City"));
    p.add(new JTextField(),          "wrap"); // wrap continues on next line
    p.add(new JLabel("State"));
    p.add(new JTextField());
    p.add(new JLabel("Postal Code"), "split");
    p.add(new JTextField(),          "growx, wrap");
    p.add(new JLabel("Country"));
    p.add(new JTextField(),          "wrap 15");

    p.add(createButton("New"),        "span, split, align left");
    p.add(createButton("Delete"),     "");
    p.add(createButton("Edit"),       "");
    p.add(createButton("Save"),       "");
    p.add(createButton("Cancel"),     "wrap push");

    tabbedPane.addTab("Layout Showdown (pure)", p);


    // Fixed version *******************************************

    JPanel p2 = createTabPanel(new MigLayout("", "[]15[][grow,fill]15[][grow,fill]"));    // Makes the background gradient

    // References to text fields not stored to reduce code clutter.

    JScrollPane list2 = new JScrollPane(new JList(new String[] {"Mouse, Mickey"}));
    p2.add(list2,                     "spany, growy, wmin 150");
View Full Code Here

  public JComponent createWelcome()
  {
    JTabbedPane tabbedPane = new JTabbedPane();

    MigLayout lm = new MigLayout("ins 20, fill", "", "[grow]unrel[]");

    JPanel mainPanel = createTabPanel(lm);

    String s = "MigLayout's main purpose is to make layouts for SWT and Swing, and possibly other frameworks, much more powerful and a lot easier to create, especially for manual coding.\n\n" +
               "The motto is: \"MigLayout makes complex layouts easy and normal layouts one-liners.\"\n\n" +
View Full Code Here

  public JComponent createVisual_Bounds()
  {
    JTabbedPane tabbedPane = new JTabbedPane();

    // "NON"-corrected bounds
    JPanel p1 = createTabPanel(new MigLayout("fill, ins 3, novisualpadding"));
    p1.setBorder(new LineBorder(Color.BLACK));

    JTabbedPane demoPane2 = new JTabbedPane();
    JPanel demoPanel2 = new JPanel();
    demoPanel2.setBackground(Color.WHITE);
    demoPane2.addTab("Demo Tab", demoPanel2);

    p1.add(createTextArea("A JTextArea", 1, 100), "grow, aligny bottom, wmin 100");
    p1.add(demoPane2, "grow, aligny bottom");
    p1.add(createTextField("A JTextField", 100), "grow, aligny bottom, wmin 100");
    p1.add(createTextArea("A JTextArea", 1, 100), "newline,grow, aligny bottom, wmin 100");
    p1.add(createTextArea("A JTextArea", 1, 100), "grow, aligny bottom, wmin 100");
    p1.add(createTextArea("A JTextArea", 1, 100), "grow, aligny bottom, wmin 100");

    JPanel p2 = createTabPanel(new MigLayout("center,center,fill,ins 3"));
    p2.setBorder(new LineBorder(Color.BLACK));

    JTabbedPane demoPane = new JTabbedPane();
    JPanel demoPanel = new JPanel();
    demoPanel.setBackground(Color.WHITE);
View Full Code Here

  public JComponent createDocking()
  {
    JTabbedPane tabbedPane = new JTabbedPane();

    JPanel p1 = createTabPanel(new MigLayout("fill"));

    p1.add(createPanel("1. North"), "north");
    p1.add(createPanel("2. West"), "west");
    p1.add(createPanel("3. East"), "east");
    p1.add(createPanel("4. South"), "south");

    String[][] data = new String[20][6];
    for (int r = 0; r < data.length; r++) {
      data[r] = new String[6];
      for (int c = 0; c < data[r].length; c++)
        data[r][c] = "Cell " + (r + 1) + ", " + (c + 1);
    }
    JTable table = new JTable(data, new String[] {"Column 1", "Column 2", "Column 3", "Column 4", "Column 5", "Column 6"});
    p1.add(new JScrollPane(table), "grow");

    JPanel p2 = createTabPanel(new MigLayout("fill", "[c]", ""));

    p2.add(createPanel("1. North"), "north");
    p2.add(createPanel("2. North"), "north");
    p2.add(createPanel("3. West"), "west");
    p2.add(createPanel("4. West"), "west");
    p2.add(createPanel("5. South"), "south");
    p2.add(createPanel("6. East"), "east");
    p2.add(createButton("7. Normal"));
    p2.add(createButton("8. Normal"));
    p2.add(createButton("9. Normal"));

    JPanel p3 = createTabPanel(new MigLayout());

    p3.add(createPanel("1. North"), "north");
    p3.add(createPanel("2. South"), "south");
    p3.add(createPanel("3. West"), "west");
    p3.add(createPanel("4. East"), "east");
    p3.add(createButton("5. Normal"));

    JPanel p4 = createTabPanel(new MigLayout());

    p4.add(createPanel("1. North"), "north");
    p4.add(createPanel("2. North"), "north");
    p4.add(createPanel("3. West"), "west");
    p4.add(createPanel("4. West"), "west");
    p4.add(createPanel("5. South"), "south");
    p4.add(createPanel("6. East"), "east");
    p4.add(createButton("7. Normal"));
    p4.add(createButton("8. Normal"));
    p4.add(createButton("9. Normal"));

    JPanel p5 = createTabPanel(new MigLayout("fillx", "[c]", ""));

    p5.add(createPanel("1. North"), "north");
    p5.add(createPanel("2. North"), "north");
    p5.add(createPanel("3. West"), "west");
    p5.add(createPanel("4. West"), "west");
    p5.add(createPanel("5. South"), "south");
    p5.add(createPanel("6. East"), "east");
    p5.add(createButton("7. Normal"));
    p5.add(createButton("8. Normal"));
    p5.add(createButton("9. Normal"));

    JPanel p6 = createTabPanel(new MigLayout("fill", "", ""));

    Random rand = new Random();
    String[] sides = {"north", "east", "south", "west"};
    for (int i = 0; i < 20; i++) {
      int side = rand.nextInt(4);
View Full Code Here

  public JComponent createAbsolute_Position()
  {
    JTabbedPane tabbedPane = new JTabbedPane();

    // Pos tab
    final JPanel posPanel = createTabPanel(new MigLayout());

    posPanel.add(createButton(), "pos 0.5al 0al");
    posPanel.add(createButton(), "pos 1al 0al");
    posPanel.add(createButton(), "pos 0.5al 0.5al");
    posPanel.add(createButton(), "pos 5in 45lp");
    posPanel.add(createButton(), "pos 0.5al 0.5al");
    posPanel.add(createButton(), "pos 0.5al 1.0al");
    posPanel.add(createButton(), "pos 1al .25al");
    posPanel.add(createButton(), "pos visual.x2-pref visual.y2-pref");
    posPanel.add(createButton(), "pos 1al -1in");
    posPanel.add(createButton(), "pos 100 100");
    posPanel.add(createButton(), "pos (10+(20*3lp)) 200");
    posPanel.add(createButton("Drag Window! (pos 500-container.xpos 500-container.ypos)"),
                                "pos 500-container.xpos 500-container.ypos");

    // Bounds tab
    JPanel boundsPanel = createTabPanel(new MigLayout());

    String constr = "pos (visual.x+visual.w*0.1) visual.y2-40 (visual.x2-visual.w*0.1) visual.y2";
    JLabel southLabel = createLabel(constr, SwingConstants.CENTER);
    southLabel.setBorder(new LineBorder(Color.LIGHT_GRAY, 1));
    southLabel.setBackground(new Color(200, 200, 255, benchRuns == 0 ? 70 : 255));
    southLabel.setOpaque(true);
    southLabel.setFont(southLabel.getFont().deriveFont(Font.BOLD));
    boundsPanel.add(southLabel, constr);

    boundsPanel.add(createButton(), "pos 0 0 container.x2 n");
    boundsPanel.add(createButton(), "pos visual.x 40 visual.x2 70");
    boundsPanel.add(createButton(), "pos visual.x 100 visual.x2 p");
    boundsPanel.add(createButton(), "pos 0.1al 0.4al n (visual.y2 - 10)");
    boundsPanel.add(createButton(), "pos 0.9al 0.4al n visual.y2-10");
    boundsPanel.add(createButton(), "pos 0.5al 0.5al, pad 3 0 -3 0");
    boundsPanel.add(createButton(), "pos n n 50% 50%");
    boundsPanel.add(createButton(), "pos 50% 50% n n");
    boundsPanel.add(createButton(), "pos 50% n n 50%");
    boundsPanel.add(createButton(), "pos n 50% 50% n");

    tabbedPane.addTab("X Y Positions", posPanel);
    tabbedPane.addTab("X1 Y1 X2 Y2 Bounds", boundsPanel);

    // Glass pane tab
    if (benchRuns == 0) {
      final JPanel glassPanel = createTabPanel(new MigLayout("align c c, ins 0"));
      final JButton butt = createButton("Press me!!");
      glassPanel.add(butt);

      butt.addActionListener(new ActionListener()    {
        public void actionPerformed(ActionEvent e)
        {
          butt.setEnabled(false);
          final JPanel bg = new JPanel(new MigLayout("align c c,fill")) {
            public void paint(Graphics g)
            {
              g.setColor(getBackground());
              g.fillRect(0, 0, getWidth(), getHeight());
              super.paint(g);
View Full Code Here

  public JComponent createComponent_Links()
  {
    JTabbedPane tabbedPane = new JTabbedPane();

    JPanel linksPanel = createTabPanel(new MigLayout());

    // Links tab
    JButton mini = createButton("Mini");
    mini.setMargin(new Insets(0, 1, 0, 1));
    linksPanel.add(mini, "pos null ta.y ta.x2 null");
    linksPanel.add(createTextArea("Components, Please Link to Me!\nMy ID is: 'ta'", 3, 30), "id ta, pos 0.5al 0.5al");
    linksPanel.add(createButton(), "id b1,pos ta.x2 ta.y2");
    linksPanel.add(createButton(), "pos b1.x2+rel b1.y visual.x2 null");
    linksPanel.add(createButton(), "pos ta.x2+rel ta.y visual.x2 null");
    linksPanel.add(createButton(), "pos null ta.y+(ta.h-pref)/2 ta.x-rel null");
    linksPanel.add(createButton(), "pos ta.x ta.y2+100 ta.x2 null");
    linksPanel.add(createCheck("pos (ta.x+indent) (ta.y2+rel)"),
                               "pos (ta.x+indent) (ta.y2+rel)");

    // External tab
    JPanel externalPanel = createTabPanel(new MigLayout());

    JButton extButt = createButton("Bounds Externally Set!");
    extButt.setBounds(250, 130, 200, 40);
    externalPanel.add(extButt, "id ext, external");
    externalPanel.add(createButton(), "pos ext.x2 ext.y2");
    externalPanel.add(createButton(), "pos null null ext.x ext.y");

    // Start/End Group tab
    JPanel egPanel = createTabPanel(new MigLayout());

    egPanel.add(createButton(), "id b1, endgroupx g1, pos 200 200");
    egPanel.add(createButton(), "id b2, endgroupx g1, pos (b1.x+2ind) (b1.y2+rel)");
    egPanel.add(createButton(), "id b3, endgroupx g1, pos (b1.x+4ind) (b2.y2+rel)");
    egPanel.add(createButton(), "id b4, endgroupx g1, pos (b1.x+6ind) (b3.y2+rel)");

    // Group Bounds tab
    JPanel gpPanel = createTabPanel(new MigLayout());

    gpPanel.add(createButton(), "id grp1.b1, pos n 0.5al 50% n");
    gpPanel.add(createButton(), "id grp1.b2, pos 50% 0.5al n n");
    gpPanel.add(createButton(), "id grp1.b3, pos 0.5al n n b1.y");
    gpPanel.add(createButton(), "id grp1.b4, pos 0.5al b1.y2 n n");
View Full Code Here

    return tabbedPane;
  }

  public JPanel createFlowPanel(String gridFlow, String cellFlow)
  {
    MigLayout lm = new MigLayout("center, wrap 3," + gridFlow,
                                 "[110,fill]",
                                 "[110,fill]");
    JPanel panel = createTabPanel(lm);

    Font f = panel.getFont().deriveFont(20f);
View Full Code Here

    return createPlainImpl(true);
  }

  public JComponent createButton_Bars()
  {
    MigLayout lm = new MigLayout("ins 0 0 15lp 0",
                                      "[grow]",
                                      "[grow][baseline,nogrid]");

    final JPanel mainPanel = new JPanel(lm);
    final JLabel formatLabel = createLabel("");
View Full Code Here

TOP

Related Classes of net.miginfocom.swing.MigLayout

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.