(String position, boolean modal, boolean stretch)
| 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 | } |
no test coverage detected