public PathwayToolTip(List<VPathwayElement> elements) { applyToolTipStyle(this); setLayout(new BorderLayout()); DefaultFormBuilder builder = new DefaultFormBuilder(new FormLayout("pref")); for (ToolTipProvider p : toolTipProviders) { Component c = p.createToolTipComponent(this, elements); if (c != null) { hasContent = true; builder.append(c); builder.nextLine(); } } JPanel contents = builder.getPanel(); applyToolTipStyle(contents); JScrollPane scroll = new JScrollPane( contents, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); int w = contents.getPreferredSize().width + scroll.getVerticalScrollBar().getPreferredSize().width + 5; int h = contents.getPreferredSize().height + scroll.getHorizontalScrollBar().getPreferredSize().height + 5; w = Math.min(400, w); h = Math.min(500, h); setPreferredSize(new Dimension(w, h)); add(scroll, BorderLayout.CENTER); }
private JTabbedPane createTab() { Font mainFont = new Font("Times New Roman", Font.BOLD, 11); tabbedPane.setFont(mainFont); tabbedPane.setBorder(new BevelBorder(BevelBorder.LOWERED)); tabbedPane.add("New application", new NewAppPanel()); JPanel existingApp = new JPanel(); existingApp.setLayout(new BoxLayout(existingApp, BoxLayout.X_AXIS)); JLabel pictureLabel = new JLabel("Configuration:"); JButton pictureChooser = new JButton("Choose"); pictureFileName.setEditable(false); pictureFileName.setMaximumSize(new Dimension(contentPane.getPreferredSize().width, 25)); existingApp.add(Box.createHorizontalStrut(20)); existingApp.add(pictureLabel); existingApp.add(pictureFileName); existingApp.add(Box.createHorizontalStrut(5)); existingApp.add(pictureChooser); existingApp.add(Box.createHorizontalStrut(20)); pictureChooser.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { loadFromFile(); } }); tabbedPane.add("Existing application", existingApp); tabbedPane.setPreferredSize(contentPane.getPreferredSize()); return tabbedPane; }
protected void addIconsToPanel(HashMap<String, NamedIcon> iconMap) { if (iconMap == null) { log.warn("iconMap is null for type " + _itemType + " family " + _family); return; } GridBagLayout gridbag = new GridBagLayout(); _iconPanel.setLayout(gridbag); int numCol = 4; GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.CENTER; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = 1; c.gridheight = 1; c.gridx = -1; c.gridy = 0; int cnt = iconMap.size(); Iterator<Entry<String, NamedIcon>> it = iconMap.entrySet().iterator(); while (it.hasNext()) { Entry<String, NamedIcon> entry = it.next(); NamedIcon icon = new NamedIcon(entry.getValue()); // make copy for possible reduction icon.reduceTo(100, 100, 0.2); JPanel panel = new JPanel(new FlowLayout()); String borderName = getIconBorderName(entry.getKey()); panel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.black), borderName)); JLabel image = new JLabel(icon); if (icon.getIconWidth() < 1 || icon.getIconHeight() < 1) { image.setText(Bundle.getMessage("invisibleIcon")); image.setForeground(Color.lightGray); } image.setToolTipText(icon.getName()); panel.add(image); int width = Math.max(100, panel.getPreferredSize().width); panel.setPreferredSize(new java.awt.Dimension(width, panel.getPreferredSize().height)); c.gridx += 1; if (c.gridx >= numCol) { // start next row c.gridy++; c.gridx = 0; if (cnt < numCol - 1) { // last row JPanel p = new JPanel(new FlowLayout()); p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); p.add(Box.createHorizontalStrut(100)); gridbag.setConstraints(p, c); // if (log.isDebugEnabled()) log.debug("addIconsToPanel: gridx= "+c.gridx+" gridy= // "+c.gridy); _iconPanel.add(p); c.gridx = 1; } } cnt--; gridbag.setConstraints(panel, c); _iconPanel.add(panel); } }
@Override public void setComponentValues(BaseModelObject baseModelObject) { for (PropertyObjectDefinition property : definitions) { if (propertyFields.containsKey(property) == true) { PropertyField propertyField = propertyFields.get(property); StyledLabel propertyLabel = propertyLabels.get(property); propertyField.setComponentValue(baseModelObject); propertyLabel.setVisible(propertyField.isVisible()); } } boolean visible = false; for (int i = 0; i < contentPanel.getComponentCount(); i++) { Component component = contentPanel.getComponent(i); if (component.isVisible() == true) { visible = true; break; } } setVisible(visible); revalidate(); Dimension preferredSize = contentPanel.getPreferredSize(); contentPanel.setSize(preferredSize); contentPanel.setMinimumSize(preferredSize); }
public void setLocation(@NotNull final Point screenPoint) { if (myPopup == null) { myForcedLocation = screenPoint; } else { moveTo(myContent, screenPoint, myLocateByContent ? myHeaderPanel.getPreferredSize() : null); } }
/** Construct a FileTree */ public FilePanel(JPanel panel, final IDEWindow ideWindow) { pane = panel; setLayout(new BorderLayout()); // Make a tree list with all the nodes, and make it a JTree JTree tree = new JTree(addNodes(null, new File(System.getProperty("user.dir")))); // Add a listener tree.addTreeSelectionListener( new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.getPath().getLastPathComponent(); File file = null; if (node.isLeaf()) { file = new File(node.getParent() + "/" + node); ToolbarFunctions.open(file, ideWindow); } } }); setSize(panel.getPreferredSize()); // Lastly, put the JTree into a JScrollPane. JScrollPane scrollpane = new JScrollPane(); scrollpane.getViewport().add(tree); add(BorderLayout.CENTER, scrollpane); }
ToolAdaptersManagementDialog(AppContext appContext, String title, String helpID) { super(appContext.getApplicationWindow(), title, 0, helpID); this.appContext = appContext; JPanel contentPanel = createContentPanel(); setContent(contentPanel); super.getJDialog().setMinimumSize(contentPanel.getPreferredSize()); }
private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) { JPopupMenu jp = new JPopupMenu(); JMenuItem mi = new JMenuItem("Help"); // No i18n JPanel panel = new JPanel(); String msgTxt = "<html>Drops redundant events/alerts. <br>The suppressed/dropped Events/alerts will not <br>be added to the database. <br>You can choose to suppress all events/alerts <br>or only those that occur after a <br>certain period of time. <br>Refer Admin Guide for details.</html>"; // No i18n /*JTextArea ep = new JTextArea(); ep.setColumns(20); ep.setLineWrap(true); ep.setRows(10); ep.setBackground(new java.awt.Color(200, 200, 200)); ep.setWrapStyleWord(true);*/ JLabel ep = new JLabel(); ep.setSize(300, 200); ep.setText(msgTxt); panel.add(ep); mi.setLayout(new BorderLayout()); mi.setPreferredSize(panel.getPreferredSize()); mi.setFocusPainted(false); mi.add(panel, BorderLayout.CENTER); jp.setLayout(new BorderLayout()); jp.add(mi, BorderLayout.CENTER); jp.show(helpButton, -60, -60); }
public void enableControlPanel() { boolean bVisible = false; int nmembers = buttonPane.getComponentCount(); for (int k = 0; k < nmembers; k++) { Component comp = buttonPane.getComponent(k); if (comp != null) { if (comp.isVisible() || comp.isEnabled()) { bVisible = true; break; } } } if (bVisible && !buttonPane.isVisible()) { Dimension dim = getSize(); Dimension dim1 = buttonPane.getPreferredSize(); int w = dim.width; int h = dim.height + dim1.height; if (dim1.width > w) w = dim1.width; if (w < 300) w = 300; if (h < 200) h = 200; setSize(w, h); } buttonPane.setVisible(bVisible); }
private void initGui() { JComponent filler = new JComponent() { @Override public Dimension getPreferredSize() { return myTextLabel.getPreferredSize(); } }; setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(3, 20, 3, 20)); add(myTextLabel, BorderLayout.WEST); Box box = Box.createHorizontalBox(); box.add(Box.createHorizontalGlue()); JPanel panel = new JPanel(new GridLayout(1, myLabels.size(), 0, 0)); for (final JComponent myLabel : myLabels) { panel.add(myLabel); } panel.setMaximumSize(panel.getPreferredSize()); box.add(panel); box.add(Box.createHorizontalGlue()); add(box, BorderLayout.CENTER); add(filler, BorderLayout.EAST); }
private JPanel createCompPanel() { filesets = new Vector(); int count = installer.getIntegerProperty("comp.count"); JPanel panel = new JPanel(new GridLayout(count, 1)); String osClass = OperatingSystem.getOperatingSystem().getClass().getName(); osClass = osClass.substring(osClass.indexOf('$') + 1); for (int i = 0; i < count; i++) { String os = installer.getProperty("comp." + i + ".os"); if (os != null && !osClass.equals(os)) continue; JCheckBox checkBox = new JCheckBox( installer.getProperty("comp." + i + ".name") + " (" + installer.getProperty("comp." + i + ".disk-size") + "Mb)"); checkBox.getModel().setSelected(true); checkBox.addActionListener(this); checkBox.setRequestFocusEnabled(false); filesets.addElement(new Integer(i)); panel.add(checkBox); } Dimension dim = panel.getPreferredSize(); dim.width = Integer.MAX_VALUE; panel.setMaximumSize(dim); return panel; }
public void addPanel(String name, JPanel panel) { if (tabbedPane.getTabCount() == 0) { preffered = panel.getPreferredSize(); } panel.setPreferredSize(preffered); tabbedPane.add(name, panel); }
public World() { super(GAME_TITLE); _fileFilter = new FileNameExtensionFilter("Blockamon SAVE", "save"); this.setLayout(new BorderLayout()); inBattle = false; playingField = new JPanel(null); playingField.setBorder(BorderFactory.createLineBorder(Color.black)); playingField.setPreferredSize(new Dimension(400, 300)); worldSize = playingField.getPreferredSize(); }
@Override public Point getLocationOnScreen() { Dimension headerCorrectionSize = myLocateByContent ? myHeaderPanel.getPreferredSize() : null; Point screenPoint = myContent.getLocationOnScreen(); if (headerCorrectionSize != null) { screenPoint.y -= headerCorrectionSize.height; } return screenPoint; }
public StatementExecutionVariablesForm( StatementExecutionVariablesBundle variablesBundle, String statementText) { this.variablesBundle = variablesBundle; this.statementText = statementText; variablesPanel.setLayout(new BoxLayout(variablesPanel, BoxLayout.Y_AXIS)); for (StatementExecutionVariable variable : variablesBundle.getVariables()) { StatementExecutionVariableValueForm variableValueForm = new StatementExecutionVariableValueForm(variable); variableValueForms.add(variableValueForm); variablesPanel.add(variableValueForm.getComponent()); variableValueForm.addDocumentListener( new DocumentAdapter() { protected void textChanged(DocumentEvent e) { updatePreview(); } }); variableValueForm.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { updatePreview(); } }); } int[] metrics = new int[] {0, 0}; for (StatementExecutionVariableValueForm variableValueForm : variableValueForms) { metrics = variableValueForm.getMetrics(metrics); } for (StatementExecutionVariableValueForm variableValueForm : variableValueForms) { variableValueForm.adjustMetrics(metrics); } updatePreview(); GuiUtils.replaceJSplitPaneWithIDEASplitter(mainPanel); Dimension preferredSize = variablesPanel.getPreferredSize(); int height = (int) Math.min(preferredSize.getHeight(), 200) + 24; splitPane.setDividerLocation(height); mainPanel.setPreferredSize( new Dimension((int) mainPanel.getPreferredSize().getWidth(), height + 250)); }
/** * The constructor for the class It's going to set the dimension of the program to 600x600, the * background is going to be white (in order to blend in with the vor image), and it is going to * add in the VOR radar and a radial indicator that will let the user know which radial he/she is * on */ public finalVORGUI(int r) { deg = r; this.vor = new VorReceiver(deg, ".- -... -.-."); this.vor.setOBS(90); // set the OBS to 30 JLayeredPane lp = new JLayeredPane(); lp.setPreferredSize(new Dimension(WIDTH, HEIGHT)); setBackground(Color.white); lp.setLayout(null); lp.setFocusable(true); degrees = deg; // r is intended radial CurrentRadial = new JLabel( "Intended Radial: " + deg); // A string that is always going to be above the radar. it's going to let // the user know the current radial CurrentRadial.setBounds(220, 18, 200, 200); MorseCode = new JLabel("Station: TO ENTER HERE"); MorseCode.setBounds(200, 500, 200, 50); MorseCode.setText("Station: " + this.vor.getMorse()); // vor.printVorStatus_v1(); rotationPanel = new JPanel(); rotationPanel = new TurningCanvas(); rotationPanel.setBounds( 157, 125, rotationPanel.getPreferredSize().width, rotationPanel.getPreferredSize().height); needle = new JPanel(); needle = new DrawAttributes(); needle.setBounds(100, 0, needle.getPreferredSize().width, needle.getPreferredSize().height); OBS = new JPanel(); OBS = new AddButtons(); OBS.setBounds(110, 350, 200, 100); lp.add(rotationPanel, Integer.valueOf(1)); lp.add(needle, Integer.valueOf(2)); lp.add(OBS, Integer.valueOf(3)); lp.add(CurrentRadial, Integer.valueOf(4)); lp.add(MorseCode, Integer.valueOf(5)); add(lp); x = 172; // x is the location of the needle y1 = 155; y2 = 330; }
@Override public Dimension getPreferredSize() { if (getModel().getParent() instanceof IETDWidget) { Dimension d = container.getPreferredSize(); d.width += 2; d.height += 2; return d; } Dimension d = super.getPreferredSize(); return d; }
protected void makeDndIconPanel(HashMap<String, NamedIcon> iconMap, String displayKey) { if (_supressDragging) { return; } if (!jmri.util.ThreadingUtil.isGUIThread()) log.error("Not on GUI thread", new Exception("traceback")); _dragIconPanel.setToolTipText(Bundle.getMessage("ToolTipDragIcon")); if (iconMap != null) { if (iconMap.get(displayKey) == null) { displayKey = (String) iconMap.keySet().toArray()[0]; } NamedIcon ic = iconMap.get(displayKey); if (ic != null) { NamedIcon icon = new NamedIcon(ic); JPanel panel = new JPanel(new FlowLayout()); String borderName = ItemPalette.convertText("dragToPanel"); panel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.black), borderName)); JLabel label; try { label = getDragger(new DataFlavor(Editor.POSITIONABLE_FLAVOR), iconMap); if (label != null) { label.setToolTipText(Bundle.getMessage("ToolTipDragIcon")); label.setIcon(icon); label.setName(borderName); panel.add(label); } } catch (java.lang.ClassNotFoundException cnfe) { log.warn("no DndIconPanel {} created", borderName, cnfe); } int width = Math.max(100, panel.getPreferredSize().width); panel.setPreferredSize(new java.awt.Dimension(width, panel.getPreferredSize().height)); panel.setToolTipText(Bundle.getMessage("ToolTipDragIcon")); _dragIconPanel.add(panel); return; } } else { log.error("No iconMap for makeDndIconPanel"); } }
/** * If the <code>preferredSize</code> has been set to a non-<code>null</code> value just returns * it. If the UI delegate's <code>getPreferredSize</code> method returns a non <code>null</code> * value then return that; otherwise defer to the component's layout manager. * * @return the value of the <code>preferredSize</code> property * @see #setPreferredSize * @see javax.swing.plaf.ComponentUI */ @Override public Dimension getPreferredSize() { if (listPanel == null) { return super.getPreferredSize(); } else { Dimension d = listPanel.getPreferredSize(); Component p = getRootPane(); int h = listPanel.isVisible() ? d.height : 0; int w = p == null ? d.width : getParent().getWidth(); return new Dimension(w, 3 + 3 + 30 + h); } }
public BorderedComponent(String text, JComponent comp, boolean collapsible) { super(null); this.comp = comp; // Only add border if text is not null if (text != null) { TitledBorder border; if (collapsible) { final JLabel textLabel = new JLabel(text); JPanel borderLabel = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0)) { public int getBaseline(int w, int h) { Dimension dim = textLabel.getPreferredSize(); return textLabel.getBaseline(dim.width, dim.height) + textLabel.getY(); } }; borderLabel.add(textLabel); border = new LabeledBorder(borderLabel); textLabel.setForeground(border.getTitleColor()); if (IS_WIN) { collapseIcon = new ImageIcon(getImage("collapse-winlf")); expandIcon = new ImageIcon(getImage("expand-winlf")); } else { collapseIcon = new ArrowIcon(SOUTH, textLabel); expandIcon = new ArrowIcon(EAST, textLabel); } moreOrLessButton = new JButton(collapseIcon); moreOrLessButton.setContentAreaFilled(false); moreOrLessButton.setBorderPainted(false); moreOrLessButton.setMargin(new Insets(0, 0, 0, 0)); moreOrLessButton.addActionListener(this); String toolTip = Messages.BORDERED_COMPONENT_MORE_OR_LESS_BUTTON_TOOLTIP; moreOrLessButton.setToolTipText(toolTip); borderLabel.add(moreOrLessButton); borderLabel.setSize(borderLabel.getPreferredSize()); add(borderLabel); } else { border = new TitledBorder(text); } setBorder(new CompoundBorder(new FocusBorder(this), border)); } else { setBorder(new FocusBorder(this)); } if (comp != null) { add(comp); } }
@Override public void actionPerformed(AnActionEvent e) { JPanel result = new JPanel(new BorderLayout()); JLabel label = new JLabel("Lines around:"); label.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 0)); JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(label, BorderLayout.NORTH); result.add(wrapper, BorderLayout.WEST); final JSlider slider = new JSlider(JSlider.HORIZONTAL, 1, 5, 1); slider.setMinorTickSpacing(1); slider.setPaintTicks(true); slider.setPaintTrack(true); slider.setSnapToTicks(true); UIUtil.setSliderIsFilled(slider, true); slider.setPaintLabels(true); slider.setLabelTable(LABELS); result.add(slider, BorderLayout.CENTER); final VcsConfiguration configuration = VcsConfiguration.getInstance(myProject); for (int i = 0; i < ourMarks.length; i++) { int mark = ourMarks[i]; if (mark == configuration.SHORT_DIFF_EXTRA_LINES) { slider.setValue(i + 1); } } JBPopup popup = JBPopupFactory.getInstance().createComponentPopupBuilder(result, slider).createPopup(); popup.setFinalRunnable( new Runnable() { @Override public void run() { int value = slider.getModel().getValue(); if (configuration.SHORT_DIFF_EXTRA_LINES != ourMarks[value - 1]) { configuration.SHORT_DIFF_EXTRA_LINES = ourMarks[value - 1]; myFragmentedContent.recalculate(); refreshData(myFragmentedContent); } } }); InputEvent inputEvent = e.getInputEvent(); if (inputEvent instanceof MouseEvent) { int width = result.getPreferredSize().width; MouseEvent inputEvent1 = (MouseEvent) inputEvent; Point point1 = new Point(inputEvent1.getX() - width / 2, inputEvent1.getY()); RelativePoint point = new RelativePoint(inputEvent1.getComponent(), point1); popup.show(point); } else { popup.showInBestPositionFor(e.getDataContext()); } }
@Override public void doLayout() { if (labelBar == null || listPanel == null) return; Dimension d = listPanel.getPreferredSize(); Component p = getParent(); int w = p == null ? d.width : getParent().getWidth(); int y = 0; labelBar.setBounds(0, y, w, 30); y += 30; //noinspection SuspiciousNameCombination listPanel.setBounds(y, 33, w, d.height); }
private void init() { setLayout(new BorderLayout(0, 5)); setBorder(makeBorder()); Box box = Box.createVerticalBox(); box.add(makeTitlePanel()); box.add(createResetPanel()); box.add(createParameterPanel()); box.add(createFilenamePanel()); add(box, BorderLayout.NORTH); JPanel panel = createScriptPanel(); add(panel, BorderLayout.CENTER); // Don't let the input field shrink too much add(Box.createVerticalStrut(panel.getPreferredSize().height), BorderLayout.WEST); }
private JPanel createContentPanel() { // compute content and other buttons SpringLayout springLayout = new SpringLayout(); JPanel panel = new JPanel(springLayout); int panelHeight = 0; JTable propertiesPanel = createPropertiesPanel(); panelHeight += propertiesPanel.getPreferredSize().getHeight(); panel.add(propertiesPanel); panelHeight += 10; panel.add(Box.createVerticalStrut(10)); JScrollPane scrollPane = new JScrollPane(createAdaptersPanel()); panelHeight += scrollPane.getPreferredSize().getHeight(); panel.add(scrollPane); panelHeight += 10; panel.add(Box.createVerticalStrut(10)); JPanel buttonsPanel = createButtonsPanel(); panelHeight += buttonsPanel.getPreferredSize().getHeight(); panel.add(buttonsPanel); springLayout.putConstraint( SpringLayout.NORTH, panel, DEFAULT_PADDING, SpringLayout.NORTH, propertiesPanel); springLayout.putConstraint( SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, propertiesPanel); springLayout.putConstraint( SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, propertiesPanel); springLayout.putConstraint( SpringLayout.NORTH, scrollPane, DEFAULT_PADDING, SpringLayout.SOUTH, propertiesPanel); springLayout.putConstraint( SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, scrollPane); springLayout.putConstraint( SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, scrollPane); springLayout.putConstraint( SpringLayout.NORTH, scrollPane, DEFAULT_PADDING, SpringLayout.SOUTH, buttonsPanel); springLayout.putConstraint( SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, buttonsPanel); springLayout.putConstraint( SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, buttonsPanel); panel.setPreferredSize( new Dimension( CHECK_COLUMN_WIDTH + LABEL_COLUMN_WIDTH + COLUMN_WIDTH - 32, panelHeight + DEFAULT_PADDING)); makeCompactGrid(panel, 5, 1, 0, 0, 0, 0); return panel; }
private void ensureProperViewSize() { Dimension ps = v.getViewport().getMinimumSize(); Dimension rs = v.getViewport().getSize(); int nw = Math.min(4, Math.max(((rs.width - 5 + ps.width / 2) / (ps.width - 5)), 1)); int nh = Math.min(5, Math.max(((rs.height - 5 + ps.height / 2) / (ps.height - 5)), 1)); if (nh > (jp.getComponentCount() - 1) / nw + 1) nh = (jp.getComponentCount() - 1) / nw + 1; Dimension ns = new Dimension(nw * (ps.width - 5) + 5, nh * (ps.height - 5) + 5); if (ns.equals(rs)) return; columns = nw; setPreferredPanelSize(); v.getViewport().setPreferredSize(ns); main.pack(); v.getViewport().setViewPosition(new Point(0, jp.getPreferredSize().height)); checkHighlightVisible(); }
protected void layoutItems() { Insets insets = main.getInsets(); Dimension size = new Dimension(); int xOff = 12 + insets.left; int yOff = 57; xOff += layoutXOffAdjustment; yOff += layoutYOffAdjustment; int x = 0; int y = yOff; Rectangle b = main.getBounds(); for (T item : itemList) { size = item.getPreferredSize(); lc.itemsPerRow = (b.height - yOff) / (size.height + layoutItemHeightAdjustment); item.setBounds(xOff + x, y + insets.top, size.width, size.height); y += size.height + layoutItemHeightAdjustment; if (!layoutHeightOnly) { if (y + size.height > b.height) { x += size.width + xOff; y = yOff; } } } Dimension d = main.getPreferredSize(); d.width = x + size.width + xOff * 2; if (layoutHeightOnly) { d.height = y + size.height + yOff; } main.setPreferredSize(d); main.repaint(); }
public ScalaApplicationSettingsForm(ScalaApplicationSettings settings) { mySettings = settings; myEnableCompileServer.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { updateCompilationServerSettingsPanel(); } }); initCompilerTypeCmb(); initCompileOrderCmb(); ProjectSdksModel model = new ProjectSdksModel(); model.reset(null); myCompilationServerSdk = new JdkComboBox(model); myCompilationServerSdk.insertItemAt(new JdkComboBox.NoneJdkComboBoxItem(), 0); mySdkPanel.add(myCompilationServerSdk, BorderLayout.CENTER); mySdkPanel.setSize(mySdkPanel.getPreferredSize()); myNote.setForeground(JBColor.GRAY); delaySpinner.setEnabled(showTypeInfoOnCheckBox.isSelected()); showTypeInfoOnCheckBox.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { delaySpinner.setEnabled(showTypeInfoOnCheckBox.isSelected()); } }); delaySpinner.setValue(mySettings.SHOW_TYPE_TOOLTIP_DELAY); updateCompilationServerSettingsPanel(); }
/** * Utility used by uk.ac.sanger.artemis.components.Plot * @param numPlots * @param lines * @param plot * @return */ public static LineAttributes[] configurePlots( final List<String> bamList, final LineAttributes[] lines, final JPanel covergePanel) { JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); final int numPlots = bamList.size(); final LineAttributes[] thislines; if(lines.length < numPlots) thislines = init(numPlots); else thislines = lines; int gridx = 0; int gridy = 0; c.gridy = gridy++; c.gridx = gridx; // open / filled panel.add(new JLabel("Plot Options:"), c); final JComboBox openPlot = new JComboBox(PLOT_TYPES); openPlot.setSelectedItem(thislines[0].plotType); openPlot.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { for(int i=0; i<numPlots; i++) thislines[i].plotType = (String) openPlot.getSelectedItem(); covergePanel.repaint(); } }); c.gridy = gridy++; panel.add(openPlot, c); c.gridy = gridy++; panel.add(new JLabel("Line Options:"), c); c.gridx = gridx++; c.gridy = gridy++; gridx++; final JCheckBox applyToAll = new JCheckBox("Apply colour to all"); panel.add(new JLabel("Colour"), c); c.gridx = gridx++; panel.add(new JLabel("Line style"), c); c.gridx = gridx; panel.add(new JLabel("Line size"), c); for(int i=0; i<numPlots; i++) { c.gridy = gridy++; final int colourNumber = i; gridx = 0; c.gridx = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHWEST; final JLabel bamFileName = new JLabel(bamList.get(i)); panel.add(bamFileName,c); c.gridwidth = 1; c.gridy = gridy++; final JLabel colourLabel = new JLabel(" "); colourLabel.setBackground(thislines[i].getLineColour()); colourLabel.setOpaque(true); c.gridx = gridx++; panel.add(colourLabel,c); JButton butt = new JButton("Select"); butt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent _) { Color newColour = JColorChooser.showDialog(null, "Colour Chooser", thislines[colourNumber].getLineColour()); if(applyToAll.isSelected()) { for(int iplot=0; iplot<numPlots; iplot++) thislines[iplot].setLineColour(newColour); } else thislines[colourNumber].setLineColour(newColour); colourLabel.setBackground(thislines[colourNumber].getLineColour()); covergePanel.repaint(); } }); c.gridx = gridx++; panel.add(butt, c); // line style final JSlider slider = new JSlider(1, 10, (int)lines[colourNumber].getStroke().getLineWidth()); Integer index[] = new Integer[STROKES.length]; for(int j=0; j<index.length; j++) index[j] = j; final JComboBox lineStyle = new JComboBox(index); lineStyle.setRenderer(new LineStyleListRenderer()); lineStyle.setSelectedIndex( LineAttributes.getStyleIndex(thislines[colourNumber].getStroke())); lineStyle.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { thislines[colourNumber].setStroke( STROKES[lineStyle.getSelectedIndex()]); setLineSize(covergePanel, slider, thislines, colourNumber); } }); c.gridx = gridx++; panel.add(lineStyle, c); // line size slider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { setLineSize(covergePanel, slider, thislines, colourNumber); } }); c.gridx = gridx; panel.add(slider, c); } c.gridx = 0; c.gridy = gridy++; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; panel.add(applyToAll, c); JScrollPane jsp = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); if(panel.getPreferredSize().height > d.height/2) { d.setSize(jsp.getPreferredSize().width, d.height/2); jsp.setPreferredSize(d); } String config_options[] = { "OK" }; JOptionPane.showOptionDialog(null, jsp, "Configure Lines", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, config_options, config_options[0]); return thislines; }
public JComponent createCenterPanel() { List<FileStructureFilter> fileStructureFilters = new ArrayList<FileStructureFilter>(); List<FileStructureNodeProvider> fileStructureNodeProviders = new ArrayList<FileStructureNodeProvider>(); if (myTreeActionsOwner != null) { for (Filter filter : myBaseTreeModel.getFilters()) { if (filter instanceof FileStructureFilter) { final FileStructureFilter fsFilter = (FileStructureFilter) filter; myTreeActionsOwner.setActionIncluded(fsFilter, true); fileStructureFilters.add(fsFilter); } } if (myBaseTreeModel instanceof ProvidingTreeModel) { for (NodeProvider provider : ((ProvidingTreeModel) myBaseTreeModel).getNodeProviders()) { if (provider instanceof FileStructureNodeProvider) { fileStructureNodeProviders.add((FileStructureNodeProvider) provider); } } } } final JPanel panel = new JPanel(new BorderLayout()); JPanel comboPanel = new JPanel(new GridLayout(0, 2, 0, 0)); final Shortcut[] F4 = ActionManager.getInstance() .getAction(IdeActions.ACTION_EDIT_SOURCE) .getShortcutSet() .getShortcuts(); final Shortcut[] ENTER = CustomShortcutSet.fromString("ENTER").getShortcuts(); final CustomShortcutSet shortcutSet = new CustomShortcutSet(ArrayUtil.mergeArrays(F4, ENTER)); new AnAction() { public void actionPerformed(AnActionEvent e) { final boolean succeeded = navigateSelectedElement(); if (succeeded) { unregisterCustomShortcutSet(panel); } } }.registerCustomShortcutSet(shortcutSet, panel); new AnAction() { public void actionPerformed(AnActionEvent e) { if (mySpeedSearch != null && mySpeedSearch.isPopupActive()) { mySpeedSearch.hidePopup(); } else { myPopup.cancel(); } } }.registerCustomShortcutSet(CustomShortcutSet.fromString("ESCAPE"), myTree); new ClickListener() { @Override public boolean onClick(MouseEvent e, int clickCount) { navigateSelectedElement(); return true; } }.installOn(myTree); for (FileStructureFilter filter : fileStructureFilters) { addCheckbox(comboPanel, filter); } for (FileStructureNodeProvider provider : fileStructureNodeProviders) { addCheckbox(comboPanel, provider); } myPreferredWidth = Math.max(comboPanel.getPreferredSize().width, 350); panel.add(comboPanel, BorderLayout.NORTH); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myAbstractTreeBuilder.getTree()); scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP | SideBorder.BOTTOM)); panel.add(scrollPane, BorderLayout.CENTER); panel.add(createSouthPanel(), BorderLayout.SOUTH); DataManager.registerDataProvider( panel, new DataProvider() { @Override public Object getData(@NonNls String dataId) { if (PlatformDataKeys.PROJECT.is(dataId)) { return myProject; } if (LangDataKeys.PSI_ELEMENT.is(dataId)) { final Object node = ContainerUtil.getFirstItem(myAbstractTreeBuilder.getSelectedElements()); if (!(node instanceof FilteringTreeStructure.FilteringNode)) return null; return getPsi((FilteringTreeStructure.FilteringNode) node); } if (LangDataKeys.POSITION_ADJUSTER_POPUP.is(dataId)) { return myPopup; } if (PlatformDataKeys.TREE_EXPANDER.is(dataId)) { return myTreeExpander; } return null; } }); return panel; }
private JComponent getButtonPanel() { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); choiceType = new JComboBox<PersonTypeItem>(); choiceType.setMaximumSize( new Dimension(Short.MAX_VALUE, (int) choiceType.getPreferredSize().getHeight())); DefaultComboBoxModel<PersonTypeItem> personTypeModel = new DefaultComboBoxModel<>(); personTypeModel.addElement( new PersonTypeItem(resourceMap.getString("primaryRole.choice.text"), null)); // $NON-NLS-1$ for (int i = 1; i < Person.T_NUM; ++i) { personTypeModel.addElement( new PersonTypeItem(Person.getRoleDesc(i, campaign.getFaction().isClan()), i)); } personTypeModel.addElement( new PersonTypeItem(Person.getRoleDesc(0, campaign.getFaction().isClan()), 0)); // Add "none" for generic AsTechs choiceType.setModel(personTypeModel); choiceType.setSelectedIndex(0); choiceType.addActionListener( e -> { personnelFilter.setPrimaryRole(((PersonTypeItem) choiceType.getSelectedItem()).id); updatePersonnelTable(); }); panel.add(choiceType); choiceExp = new JComboBox<PersonTypeItem>(); choiceExp.setMaximumSize( new Dimension(Short.MAX_VALUE, (int) choiceType.getPreferredSize().getHeight())); DefaultComboBoxModel<PersonTypeItem> personExpModel = new DefaultComboBoxModel<>(); personExpModel.addElement( new PersonTypeItem(resourceMap.getString("experience.choice.text"), null)); // $NON-NLS-1$ for (int i = 0; i < 5; ++i) { personExpModel.addElement(new PersonTypeItem(SkillType.getExperienceLevelName(i), i)); } choiceExp.setModel(personExpModel); choiceExp.setSelectedIndex(0); choiceExp.addActionListener( e -> { personnelFilter.setExpLevel(((PersonTypeItem) choiceExp.getSelectedItem()).id); updatePersonnelTable(); }); panel.add(choiceExp); choiceSkill = new JComboBox<String>(); choiceSkill.setMaximumSize( new Dimension(Short.MAX_VALUE, (int) choiceSkill.getPreferredSize().getHeight())); DefaultComboBoxModel<String> personSkillModel = new DefaultComboBoxModel<>(); personSkillModel.addElement(choiceNoSkill); for (String skill : SkillType.getSkillList()) { personSkillModel.addElement(skill); } choiceSkill.setModel(personSkillModel); choiceSkill.setSelectedIndex(0); choiceSkill.addActionListener( e -> { if (choiceNoSkill.equals(choiceSkill.getSelectedItem())) { personnelFilter.setSkill(null); ((SpinnerNumberModel) skillLevel.getModel()).setMaximum(10); buttonSpendXP.setEnabled(false); } else { String skillName = (String) choiceSkill.getSelectedItem(); personnelFilter.setSkill(skillName); int maxSkillLevel = SkillType.getType(skillName).getMaxLevel(); int currentLevel = (Integer) skillLevel.getModel().getValue(); ((SpinnerNumberModel) skillLevel.getModel()).setMaximum(maxSkillLevel); if (currentLevel > maxSkillLevel) { skillLevel.getModel().setValue(Integer.valueOf(maxSkillLevel)); } buttonSpendXP.setEnabled(true); } updatePersonnelTable(); }); panel.add(choiceSkill); panel.add(Box.createRigidArea(new Dimension(10, 10))); panel.add(new JLabel(resourceMap.getString("targetSkillLevel.text"))); // $NON-NLS-1$ skillLevel = new JSpinner(new SpinnerNumberModel(10, 0, 10, 1)); skillLevel.setMaximumSize( new Dimension(Short.MAX_VALUE, (int) skillLevel.getPreferredSize().getHeight())); skillLevel.addChangeListener( e -> { personnelFilter.setMaxSkillLevel((Integer) skillLevel.getModel().getValue()); updatePersonnelTable(); }); panel.add(skillLevel); allowPrisoners = new JCheckBox(resourceMap.getString("allowPrisoners.text")); // $NON-NLS-1$ allowPrisoners.setHorizontalAlignment(SwingConstants.LEFT); allowPrisoners.setMaximumSize( new Dimension(Short.MAX_VALUE, (int) allowPrisoners.getPreferredSize().getHeight())); allowPrisoners.addChangeListener( e -> { personnelFilter.setAllowPrisoners(allowPrisoners.isSelected()); updatePersonnelTable(); }); JPanel allowPrisonersPanel = new JPanel(new GridLayout(1, 1)); allowPrisonersPanel.setAlignmentY(JComponent.LEFT_ALIGNMENT); allowPrisonersPanel.add(allowPrisoners); allowPrisonersPanel.setMaximumSize( new Dimension(Short.MAX_VALUE, (int) allowPrisonersPanel.getPreferredSize().getHeight())); panel.add(allowPrisonersPanel); panel.add(Box.createVerticalGlue()); matchedPersonnelLabel = new JLabel(""); // $NON-NLS-1$ matchedPersonnelLabel.setMaximumSize( new Dimension(Short.MAX_VALUE, (int) matchedPersonnelLabel.getPreferredSize().getHeight())); panel.add(matchedPersonnelLabel); JPanel buttons = new JPanel(new FlowLayout()); buttons.setMaximumSize( new Dimension(Short.MAX_VALUE, (int) buttons.getPreferredSize().getHeight())); buttonSpendXP = new JButton(resourceMap.getString("spendXP.text")); // $NON-NLS-1$ buttonSpendXP.setEnabled(false); buttonSpendXP.addActionListener(e -> spendXP()); buttons.add(buttonSpendXP); JButton button = new JButton(resourceMap.getString("close.text")); // $NON-NLS-1$ button.addActionListener(e -> setVisible(false)); buttons.add(button); panel.add(buttons); panel.setMaximumSize(new Dimension((int) panel.getPreferredSize().getWidth(), Short.MAX_VALUE)); panel.setMinimumSize(new Dimension((int) panel.getPreferredSize().getWidth(), 300)); return panel; }