use of net.miginfocom.layout.CC in project cuba by cuba-platform.
the class VclTestApp method createAlignTab.
private Component createAlignTab() {
JPanel box = new JPanel();
box.setFocusable(false);
MigLayout boxLayout = new MigLayout("debug 1000, fill");
box.setLayout(boxLayout);
JPanel panel = new JPanel();
MigLayout layout = new MigLayout("debug 1000, fill");
panel.setLayout(layout);
JLabel label = new JLabel("Label");
CC cc = new CC();
cc.alignX("right").alignY("50%");
panel.add(label);
layout.setComponentConstraints(label, cc);
LC lc = new LC();
// The size of an invisible component will be set to 0, 0 and the gaps will also be set to 0 around it.
lc.hideMode(2);
lc.debug(1000);
AC rowConstr = new AC();
AC colConstr = new AC();
lc.fillX();
lc.flowY();
lc.gridGapY("0");
layout.setLayoutConstraints(lc);
layout.setRowConstraints(rowConstr);
layout.setColumnConstraints(colConstr);
box.add(panel, "height 100px, width 100px");
layout.setComponentConstraints(label, cc);
return box;
}
use of net.miginfocom.layout.CC in project cuba by cuba-platform.
the class VclTestApp method createTableTab.
private Component createTableTab() {
final JPanel box = new JPanel();
box.setFocusable(false);
MigLayout boxLayout = new MigLayout("fill");
box.setLayout(boxLayout);
final JScrollPane outerScrollPane = new JScrollPane();
outerScrollPane.setViewportView(box);
outerScrollPane.addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
final Dimension minimumSize = box.getMinimumSize();
final int width = Math.max(minimumSize.width, outerScrollPane.getViewport().getWidth());
box.setPreferredSize(new Dimension(width, minimumSize.height));
}
});
JPanel tablePanel = new JPanel();
MigLayout tablePanellayout = new MigLayout("flowy, fill, insets 0", "", "[min!][fill]");
tablePanel.setLayout(tablePanellayout);
JPanel topPanel = new JPanel(new FlowLayout());
topPanel.setVisible(true);
tablePanel.add(topPanel);
topPanel.add(new JButton("Button1"));
topPanel.add(new JButton("Button2"));
topPanel.add(new JButton("Button3"));
topPanel.add(new JButton("Button4"));
topPanel.add(new JButton("Button5"));
JXTableExt table = new JXTableExt();
JScrollPane tableScrollPane = new JScrollPane(table);
// table.setFillsViewportHeight(true);
tablePanel.add(tableScrollPane, "grow");
table.setShowGrid(true);
table.setGridColor(Color.lightGray);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setColumnControlVisible(true);
table.setModel(new AbstractTableModel() {
@Override
public int getRowCount() {
return 20;
}
@Override
public int getColumnCount() {
return 20;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return rowIndex + "-" + columnIndex;
}
});
CC cc = new CC();
// cc.growX(0);
// cc.width("300!");
cc.width("100%");
// cc.growY(0.0f);
cc.height("200!");
// cc.height("100%");
box.add(tablePanel);
boxLayout.setComponentConstraints(tablePanel, cc);
return outerScrollPane;
}
use of net.miginfocom.layout.CC in project cuba by cuba-platform.
the class DesktopAbstractBox method updateComponentInternal.
protected void updateComponentInternal(Component child) {
boolean componentReAdded = false;
if (DesktopContainerHelper.mayHaveExternalCaption(child) || DesktopContainerHelper.mayHaveExternalContextHelp(child)) {
if (captions.containsKey(child) && !DesktopContainerHelper.hasExternalCaption(child) && !DesktopContainerHelper.hasExternalContextHelp(child)) {
reAddChild(child);
componentReAdded = true;
} else if (!captions.containsKey(child) && (DesktopContainerHelper.hasExternalCaption(child) || DesktopContainerHelper.hasExternalContextHelp(child))) {
reAddChild(child);
componentReAdded = true;
} else if (captions.containsKey(child)) {
ComponentCaption caption = captions.get(child);
caption.update();
BoxLayoutAdapter adapterForCaption = layoutAdapter;
if (wrappers.containsKey(child)) {
adapterForCaption = wrappers.get(child).getSecond();
}
adapterForCaption.updateConstraints(caption, adapterForCaption.getCaptionConstraints(child));
}
}
if (!componentReAdded) {
JComponent composition;
if (wrappers.containsKey(child)) {
composition = wrappers.get(child).getFirst();
CC constraints = MigLayoutHelper.getConstraints(child);
if (child.getHeight() == -1.0) {
MigLayoutHelper.applyHeight(constraints, -1, UNITS_PIXELS, false);
} else {
MigLayoutHelper.applyHeight(constraints, 100, UNITS_PERCENTAGE, false);
}
if (child.getWidth() == -1.0) {
MigLayoutHelper.applyWidth(constraints, -1, UNITS_PIXELS, false);
} else {
MigLayoutHelper.applyWidth(constraints, 100, UNITS_PERCENTAGE, false);
}
BoxLayoutAdapter adapter = wrappers.get(child).getSecond();
adapter.updateConstraints(DesktopComponentsHelper.getComposition(child), constraints);
} else {
composition = DesktopComponentsHelper.getComposition(child);
}
layoutAdapter.updateConstraints(composition, layoutAdapter.getConstraints(child));
}
}
Aggregations