GithubHelp home page GithubHelp logo

miglayout's Introduction

miglayout

Official MiG Layout for Swing, SWT and JavaFX

For Java developers writing GUI layouts by hand that wants simplicity, power and automatic per platform fidelity, that are dissatisfied with the current layout managers in Swing, JavaFX and SWT, MigLayout solves your layout problems. User interfaces created with MigLayout is easy to maintain, you will understand how the layout will look like just by looking at the source code.

MigLayout is a superbly versatile JavaFX/SWT/Swing layout manager that makes layout problems trivial. It is using String or API type-checked constraints to format the layout. MigLayout can produce flowing, grid based, absolute (with links), grouped and docking layouts. You will never have to switch to another layout manager ever again! MigLayout is created to be to manually coded layouts what Matisse/GroupLayout is to IDE supported visual layouts.

For documentation see http://miglayout.com

miglayout's People

Contributors

aalmiray avatar cquiroz avatar ctrueden avatar dependabot[bot] avatar devcharly avatar develar avatar jlleitschuh avatar karlvr avatar matklad avatar mikaelgrev avatar monezz avatar nu11ptr avatar ptziegler avatar swimmesberger avatar tbee avatar urskr avatar vlsi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

miglayout's Issues

Component grows unexpectedly in height

Since I upgraded to MigLayout 5.0, I got an issue with my JLabel displaying HTML text. First I thought the HTML rendering is broken but then I realized it works with MigLayout 4.2. Note: it does not happen when I remove the <li> tags.

Here is an example:

import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import net.miginfocom.swing.MigLayout;

public class TestLITag {
  public static void main(final String[] args) {

    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {

        final String s = "<html><p>Connection refused, the server does not respond as expected</p>"
            + "<li>Check the URL below, especially the port</li>"
            + "<li>Check the connection to the device</li>"
            + "<li>Check the port configuration of the device</li>"
            + "<li>Check the configuration of your antivirus or firewall software</li>"
            + "<li>Contact your administrator</li>"
            + "<li>Contact our service or send an error report</li>"
            + "</html>";

        final JLabel warningLabel = new JLabel(s);

        final JPanel p = new JPanel(new MigLayout());

        p.add(warningLabel);

        JOptionPane.showMessageDialog(null, p);
      }
    });

  }
}

Is soft-wrap possible?

Hi,

MigLayout is great. I've implemented a face lifting for Apache JMeter: apache/jmeter#513, and it does make the UI much more solid :)

Here's a question: can I wrap components depending on the width of the window?

For instance, the above link has "action to be taken after a sampler error" group.
The group includes 5 radio buttons. Can I make the buttons wrap to the next line if they don't fit the line?

I tried new MigLayout("nogrid"), but it does not really help (which is kind of understandable, but I tried)

How to use MigLayout with FXML?

Is there a way to use MigLayout in an FXML file and specify the constraints?

<MigPane xmlns="http://javafx.com/javafx"
         xmlns:fx="http://javafx.com/fxml"
         fx:controller="com.company.project.login.LoginScreenController"
>
    <layoutConstraints>
<!-- How to specify constraints here? -->
    </layoutConstraints>
    <rowConstraints>

    </rowConstraints>
    <columnConstraints>

    </columnConstraints>
...
</MigPane>

Miglayout not compatible with iOS/robovm because of Java8 API dependency

Hi,

I am trying to get my application to run on iOS using robovm but ran into a 
show-stopping problem, i.e. that my build failed complaining that my code 
somewhere (indirectly) referenced something from the java.util.function/stream 
packages which are not supported in the robovm runtime (see javafxports). I 
think I have found the problem in Miglayout, i.e. the following line from 
MigPane.java:

return getManagedChildren().stream().map(node -> new 
FX2ComponentWrapper(node)).toArray(FX2ComponentWrapper[]::new);

Could you replace this code by a JDK6-compatible version, so that Miglayout 
becomes an option on iOS?

Thanks,

Robert

Original issue reported on code.google.com by [email protected] on 3 Apr 2015 at 2:46

The last stable release is 3 years old…

The last stable release is version 4.2 on 2011/12/09:
http://www.miglayout.com/mavensite/changes-report.html

Release 5.0 is mentioned on the web site but there are only snapshot versions 
without release notes. Most stable projects don't want to use snapshot 
dependencies because they need reproducible builds and don't want to suffer 
from regressions that could be introduced in new snapshots. This means those 
are stuck with release 4.2 for now -- or need to repackage the project.

For example, we are using release 4.2 and just discovered the memory leak 
mentioned here:
http://migcalendar.com/forums/viewtopic.php?f=8&t=3906
which says “This is fixed in the next version out in about a week.” -- this 
was in February 2013…

I know maintaining such a project (for free!) is time consuming but it really 
looks like the project is dying. The only thing that seems to tell the opposite 
is the git activity (which is already good).

I think though that it would be good to already publish version 5.0 and maybe 
continue with small incremental but more frequent versions (e.g. 5.0.1 and so 
on). This would also give more attention to the project and maybe attract some 
contributors. RERO! :)

p.s.: I'm sorry but I could not find a way to contact Mikael directly, neither 
on the web site, nor the forum or here on google code…

Original issue reported on code.google.com by [email protected] on 23 Dec 2014 at 10:33

Add OSGi support

We'd like to have OSGi support, basically adding export headers to the jar file. This should be automated on the build process using the maven-bundle-plugin

MigLayout 5.0-SNAPSHOT performs slowly when calculating layout for a lot of nodes in JavaFX 8

Since it resolves issue #6, I migrated my code to MigLayout 5.0-SNAPSHOT.

Running the full application, I took a severe performance hit:
When adding a good number of nodes, part of them stacked MigLayouts to a scene, 
my application spend most of its time calculation the new layout, becoming 
inresponsive for a good while.

My profiler indicates that this is due to the hashcode calculation, where you 
concatenate a number of Strings.

I have attached the profiling results. 

If you need one, I will try to come up with a running example of this issue.

Original issue reported on code.google.com by [email protected] on 12 Apr 2014 at 12:06

Attachments:

The component constraint "eg" throws a "Unknown keyword" exception.

What steps will reproduce the problem?
1. add(mycomponent, "eg");

What is the expected output? What do you see instead?
The white paper explains the expected behavior of the constraint "eg".
I see 
java.lang.IllegalArgumentException: Illegal Constraint: 'eg'
Unknown keyword.


What version of the product are you using? On what operating system?
I downloaded the version on 3-19-2013.


Original issue reported on code.google.com by [email protected] on 26 Feb 2014 at 4:13

Size group shrinks instead of expands

MigPane root = new MigPane(new LC().debug(1000));
root.add(new Label("Label1"), "sgx, wrap");
root.add(new Label("Second Label"), "sgx");

The first label should be expanded to the size of the second label but instead 
the second label is shrunk to the size of the first.


Original issue reported on code.google.com by [email protected] on 12 Apr 2012 at 6:45

Invalid reference in white paper

The MigLayout white paper 
(http://www.migcalendar.com/miglayout/mavensite/docs/whitepaper.html) mentions 
PlatformConverter.getButtonBarOrder(int type) as a reference for detailed tag 
name information. But neither the class, nor the method exists.

Original issue reported on code.google.com by [email protected] on 24 Nov 2012 at 10:08

Most recent 5.0-SNAPSHOT breaks example for Issue #6

The recent changes on 5.0-SNAPSHOT for JavaFX introduce major issues.
Using the latest build renders both my application and the (very simple) 
example[1] I created for Issue #6 unusable.

The commits are 61479b744417 and 96fcdad92c88, but both are so extensive that I 
can't yet pinpoint the issue.

[1]: https://github.com/UrsKR/miglayout-repaint

Original issue reported on code.google.com by [email protected] on 17 Apr 2014 at 7:30

Attachments:

IllegalArgumentException in ver 5.2 (OK in ver 5.1)

When using MigLayout ver 5.2 in pom.xml for
https://sourceforge.net/p/jgpstrackedit/code/ci/master/tree/
class DlgMerge:

import net.miginfocom.swing.MigLayout;

public class DlgMerge extends JDialog {
...
contentPanel.setLayout(new MigLayout("", "[][]", "[][][][]"));
...
this.pack();
...
}

=>

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Width and height must be >= 0
at java.awt.Component.getBaseline(Unknown Source)
at javax.swing.JComponent.getBaseline(Unknown Source)
at javax.swing.plaf.basic.BasicComboBoxUI.getBaseline(Unknown Source)
at javax.swing.JComponent.getBaseline(Unknown Source)
at net.miginfocom.swing.SwingComponentWrapper.getBaseline(Unknown Source)
at net.miginfocom.layout.Grid$CompWrap.getBaseline(Unknown Source)
at net.miginfocom.layout.Grid$CompWrap.access$5000(Unknown Source)
at net.miginfocom.layout.Grid.getBaselineAboveBelow(Unknown Source)
at net.miginfocom.layout.Grid.access$4500(Unknown Source)
at net.miginfocom.layout.Grid$LinkedDimGroup.getMinPrefMax(Unknown Source)
at net.miginfocom.layout.Grid$LinkedDimGroup.access$3300(Unknown Source)
at net.miginfocom.layout.Grid.getTotalGroupsSizeParallel(Unknown Source)
at net.miginfocom.layout.Grid.calcRowsOrColsSizes(Unknown Source)
at net.miginfocom.layout.Grid.calcGridSizes(Unknown Source)
at net.miginfocom.layout.Grid.checkSizeCalcs(Unknown Source)
at net.miginfocom.layout.Grid.layoutImpl(Unknown Source)
at net.miginfocom.layout.Grid.layout(Unknown Source)
at net.miginfocom.swing.MigLayout.layoutContainer(Unknown Source)
at java.awt.Container.layout(Unknown Source)
at java.awt.Container.doLayout(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validate(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Memory Leak in LinkHandler?

We have an application where we are instantiating a lot of (~2000+) instances 
of MigLayout.

For each instance there are created at least one HashMap in LinkHandler. Those 
HashMaps are never cleaned up in our application.

Debugging showed me, that net.miginfocom.layout.LinkHandler#getValue() is never 
called.
I have added some code that calls the read method regularly, which fixes this 
issue. 


BTW:
net.miginfocom.layout.LinkHandler#clearWeakReferencesNow seems to not clear 
VALUES and VALUES_TEMP. 
I don't see any way those collections are cleaned up when 
clearWeakReferencesNow() has been called.

Original issue reported on code.google.com by [email protected] on 28 Jan 2015 at 9:14

Custom component is misaligned in latest revision of 5.0-SNAPSHOT

The latest revision misaligns a custom component in my application.
This is especially visible after initial layout and gets less so after using 
the component.

The screens below show the initial layout and the layout after use.

Note that the component doesn't use MigLayout internally, but there are several 
MigPanes per visible row, as the screenshots taken with Debug activated 
illustrate.

I haven't yet tried to create a running sample of this issue, will do on 
request.

Original issue reported on code.google.com by [email protected] on 18 Apr 2014 at 7:54

Attachments:

NPE in getMinPrefMaxSumSize when using setGraphics in ListView in Java9

Hi,
We just started experimenting with Java9 in our application and we ran into a NPE when using "setGraphics" in ListView. Below is a simple test program to reproduce the error. Note that the error can be avoided by fixing the dimensions of the MigPane as demonstrated in the test program.

Best regards,

-Bjarni

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException at net.miginfocom.layout.Grid$FlowSizeSpec.access$2700(Unknown Source) at net.miginfocom.layout.Grid.getMinPrefMaxSumSize(Unknown Source) at net.miginfocom.layout.Grid.calcGridSizes(Unknown Source) at net.miginfocom.layout.Grid.checkSizeCalcs(Unknown Source) at net.miginfocom.layout.Grid.getWidth(Unknown Source) at org.tbee.javafx.scene.layout.MigPane.computeWidth(Unknown Source) at org.tbee.javafx.scene.layout.MigPane.computeMinWidth(Unknown Source) at javafx.graphics/javafx.scene.Parent.minWidth(Parent.java:1067) at javafx.graphics/javafx.scene.layout.Region.minWidth(Region.java:1509) at org.tbee.javafx.scene.layout.MigPane$FXComponentWrapper.getMinimumWidth(Unknown Source)

Simple test program:

import org.tbee.javafx.scene.layout.MigPane;

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.stage.Stage;

/**
 * Simple test app for the ListView setGraphics bug in MigPane
 */
public class ListViewTestApp extends Application {

    /**
     * @param args a
     */
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {

        ListViewTester listViewTester = new ListViewTester();

        Button btn = new Button("Add to list");
        btn.setOnAction(e -> listViewTester.stringsData.add("New " + listViewTester.stringsData.size()));

        MigPane pane = new MigPane();
        pane.add(new Label("Error in MigPane 5.1 on Java9"), "wrap");
        pane.add(new Label("Reproduce for example by adding a few items to the list view and then quickly select different items in the list"), "wrap");
        pane.add(btn, "wrap");
        pane.add(listViewTester, "growx, pushx");

        primaryStage.setTitle("ListView test");
        primaryStage.setScene(new Scene(pane));

        // solution: avoid dimension calculation, with either bind
//        bindDimensions(listViewTester, primaryStage.getScene());
        // or absolute fix
//        listViewTester.setMinHeight(500);
//        listViewTester.setMaxHeight(500);
//        listViewTester.setPrefHeight(500);
//        listViewTester.setMinWidth(500);
//        listViewTester.setMaxWidth(500);
//        listViewTester.setPrefWidth(500);

        primaryStage.show();
    }

    private static void bindDimensions(MigPane migPane, Scene scene) {
        migPane.minWidthProperty().bind(scene.widthProperty());
        migPane.maxWidthProperty().bind(scene.widthProperty());
        migPane.prefWidthProperty().bind(scene.widthProperty());
        migPane.minHeightProperty().bind(scene.heightProperty());
        migPane.maxHeightProperty().bind(scene.heightProperty());
        migPane.prefHeightProperty().bind(scene.heightProperty());
    }

    private static class ListViewTester extends MigPane {
        ListView<String> stringsView = new ListView<>();
        ObservableList<String> stringsData = FXCollections.observableArrayList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");

        ListViewTester() {
            stringsView.setItems(stringsData);
            stringsView.setCellFactory(list -> new TestCell());
            add(stringsView, "growx, pushx");
        }
    }

    private static class TestCell extends ListCell<String> {
        @Override
        public void updateItem(String item, boolean empty) {
            super.updateItem(item, empty);
            if (empty || item == null) {
                setText(null);
                setGraphic(null);
            } else {
//                setText(item);
                setGraphic(new Label("Label: " + item));
            }
        }
    }
}

Could "temporary default component constraints" be added?

Use case:

apache/jmeter#513

I want to build a JPanel for the right part of the window.

The case there is:

Name:      _____
Comments:  _____
...

In current implementation, "name and comments" is its own MigLayout("fillx, wrap 2, insets 0", "[][fill,grow]")

The problem: what if I want to add some fields below Name and Comments?

If I just call panel.add(component), then it would add the component to the first cell.
Of course, the workaround would be panel.add(extraComponent, "span 2"), however, it does not work if I want the UI to be extensible.
In other words, the one who adds extraComponent does not really know that name/comments is structured as two columns.

What if the was MigLayout#setDefaultComponentConstraintsForNextComponents(String)?
Then I could create my name/comments panel as two-column panel, then I call setDefaultComponentConstraintsForNextComponents("span 2") and everyone else who adds components would automatically get span 2 constraint.

On the other hand, the one who cares could either reset the default or override it by using span 1. Then one could add Description: _____ field which would align nicely with Name/comments fields.

Does the above make sense?

Rotate is not handled correctly

Comment out the setRotate and things are peachy, leaving it in not so much. Resizing also works in the wrong direction. Try 45 degrees or adding it to the regular layout. We need to compensate for / undo the rotation somehow.

`
package org.tbee.javafx.scene.layout.trial;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import net.miginfocom.layout.CC;
import net.miginfocom.layout.LC;
import org.tbee.javafx.scene.layout.MigPane;

public class MigPaneTrial1 extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        MigPane migPane = new MigPane(new LC());
        migPane.add(new Label("Label"), new CC().wrap());
        migPane.add(new Label("Label"), new CC().wrap().push().grow());
        migPane.add(new Label("Label"), new CC().wrap());
        Button button = new Button("Button");
        migPane.add(button, new CC().dockWest().grow());
        //migPane.add(button, new CC().wrap().grow().push());
        button.setRotate(90);
        Scene scene = new Scene(migPane);
        stage.setScene(scene);
        stage.show();
    }
}

`

Wrong source level in Maven POMs

MigLayout Core uses diamond operators in Grid, but doesn't specify source level 
1.7 in its Maven POM. This leads to errors during the build, as Maven defaults 
to source level 1.6.

I don't provide a pullable commit for this, as I am not sure about your 
intention here - support 1.6 or update?
In any case, you have the necessary configuration in the POM for MigLayout 
JavaFX.

Original issue reported on code.google.com by [email protected] on 17 Apr 2014 at 6:52

Will miglayout support android officially?

The layout managers provided by android is even worse than java's. I hope to 
use miglayout in my android development. For now, I found: 
https://github.com/saynomoo/mig4android , but it is buggy.

Will miglayout support android officially? It will be a great news for android 
developers.

Original issue reported on code.google.com by [email protected] on 23 Sep 2012 at 5:39

Latest 5.0-SNAPSHOT does not render children added via MigPane.getChildren().add(Node)

Testing with the latest SNAPSHOT in the Maven repository, I noticed that nodes 
are rendered in an unexpected fashion - or not rendered at all - when added via 
getChildren.add(Node).

This wouldn't be much of an issue, but direct interaction with the list is the 
only way to inject a node at an earlier position without adressing cells 
directly. Also, direct interaction with the List is the default way of adding 
nodes to a layout in JavaFX.

I assume that this was caused by the changes to constraint-mapping in 
3cf3981af5ec.

Original issue reported on code.google.com by [email protected] on 23 Apr 2014 at 4:22

Attachments:

Migpane problem with size

Hello,
Having used Mig for Swing for many and now am transitioning to JavaFX and have discovered a strange issue how nodes are displayed on differnet computers.

Consider this code;

`public class MigPaneMain extends Application {

@Override
public void start (Stage stage) throws Exception {
        MigPane root = new MigPane();
        Scene scene = new Scene(root);

        Label lbl = new Label("label");
        TextField tf = new TextField();
        VBox box = new VBox(tf, lbl);
        
        root.add(box, "w 200!");
        
        //Button b = new Button("Hello");
        //root.getChildren().add(b);

        stage.setScene(scene);
        stage.setTitle("FX");
        stage.setWidth(1000);
        stage.setHeight(500);
        stage.show();
}

public static void main (String[] args) {
        launch (args);
}

}`
Both computer Windows 10. Java-8_181. MipPane. 5.3.

Computer 1. w 200! is not respected

image

Computer 2

image

Let me know if you need debug information.

Br,
Hugo

JavaFX MigPane not updating after using getLayoutConstraints().setWrapAfter()

I'm using a MigPane in JavaFX, and updating the wrap value in the layout constraints dynamically using getLayoutConstraints().setWrapAfter(newWrapValue). The issue is that this doesn't seem to force a relayout of the pane. I've tried following that up with a few things including requestLayout() and setNeedsLayout(true), but the only thing I've found that seems to force a relayout is changing the children nodes of the pane.

As a side note, I had the same issue with row and column size constraints (ex. getColumnConstraints().size()), and calling requestLayout() after those changes did in fact force a relayout.

Loading an image into a button moves adjacent text in latest revision of 5.0-SNAPSHOT

When I load an Image into a Button's ImageView, the layout sees reason to 
change and move adjacent text down, so that it is no longer aligned with the 
button.

Attached is a sample application that illustrates the problem.
Drop the main class in src/test/java, the image into src/test/resources and run 
the main method.

(Sorry for the weird summary, I had no clue how to summarize this issue.)

Original issue reported on code.google.com by [email protected] on 18 Apr 2014 at 7:00

Attachments:

Swing JLabel with HTML content - height correlates with width

I'm still experiencing issues with JLabels and html somehow when the length of a label is changed the rows of miglayout get larger. To better demonstrate the issue I have created a small single class application:
https://gist.github.com/swimmesberger/9b7f1d6fecee005bb7587286d4e65399

If you click on the "switch" button you see that the row in miglayout changes height even though there is enough space to only scale horizontally. It has something to do with the getBaseline method if I change that to return only "-1" it works as expected.
Also if no HTML is used it works as expected.

absolute layout (x,y,w,h) looks different on Windows and Mac (windows wrong)

in MigLayout 5.1 (current snapshot) there are layout problems on Windows and Mac. The main problem ist: When I make a layout via absolute coordinates (x,y,w,h), the layout on Windows is rendered wrong, on Mac it's correct.

miglayout-mac
miglayout-win

Example:

Example shows a Label which should have 50% of width of the parent container (frame). On Mac it's correct, on windows width is higher than 50%...

package com.ultramixer;

import net.miginfocom.swing.MigLayout;
import javax.swing.*;

public class TestMigLayout extends JFrame
{
    public TestMigLayout()
    {
        this.setLayout(new MigLayout("hidemode 2,debug,ins 0", "[]", "[]"));

        JLabel label = new JLabel("TEST MIGLAYOUT");
        this.add(label, "x 0, y 0, w 250, h 200");

        this.setSize(500, 400);
        this.setVisible(true);
    }

    public static void main(String[] args)
    {
        new TestMigLayout();
    }
}

Build error running on OSX

Checked out the project (HEAD = c15906b) and tried a build with Azul's ZuluFX

$ mvn --version
Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /Users/aalmiray/.sdkman/candidates/maven/current
Java version: 1.8.0_265, vendor: Azul Systems, Inc., runtime: /Users/aalmiray/.sdkman/candidates/java/8.0.265.fx-zulu/zulu-8.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.7", arch: "x86_64", family: "mac"
$ java -version
openjdk version "1.8.0_265"
OpenJDK Runtime Environment (Zulu 8.48.0.53-CA-macosx) (build 1.8.0_265-b11)
OpenJDK 64-Bit Server VM (Zulu 8.48.0.53-CA-macosx) (build 25.265-b11, mixed mode)

The miglayout-javafx module fails with

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.tbee.javafx.scene.layout.test.MigPaneInternalLayoutTest
Tests run: 8, Failures: 8, Errors: 0, Skipped: 0, Time elapsed: 3.813 sec <<< FAILURE!

Results :

Failed tests: 
  external(org.tbee.javafx.scene.layout.test.MigPaneInternalLayoutTest): expected:<200.0> but was:<218.0>
  pack(org.tbee.javafx.scene.layout.test.MigPaneInternalLayoutTest): expected:<140.0> but was:<144.0>
  size(org.tbee.javafx.scene.layout.test.MigPaneInternalLayoutTest): expected:<1165.0> but was:<690.0>
  span(org.tbee.javafx.scene.layout.test.MigPaneInternalLayoutTest): expected:<834.0> but was:<879.0>
  wrap(org.tbee.javafx.scene.layout.test.MigPaneInternalLayoutTest): expected:<475.0> but was:<519.0>
  defaultLayout(org.tbee.javafx.scene.layout.test.MigPaneInternalLayoutTest): expected:<453.0> but was:<496.0>
  twoChildBasicLayout(org.tbee.javafx.scene.layout.test.MigPaneInternalLayoutTest): expected:<200.0> but was:<218.0>
  wrappingLabel(org.tbee.javafx.scene.layout.test.MigPaneInternalLayoutTest): expected:<48.0> but was:<52.0>

Tests run: 8, Failures: 8, Errors: 0, Skipped: 0

MigPane renders Label with setWrapText(true) wrong

If you change the available space for a Label with wrapText=true, the label is shown with ellipsis string and the height is locked and do not grow as expected.

Example

import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;
import org.tbee.javafx.scene.layout.MigPane;

/**
 * Created by TB on 28.07.16.
 */
public class TestLabelMigPaneApplication extends Application
{
    @Override
    public void start(Stage primaryStage) throws Exception
    {
        String message = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus.";

        MigPane root = new MigPane("", "[][]", "[]");


        Label text = new Label(message);
        text.setWrapText(true);

        TextFlow textFlow = new TextFlow();
        Text txt = new Text(message);
        textFlow.getChildren().add(txt);
        textFlow.setLineSpacing(1.7);

        root.add(text);
        root.add(textFlow);

        Scene scene = new Scene(root, 800, 600);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args)
    {
        launch(args);
    }
}

[RFE] Allow overriding grid gap size between components

It's quite amazing how flexible MigLayout already is, but one thing I find 
missing: I cannot override the layout grid gap size in the component 
constraints!

While I'm already able to achieve the desired layout, it's a bit cumbersome to 
have to define row constraints

new MigLayout("insets dialog", "[grow][][grow][]", "[][][] 1lp");

in order to override the default vertical gap size between two rows.

This also ties the order of components to the definition, which is a potential 
maintenance burden as you have to adjust the row constraints definition if 
components are to be rearranged.

Original issue reported on code.google.com by [email protected] on 28 Nov 2012 at 8:44

TreeView / ListView Conflicts

What steps will reproduce the problem?
1. Create a list view on the left (Or the right, but for me its on the left) in 
a single pane.
2. Create a TreeView on the right side of the pane.
3. At least 20~ items in the listview.
4. 10~ or so leafs with 1-2 children each in the treeview.

What is the expected output? What do you see instead?

Initially (Pre-Interaction) the treeview and listview both remain as they 
should, however after scrolling down some on either and trying to click one of 
the items (On listview or expand a treeview item) the components break and go 
nuts.


What version of the product are you using? On what operating system?

5.0-SNAPSHOT
JDK8u20

Please provide any additional information below.

Initially...

https://i.imgur.com/gYFWMqi.png

And then scrolled down the ListView and than tried to click (Oddly enough also 
the lower items in listView aren't even selectable for some reason) and than 
tried to click a higher item and the listview cut itself in half and became..

https://i.imgur.com/TGJOQDr.png


Messed with the Treeview and than suddenly.. kaboom

https://i.imgur.com/CQF5Vu4.png

Original issue reported on code.google.com by [email protected] on 31 Aug 2014 at 12:38

Release with debug information

The latest release in Maven central seems to be compiled without debug 
information.

I'd prefer to have them in the official release. Makes it easier to locate any 
bugs/problems with MigLayout.

Original issue reported on code.google.com by [email protected] on 28 Jan 2015 at 9:17

For JavaFX MigPane, calling "add" with an index has no effect

After running the code below in my application. the labels were shown in the order "second", "first". The label with "first" should have been first. This was working, but then broke after the latest snapshot update.

//where menuContainer is already created in some fxml
Label label1 = new Label("first");
Label label2 = new Label("second");
menuContainer.add(label2);
menuContainer.add(0, label1);

Expose boundsInGrid within CC?

Was working on something kotlin related for an extension set of functions to declare miglayout programmatically with a DSL instead of with raw strings and ran into the problem of CC::boundsInGrid not being exposed with a setter (and having to hack around this with reflection isn't ideal) Any chance this could get a public setter to go along with the getter?

Inconsistent column/row gaps with empty columns/rows

If a layout has empty columns/row, then there is an inconsistency in computing column/row gaps depending on whether column/row constraints are specified or not.

Here is a program that demonstrates the difference:

public class GapMergeTest
{
    public static void main(String[] args)
    {
        JPanel panel1 = new JPanel(new MigLayout("debug"));
        panel1.add(new JLabel("cell 0 0"), "cell 0 0");
        panel1.add(new JLabel("cell 0 2"), "cell 0 2");

        JPanel panel2 = new JPanel(new MigLayout("debug", "", "[][][]"));
        panel2.add(new JLabel("cell 0 0"), "cell 0 0");
        panel2.add(new JLabel("cell 0 2"), "cell 0 2");

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add( panel1, BorderLayout.WEST );
        frame.getContentPane().add( panel2, BorderLayout.EAST );
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}

gapmergetest

The left panel does not have column constraints and the gap between the two visible rows is as expected a single "rel".

The right panel has column constraints "[][][]", but the gap between the two visible rows is 2x "rel".

Is this correct behaviour?
Feels confusing to me...

Spacing in 5.0 for swing much greater

I recently upgraded one of my applications to MigLayout 5.0 and the users complain that the fields didn't fit on the screen anymore. Attached are screenshots of the same screen under 3.7.3, 4.2 and 5.0 and it is clearly visible under 5.0 the spacing is almost double.

3 7 3
4 2
5 0

MigPane doesn't seem to honour the 'wrap-text' property of Label

MigPane doesn't seem to honour the 'wrap-text' property of Label. It still 
crops it.

    public void start(Stage stage) throws Exception
    {
        MigPane pane = new MigPane();
        Label label = new Label("Test long label to see if the wrap works ok in a Migpane. I am"
                + " going to have to keep writing because this may not be long enough yet!!");
        pane.setStyle("-fx-border-color:blue");
        label.setWrapText(true);
        pane.getChildren().add(label);
        Scene scene = new Scene(pane, 400, 400);
        stage.setScene(scene);
        stage.show();
    }

I'm assuming it's something to do with the size calculation aspect.

Cheers, 
zonski

Original issue reported on code.google.com by zonski on 9 Jan 2012 at 3:52

MigPane sizing not properly

What steps will reproduce the problem?
Run attached source


What is the expected output? What do you see instead?
MigPane doesn't handle properly the pane sizing, in fact it should match with 
the button's preferred size (like HBox or similar layouts in FX). Instead the 
pane is more little than the button (see screenshot).

What version of the product are you using? On what operating system?
Linux 3.2.0, JRE 1.7.0_45-b18, MigLayout (MigPane) 4.2

Original issue reported on code.google.com by [email protected] on 4 Dec 2013 at 7:01

Attachments:

[Pull Request] Fixes for JavaDoc

Freshly cloning MigLayout and building miglayout-core, I found that 
mvn install 
wouldn't work properly due to several issues with the JavaDoc.
I am building on JDK 8, maybe some checks are more rigorous there.

I made the required changes to the documentation so the project builds once 
again.

You can pull the changes from 
https://github.com/UrsKR/miglayout/tree/master
if you are interested.

Original issue reported on code.google.com by [email protected] on 13 Apr 2014 at 11:08

Is it possible to expose and use ids when layouts are shared?

Use case: https://stackoverflow.com/questions/19589694/miglayout-set-equal-column-width-in-nested-panels-with-layoutmanagers

What if "nested" layout could expose its component and sizegroup ids to the parent layout?

In other words, if the children component is JLabel + JTextField, then the nested layout could expose label and field size groups.

Then the outer layout could somehow connect inner's sizegroup with its own ones.
For instance:

inner1; // panel with MigLayout, label1: textfield1
inner2; // panel with MigLayout, label2: textfield2

outer.add(inner1, "sizegroupmap outerlabel=child.label");
outer.add(inner2, "sizegroupmap outerlabel=child.label");

So far it looks like MigLayout requires all the individual elements (e.g. JTextField) to be put into a single layout grid. Are there best practices for (not?) using nested layouts?

MigLayout class is final

I'm using the last stable Miglayout 4.0 and got a Problem, that my Containers 
in the layout could maximal be 32767 pixels wide.

The problem was found soon in the following method:
public Dimension maximumLayoutSize(Container parent)
{
   return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
}


the problem now is, i can't create a new class to overwrite the methode, 
because the MigLayout class is final.
Please don't do that.

Regards

Original issue reported on code.google.com by [email protected] on 21 Jan 2015 at 4:24

Is the documentation obsolete regarding default unit?

The whitepaper says this:

No unit specified. This is the default unit and pixels will be used by default. Default unit can be set with PlatformDefaults.setDefaultUnit(int). E.g. "10"

But what can be seen in the source code in PlatformDefaults.java is:

	private static int DEF_H_UNIT = UnitValue.LPX;
	private static int DEF_V_UNIT = UnitValue.LPY;

Does that mean that the documentation is not up to date, or am I missing something?

set fill on component

I have some layout issues and i'm trying to get my head around 'fill()'.

In the javadoc of for instance CC.grow() I see:
new ComponentConstraint().noGrid().gap().fill()

Now there are 2 issues:

  1. Object ComponentConstraint() does not exist. I assume that CC() is intended.
  2. If CC() is intented CC().fill() does not exist.

Should there be a fill method on CC?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.