List of usage examples for com.jgoodies.forms.builder PanelBuilder nextLine
public final void nextLine()
From source file:cz.cuni.mff.peckam.java.origamist.gui.editor.OrigamiPropertiesFrame.java
License:Open Source License
/** * Add all components to a layout.//from w w w. ja v a 2s . c o m */ protected void buildLayout() { Configuration conf = ServiceLocator.get(ConfigurationManager.class).get(); CellConstraints cc = new CellConstraints(); final JTabbedPane tabPane = new JTabbedPane(); int tabIndex = 0; JPanel basicPanel = new JPanel(new FormLayout("$dmargin,right:pref,$lcgap,pref:grow,$dmargin", "$dmargin,pref,$lgap,pref,$lgap,pref,$lgap,pref,$lgap,pref,$lgap,pref,$lgap,pref,$dmargin")); final int basicPanelTabIndex = tabIndex++; tabPane.addTab("", basicPanel); conf.addAndRunResourceBundleListener( new Configuration.LocaleListener("application", "OrigamiPropertiesFrame.basicPanelTitle") { @Override protected void updateText(String text) { tabPane.setTitleAt(basicPanelTabIndex, text); } }); basicPanel.add(nameLabel, cc.xy(2, 2)); basicPanel.add(name, cc.xy(4, 2)); basicPanel.add(creationDateLabel, cc.xy(2, 4)); basicPanel.add(creationDate, cc.xy(4, 4)); basicPanel.add(authorNameLabel, cc.xy(2, 6)); basicPanel.add(authorName, cc.xy(4, 6)); basicPanel.add(authorHomepageLabel, cc.xy(2, 8)); basicPanel.add(authorHomepage, cc.xy(4, 8)); basicPanel.add(shortDescLabel, cc.xy(2, 10)); basicPanel.add(shortDesc, cc.xy(4, 10)); basicPanel.add(originalLabel, cc.xy(2, 12)); basicPanel.add(original, cc.xy(4, 12)); basicPanel.add(description, cc.xywh(2, 14, 3, 1)); JPanel thumbnailPanel = new JPanel( new FormLayout("$dmargin,center:min(pref;50dlu),$ugap,pref,$ugap,pref,$dmargin", "$dmargin,pref,$lgap,pref,$dmargin")); final int thumbnailPanelTabIndex = tabIndex++; tabPane.addTab("", thumbnailPanel); conf.addAndRunResourceBundleListener( new Configuration.LocaleListener("application", "OrigamiPropertiesFrame.thumbnailPanelTitle") { @Override protected void updateText(String text) { tabPane.setTitleAt(thumbnailPanelTabIndex, text); } }); thumbnailPanel.add(thumbnailPreviewLabel, cc.xy(2, 2)); thumbnailPanel.add(thumbnailPreview, cc.xy(2, 4)); thumbnailPanel.add(thumbnailLoadFromModel, cc.xy(4, 2)); thumbnailPanel.add(thumbnailLoadFromFile, cc.xy(6, 2)); thumbnailPanel.add(thumbnailFileInputLabel, cc.xy(4, 4)); thumbnailPanel.add(thumbnailFileInput, cc.xy(6, 4)); final JScrollPane licenseContentScrollPane = new JScrollPane(licenseContent, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); JPanel licenseNamePanel = new JPanel(new FormLayout("pref,$lcgap,pref:grow", "pref")); licenseNamePanel.add(licenseNameLabel, cc.xy(1, 1)); licenseNamePanel.add(licenseName, cc.xy(3, 1)); licenseChooseContent.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { licenseHomepageLabel.setVisible(false); licenseContentLabel.setVisible(true); licenseContentScrollPane.setVisible(true); } } }); licenseChooseHomepage.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { licenseContentLabel.setVisible(false); licenseHomepageLabel.setVisible(true); licenseContentScrollPane.setVisible(false); } } }); licenseHomepageLabel.setVisible(licenseHomepage.isVisible()); licenseContentLabel.setVisible(licenseContent.isVisible()); licenseContentScrollPane.setVisible(licenseContent.isVisible()); JPanel licenseContentPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); licenseContentPanel.add(licenseChooseContent); licenseContentPanel.add(licenseChooseHomepage); JPanel licenseHomepagePanel = new JPanel(new FormLayout("pref,$lcgap,pref:grow", "pref")); licenseHomepagePanel.add(licenseHomepageLabel, cc.xy(1, 1)); licenseHomepagePanel.add(licenseHomepage, cc.xy(3, 1)); JPanel licensePermissionPanel = new JPanel(new GridLayout(0, 1)); licensePermissionPanel.add(licensePermissionDoNothing); licensePermissionPanel.add(licensePermissionEdit); licensePermissionPanel.add(licensePermissionExport); licensePermissionPanel.add(licensePermissionDistribute); JPanel licensePanel = new JPanel(new FormLayout("$dmargin,min(pref;500px):grow,$dmargin", "$dmargin,pref,$lgap,pref,$lgap,pref,$rgap,pref,$lgap,pref,$lgap,pref,$lgap,pref,$lgap,pref,$dmargin")); final int licensePanelTabIndex = tabIndex++; tabPane.addTab("", licensePanel); conf.addAndRunResourceBundleListener( new Configuration.LocaleListener("application", "OrigamiPropertiesFrame.licensePanelTitle") { @Override protected void updateText(String text) { tabPane.setTitleAt(licensePanelTabIndex, text); } }); JPanel predefinedLicensesPanel = new JPanel(new FormLayout("pref")); PanelBuilder builder = new PanelBuilder((FormLayout) predefinedLicensesPanel.getLayout(), predefinedLicensesPanel); for (JRadioButton b : predefinedLicenses) { builder.appendRow("$lgap"); builder.appendRow("pref"); builder.nextLine(); builder.add(b); builder.nextLine(); } JLabel licenseChooseLabel = new JLocalizedLabel("application", "OrigamiPropertiesFrame.licenseChooseLabel"); licensePanel.add(licenseNamePanel, cc.xy(2, 2)); licensePanel.add(predefinedLicensesPanel, cc.xy(2, 4)); licensePanel.add(licenseChooseLabel, cc.xy(2, 6)); licensePanel.add(licenseContentPanel, cc.xy(2, 8)); licensePanel.add(licenseContentLabel, cc.xy(2, 10)); licensePanel.add(licenseContentScrollPane, cc.xy(2, 12)); licensePanel.add(licenseHomepagePanel, cc.xy(2, 14)); licensePanel.add(licensePermissionPanel, cc.xy(2, 16)); final int diagramPaperTabIndex = tabIndex++; JPanel diagramPaperPanel = new JPanel( new FormLayout("$dmargin,default,$dmargin", "$dmargin,default,$dmargin")); diagramPaperPanel.add(diagramPaper, cc.xy(2, 2)); tabPane.addTab("", diagramPaperPanel); conf.addAndRunResourceBundleListener( new Configuration.LocaleListener("application", "OrigamiPropertiesFrame.diagramPaperLabel") { @Override protected void updateText(String text) { tabPane.setTitleAt(diagramPaperTabIndex, text); } }); final int modelPaperTabIndex = tabIndex++; JPanel modelPaperPanel = new JPanel( new FormLayout("$dmargin,default,$dmargin", "$dmargin,default,$dmargin")); modelPaperPanel.add(modelPaper, cc.xy(2, 2)); tabPane.addTab("", modelPaperPanel); conf.addAndRunResourceBundleListener( new Configuration.LocaleListener("application", "OrigamiPropertiesFrame.modelPaperLabel") { @Override protected void updateText(String text) { tabPane.setTitleAt(modelPaperTabIndex, text); } }); JPanel dialogButtonsPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING)); dialogButtonsPanel.add(cancelButton); dialogButtonsPanel.add(okButton); setLayout(new FormLayout("default", "default,$lgap,default")); add(tabPane, cc.xy(1, 1)); add(dialogButtonsPanel, cc.xy(1, 3)); pack(); }