MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / showPackedImpl

Method showPackedImpl

CodenameOne/src/com/codename1/ui/Dialog.java:1775–1842  ·  view source on GitHub ↗
(String position, boolean modal, boolean stretch)

Source from the content-addressed store, hash-verified

1773 ///
1774 /// the command selected if the dialog is modal and disposed via a command
1775 private Command showPackedImpl(String position, boolean modal, boolean stretch) {
1776 if (getTitle() == null) {
1777 setTitle("");
1778 }
1779 this.position = position;
1780 int height = Display.getInstance().getDisplayHeight();
1781 int width = Display.getInstance().getDisplayWidth();
1782 if (top > -1) {
1783 refreshTheme();
1784 }
1785 Component contentPane = super.getContentPane();
1786 if (dialogTitle != null && getUIManager().isThemeConstant("hideEmptyTitleBool", false)) {
1787 boolean b = getTitle().length() > 0;
1788 getTitleArea().setVisible(b);
1789 getTitleComponent().setVisible(b);
1790 }
1791 Style contentPaneStyle = contentPane.getStyle();
1792
1793 revalidate();
1794
1795 int prefHeight = contentPane.getPreferredH();
1796 int prefWidth = contentPane.getPreferredW();
1797 prefWidth = Math.min(prefWidth, width);
1798 if (contentPaneStyle.getBorder() != null) {
1799 prefWidth = Math.max(contentPaneStyle.getBorder().getMinimumWidth(), prefWidth);
1800 prefHeight = Math.max(contentPaneStyle.getBorder().getMinimumHeight(), prefHeight);
1801 }
1802 int topBottom = Math.max(0, (height - prefHeight) / 2);
1803 int leftRight = Math.max(0, (width - prefWidth) / 2);
1804
1805 if (BorderLayout.CENTER.equals(position)) {
1806 show(topBottom, topBottom, leftRight, leftRight, true, modal);
1807 return lastCommandPressed;
1808 }
1809 if (BorderLayout.EAST.equals(position)) {
1810 if (stretch) {
1811 show(0, 0, Math.max(0, width - prefWidth), 0, true, modal);
1812 } else {
1813 show(topBottom, topBottom, Math.max(0, width - prefWidth), 0, true, modal);
1814 }
1815 return lastCommandPressed;
1816 }
1817 if (BorderLayout.WEST.equals(position)) {
1818 if (stretch) {
1819 show(0, 0, 0, Math.max(0, width - prefWidth), true, modal);
1820 } else {
1821 show(topBottom, topBottom, 0, Math.max(0, width - prefWidth), true, modal);
1822 }
1823 return lastCommandPressed;
1824 }
1825 if (BorderLayout.NORTH.equals(position)) {
1826 if (stretch) {
1827 show(0, Math.max(0, height - prefHeight), 0, 0, true, modal);
1828 } else {
1829 show(0, Math.max(0, height - prefHeight), leftRight, leftRight, true, modal);
1830 }
1831 return lastCommandPressed;
1832 }

Callers 3

showPackedMethod · 0.95
showStretchedMethod · 0.95
showStetchedMethod · 0.95

Calls 15

getTitleMethod · 0.95
setTitleMethod · 0.95
getInstanceMethod · 0.95
getTitleComponentMethod · 0.95
getStyleMethod · 0.95
getPreferredHMethod · 0.95
getPreferredWMethod · 0.95
minMethod · 0.95
getBorderMethod · 0.95
maxMethod · 0.95
showMethod · 0.95
isThemeConstantMethod · 0.80

Tested by

no test coverage detected