List of usage examples for javax.swing Box createHorizontalStrut
public static Component createHorizontalStrut(int width)
From source file:org.jdal.swing.table.TablePanel.java
public void populateControlBox() { if (actions != null) { for (Action a : actions) { if (a instanceof TablePanelAction) ((TablePanelAction) a).setTablePanel((TablePanel<Object>) this); JButton b = new JButton(a); controlBox.add(b);//from www .j a v a 2 s . c om controlBox.add(Box.createHorizontalStrut(5)); } } controlBox.add(Box.createHorizontalGlue()); controlBox.setAlignmentX(Container.LEFT_ALIGNMENT); }
From source file:net.sf.jabref.importer.ZipFileChooser.java
/** * New Zip file chooser.//from ww w.j a va2 s . c o m * * @param owner Owner of the file chooser * @param zipFile Zip-Fle to choose from, must be readable */ public ZipFileChooser(ImportCustomizationDialog importCustomizationDialog, ZipFile zipFile) { super(importCustomizationDialog, Localization.lang("Select file from ZIP-archive"), false); ZipFileChooserTableModel tableModel = new ZipFileChooserTableModel(zipFile, getSelectableZipEntries(zipFile)); JTable table = new JTable(tableModel); TableColumnModel cm = table.getColumnModel(); cm.getColumn(0).setPreferredWidth(200); cm.getColumn(1).setPreferredWidth(150); cm.getColumn(2).setPreferredWidth(100); JScrollPane sp = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setPreferredScrollableViewportSize(new Dimension(500, 150)); if (table.getRowCount() > 0) { table.setRowSelectionInterval(0, 0); } // cancel: no entry is selected JButton cancelButton = new JButton(Localization.lang("Cancel")); cancelButton.addActionListener(e -> dispose()); // ok: get selected class and check if it is instantiable as an importer JButton okButton = new JButton(Localization.lang("OK")); okButton.addActionListener(e -> { int row = table.getSelectedRow(); if (row == -1) { JOptionPane.showMessageDialog(this, Localization.lang("Please select an importer.")); } else { ZipFileChooserTableModel model = (ZipFileChooserTableModel) table.getModel(); ZipEntry tempZipEntry = model.getZipEntry(row); CustomImporter importer = new CustomImporter(); importer.setBasePath(model.getZipFile().getName()); String className = tempZipEntry.getName().substring(0, tempZipEntry.getName().lastIndexOf('.')) .replace("/", "."); importer.setClassName(className); try { ImportFormat importFormat = importer.getInstance(); importer.setName(importFormat.getFormatName()); importer.setCliId(importFormat.getId()); importCustomizationDialog.addOrReplaceImporter(importer); dispose(); } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException exc) { LOGGER.warn("Could not instantiate importer: " + importer.getName(), exc); JOptionPane.showMessageDialog(this, Localization.lang("Could not instantiate %0 %1", importer.getName() + ":\n", exc.getMessage())); } } }); // Key bindings: JPanel mainPanel = new JPanel(); //ActionMap am = mainPanel.getActionMap(); //InputMap im = mainPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); //im.put(Globals.getKeyPrefs().getKey(KeyBinds.CLOSE_DIALOG), "close"); //am.put("close", closeAction); mainPanel.setLayout(new BorderLayout()); mainPanel.add(sp, BorderLayout.CENTER); JPanel optionsPanel = new JPanel(); optionsPanel.add(okButton); optionsPanel.add(cancelButton); optionsPanel.add(Box.createHorizontalStrut(5)); getContentPane().add(mainPanel, BorderLayout.CENTER); getContentPane().add(optionsPanel, BorderLayout.SOUTH); this.setSize(getSize()); pack(); this.setLocationRelativeTo(importCustomizationDialog); new FocusRequester(table); }
From source file:org.eobjects.datacleaner.widgets.result.PatternFinderResultSwingRendererCrosstabDelegate.java
@Override protected void decorate(CrosstabResult result, DCTable table, DisplayChartCallback displayChartCallback) { super.decorate(result, table, displayChartCallback); table.setAlignment(1, Alignment.RIGHT); final int rowCount = table.getRowCount(); for (int i = 0; i < rowCount; i++) { final Object expressionObject = table.getValueAt(i, 0); final String label = extractString(expressionObject); final String expression = extractExpression(label); final String stringPatternName = "PF: " + label; if (!_catalog.containsStringPattern(stringPatternName)) { DCPanel panel = new DCPanel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); panel.add(Box.createHorizontalStrut(4)); panel.add(new JLabel(label)); final JButton button = WidgetFactory.createSmallButton("images/actions/save.png"); button.setToolTipText("Save as string pattern"); button.addActionListener(new ActionListener() { @Override/* w ww .j a v a 2 s .c om*/ public void actionPerformed(ActionEvent e) { _catalog.addStringPattern(new SimpleStringPattern(stringPatternName, expression)); button.setEnabled(false); } }); panel.add(Box.createHorizontalStrut(4)); panel.add(button); table.setValueAt(panel, i, 0); } } if (isInitiallyCharted(table)) { displayChart(table, displayChartCallback); } }
From source file:org.datacleaner.widgets.result.PatternFinderResultSwingRendererCrosstabDelegate.java
@Override protected void decorate(CrosstabResult result, DCTable table, DisplayChartCallback displayChartCallback) { super.decorate(result, table, displayChartCallback); table.setAlignment(1, Alignment.RIGHT); final int rowCount = table.getRowCount(); for (int i = 0; i < rowCount; i++) { final Object expressionObject = table.getValueAt(i, 0); final String label = extractString(expressionObject); final String expression = extractExpression(label); final String stringPatternName = "PF: " + label; if (!_catalog.containsStringPattern(stringPatternName)) { DCPanel panel = new DCPanel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); panel.add(Box.createHorizontalStrut(4)); panel.add(new JLabel(label)); final JButton button = WidgetFactory.createSmallButton(IconUtils.ACTION_SAVE_DARK); button.setToolTipText("Save as string pattern"); button.addActionListener(new ActionListener() { @Override//from www .j a v a 2s . c o m public void actionPerformed(ActionEvent e) { _catalog.addStringPattern(new SimpleStringPattern(stringPatternName, expression)); button.setEnabled(false); } }); panel.add(Box.createHorizontalStrut(4)); panel.add(button); table.setValueAt(panel, i, 0); } } if (isInitiallyCharted(table)) { displayChart(table, displayChartCallback); } }
From source file:FillViewportHeightDemo.java
public FillViewportHeightDemo() { super("Empty Table DnD Demo"); tableModel = getDefaultTableModel(); table = new JTable(tableModel); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.setDropMode(DropMode.INSERT_ROWS); table.setTransferHandler(new TransferHandler() { public boolean canImport(TransferSupport support) { // for the demo, we'll only support drops (not clipboard paste) if (!support.isDrop()) { return false; }/* ww w . j ava2 s. c o m*/ // we only import Strings if (!support.isDataFlavorSupported(DataFlavor.stringFlavor)) { return false; } return true; } public boolean importData(TransferSupport support) { // if we can't handle the import, say so if (!canImport(support)) { return false; } // fetch the drop location JTable.DropLocation dl = (JTable.DropLocation) support.getDropLocation(); int row = dl.getRow(); // fetch the data and bail if this fails String data; try { data = (String) support.getTransferable().getTransferData(DataFlavor.stringFlavor); } catch (UnsupportedFlavorException e) { return false; } catch (IOException e) { return false; } String[] rowData = data.split(","); tableModel.insertRow(row, rowData); Rectangle rect = table.getCellRect(row, 0, false); if (rect != null) { table.scrollRectToVisible(rect); } // demo stuff - remove for blog model.removeAllElements(); model.insertElementAt(getNextString(count++), 0); // end demo stuff return true; } }); JList dragFrom = new JList(model); dragFrom.setFocusable(false); dragFrom.setPrototypeCellValue(getNextString(100)); model.insertElementAt(getNextString(count++), 0); dragFrom.setDragEnabled(true); dragFrom.setBorder(BorderFactory.createLoweredBevelBorder()); dragFrom.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent me) { if (SwingUtilities.isLeftMouseButton(me) && me.getClickCount() % 2 == 0) { String text = (String) model.getElementAt(0); String[] rowData = text.split(","); tableModel.insertRow(table.getRowCount(), rowData); model.removeAllElements(); model.insertElementAt(getNextString(count++), 0); } } }); JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); JPanel wrap = new JPanel(); wrap.add(new JLabel("Drag from here:")); wrap.add(dragFrom); p.add(Box.createHorizontalStrut(4)); p.add(Box.createGlue()); p.add(wrap); p.add(Box.createGlue()); p.add(Box.createHorizontalStrut(4)); getContentPane().add(p, BorderLayout.NORTH); JScrollPane sp = new JScrollPane(table); getContentPane().add(sp, BorderLayout.CENTER); fillBox = new JCheckBoxMenuItem("Fill Viewport Height"); fillBox.addActionListener(this); JMenuBar mb = new JMenuBar(); JMenu options = new JMenu("Options"); mb.add(options); setJMenuBar(mb); JMenuItem clear = new JMenuItem("Reset"); clear.addActionListener(this); options.add(clear); options.add(fillBox); getContentPane().setPreferredSize(new Dimension(260, 180)); }
From source file:com.diversityarrays.dal.server.SqlDialog.java
SqlDialog(JFrame owner, SqlDalDatabase db) { super(owner, "SQL", ModalityType.MODELESS); setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.database = db; runner = new DefaultBackgroundRunner("SQL Command", this); setGlassPane(runner.getBlockingPane()); sqlCommands.setFont(GuiUtil.createMonospacedFont(12)); includeHeadingsInCopy.addItemListener(new ItemListener() { @Override//from www . ja v a 2s . co m public void itemStateChanged(ItemEvent e) { boolean b = includeHeadingsInCopy.isSelected(); for (int n = tabbedPane.getTabCount(); --n >= 0;) { Component c = tabbedPane.getComponentAt(n); if (c instanceof SqlResultsPanel) { ((SqlResultsPanel) c).setIncludeHeadings(b); } } } }); tabbedPane.addContainerListener(new ContainerListener() { @Override public void componentRemoved(ContainerEvent e) { updateClosePanelAction(); } @Override public void componentAdded(ContainerEvent e) { updateClosePanelAction(); } }); updateClosePanelAction(); Box buttons = Box.createHorizontalBox(); buttons.add(Box.createHorizontalStrut(10)); buttons.add(new JButton(runAction)); buttons.add(Box.createHorizontalStrut(20)); buttons.add(new JButton(closePanelAction)); buttons.add(Box.createHorizontalGlue()); buttons.add(includeHeadingsInCopy); buttons.add(Box.createHorizontalStrut(10)); buttons.add(new JButton(helpAction)); buttons.add(Box.createHorizontalStrut(10)); JPanel top = new JPanel(new BorderLayout()); top.add(BorderLayout.CENTER, new JScrollPane(sqlCommands)); top.add(BorderLayout.SOUTH, buttons); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, top, tabbedPane); splitPane.setResizeWeight(0.25); setContentPane(splitPane); pack(); setSize(800, 600); addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { splitPane.setDividerLocation(0.25); removeWindowListener(this); } }); }
From source file:com.gdc.nms.web.mibquery.wizard.ciscavate.cjwizard.WizardContainer.java
/** * /*from w ww . j a v a 2s .c o m*/ */ private void initComponents() { final JButton prevBtn = new JButton(_prevAction); final JButton nextBtn = new JButton(_nextAction); final JButton finishBtn = new JButton(_finishAction); final JButton cancelBtn = new JButton(_cancelAction); _extraButtonPanel = new JPanel(); _extraButtonPanel.setLayout(new BoxLayout(_extraButtonPanel, BoxLayout.LINE_AXIS)); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.add(_extraButtonPanel); buttonPanel.add(Box.createHorizontalGlue()); buttonPanel.add(prevBtn); buttonPanel.add(Box.createHorizontalStrut(5)); buttonPanel.add(nextBtn); buttonPanel.add(Box.createHorizontalStrut(10)); buttonPanel.add(finishBtn); buttonPanel.add(Box.createHorizontalStrut(10)); buttonPanel.add(cancelBtn); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15)); //this.setLayout(new BorderLayout()); //this.add(_template, BorderLayout.CENTER); //this.add(buttonPanel, BorderLayout.SOUTH); }
From source file:com.github.cjwizard.WizardContainer.java
/** * //from www.j ava 2s . c o m */ private void initComponents() { final JButton prevBtn = new JButton(_prevAction); final JButton nextBtn = new JButton(_nextAction); final JButton finishBtn = new JButton(_finishAction); final JButton cancelBtn = new JButton(_cancelAction); _extraButtonPanel = new JPanel(); _extraButtonPanel.setLayout(new BoxLayout(_extraButtonPanel, BoxLayout.LINE_AXIS)); final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.add(_extraButtonPanel); buttonPanel.add(Box.createHorizontalGlue()); buttonPanel.add(prevBtn); buttonPanel.add(Box.createHorizontalStrut(5)); buttonPanel.add(nextBtn); buttonPanel.add(Box.createHorizontalStrut(10)); buttonPanel.add(finishBtn); buttonPanel.add(Box.createHorizontalStrut(10)); buttonPanel.add(cancelBtn); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 15, 5, 15)); this.setLayout(new BorderLayout()); this.add(_template, BorderLayout.CENTER); this.add(buttonPanel, BorderLayout.SOUTH); }
From source file:com.apatar.ui.JPublishToApatarDialog.java
private void createDialog() { GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); this.setLayout(gridbag); c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0;/* ww w .j ava 2 s . co m*/ c.weighty = 0.0; c.fill = GridBagConstraints.HORIZONTAL; //c.insets = new Insets(5, 5, 5, 5); JPanel panelLogin = new JPanel(); panelLogin.setBorder(new EmptyBorder(10, 10, 0, 10)); panelLogin.setLayout(new BoxLayout(panelLogin, BoxLayout.X_AXIS)); panelLogin.add(new JLabel("User Name")); panelLogin.add(Box.createHorizontalStrut(5)); panelLogin.add(username); username.setComponentPopupMenu(new JDefaultContextMenu(username)); panelLogin.add(Box.createHorizontalStrut(5)); panelLogin.add(new JLabel("Password")); panelLogin.add(Box.createHorizontalStrut(5)); panelLogin.add(password); JPanel panelForgotPassLink = new JPanel(); panelForgotPassLink.setBorder(new EmptyBorder(10, 10, 0, 10)); panelForgotPassLink.setLayout(new BoxLayout(panelForgotPassLink, BoxLayout.X_AXIS)); panelForgotPassLink.add(new JLabel("Lost your password? ")); panelForgotPassLink.add(Box.createHorizontalStrut(5)); panelForgotPassLink.add(forgotPassLinkLabel); forgotPassLinkLabel.setFont(UiUtils.NORMAL_SIZE_12_FONT); forgotPassLinkLabel.addMouseListener(new MouseHyperLinkEvent()); forgotPassLinkLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); forgotPassLinkLabel.setText( "<html><a href='http://www.apatarforge.org/profile/lostpassword.html'>Click here to retrieve it</a></html>"); JPanel panelFile = new JPanel(); panelFile.setBorder(new EmptyBorder(10, 10, 0, 10)); panelFile.setLayout(new BoxLayout(panelFile, BoxLayout.X_AXIS)); panelFile.add(selectFromFile); panelFile.add(Box.createHorizontalStrut(5)); panelFile.add(new JLabel("New File ")); panelFile.add(Box.createHorizontalStrut(5)); panelFile.add(nameFile); panelFile.add(Box.createHorizontalStrut(5)); panelFile.add(browse); nameFile.setEnabled(false); nameFile.setComponentPopupMenu(new JDefaultContextMenu(nameFile)); browse.setEnabled(false); JPanel panelLocation = new JPanel(); panelLocation.setBorder(new EmptyBorder(10, 10, 0, 10)); panelLocation.setLayout(new BoxLayout(panelLocation, BoxLayout.X_AXIS)); panelLocation.add(new JLabel("Suggest Location:")); panelLocation.add(Box.createHorizontalStrut(5)); panelLocation.add(location); JPanel panelDMName = new JPanel(); panelDMName.setBorder(new EmptyBorder(10, 10, 0, 10)); panelDMName.setLayout(new BoxLayout(panelDMName, BoxLayout.X_AXIS)); JLabel datamapNameLabel = new JLabel("DataMap Name:"); datamapNameLabel.setBorder(new EmptyBorder(0, 0, 0, 10)); panelDMName.add(datamapNameLabel); panelDMName.add(Box.createHorizontalStrut(5)); panelDMName.add(dataMapName); dataMapName.setComponentPopupMenu(new JDefaultContextMenu(dataMapName)); JPanel panelDMDescription = new JPanel(); panelDMDescription.setBorder(new EmptyBorder(10, 10, 0, 10)); panelDMDescription.setLayout(new BoxLayout(panelDMDescription, BoxLayout.X_AXIS)); panelDMDescription.add(new JLabel("DataMap Description (16000 Chars)")); panelDMDescription.add(Box.createHorizontalStrut(5)); //JScrollPane scroll = new JScrollPane(dataMapDescription); //scroll.setSize(300, 50); dataMapDescription.setLineWrap(true); dataMapDescription.setWrapStyleWord(true); panelDMDescription.add(new JScrollPane(dataMapDescription)); JPanel panelDMShortDescription = new JPanel(); panelDMShortDescription.setBorder(new EmptyBorder(10, 10, 0, 10)); panelDMShortDescription.setLayout(new BoxLayout(panelDMShortDescription, BoxLayout.X_AXIS)); JLabel labelShort = new JLabel("Short Description:"); labelShort.setBorder(new EmptyBorder(0, 0, 0, 85)); panelDMShortDescription.add(labelShort); panelDMShortDescription.add(Box.createHorizontalStrut(5)); shortDescription.setLineWrap(true); shortDescription.setWrapStyleWord(true); panelDMShortDescription.add(new JScrollPane(shortDescription)); setEnableShortDescription(false); // ------------- JPanel panelTitleForTags = new JPanel(); panelTitleForTags.setBorder(new EmptyBorder(10, 10, 0, 10)); panelTitleForTags.setLayout(new BoxLayout(panelTitleForTags, BoxLayout.X_AXIS)); panelTitleForTags.add(new JLabel("Add tags associated with your DataMap:")); // ------------- JPanel panelListAddedTags = new JPanel(); panelListAddedTags.setBorder(new EmptyBorder(0, 10, 10, 10)); panelListAddedTags.setLayout(new BoxLayout(panelListAddedTags, BoxLayout.X_AXIS)); // -- JPanel panelFrom = new JPanel(); panelFrom.setLayout(new BoxLayout(panelFrom, BoxLayout.Y_AXIS)); JPanel panelMiddle = new JPanel(); panelMiddle.setLayout(new BoxLayout(panelMiddle, BoxLayout.X_AXIS)); JPanel panelTo = new JPanel(); panelTo.setLayout(new BoxLayout(panelTo, BoxLayout.Y_AXIS)); // -- JPanel panelAddNewTag = new JPanel(); panelAddNewTag.setLayout(new BoxLayout(panelAddNewTag, BoxLayout.X_AXIS)); panelAddNewTag.add(new JLabel("Add new tag:")); panelAddNewTag.add(Box.createHorizontalStrut(5)); textfieldAddNewTag = new JTextField(); textfieldAddNewTag.setComponentPopupMenu(new JDefaultContextMenu(textfieldAddNewTag)); panelAddNewTag.add(textfieldAddNewTag); panelAddNewTag.add(Box.createHorizontalStrut(5)); JButton buttonAddTag = new JButton("Add"); buttonAddTag.addActionListener(addNewTagMouseListener); panelAddNewTag.add(buttonAddTag); // -- JPanel panelDeleteTags = new JPanel(); panelDeleteTags.setLayout(new BoxLayout(panelDeleteTags, BoxLayout.X_AXIS)); panelDeleteTags.add(new JLabel("Delete selected tag(s):")); panelDeleteTags.add(Box.createHorizontalStrut(5)); JButton buttonDeleteTag = new JButton("Delete"); buttonDeleteTag.addActionListener(deleteTagMouseListener); panelDeleteTags.add(buttonDeleteTag); panelDeleteTags.add(new JPanel()); // -- JButton moveTag = new JButton(UiUtils.ARROW_ICON); moveTag.addActionListener(addTagsMouseListener); panelMiddle.add(moveTag); tblModelFrom = new DefaultTableModel(); tblModelTo = new DefaultTableModel(); tblModelFrom.addColumn("Tag Name"); tblModelTo.addColumn("Tag Name"); tagsTableFrom = new JTable(tblModelFrom); tagsTableTo = new JTable(tblModelTo); tagsTableFrom.setOpaque(false); tagsTableFrom.setBackground(null); tagsTableFrom.setBorder(null); tagsTableFrom.setShowGrid(false); tagsTableTo.setOpaque(false); tagsTableTo.setBackground(null); tagsTableTo.setBorder(null); tagsTableTo.setShowGrid(false); tagsTableFrom.getColumn("Tag Name").setCellEditor(new CellEditor(new JTextField())); tagsTableTo.getColumn("Tag Name").setCellEditor(new CellEditor(new JTextField())); fillTableTags(); tagsTableFrom.setComponentPopupMenu(new JDefaultContextMenu(tagsTableFrom)); tagsTableTo.setComponentPopupMenu(new JDefaultContextMenu(tagsTableTo)); JScrollPane srollPane = new JScrollPane(tagsTableFrom); srollPane.setBorder(null); JScrollPane srollPane2 = new JScrollPane(tagsTableTo); srollPane.setBorder(null); panelFrom.add(srollPane); panelFrom.add(Box.createVerticalStrut(5)); panelFrom.add(panelAddNewTag); panelTo.add(srollPane2); panelTo.add(Box.createVerticalStrut(5)); panelTo.add(panelDeleteTags); panelListAddedTags.add(panelFrom); panelListAddedTags.add(Box.createHorizontalStrut(5)); panelListAddedTags.add(panelMiddle); panelListAddedTags.add(Box.createHorizontalStrut(5)); panelListAddedTags.add(panelTo); // ------- JPanel panelButton = new JPanel(); panelButton.setLayout(new BoxLayout(panelButton, BoxLayout.X_AXIS)); panelButton.add(Box.createHorizontalGlue()); panelButton.add(bOk); panelButton.add(Box.createHorizontalStrut(5)); panelButton.add(bCancel); panelButton.add(Box.createHorizontalStrut(5)); ComponentBuilder.makeComponent(new JCommentPanel(), gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelLogin, gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelForgotPassLink, gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelFile, gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelLocation, gridbag, c, getContentPane()); ComponentBuilder.makeComponent(panelDMName, gridbag, c, getContentPane()); c.fill = GridBagConstraints.BOTH; c.weighty = 2.0; ComponentBuilder.makeComponent(panelDMDescription, gridbag, c, getContentPane()); c.weighty = 0.0; ComponentBuilder.makeComponent(autoGenerateShortDescription, gridbag, c, getContentPane()); c.weighty = 1.0; ComponentBuilder.makeComponent(panelDMShortDescription, gridbag, c, getContentPane()); c.weighty = 1.0; ComponentBuilder.makeComponent(panelTitleForTags, gridbag, c, getContentPane()); c.weighty = 3.0; ComponentBuilder.makeComponent(panelListAddedTags, gridbag, c, getContentPane()); c.weighty = 0.0; ComponentBuilder.makeComponent(new JSeparator(), gridbag, c, getContentPane()); c.weighty = 1.0; ComponentBuilder.makeComponent(panelButton, gridbag, c, getContentPane()); }
From source file:aurelienribon.gdxsetupui.ui.panels.LibrarySelectionPanel.java
private void buildLibraryPanel(final String libraryName) { ActionListener nameChkAL = new ActionListener() { @Override//from w w w . ja v a 2s . c om public void actionPerformed(ActionEvent e) { if (((CompactCheckBox) e.getSource()).isSelected()) { if (!Ctx.cfgSetup.libraries.contains(libraryName)) Ctx.cfgSetup.libraries.add(libraryName); if (!Ctx.cfgUpdate.libraries.contains(libraryName)) Ctx.cfgUpdate.libraries.add(libraryName); } else { Ctx.cfgSetup.libraries.remove(libraryName); Ctx.cfgUpdate.libraries.remove(libraryName); } Ctx.fireCfgSetupChanged(); Ctx.fireCfgUpdateChanged(); } }; Action infoAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { showInfo(libraryName); } }; Action browseAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { browse(libraryName); } }; Action getStableAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { getStable(libraryName); } }; Action getLatestAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { getLatest(libraryName); } }; LibraryDef def = Ctx.libs.getDef(libraryName); CompactCheckBox nameChk = new CompactCheckBox(def.name + " "); JLabel html5Label = new JLabel(Res.getImage("gfx/ic_html5.png")); JButton infoBtn = new JButton(infoAction); JButton browseBtn = new JButton(browseAction); JButton getStableBtn = new JButton(getStableAction); JButton getLatestBtn = new JButton(getLatestAction); nameChk.addActionListener(nameChkAL); nameChk.setForeground(LIB_NOTFOUND_COLOR); html5Label.setToolTipText("Compatible with HTML backend"); infoBtn.setIcon(Res.getImage("gfx/ic_info.png")); browseBtn.setIcon(Res.getImage("gfx/ic_browse.png")); getStableBtn.setIcon(Res.getImage("gfx/ic_download_stable.png")); getLatestBtn.setIcon(Res.getImage("gfx/ic_download_nightlies.png")); infoBtn.setFocusable(false); browseBtn.setFocusable(false); getStableBtn.setFocusable(false); getLatestBtn.setFocusable(false); JToolBar toolBar = new JToolBar(); toolBar.setOpaque(false); toolBar.setFloatable(false); toolBar.add(Box.createHorizontalGlue()); toolBar.add(infoBtn); toolBar.add(browseBtn); if (def.stableUrl != null) toolBar.add(getStableBtn); else toolBar.add(Box.createHorizontalStrut(libgdxGetStableBtn.getPreferredSize().width)); if (def.latestUrl != null) toolBar.add(getLatestBtn); else toolBar.add(Box.createHorizontalStrut(libgdxGetNightliesBtn.getPreferredSize().width)); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.setOpaque(false); leftPanel.add(nameChk, BorderLayout.CENTER); if (def.gwtModuleName != null) leftPanel.add(html5Label, BorderLayout.EAST); JPanel panel = new JPanel(new BorderLayout()); panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25)); panel.setOpaque(false); panel.add(leftPanel, BorderLayout.WEST); panel.add(toolBar, BorderLayout.CENTER); librariesPanel.add(panel); Style.apply(librariesPanel, style); libsNamesCmps.put(libraryName, nameChk); }