List of usage examples for javax.swing JPanel setMaximumSize
@BeanProperty(description = "The maximum size of the component.") public void setMaximumSize(Dimension maximumSize)
From source file:com.idealista.solrmeter.view.statistic.CacheHistoryPanel.java
/** * Creates the left panel, with the combo boxes to select wether to see hit ratio * or specific cache data, and if specific cache data is selected, will also show * the combo box to select the cache and the cumulative information * @return//from w w w . j a va2 s . c om */ private Component createLeftPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; constraints.weighty = 0; constraints.fill = GridBagConstraints.BOTH; constraints.insets = new Insets(1, 1, 1, 1); for (Component component : this.createControlPanel()) { panel.add(component, constraints); constraints.gridy++; } cumulativeDataPanel = this.createCumulativeDataPanel(); panel.add(cumulativeDataPanel, constraints); constraints.gridy++; constraints.weighty = 2.0; panel.add(Box.createVerticalGlue(), constraints); panel.setMaximumSize(new Dimension(100, Integer.MAX_VALUE)); return panel; }
From source file:zet.gui.assignmentEditor.JAssignmentPanel.java
/** * Adds all components to the panel.//from www . j a v a2 s .com */ private void addComponents() { setLayout(new BorderLayout()); initDistributions(); // Create the main table tablemodel = new AssignmentTableModel(); tablemodel.addTableModelListener(e -> { drawCharts(); }); distributionTable = new JTable(tablemodel); distributionTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); distributionTable.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> { drawCharts(); }); distributions = new JComboBox<>(); distributions.addItem(loc.getString("gui.AssignmentEditor.Distribution.NormalDistribution")); distributions.addItem(loc.getString("gui.AssignmentEditor.Distribution.UniformDistribution")); distributions.addItem(loc.getString("gui.AssignmentEditor.Distribution.ExponentialDistribution")); distributions.addItem(loc.getString("gui.AssignmentEditor.Distribution.ErlangDistribution")); distributions.addItem(loc.getString("gui.AssignmentEditor.Distribution.HyperExponentialDistribution")); distributionTable.getColumnModel().getColumn(COL_DISTRIBUTION) .setCellEditor(new DefaultCellEditor(distributions)); distributionTable.getColumnModel().getColumn(COL_PARAM1).setCellEditor(new SelectingCellEditor()); distributionTable.getColumnModel().getColumn(COL_PARAM2).setCellEditor(new SelectingCellEditor()); distributionTable.getColumnModel().getColumn(COL_PARAM3).setCellEditor(new SelectingCellEditor()); distributionTable.getColumnModel().getColumn(COL_PARAM4).setCellEditor(new SelectingCellEditor()); distributionTable.getColumnModel().getColumn(COL_PARAM3).setCellRenderer(new InactiveRenderer()); distributionTable.getColumnModel().getColumn(COL_PARAM4).setCellRenderer(new InactiveRenderer()); add(getRightPanel(), BorderLayout.CENTER); final JPanel leftPanel = getLeftPanel(); leftPanel.setMaximumSize(new Dimension(200, 0)); add(leftPanel, BorderLayout.WEST); assignmentSelector.displayAssignments(myProject.getProject()); }
From source file:jchrest.gui.VisualSearchPane.java
private JPanel constructTrainingOptions() { _maxTrainingCycles = new JSpinner(new SpinnerNumberModel(5, 1, 1000, 1)); _numFixations = new JSpinner(new SpinnerNumberModel(20, 1, 1000, 1)); _maxNetworkSize = new JSpinner(new SpinnerNumberModel(100000, 1, 10000000, 1)); JPanel panel = new JPanel(); panel.setLayout(new SpringLayout()); Utilities.addLabel(panel, "Domain of scenes:", _domainSelector); Utilities.addLabel(panel, "Number of scenes:", new JLabel("" + _scenes.size())); Utilities.addLabel(panel, "Maximum training cycles:", _maxTrainingCycles); Utilities.addLabel(panel, "Number of fixations per scene:", _numFixations); Utilities.addLabel(panel, "Maximum network size:", _maxNetworkSize); Utilities.makeCompactGrid(panel, 5, 2, 3, 3, 10, 5); panel.setMaximumSize(panel.getPreferredSize()); JPanel ePanel = new JPanel(); ePanel.setLayout(new GridLayout(1, 1)); ePanel.add(panel);/*from ww w. j av a 2 s . com*/ return ePanel; }
From source file:com.idealista.solrmeter.view.statistic.OperationTimeLineChartPanel.java
private Component createCheckBoxPanel() { JPanel panelCheckBox = new JPanel(); panelCheckBox.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panelCheckBox.setLayout(new BoxLayout(panelCheckBox, BoxLayout.X_AXIS)); checkBoxShowCommit = new JCheckBox(I18n.get("statistic.operationTimeLineChartPanel.checkbox.commit")); checkBoxShowCommit.addActionListener(this); checkBoxShowOptimize = new JCheckBox(I18n.get("statistic.operationTimeLineChartPanel.checkbox.optimize")); checkBoxShowOptimize.addActionListener(this); checkBoxShowAdd = new JCheckBox(I18n.get("statistic.operationTimeLineChartPanel.checkbox.add")); checkBoxShowAdd.addActionListener(this); checkBoxShowQueries = new JCheckBox(I18n.get("statistic.operationTimeLineChartPanel.checkbox.query")); checkBoxShowQueries.addActionListener(this); panelCheckBox.add(Box.createHorizontalGlue()); panelCheckBox.add(checkBoxShowCommit); panelCheckBox.add(Box.createHorizontalGlue()); panelCheckBox.add(checkBoxShowOptimize); panelCheckBox.add(Box.createHorizontalGlue()); panelCheckBox.add(checkBoxShowQueries); panelCheckBox.add(Box.createHorizontalGlue()); panelCheckBox.add(checkBoxShowAdd);/*from ww w . j ava 2s . c o m*/ panelCheckBox.add(Box.createHorizontalGlue()); panelCheckBox.setMaximumSize(new Dimension(800, 25)); checkAll(); return panelCheckBox; }
From source file:es.emergya.ui.plugins.AdminPanel.java
public AdminPanel(String t, Icon icon, Option myself, boolean canCreateNew, boolean canDelete) { super();/* w ww .j ava2s.com*/ setCanCreateNew(canCreateNew); setCanDelete(canDelete); setLayout(new SpringLayout()); this.father = myself; setBackground(Color.WHITE); // Titulo con icono JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); title = new JLabel(t); title.setIcon(icon); title.setFont(LogicConstants.deriveBoldFont(12f)); title.setBorder(new EmptyBorder(0, 10, 0, 10)); titlePanel.add(title); titlePanel.setOpaque(false); add(titlePanel); Dimension d = titlePanel.getSize(); if (icon != null) d.height = icon.getIconHeight(); titlePanel.setMaximumSize(d); // Controles de "nuevo" "seleccionar todos" etc... JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEADING)); controls.setOpaque(false); final boolean femenino = t.indexOf("atrulla") != -1 || t.indexOf("apa") != -1 || t.indexOf("lota") != -1 || t.indexOf("encia") != -1; if (getCanCreateNew()) { if (femenino) { newButton = new JButton("Nueva", getIcon("button_nuevo")); } else { newButton = new JButton("Nuevo", getIcon("button_nuevo")); } controls.add(newButton); } if (getCanDelete()) { JButton selectAll = new JButton(((femenino) ? "Seleccionar Todas" : "Seleccionar Todos"), getIcon("button_selectall")); selectAll.addActionListener(this); controls.add(selectAll); deselectAll = new JButton(((femenino) ? "Deseleccionar Todas" : "Deseleccionar Todos"), getIcon("button_unselectall")); deselectAll.addActionListener(this); controls.add(deselectAll); JButton deleteAll = new JButton(((femenino) ? "Eliminar Seleccionadas" : "Eliminar Seleccionados"), getIcon("button_delall")); deleteAll.addActionListener(this); controls.add(deleteAll); } d = controls.getSize(); controls.setMaximumSize(d); add(controls); // Tabla tablePanel = new JPanel(new BorderLayout()); tablePanel.setOpaque(false); add(tablePanel); SpringUtilities.makeCompactGrid(this, 3, 1, 0, 0, 0, 0); }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
protected void showLicense(String licenseFile) throws IOException { final JTextArea textarea = new JTextArea( IOUtils.toString(FileSync.class.getResourceAsStream("/licenses/" + licenseFile))); JPanel p = new JPanel(new BorderLayout()); JScrollPane scrollpane = new JScrollPane(textarea); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); p.add(scrollpane, BorderLayout.CENTER); p.setMaximumSize(new Dimension(screenSize.width / 2, screenSize.height / 2)); p.setPreferredSize(new Dimension(screenSize.width / 2, screenSize.height / 2)); p.setSize(new Dimension(screenSize.width / 2, screenSize.height / 2)); JOptionPane.showMessageDialog(mainFrame, p, "Lizenz", JOptionPane.INFORMATION_MESSAGE); }
From source file:com.sshtools.shift.FileTransferDialog.java
private void jbInit() throws Exception { getContentPane().setLayout(new BorderLayout()); progressbar.setToolTipText(""); progressbar.setValue(0);/*from ww w . j ava 2 s. co m*/ try { Method m = progressbar.getClass().getMethod("setIndeterminate", new Class[] { boolean.class }); Object[] args = new Object[] { new Boolean(true) }; m.invoke(progressbar, args); } catch (Throwable ex) { } //progressbar.setIndeterminate(true); progressbar.setBounds(new Rectangle(8, 45, 336, 22)); lblEstimatedTime.setText("Estimated time left: "); lblEstimatedTime.setBounds(new Rectangle(8, 74, 114, 17)); lblTimeLeftValue.setText(""); lblTimeLeftValue.setBounds(new Rectangle(109, 74, 235, 17)); lblTargetAction.setText("Downloading to:"); lblTargetAction.setBounds(new Rectangle(8, 92, 96, 17)); lblTargetValue.setText(""); lblTargetValue.setBounds(new Rectangle(109, 92, 235, 17)); lblTransferRate.setText("Transfer rate: "); lblTransferRate.setBounds(new Rectangle(8, 110, 96, 17)); lblTransferRateValue.setText(""); lblTransferRateValue.setBounds(new Rectangle(109, 110, 235, 17)); btnCancel.setText("Cancel"); btnCancel.addActionListener(new FileTransferDialog_cancel_actionAdapter( this)); chkClose.setText("Close this window when the transfer completes"); chkClose.setBounds(new Rectangle(8, 132, 307, 18)); chkClose.setSelected(true); JPanel p = new JPanel(null); lblAction.setBounds(new Rectangle(9, 5, 334, 21)); lblPathValue.setText(""); lblPathValue.setBounds(new Rectangle(10, 22, 329, 22)); p.add(progressbar); p.add(lblEstimatedTime); p.add(lblTimeLeftValue); p.add(lblTargetAction); p.add(lblTransferRate); p.add(lblTransferRateValue); p.add(lblTargetValue); p.add(lblAction); p.add(lblPathValue); p.add(chkClose); JPanel b = new JPanel(new FlowLayout(FlowLayout.RIGHT)); b.add(btnCancel); p.setMaximumSize(new Dimension(350, 185)); p.setMinimumSize(new Dimension(350, 185)); p.setPreferredSize(new Dimension(350, 185)); getContentPane().add(p, BorderLayout.CENTER); getContentPane().add(b, BorderLayout.SOUTH); elaspedTime = 0; formatMb.setMaximumFractionDigits(2); formatKb.setMaximumFractionDigits(0); formatKb1.setMaximumFractionDigits(1); setResizable(true); setSize(new Dimension(350, 184)); UIUtil.positionComponent(UIUtil.CENTER, this); }
From source file:ffx.ui.ModelingPanel.java
private JPanel getAminoAcidPanel() { if (aminoPanel != null) { return aminoPanel; }/*from ww w .j a v a 2s. c o m*/ JPanel buttonPanel = new JPanel(new GridLayout(4, 5, 2, 2)); Residue.AA3 a[] = Residue.AA3.values(); for (int i = 0; i < 20; i++) { JButton button = new JButton(a[i].name()); button.setActionCommand("PROTEIN"); button.addActionListener(this); buttonPanel.add(button); } buttonPanel.setMaximumSize(buttonPanel.getPreferredSize()); aminoPanel = new JPanel(); aminoPanel.setLayout(new BoxLayout(aminoPanel, BoxLayout.Y_AXIS)); aminoPanel.add(buttonPanel); conformationComboBox = new JComboBox<>(Residue.Ramachandran); conformationComboBox.setFont(Font.decode("Monospaced")); conformationComboBox.setMaximumSize(buttonPanel.getPreferredSize()); aminoPanel.add(conformationComboBox); return aminoPanel; }
From source file:io.github.jeremgamer.editor.panels.components.PanelsPanel.java
public PanelsPanel(JFrame frame, final PanelSave ps) { this.ps = ps; this.frame = frame; this.setSize(new Dimension(395, frame.getHeight() - 27 - 23)); this.setLocation(300, 0); this.setBorder(BorderFactory.createTitledBorder("Edition du panneau")); JPanel content = new JPanel(); JScrollPane scroll = new JScrollPane(content); scroll.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); scroll.setBorder(null);//from w w w . j ava 2 s . c o m content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS)); scroll.setPreferredSize(new Dimension(382, frame.getHeight() - 27 - 46 - 20)); JPanel namePanel = new JPanel(); name.setPreferredSize(new Dimension(this.getWidth() - 280, 30)); name.setEditable(false); namePanel.add(new JLabel("Nom :")); namePanel.add(name); namePanel.add(Box.createRigidArea(new Dimension(10, 1))); layout.addItem("Basique"); layout.addItem("Bordures"); layout.addItem("Ligne"); layout.addItem("Colonne"); layout.addItem("Grille"); layout.addItem("Empil"); layout.setPreferredSize(new Dimension(110, 30)); layout.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); cl.show(advanced, listContent[combo.getSelectedIndex()]); ps.set("layout", combo.getSelectedIndex()); ActionPanel.updateLists(); } }); namePanel.add(new JLabel("Disposition :")); namePanel.add(layout); namePanel.setPreferredSize(new Dimension(365, 50)); namePanel.setMaximumSize(new Dimension(365, 50)); content.add(namePanel); advanced.setPreferredSize(new Dimension(365, 300)); advanced.setMaximumSize(new Dimension(365, 300)); advanced.add(ble, listContent[0]); advanced.add(brdle, listContent[1]); advanced.add(lle, listContent[2]); advanced.add(rle, listContent[3]); advanced.add(gle, listContent[4]); advanced.add(cle, listContent[5]); content.add(advanced); topBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); ps.set("border.top", combo.getSelectedItem()); } }); leftBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); ps.set("border.left", combo.getSelectedItem()); } }); centerBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); ps.set("border.center", combo.getSelectedItem()); } }); rightBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); ps.set("border.right", combo.getSelectedItem()); } }); bottomBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); ps.set("border.bottom", combo.getSelectedItem()); } }); JPanel prefSize = new JPanel(); prefSize.setPreferredSize(new Dimension(365, 110)); prefSize.setMaximumSize(new Dimension(365, 110)); prefSize.setBorder(BorderFactory.createTitledBorder("Taille prfre")); JPanel prefSizePanel = new JPanel(); prefSizePanel.setLayout(new GridLayout(2, 4)); prefSizePanel.setPreferredSize(new Dimension(300, 55)); prefSizePanel.setMaximumSize(new Dimension(300, 55)); prefSizePanel.add(prefSizeEnabled); prefSizePanel.add(new JLabel("")); prefSizePanel.add(new JLabel("")); prefSizePanel.add(new JLabel("(en pixels)")); prefSizePanel.add(new JLabel("Largeur :")); prefSizePanel.add(prefWidth); prefSizePanel.add(new JLabel("Hauteur :")); prefSizePanel.add(prefHeight); prefWidth.setEnabled(false); prefHeight.setEnabled(false); prefSizeEnabled.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JCheckBox check = (JCheckBox) event.getSource(); ps.set("preferredSize", check.isSelected()); prefWidth.setEnabled(check.isSelected()); prefHeight.setEnabled(check.isSelected()); } }); prefWidth.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JSpinner spinner = (JSpinner) event.getSource(); ps.set("preferredWidth", spinner.getValue()); } }); prefHeight.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JSpinner spinner = (JSpinner) event.getSource(); ps.set("preferredHeight", spinner.getValue()); } }); prefSize.add(prefSizePanel); content.add(prefSize); JPanel insetsPanel = new JPanel(); insetsPanel.setBorder(BorderFactory.createTitledBorder("carts")); insetsPanel.setPreferredSize(new Dimension(365, 100)); insetsPanel.setMaximumSize(new Dimension(365, 100)); JPanel insetsContent = new JPanel(); insetsContent.setLayout(new BoxLayout(insetsContent, BoxLayout.PAGE_AXIS)); JPanel insetInput = new JPanel(); insetInput.setLayout(new GridLayout(2, 4)); insetInput.add(insetsEnabled); insetInput.add(new JLabel("")); insetInput.add(new JLabel("")); insetInput.add(new JLabel("(en pixels)")); insetInput.add(new JLabel("Horizontaux :")); insetInput.add(insetHz); insetInput.add(new JLabel("Verticaux :")); insetInput.add(insetVt); insetsEnabled.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JCheckBox check = (JCheckBox) event.getSource(); if (check.isSelected()) { insetHz.setEnabled(true); insetVt.setEnabled(true); ps.set("insets", true); } else { insetHz.setEnabled(true); insetVt.setEnabled(true); ps.set("insets", false); } } }); insetHz.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JSpinner spinner = (JSpinner) event.getSource(); ps.set("insets.horizontal", spinner.getValue()); } }); insetVt.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { JSpinner spinner = (JSpinner) event.getSource(); ps.set("insets.vertical", spinner.getValue()); } }); insetsContent.add(insetInput); insetsPanel.add(insetsContent); content.add(insetsPanel); JPanel web = new JPanel(); web.setPreferredSize(new Dimension(365, 100)); web.setMaximumSize(new Dimension(365, 100)); web.setBorder(BorderFactory.createTitledBorder("Page Web")); JPanel webContent = new JPanel(); webContent.setLayout(new BorderLayout()); webContent.add(webEnabled, BorderLayout.NORTH); webEnabled.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCheckBox check = (JCheckBox) e.getSource(); ps.set("web", check.isSelected()); if (check.isSelected() == true) { layout.setSelectedIndex(0); layout.setEnabled(false); ble.removeAllComponents(); ble.disableComponents(); adress.setEnabled(true); } else { ble.enableComponents(); layout.setEnabled(true); adress.setEnabled(false); } } }); JPanel webInput = new JPanel(); webInput.add(new JLabel("Adresse :")); adress.setPreferredSize(new Dimension(250, 30)); CaretListener caretUpdate = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); ps.set("web.adress", text.getText()); } }; adress.addCaretListener(caretUpdate); webInput.add(adress); webContent.add(webInput, BorderLayout.CENTER); web.add(webContent); JPanel background = new JPanel(); BorderLayout bLayout = new BorderLayout(); bLayout.setVgap(12); background.setLayout(bLayout); background.setBorder(BorderFactory.createTitledBorder("Couleur de fond")); background.setPreferredSize(new Dimension(365, 210)); background.setMaximumSize(new Dimension(365, 210)); cp.setPreferredSize(new Dimension(347, 145)); cp.setMaximumSize(new Dimension(347, 145)); opaque.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCheckBox check = (JCheckBox) e.getSource(); ps.set("background.opaque", check.isSelected()); cp.enableComponents(check.isSelected()); } }); background.add(opaque, BorderLayout.NORTH); background.add(cp, BorderLayout.CENTER); JPanel image = new JPanel(); image.setBorder(BorderFactory.createTitledBorder("Image de fond")); image.setPreferredSize(new Dimension(365, 125)); image.setMaximumSize(new Dimension(365, 125)); image.setLayout(new BorderLayout()); try { remove = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } remove.setEnabled(false); remove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { File img = new File( "projects/" + Editor.getProjectName() + "/panels/" + name.getText() + "/background.png"); if (img.exists()) { img.delete(); } browseImage.setEnabled(true); } }); JPanel top = new JPanel(); browseImage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JButton button = (JButton) e.getSource(); String path = null; JFileChooser chooser = new JFileChooser(Editor.lastPath); FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg", "bmp"); chooser.setFileFilter(filter); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); int option = chooser.showOpenDialog(null); if (option == JFileChooser.APPROVE_OPTION) { path = chooser.getSelectedFile().getAbsolutePath(); Editor.lastPath = chooser.getSelectedFile().getParent(); copyImage(new File(path), "background.png"); nameBackground.setText(new File(path).getName()); ps.set("background.image", new File(path).getName()); button.setEnabled(false); size.setEnabled(true); size2.setEnabled(true); remove.setEnabled(true); } } }); bg.add(size); bg.add(size2); JPanel sizePanel = new JPanel(); sizePanel.setLayout(new BoxLayout(sizePanel, BoxLayout.PAGE_AXIS)); size.setEnabled(false); size2.setEnabled(false); sizePanel.add(size); sizePanel.add(size2); size.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { ps.set("background.size", 0); } }); size2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { ps.set("background.size", 1); } }); top.add(browseImage); top.add(sizePanel); remove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { JButton button = (JButton) event.getSource(); new File("projects/" + Editor.getProjectName() + "/panels/" + name.getText() + "/background.png") .delete(); nameBackground.setText(""); ps.set("background.image", ""); button.setEnabled(false); } }); nameBackground.setFont(new Font("Sans Serif", Font.PLAIN, 15)); JPanel center = new JPanel(new BorderLayout()); center.add(nameBackground, BorderLayout.CENTER); center.add(remove, BorderLayout.EAST); image.add(top, BorderLayout.NORTH); image.add(center, BorderLayout.CENTER); content.add(web); content.add(background); content.add(image); this.add(scroll); }
From source file:lcmc.gui.resources.ServiceInfo.java
/** Returns info panel with comboboxes for service parameters. */ @Override/*from w w w . jav a2 s .com*/ public JComponent getInfoPanel() { if (!getResourceAgent().isMetaDataLoaded()) { final JPanel p = new JPanel(); p.add(new JLabel(Tools.getString("ServiceInfo.LoadingMetaData"))); return p; } final CloneInfo ci = getCloneInfo(); if (ci == null) { getBrowser().getCRMGraph().pickInfo(this); } else { getBrowser().getCRMGraph().pickInfo(ci); } if (infoPanel != null) { return infoPanel; } /* init save button */ final boolean abExisted = getApplyButton() != null; final ServiceInfo thisClass = this; final ButtonCallback buttonCallback = new ButtonCallback() { private volatile boolean mouseStillOver = false; /** * Whether the whole thing should be enabled. */ @Override public final boolean isEnabled() { final Host dcHost = getBrowser().getDCHost(); if (dcHost == null) { return false; } if (Tools.versionBeforePacemaker(dcHost)) { return false; } return true; } @Override public final void mouseOut() { if (!isEnabled()) { return; } mouseStillOver = false; getBrowser().getCRMGraph().stopTestAnimation(getApplyButton()); getApplyButton().setToolTipText(null); } @Override public final void mouseOver() { if (!isEnabled()) { return; } mouseStillOver = true; getApplyButton().setToolTipText(ClusterBrowser.STARTING_PTEST_TOOLTIP); getApplyButton() .setToolTipBackground(Tools.getDefaultColor("ClusterBrowser.Test.Tooltip.Background")); Tools.sleep(250); if (!mouseStillOver) { return; } mouseStillOver = false; final CountDownLatch startTestLatch = new CountDownLatch(1); getBrowser().getCRMGraph().startTestAnimation(getApplyButton(), startTestLatch); final Host dcHost = getBrowser().getDCHost(); getBrowser().ptestLockAcquire(); final ClusterStatus cs = getBrowser().getClusterStatus(); cs.setPtestData(null); apply(dcHost, true); final PtestData ptestData = new PtestData(CRM.getPtest(dcHost)); getApplyButton().setToolTipText(ptestData.getToolTip()); cs.setPtestData(ptestData); getBrowser().ptestLockRelease(); startTestLatch.countDown(); } }; if (getResourceAgent().isGroup()) { initApplyButton(buttonCallback, Tools.getString("Browser.ApplyGroup")); } else { initApplyButton(buttonCallback); } if (ci != null) { ci.setApplyButton(getApplyButton()); ci.setRevertButton(getRevertButton()); } /* add item listeners to the apply button. */ if (!abExisted) { getApplyButton().addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final Thread thread = new Thread(new Runnable() { @Override public void run() { getBrowser().clStatusLock(); apply(getBrowser().getDCHost(), false); getBrowser().clStatusUnlock(); } }); thread.start(); } }); getRevertButton().addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final Thread thread = new Thread(new Runnable() { @Override public void run() { getBrowser().clStatusLock(); revert(); getBrowser().clStatusUnlock(); } }); thread.start(); } }); } /* main, button and options panels */ final JPanel mainPanel = new JPanel(); mainPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); final JPanel buttonPanel = new JPanel(new BorderLayout()); buttonPanel.setBackground(ClusterBrowser.BUTTON_PANEL_BACKGROUND); buttonPanel.setMinimumSize(new Dimension(0, 50)); buttonPanel.setPreferredSize(new Dimension(0, 50)); buttonPanel.setMaximumSize(new Dimension(Short.MAX_VALUE, 50)); final JPanel optionsPanel = new JPanel(); optionsPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND); optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS)); optionsPanel.setAlignmentX(Component.LEFT_ALIGNMENT); /* Actions */ final JMenuBar mb = new JMenuBar(); mb.setBackground(ClusterBrowser.PANEL_BACKGROUND); AbstractButton serviceMenu; if (ci == null) { serviceMenu = getActionsButton(); } else { serviceMenu = ci.getActionsButton(); } buttonPanel.add(serviceMenu, BorderLayout.EAST); String defaultValue = PRIMITIVE_TYPE_STRING; if (ci != null) { if (ci.getService().isMaster()) { defaultValue = MASTER_SLAVE_TYPE_STRING; } else { defaultValue = CLONE_TYPE_STRING; } } if (!getResourceAgent().isClone() && getGroupInfo() == null) { typeRadioGroup = new Widget(defaultValue, new String[] { PRIMITIVE_TYPE_STRING, CLONE_TYPE_STRING, MASTER_SLAVE_TYPE_STRING }, null, /* units */ Widget.Type.RADIOGROUP, null, /* regexp */ ClusterBrowser.SERVICE_LABEL_WIDTH + ClusterBrowser.SERVICE_FIELD_WIDTH, null, /* abbrv */ new AccessMode(ConfigData.AccessType.ADMIN, false)); if (!getService().isNew()) { typeRadioGroup.setEnabled(false); } typeRadioGroup.addListeners(new WidgetListener() { @Override public void check(final Object value) { changeType(((JRadioButton) value).getText()); } }); final JPanel tp = new JPanel(); tp.setBackground(ClusterBrowser.PANEL_BACKGROUND); tp.setLayout(new BoxLayout(tp, BoxLayout.Y_AXIS)); tp.add(typeRadioGroup); typeRadioGroup.setBackgroundColor(ClusterBrowser.PANEL_BACKGROUND); optionsPanel.add(tp); } if (ci != null) { /* add clone fields */ addCloneFields(optionsPanel, ClusterBrowser.SERVICE_LABEL_WIDTH, ClusterBrowser.SERVICE_FIELD_WIDTH); } getResource().setValue(GUI_ID, getService().getId()); /* get dependent resources and create combo boxes for ones, that * need parameters */ final String[] params = getParametersFromXML(); final Info savedMAIdRef = savedMetaAttrInfoRef; addParams(optionsPanel, params, ClusterBrowser.SERVICE_LABEL_WIDTH, ClusterBrowser.SERVICE_FIELD_WIDTH, getSameAsFields(savedMAIdRef)); if (ci == null) { /* score combo boxes */ addHostLocations(optionsPanel, ClusterBrowser.SERVICE_LABEL_WIDTH, ClusterBrowser.SERVICE_FIELD_WIDTH); } for (final String param : params) { if (isMetaAttr(param)) { final Widget wi = getWidget(param, null); wi.setEnabled(savedMAIdRef == null); } } if (!getService().isNew()) { getWidget(GUI_ID, null).setEnabled(false); } if (!getResourceAgent().isGroup() && !getResourceAgent().isClone()) { /* Operations */ addOperations(optionsPanel, ClusterBrowser.SERVICE_LABEL_WIDTH, ClusterBrowser.SERVICE_FIELD_WIDTH); /* add item listeners to the operations combos */ for (final String op : getResourceAgent().getOperationNames()) { for (final String param : getBrowser().getCRMOperationParams(op)) { addOperationListeners(op, param); } } } /* add item listeners to the host scores combos */ if (ci == null) { addHostLocationsListeners(); } else { ci.addHostLocationsListeners(); } /* apply button */ addApplyButton(buttonPanel); addRevertButton(buttonPanel); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { /* invoke later on purpose */ setApplyButtons(null, params); } }); mainPanel.add(optionsPanel); final JPanel newPanel = new JPanel(); newPanel.setBackground(ClusterBrowser.PANEL_BACKGROUND); newPanel.setLayout(new BoxLayout(newPanel, BoxLayout.Y_AXIS)); newPanel.add(buttonPanel); newPanel.add( getMoreOptionsPanel(ClusterBrowser.SERVICE_LABEL_WIDTH + ClusterBrowser.SERVICE_FIELD_WIDTH + 4)); newPanel.add(new JScrollPane(mainPanel)); /* if id textfield was changed and this id is not used, * enable apply button */ infoPanel = newPanel; infoPanelDone(); return infoPanel; }