private void buildExternalsPanel() { FormBuilder builder = FormBuilder.create().layout(new FormLayout("fill:pref:grow", "p")); int row = 1; for (ExternalFileEntry efe : externals) { builder.add(efe.getPanel()).xy(1, row); builder.appendRows("2dlu, p"); row += 2; } builder.add(Box.createVerticalGlue()).xy(1, row); builder.appendRows("2dlu, p, 2dlu, p"); builder.add(addExtPan).xy(1, row + 2); builder.add(Box.createVerticalGlue()).xy(1, row + 2); // builder.getPanel().setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.green)); // externalFilesPanel.setBorder(BorderFactory.createMatteBorder(1,1,1,1,Color.red)); JScrollPane pane = new JScrollPane(builder.getPanel()); pane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); externalFilesPanel.setMinimumSize(new Dimension(400, 400)); externalFilesPanel.setPreferredSize(new Dimension(400, 400)); externalFilesPanel.removeAll(); externalFilesPanel.add(pane, BorderLayout.CENTER); externalFilesPanel.revalidate(); externalFilesPanel.repaint(); }
/** * Loads the tileset defined in the constructor into a JPanel which it then returns. Makes no * assumptions about height or width, which means it needs to read an extra 64 tiles at worst (32 * down to check height and 32 across for width), since the maximum height/width is 32 tiles. */ public JPanel loadTileset() { int height = MAX_TILESET_SIZE; int width = MAX_TILESET_SIZE; boolean maxHeight = false; boolean maxWidth = false; // find width int j = 0; while (!maxWidth) { try { File f = new File(tileDir + "/" + j + "_" + 0 + ".png"); ImageIO.read(f); } catch (IOException e) { width = j; maxWidth = true; } j += TILE_SIZE; } // find height int i = 0; while (!maxHeight) { try { File f = new File(tileDir + "/" + 0 + "_" + i + ".png"); ImageIO.read(f); } catch (IOException e) { height = i; maxHeight = true; } i += TILE_SIZE; } JPanel tileDisplay = new JPanel(); tileDisplay.setLayout(new GridLayout(height / TILE_SIZE, width / TILE_SIZE)); tileDisplay.setMinimumSize(new Dimension(width, height)); tileDisplay.setPreferredSize(new Dimension(width, height)); tileDisplay.setMaximumSize(new Dimension(width, height)); for (i = 0; i < height; i += TILE_SIZE) { for (j = 0; j < width; j += TILE_SIZE) { String fPath = tileDir + "/" + j + "_" + i; try { int[] mov = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; Image icon = getTile(tileDir, j, i, 1); Tile tile = new Tile(new ImageIcon(icon), "palette", 0, 0, mov, "none", false, "" + j + "_" + i); tile.addMouseListener(new PaletteButtonListener()); tile.setMaximumSize(new Dimension(TILE_SIZE, TILE_SIZE)); tile.setPreferredSize(new Dimension(TILE_SIZE, TILE_SIZE)); tile.setMinimumSize(new Dimension(TILE_SIZE, TILE_SIZE)); tileDisplay.add(tile); } catch (IOException e) { } } } return tileDisplay; }
private void createPropertiesPanel() { myPropertiesPanel = new JPanel(new BorderLayout()); final JPanel emptyPanel = new JPanel(); emptyPanel.setMinimumSize(JBUI.emptySize()); emptyPanel.setPreferredSize(JBUI.emptySize()); myPropertiesPanelWrapper = new JPanel(new CardLayout()); myPropertiesPanel.setBorder(new CustomLineBorder(1, 0, 0, 0)); myPropertiesPanelWrapper.add(EMPTY_CARD, emptyPanel); myPropertiesPanelWrapper.add(PROPERTIES_CARD, myPropertiesPanel); }
public void addRow(Component... components) { remove(puff); final JPanel row = new JPanel(); row.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { gui.notifyObserver("/use " + rows.indexOf(event.getSource())); } }); row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS)); // row.add(Box.createHorizontalStrut(3)); row.setMinimumSize(new Dimension(10, 30)); row.setMaximumSize(new Dimension(250, 30)); for (Component component : components) { row.add(component); } JButton red = new JButton("x"); red.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent event) { int deleted = rows.indexOf(row); gui.notifyObserver("/use " + deleted); gui.notifyObserver("/disconnect"); } }); red.setBackground(Color.PINK.darker()); red.setForeground(Color.WHITE); row.add(Box.createHorizontalGlue()); row.add(red); rows.add(row); Component strut = Box.createVerticalStrut(5); struts.add(strut); add(row); add(strut); add(puff); repaint(); updateUI(); }
private void setupComponents() { panel.removeAll(); JScrollPane scrollPane1 = new JScrollPane( parametersTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane1.setOpaque(false); ActionPanel actionPanel1 = new ActionPanel(false); actionPanel1.setAddAction(addParameterAction); actionPanel1.setRemoveAction(removeParameterAction); actionPanel1.setAddToolTipText("Use this button to add an existing parameter to the prior"); actionPanel1.setRemoveToolTipText("Use this button to remove a parameter from the prior"); removeParameterAction.setEnabled(false); JPanel controlPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); controlPanel1.setOpaque(false); controlPanel1.add(actionPanel1); JPanel panel1 = new JPanel(new BorderLayout(0, 0)); panel1.setOpaque(false); panel1.add(new JLabel("Linked parameters:"), BorderLayout.NORTH); panel1.add(scrollPane1, BorderLayout.CENTER); // removing the control panel for now. Not sure whether we really want adding and // removing of parameteres in this dialog. // panel1.add(controlPanel1, BorderLayout.SOUTH); panel1.setSize(new Dimension(PREFERRED_TABLE_WIDTH, PREFERRED_TABLE_HEIGHT)); panel1.setPreferredSize(new Dimension(PREFERRED_TABLE_WIDTH, PREFERRED_TABLE_HEIGHT)); panel1.setMinimumSize(new Dimension(MINIMUM_TABLE_WIDTH, MINIMUM_TABLE_HEIGHT)); OptionsPanel optionsPanel = new OptionsPanel(0, 6); if (parameter.getName() != null) { nameField.setText(parameter.getName()); } else { nameField.setText("Untitled"); } optionsPanel.addComponentWithLabel("Unique Name: ", nameField); // optionsPanel.addComponentWithLabel("Initial Value: ", initialField); panel.setOpaque(false); panel.setBorder(new BorderUIResource.EmptyBorderUIResource(new Insets(12, 12, 12, 12))); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 0; c.weighty = 0; c.anchor = GridBagConstraints.PAGE_START; c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = 2; panel.add(optionsPanel, c); c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.PAGE_START; c.fill = GridBagConstraints.VERTICAL; c.gridwidth = 1; panel.add(panel1, c); c.gridx = 1; c.gridy = 1; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.PAGE_START; c.gridwidth = GridBagConstraints.REMAINDER; panel.add(priorSettingsPanel, c); }
/** * Draws the GUI that allows a user to select assets to be updated. * * @return true if the user made a valid choice of assets to replace. * @throws PipelineException */ private boolean buildUpdateGUI() throws PipelineException { Box finalBox = new Box(BoxLayout.Y_AXIS); top = new Box(BoxLayout.Y_AXIS); JScrollPane scroll; { scroll = new JScrollPane(finalBox); scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); Dimension size = new Dimension(sVSize + sVSize + sTSize + 52, 500); scroll.setMinimumSize(size); scroll.setPreferredSize(size); scroll.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); } /* query the user */ diag = new JToolDialog("Propagate Asset", scroll, "Continue"); areas = mclient.getWorkingAreas(); { Box hbox = new Box(BoxLayout.X_AXIS); Component comps[] = UIFactory.createTitledPanels(); JPanel tpanel = (JPanel) comps[0]; JPanel vpanel = (JPanel) comps[1]; { userField = UIFactory.createTitledCollectionField( tpanel, "User:"******"The user whose area the node is being created in."); userField.setActionCommand("user"); userField.setSelected(PackageInfo.sUser); userField.addActionListener(this); } UIFactory.addVerticalSpacer(tpanel, vpanel, 3); { viewField = UIFactory.createTitledCollectionField( tpanel, "View:", sTSize, vpanel, areas.get(PackageInfo.sUser), diag, sVSize, "The working area to create the nodes in."); viewField.setActionCommand("wrap"); viewField.addActionListener(this); } UIFactory.addVerticalSpacer(tpanel, vpanel, 3); { toolsetField = UIFactory.createTitledCollectionField( tpanel, "Toolset:", sTSize, vpanel, mclient.getActiveToolsetNames(), diag, sVSize, "The toolset to set on all the nodes."); toolsetField.setSelected(mclient.getDefaultToolsetName()); toolsetField.setActionCommand("wrap"); toolsetField.addActionListener(this); } UIFactory.addVerticalSpacer(tpanel, vpanel, 3); w = new Wrapper( userField.getSelected(), viewField.getSelected(), toolsetField.getSelected(), mclient); charList = SonyConstants.getAssetList(w, project, AssetType.CHARACTER); setsList = SonyConstants.getAssetList(w, project, AssetType.SET); propsList = SonyConstants.getAssetList(w, project, AssetType.PROP); { projectField = UIFactory.createTitledCollectionField( tpanel, "Project:", sTSize, vpanel, Globals.getChildrenDirs(w, "/projects"), diag, sVSize, "All the projects in pipeline."); projectField.setActionCommand("proj"); projectField.addActionListener(this); } hbox.add(comps[2]); top.add(hbox); } { Box vbox = new Box(BoxLayout.Y_AXIS); Box hbox = new Box(BoxLayout.X_AXIS); JButton button = new JButton("Propagate Additional Asset"); button.setName("ValuePanelButton"); button.setRolloverEnabled(false); button.setFocusable(false); Dimension d = new Dimension(sVSize, 25); button.setPreferredSize(d); button.setMinimumSize(d); button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25)); vbox.add(Box.createRigidArea(new Dimension(0, 5))); hbox.add(button); hbox.add(Box.createRigidArea(new Dimension(4, 0))); vbox.add(hbox); vbox.add(Box.createRigidArea(new Dimension(0, 5))); button.setActionCommand("add"); button.addActionListener(this); top.add(vbox); } list = new Box(BoxLayout.Y_AXIS); test = new JDrawer("Propagate Additional Asset", list, false); top.add(test); list.add(assetChoiceBox()); finalBox.add(top); { JPanel spanel = new JPanel(); spanel.setName("Spacer"); spanel.setMinimumSize(new Dimension(sTSize + sVSize, 7)); spanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); spanel.setPreferredSize(new Dimension(sTSize + sVSize, 7)); finalBox.add(spanel); } diag.setVisible(true); if (diag.wasConfirmed()) { // get list of things to change. for (Component comp : list.getComponents()) { if (comp instanceof Box) { Box can = (Box) comp; JCollectionField oldOne = (JCollectionField) can.getComponent(2); JCollectionField newOne = (JCollectionField) can.getComponent(4); TreeMap<String, String> assetList = new TreeMap<String, String>(); assetList.putAll(charList); assetList.putAll(propsList); assetList.putAll(setsList); String key = assetList.get(oldOne.getSelected()) + lr; String value = assetList.get(newOne.getSelected()) + lr; if (!key.equals(value)) { potentialUpdates.add(key); pAssetManager.put(key, new AssetInfo(key, value)); } // System.err.println("bUG: "+pAssetManager.get(key).getHiLoResShots()); } } if (!pAssetManager.isEmpty()) return true; } return false; } // end buildReplacementGUI
/** * Present a GUI allowing the user to select shots in which each previously selected asset should * be updated. * * @return * @throws PipelineException */ private String confirmShotsToUpdate() throws PipelineException { /* DO GUI DRAWING STUFF*/ JScrollPane scroll = null; { Box ibox = new Box(BoxLayout.Y_AXIS); if (pAssetManager.isEmpty()) { Component comps[] = UIFactory.createTitledPanels(); JPanel tpanel = (JPanel) comps[0]; JPanel vpanel = (JPanel) comps[1]; tpanel.add(Box.createRigidArea(new Dimension(sTSize - 7, 0))); vpanel.add(Box.createHorizontalGlue()); ibox.add(comps[2]); } else { for (String assetName : pAssetManager.keySet()) { String name = getShortName(assetName); AssetInfo info = pAssetManager.get(assetName); Component comps[] = UIFactory.createTitledPanels(); JPanel tpanel = (JPanel) comps[0]; JPanel vpanel = (JPanel) comps[1]; String title = "Replace " + name + " with "; title += getShortName(info.getNewAsset()); JDrawer shotList = new JDrawer(title, (JComponent) comps[2], true); ibox.add(shotList); for (String shot : info.getLoHiResShots().keySet()) { String shortShot = getShortName(shot); JBooleanField field = UIFactory.createTitledBooleanField( tpanel, shortShot, sVSize, vpanel, sTSize, "Whether to replace this asset source for the node."); field.setName(shot); field.setValue(true); if (!pSubstituteFields.containsKey(assetName)) pSubstituteFields.put(assetName, new LinkedList<JBooleanField>()); pSubstituteFields.get(assetName).add(field); UIFactory.addVerticalSpacer(tpanel, vpanel, 3); } } } { JPanel spanel = new JPanel(); spanel.setName("Spacer"); spanel.setMinimumSize(new Dimension(sTSize + sVSize, 7)); spanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); spanel.setPreferredSize(new Dimension(sTSize + sVSize, 7)); ibox.add(spanel); } { scroll = new JScrollPane(ibox); scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); Dimension size = new Dimension(sTSize + sVSize + 52, 300); scroll.setMinimumSize(size); scroll.setPreferredSize(size); scroll.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); } } /* query the user */ JToolDialog diag = new JToolDialog("Update Assets Per Shot", scroll, "Confirm"); diag.setVisible(true); /* Process User Input */ if (diag.wasConfirmed()) { for (String asset : pSubstituteFields.keySet()) { for (JBooleanField field : pSubstituteFields.get(asset)) { Boolean bUpdate = field.getValue(); if ((bUpdate == null) || !bUpdate) { pAssetManager.get(asset).getLoHiResShots().remove(field.getName()); // logLine("\tRemoving: "+ getShortName(field.getName()) // TODO +" from list for "+ getShortName(asset)); } } } return ": Modifying Nodes..."; } return null; } // end confirmShotsToUpdate
private void jbInit() throws Exception { panel1.setLayout(borderLayout1); jLabelSynapseType.setText("Synapse type:"); jLabelDelay.setText("Internal delay:"); jButtonOK.setText("OK"); jButtonOK.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonOK_actionPerformed(e); } }); jButtonCancel.setText("Cancel"); jButtonCancel.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonCancel_actionPerformed(e); } }); jPanelMain.setLayout(gridBagLayout1); jButtonDelay.setText("..."); jButtonDelay.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonDelay_actionPerformed(e); } }); jTextFieldDelay.setEditable(false); jTextFieldDelay.setText(""); panel1.setMaximumSize(new Dimension(400, 200)); panel1.setMinimumSize(new Dimension(400, 200)); panel1.setPreferredSize(new Dimension(400, 200)); jLabelWeights.setText("Synaptic weights:"); jButtonWeights.setText("..."); jButtonWeights.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButtonWeights_actionPerformed(e); } }); jTextFieldWeights.setEditable(false); jTextFieldWeights.setText(""); jLabelThreshold.setText("Voltage threshold:"); jTextFieldThreshold.setText(""); getContentPane().add(panel1); panel1.add(jPanelMain, BorderLayout.CENTER); jPanelMain.add( jLabelSynapseType, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 20, 6, 12), 0, 0)); jPanelMain.add( jLabelDelay, new GridBagConstraints( 0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 20, 6, 0), 0, 0)); jPanelMain.add( jTextFieldDelay, new GridBagConstraints( 1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 0, 6, 6), 0, 0)); jPanelMain.add( jButtonDelay, new GridBagConstraints( 2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 6, 0, 20), 0, 0)); jPanelMain.add( jLabelWeights, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 12, 6, 12), 0, 0)); jPanelMain.add( jTextFieldWeights, new GridBagConstraints( 1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 0, 6, 6), 0, 0)); jPanelMain.add( jButtonWeights, new GridBagConstraints( 2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(6, 6, 6, 20), 0, 0)); panel1.add(jPanelButtons, BorderLayout.SOUTH); jPanelButtons.add(jButtonOK, null); jPanelButtons.add(jButtonCancel, null); jPanelMain.add( jLabelThreshold, new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 12, 6, 12), 0, 0)); jPanelMain.add( jTextFieldThreshold, new GridBagConstraints( 1, 3, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 0, 6, 20), 0, 0)); jPanelMain.add( jComboBoxSynapseType, new GridBagConstraints( 1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(6, 0, 6, 20), 0, 0)); }
public AddSupportForFrameworksPanel( final List<FrameworkSupportInModuleProvider> providers, final FrameworkSupportModelBase model, boolean vertical, @Nullable JPanel associatedFrameworksPanel) { myModel = model; myAssociatedFrameworksPanel = associatedFrameworksPanel; myLibrariesContainer = model.getLibrariesContainer(); myLabel.setVisible(!vertical); Splitter splitter = vertical ? new Splitter(true, 0.6f, 0.2f, 0.8f) : new Splitter(false, 0.3f, 0.3f, 0.7f); splitter.setHonorComponentsMinimumSize(false); myFrameworksTree = new FrameworksTree(model) { @Override protected void onNodeStateChanged(CheckedTreeNode node) { if (!(node instanceof FrameworkSupportNode)) return; final FrameworkSupportNode frameworkSupportNode = (FrameworkSupportNode) node; if (frameworkSupportNode == getSelectedNode()) { updateOptionsPanel(); } final FrameworkSupportInModuleConfigurable configurable = frameworkSupportNode.getConfigurable(); configurable.onFrameworkSelectionChanged(node.isChecked()); myModel.onFrameworkSelectionChanged(frameworkSupportNode); onFrameworkStateChanged(); } }; model.addFrameworkVersionListener( new FrameworkVersionListener() { @Override public void versionChanged(FrameworkVersion version) { ((DefaultTreeModel) myFrameworksTree.getModel()).nodeChanged(getSelectedNode()); } }, this); myFrameworksTree.addTreeSelectionListener( new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { onSelectionChanged(); } }); JPanel treePanel = new JPanel(new BorderLayout()); treePanel.add(ScrollPaneFactory.createScrollPane(myFrameworksTree), BorderLayout.CENTER); treePanel.setMinimumSize(new Dimension(200, 300)); splitter.setFirstComponent(treePanel); myOptionsPanel = new JPanel(new CardLayout()); JPanel emptyCard = new JPanel(); emptyCard.setPreferredSize(new Dimension(400, 100)); myOptionsPanel.add(EMPTY_CARD, emptyCard); splitter.setSecondComponent(myOptionsPanel); myFrameworksPanel.add(splitter, BorderLayout.CENTER); setProviders(providers); }
/** Construct a new dialog. */ public JExecDetailsDialog() { super("Execution Details"); /* create dialog body components */ { JPanel body = new JPanel(); body.setLayout(new BoxLayout(body, BoxLayout.Y_AXIS)); { JPanel panel = new JPanel(); panel.setName("MainDialogPanel"); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); /* working directory */ { panel.add(UIFactory.createPanelLabel("Working Directory:")); panel.add(Box.createRigidArea(new Dimension(0, 4))); JTextField field = UIFactory.createTextField(null, 100, JLabel.LEFT); pWorkingDirField = field; panel.add(field); } body.add(panel); } { JPanel panel = new JPanel(); panel.setName("HorizontalBar"); Dimension size = new Dimension(100, 7); panel.setPreferredSize(size); panel.setMinimumSize(size); panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 7)); body.add(panel); } /* command line */ JPanel above = new JPanel(); { above.setName("MainDialogPanel"); above.setLayout(new BoxLayout(above, BoxLayout.Y_AXIS)); { Box hbox = new Box(BoxLayout.X_AXIS); hbox.add(Box.createRigidArea(new Dimension(4, 0))); { JLabel label = new JLabel("X"); pCommandLineLabel = label; label.setName("PanelLabel"); hbox.add(label); } hbox.add(Box.createHorizontalGlue()); above.add(hbox); } above.add(Box.createRigidArea(new Dimension(0, 4))); { JTextArea area = new JTextArea(null, 5, 70); pCommandLineArea = area; area.setName("CodeTextArea"); area.setLineWrap(true); area.setWrapStyleWord(true); area.setEditable(false); } { JScrollPane scroll = UIFactory.createScrollPane( pCommandLineArea, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, new Dimension(100, 27), null, null); above.add(scroll); } } /* environment */ JPanel below = new JPanel(); { below.setName("MainDialogPanel"); below.setLayout(new BoxLayout(below, BoxLayout.Y_AXIS)); { Box hbox = new Box(BoxLayout.X_AXIS); hbox.add(Box.createRigidArea(new Dimension(4, 0))); { JLabel label = new JLabel("X"); pEnvLabel = label; label.setName("PanelLabel"); hbox.add(label); } hbox.add(Box.createHorizontalGlue()); below.add(hbox); } below.add(Box.createRigidArea(new Dimension(0, 4))); Component comps[] = UIFactory.createTitledPanels(); { JPanel tpanel = (JPanel) comps[0]; JPanel vpanel = (JPanel) comps[1]; tpanel.add(Box.createRigidArea(new Dimension(sTSize, 0))); vpanel.add(Box.createHorizontalGlue()); } { pEnvScroll = UIFactory.createScrollPane( comps[2], ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, new Dimension(100, 50), new Dimension(100, 300), null); below.add(pEnvScroll); } } { JVertSplitPanel split = new JVertSplitPanel(above, below); split.setResizeWeight(0.0); split.setAlignmentX(0.5f); body.add(split); } super.initUI("X", body, null, null, null, "Close", null); } }
private void jbInit() throws Exception { saveButton.setText("Save"); saveButton.addActionListener(new PrintfTemplateEditor_saveButton_actionAdapter(this)); cancelButton.setText("Cancel"); cancelButton.addActionListener(new PrintfTemplateEditor_cancelButton_actionAdapter(this)); this.setTitle(this.getTitle() + " Template Editor"); printfPanel.setLayout(gridBagLayout1); formatLabel.setFont(new java.awt.Font("DialogInput", 0, 12)); formatLabel.setText("Format String:"); buttonPanel.setLayout(flowLayout1); printfPanel.setBorder(BorderFactory.createEtchedBorder()); printfPanel.setMinimumSize(new Dimension(100, 160)); printfPanel.setPreferredSize(new Dimension(380, 160)); parameterPanel.setLayout(gridBagLayout2); parameterLabel.setText("Parameters:"); parameterLabel.setFont(new java.awt.Font("DialogInput", 0, 12)); parameterTextArea.setMinimumSize(new Dimension(100, 25)); parameterTextArea.setPreferredSize(new Dimension(200, 25)); parameterTextArea.setEditable(true); parameterTextArea.setText(""); insertButton.setMaximumSize(new Dimension(136, 20)); insertButton.setMinimumSize(new Dimension(136, 20)); insertButton.setPreferredSize(new Dimension(136, 20)); insertButton.setToolTipText( "insert the format in the format string and add parameter to list."); insertButton.setText("Insert Parameter"); insertButton.addActionListener(new PrintfTemplateEditor_insertButton_actionAdapter(this)); formatTextArea.setMinimumSize(new Dimension(100, 25)); formatTextArea.setPreferredSize(new Dimension(200, 15)); formatTextArea.setText(""); parameterPanel.setBorder(null); parameterPanel.setMinimumSize(new Dimension(60, 40)); parameterPanel.setPreferredSize(new Dimension(300, 40)); insertMatchButton.addActionListener( new PrintfTemplateEditor_insertMatchButton_actionAdapter(this)); insertMatchButton.setText("Insert Match"); insertMatchButton.setToolTipText( "insert the match in the format string and add parameter to list."); insertMatchButton.setPreferredSize(new Dimension(136, 20)); insertMatchButton.setMinimumSize(new Dimension(136, 20)); insertMatchButton.setMaximumSize(new Dimension(136, 20)); matchPanel.setPreferredSize(new Dimension(300, 40)); matchPanel.setBorder(null); matchPanel.setMinimumSize(new Dimension(60, 60)); matchPanel.setLayout(gridBagLayout3); InsertPanel.setLayout(gridLayout1); gridLayout1.setColumns(1); gridLayout1.setRows(2); gridLayout1.setVgap(0); InsertPanel.setBorder(BorderFactory.createEtchedBorder()); InsertPanel.setMinimumSize(new Dimension(100, 100)); InsertPanel.setPreferredSize(new Dimension(380, 120)); editorPane.setText(""); editorPane.addKeyListener(new PrintfEditor_editorPane_keyAdapter(this)); printfTabPane.addChangeListener(new PrintfEditor_printfTabPane_changeAdapter(this)); parameterPanel.add( insertButton, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(8, 6, 13, 8), 0, 10)); parameterPanel.add( paramComboBox, new GridBagConstraints( 0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(8, 8, 13, 0), 258, 11)); paramComboBox.setRenderer(new MyCellRenderer()); InsertPanel.add(matchPanel, null); InsertPanel.add(parameterPanel, null); buttonPanel.add(cancelButton, null); buttonPanel.add(saveButton, null); this.getContentPane().add(printfTabPane, BorderLayout.NORTH); this.getContentPane().add(InsertPanel, BorderLayout.CENTER); matchPanel.add( insertMatchButton, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(8, 6, 13, 8), 0, 10)); matchPanel.add( matchComboBox, new GridBagConstraints( 0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(8, 8, 13, 0), 258, 11)); printfPanel.add( parameterLabel, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(7, 5, 0, 5), 309, 0)); printfPanel.add( formatLabel, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 5, 0, 5), 288, 0)); printfPanel.add( formatTextArea, new GridBagConstraints( 0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 5, 0, 5), 300, 34)); printfPanel.add( parameterTextArea, new GridBagConstraints( 0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 5, 6, 5), 300, 34)); printfTabPane.addTab("Editor View", null, editorPanel, "View in Editor"); printfTabPane.addTab("Printf View", null, printfPanel, "Vies as Printf"); editorPane.setCharacterAttributes(PLAIN_ATTR, true); editorPane.addStyle("PLAIN", editorPane.getLogicalStyle()); editorPanel.getViewport().add(editorPane, null); this.getContentPane().add(buttonPanel, BorderLayout.SOUTH); buttonGroup.add(cancelButton); }
public ListSelectionDemo() { super(new BorderLayout()); String[] listData = {"one", "two", "three", "four", "five", "six", "seven"}; String[] columnNames = {"French", "Spanish", "Italian"}; list = new JList(listData); listSelectionModel = list.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); JScrollPane listPane = new JScrollPane(list); JPanel controlPane = new JPanel(); String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" }; final JComboBox comboBox = new JComboBox(modes); comboBox.setSelectedIndex(2); comboBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String newMode = (String) comboBox.getSelectedItem(); if (newMode.equals("SINGLE_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } else { listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } output.append("----------" + "Mode: " + newMode + "----------" + newline); } }); controlPane.add(new JLabel("Selection mode:")); controlPane.add(comboBox); // Build output area. output = new JTextArea(1, 10); output.setEditable(false); JScrollPane outputPane = new JScrollPane( output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); // Do the layout. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS)); JPanel listContainer = new JPanel(new GridLayout(1, 1)); listContainer.setBorder(BorderFactory.createTitledBorder("List")); listContainer.add(listPane); topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); topHalf.add(listContainer); // topHalf.add(tableContainer); topHalf.setMinimumSize(new Dimension(100, 50)); topHalf.setPreferredSize(new Dimension(100, 110)); splitPane.add(topHalf); JPanel bottomHalf = new JPanel(new BorderLayout()); bottomHalf.add(controlPane, BorderLayout.PAGE_START); bottomHalf.add(outputPane, BorderLayout.CENTER); // XXX: next line needed if bottomHalf is a scroll pane: // bottomHalf.setMinimumSize(new Dimension(400, 50)); bottomHalf.setPreferredSize(new Dimension(450, 135)); splitPane.add(bottomHalf); }