List of usage examples for javax.swing BorderFactory createTitledBorder
public static TitledBorder createTitledBorder(Border border)
From source file:BorderDemo.java
public BorderDemo() { super("BorderDemo"); Border blackline, etched, raisedbevel, loweredbevel, empty; //A border that puts 10 extra pixels at the sides and //bottom of each pane. Border paneEdge = BorderFactory.createEmptyBorder(0, 10, 10, 10); blackline = BorderFactory.createLineBorder(Color.black); etched = BorderFactory.createEtchedBorder(); raisedbevel = BorderFactory.createRaisedBevelBorder(); loweredbevel = BorderFactory.createLoweredBevelBorder(); empty = BorderFactory.createEmptyBorder(); //First pane: simple borders JPanel simpleBorders = new JPanel(); simpleBorders.setBorder(paneEdge);/*from ww w. j av a 2 s . c o m*/ simpleBorders.setLayout(new BoxLayout(simpleBorders, BoxLayout.Y_AXIS)); addCompForBorder(blackline, "line border", simpleBorders); addCompForBorder(etched, "etched border", simpleBorders); addCompForBorder(raisedbevel, "raised bevel border", simpleBorders); addCompForBorder(loweredbevel, "lowered bevel border", simpleBorders); addCompForBorder(empty, "empty border", simpleBorders); //Second pane: matte borders JPanel matteBorders = new JPanel(); matteBorders.setBorder(paneEdge); matteBorders.setLayout(new BoxLayout(matteBorders, BoxLayout.Y_AXIS)); //XXX: We *should* size the component so that the //XXX: icons tile OK. Without that, the icons are //XXX: likely to be cut off and look bad. ImageIcon icon = new ImageIcon("images/left.gif"); //20x22 Border border = BorderFactory.createMatteBorder(-1, -1, -1, -1, icon); addCompForBorder(border, "matte border (-1,-1,-1,-1,icon)", matteBorders); border = BorderFactory.createMatteBorder(1, 5, 1, 1, Color.red); addCompForBorder(border, "matte border (1,5,1,1,Color.red)", matteBorders); border = BorderFactory.createMatteBorder(0, 20, 0, 0, icon); addCompForBorder(border, "matte border (0,20,0,0,icon)", matteBorders); //Third pane: titled borders JPanel titledBorders = new JPanel(); titledBorders.setBorder(paneEdge); titledBorders.setLayout(new BoxLayout(titledBorders, BoxLayout.Y_AXIS)); TitledBorder titled; titled = BorderFactory.createTitledBorder("title"); addCompForBorder(titled, "default titled border" + " (default just., default pos.)", titledBorders); titled = BorderFactory.createTitledBorder(blackline, "title"); addCompForTitledBorder(titled, "titled line border" + " (centered, default pos.)", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(etched, "title"); addCompForTitledBorder(titled, "titled etched border" + " (right just., default pos.)", TitledBorder.RIGHT, TitledBorder.DEFAULT_POSITION, titledBorders); titled = BorderFactory.createTitledBorder(loweredbevel, "title"); addCompForTitledBorder(titled, "titled lowered bevel border" + " (default just., above top)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.ABOVE_TOP, titledBorders); titled = BorderFactory.createTitledBorder(empty, "title"); addCompForTitledBorder(titled, "titled empty border" + " (default just., bottom)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.BOTTOM, titledBorders); //Fourth pane: compound borders JPanel compoundBorders = new JPanel(); compoundBorders.setBorder(paneEdge); compoundBorders.setLayout(new BoxLayout(compoundBorders, BoxLayout.Y_AXIS)); Border redline = BorderFactory.createLineBorder(Color.red); Border compound; compound = BorderFactory.createCompoundBorder(raisedbevel, loweredbevel); addCompForBorder(compound, "compound border (two bevels)", compoundBorders); compound = BorderFactory.createCompoundBorder(redline, compound); addCompForBorder(compound, "compound border (add a red outline)", compoundBorders); titled = BorderFactory.createTitledBorder(compound, "title", TitledBorder.CENTER, TitledBorder.BELOW_BOTTOM); addCompForBorder(titled, "titled compound border" + " (centered, below bottom)", compoundBorders); JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.addTab("Simple", null, simpleBorders, null); tabbedPane.addTab("Matte", null, matteBorders, null); tabbedPane.addTab("Titled", null, titledBorders, null); tabbedPane.addTab("Compound", null, compoundBorders, null); tabbedPane.setSelectedIndex(0); getContentPane().add(tabbedPane, BorderLayout.CENTER); }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a bordered 'sub-panel' with title to a container * /*from w ww . j av a2s . c o m*/ * @param container - parent container * @param tableSize - TableLayout table array * @param name - panel name * @param debug - turn on/off red debug borders * @return new JPanel */ public static JPanel addBorderedPanel(Container container, double tableSize[][], String name, boolean debug) { JPanel panel = new JPanel(); panel.setOpaque(false); TableLayout layout = new TableLayout(tableSize); panel.setLayout(layout); panel.setBorder(BorderFactory.createTitledBorder(name)); if (debug == true) panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), panel.getBorder())); return panel; }
From source file:com.xilinx.kintex7.DMABarChart.java
public ChartPanel getChart(String title) { ChartPanel chartpanel = new ChartPanel(chart); chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(title), BorderFactory.createRaisedBevelBorder())); return chartpanel; }
From source file:de.codesourcery.jasm16.ide.ui.views.ProjectConfigurationView.java
@Override protected JPanel getPanel() { final JPanel result = new JPanel(); result.setLayout(new GridBagLayout()); // project name int y = 0;//from w ww . ja va 2 s. c o m GridBagConstraints cnstrs = constraints(0, y, false, false, GridBagConstraints.NONE); result.add(new JLabel("Project name"), cnstrs); cnstrs = constraints(1, y++, true, false, GridBagConstraints.NONE); result.add(projectName, cnstrs); // build options panel final JPanel buildOptionsPanel = new JPanel(); buildOptionsPanel.setLayout(new GridBagLayout()); buildOptionsPanel.setBorder(BorderFactory.createTitledBorder("Build options")); cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); buildOptionsPanel.add(new JLabel("Compilation root"), cnstrs); cnstrs = constraints(1, 0, false, false, GridBagConstraints.NONE); compilationRootName.setEditable(false); compilationRootName.setColumns(25); buildOptionsPanel.add(compilationRootName, cnstrs); cnstrs = constraints(2, 0, true, false, GridBagConstraints.NONE); buildOptionsPanel.add(compilationRootButton, cnstrs); compilationRootButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser chooser; File baseDir = null; if (project != null) { baseDir = project.getConfiguration().getBaseDirectory(); } if (StringUtils.isNotBlank(compilationRootName.getText())) { File tmp = new File(compilationRootName.getText()).getParentFile(); if (tmp.exists() && tmp.isDirectory()) { baseDir = tmp; } } if (baseDir != null) { chooser = new JFileChooser(baseDir); } else { chooser = new JFileChooser(); } final int result = chooser.showOpenDialog(null); if (result == JFileChooser.APPROVE_OPTION && chooser.getSelectedFile().isFile()) { compilationRootName.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); // generate self-relocating code ? cnstrs = constraints(0, 1, false, false, GridBagConstraints.NONE); buildOptionsPanel.add(new JLabel("Generate self-relocating code?"), cnstrs); cnstrs = constraints(1, 1, true, true, GridBagConstraints.NONE); cnstrs.gridwidth = 2; buildOptionsPanel.add(generateSelfRelocatingCode, cnstrs); // inline short literals ? cnstrs = constraints(0, 2, false, false, GridBagConstraints.NONE); buildOptionsPanel.add(new JLabel("Inline short literals?"), cnstrs); cnstrs = constraints(1, 2, true, true, GridBagConstraints.NONE); cnstrs.gridwidth = 2; buildOptionsPanel.add(inlineShortLiterals, cnstrs); // add build options panel to parent cnstrs = constraints(0, y++, true, false, GridBagConstraints.BOTH); cnstrs.gridwidth = 2; result.add(buildOptionsPanel, cnstrs); // buttons final JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); buttonPanel.add(saveButton, cnstrs); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (hasValidInput()) { onSave(); } } }); cnstrs = constraints(1, 0, true, true, GridBagConstraints.NONE); buttonPanel.add(cancelButton, cnstrs); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onCancel(); } }); // button panel cnstrs = constraints(0, y++, true, true, GridBagConstraints.NONE); cnstrs.gridwidth = 2; result.add(buttonPanel, cnstrs); return result; }
From source file:dbseer.gui.panel.DBSeerLiveMonitorPanel.java
private void initialize() { JScrollPane tableScrollPane = new JScrollPane(monitorTable); tableScrollPane.setPreferredSize(new Dimension(300, 300)); JScrollPane transactionTypesScrollPane = new JScrollPane(); leftDockPanel = new JPanel(); leftDockPanel.setLayout(new MigLayout("fill")); transactionTypesPanel = new JPanel(); transactionTypesPanel.setLayout(new MigLayout("wrap 3")); rightPanel = new JPanel(); rightPanel.setLayout(new MigLayout("fill")); rightPanel.setPreferredSize(new Dimension(640, 480)); transactionTypesScrollPane.setViewportView(transactionTypesPanel); transactionTypesScrollPane.setBorder(BorderFactory.createTitledBorder("Transaction types")); transactionTypesScrollPane.setPreferredSize(new Dimension(360, 300)); throughputCollection = new TimeSeriesCollection(); throughputChartPanel = new ChartPanel(createThroughputChart(throughputCollection)); latencyCollection = new TimeSeriesCollection(); latencyChartPanel = new ChartPanel(createAverageLatencyChart(latencyCollection)); leftDockPanel.add(tableScrollPane, "wrap, grow"); leftDockPanel.add(transactionTypesScrollPane, "grow"); rightPanel.add(throughputChartPanel, "grow, wrap"); rightPanel.add(latencyChartPanel, "grow"); this.add(leftDockPanel, "dock west, growy"); this.add(rightPanel, "grow"); }
From source file:BoxAlignmentDemo.java
protected JPanel createLabelAndComponent(boolean doItRight) { JPanel pane = new JPanel(); JComponent component = new JPanel(); Dimension size = new Dimension(150, 100); component.setMaximumSize(size);// w ww.j a v a 2s . c o m component.setPreferredSize(size); component.setMinimumSize(size); TitledBorder border = new TitledBorder(new LineBorder(Color.black), "A JPanel", TitledBorder.CENTER, TitledBorder.BELOW_TOP); border.setTitleColor(Color.black); component.setBorder(border); JLabel label = new JLabel("This is a JLabel"); String title; if (doItRight) { title = "Matched"; label.setAlignmentX(CENTER_ALIGNMENT); } else { title = "Mismatched"; } pane.setBorder(BorderFactory.createTitledBorder(title)); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); pane.add(label); pane.add(component); return pane; }
From source file:MenuItemChooser.java
private void initGUI() { JPanel itemDetailsPanel = new JPanel(); itemDetailsPanel.setLayout(new GridLayout(4, 2)); itemDetailsPanel.setBackground(Color.WHITE); JLabel lbl = new JLabel("Item: "); itemDetailsPanel.add(lbl);/*from w ww . ja v a 2 s . c o m*/ itemName = new JLabel(""); itemDetailsPanel.add(itemName); lbl = new JLabel("Type: "); itemDetailsPanel.add(lbl); itemType = new JLabel(""); itemDetailsPanel.add(itemType); lbl = new JLabel("Price: $ "); itemDetailsPanel.add(lbl); price = new JLabel(""); itemDetailsPanel.add(price); lbl = new JLabel("Quantity: "); itemDetailsPanel.add(lbl); qty = new JTextField("0", 1); qty.addActionListener(this); qty.addFocusListener(this); itemDetailsPanel.add(qty); JPanel imgDescPanel = new JPanel(new BorderLayout()); imgDescPanel.setBackground(Color.WHITE); image = new JLabel(""); image.setHorizontalAlignment(SwingConstants.CENTER); image.setVerticalAlignment(SwingConstants.CENTER); imgDescPanel.add(image, BorderLayout.NORTH); desc = new JLabel("desc"); imgDescPanel.add(desc, BorderLayout.SOUTH); JPanel buttonPanel = new JPanel(); buttonPanel.setBackground(Color.WHITE); next = new JButton("Next"); next.addActionListener(this); buttonPanel.add(next); prev = new JButton("Previous"); prev.addActionListener(this); buttonPanel.add(prev); order = new JButton("Order"); order.addActionListener(this); buttonPanel.add(order); cancel = new JButton("Cancel / New"); cancel.addActionListener(this); buttonPanel.add(cancel); close = new JButton("Close"); close.addActionListener(this); close.setEnabled(false); buttonPanel.add(close); totalLbl = new JLabel(""); totalLbl.setFont(new Font("Serif", Font.BOLD, 14)); totalLbl.setForeground((Color.GREEN).darker()); buttonPanel.add(totalLbl); BorderLayout bl = new BorderLayout(); bl.setHgap(30); bl.setVgap(20); setLayout(bl); setBackground(Color.WHITE); add(itemDetailsPanel, BorderLayout.WEST); add(imgDescPanel, BorderLayout.EAST); add(buttonPanel, BorderLayout.SOUTH); TitledBorder title = BorderFactory.createTitledBorder("Choose Menu Items And Place Order"); setBorder(title); loadMenuItem(); }
From source file:marytts.tools.voiceimport.DatabaseImportMain.java
protected void setupGUI() { // A scroll pane containing one labelled checkbox per component, // and a "run selected components" button below. GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridC = new GridBagConstraints(); getContentPane().setLayout(gridBagLayout); JPanel checkboxPane = new JPanel(); checkboxPane.setLayout(new BoxLayout(checkboxPane, BoxLayout.Y_AXIS)); //checkboxPane.setPreferredSize(new Dimension(300, 300)); int compIndex = 0; for (int j = 0; j < groups2Comps.length; j++) { String[] nextGroup = groups2Comps[j]; JPanel groupPane = new JPanel(); groupPane.setLayout(new BoxLayout(groupPane, BoxLayout.Y_AXIS)); groupPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(nextGroup[0]), BorderFactory.createEmptyBorder(1, 1, 1, 1))); for (int i = 1; i < nextGroup.length; i++) { JButton configButton = new JButton(); Icon configIcon = new ImageIcon(DatabaseImportMain.class.getResource("configure.png"), "Configure"); configButton.setIcon(configIcon); configButton.setPreferredSize(new Dimension(configIcon.getIconWidth(), configIcon.getIconHeight())); configButton.addActionListener(new ConfigButtonActionListener(nextGroup[i])); configButton.setBorderPainted(false); //System.out.println("Adding checkbox for "+components[i].getClass().getName()); checkboxes[compIndex] = new JCheckBox(nextGroup[i]); checkboxes[compIndex].setFocusable(true); //checkboxes[i].setPreferredSize(new Dimension(200, 30)); JPanel line = new JPanel(); line.setLayout(new BorderLayout(5, 0)); line.add(configButton, BorderLayout.WEST); line.add(checkboxes[compIndex], BorderLayout.CENTER); groupPane.add(line);//from w ww .j a v a2 s. co m compIndex++; } checkboxPane.add(groupPane); } gridC.gridx = 0; gridC.gridy = 0; gridC.fill = GridBagConstraints.BOTH; JScrollPane scrollPane = new JScrollPane(checkboxPane); scrollPane.setPreferredSize(new Dimension(450, 300)); gridBagLayout.setConstraints(scrollPane, gridC); getContentPane().add(scrollPane); JButton helpButton = new JButton("Help"); helpButton.setMnemonic(KeyEvent.VK_H); helpButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { displayHelpGUI(); } }); JButton settingsButton = new JButton("Settings"); settingsButton.setMnemonic(KeyEvent.VK_S); settingsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { currentComponent = "Global properties"; displaySettingsGUI(); } }); runButton = new JButton("Run"); runButton.setMnemonic(KeyEvent.VK_R); runButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { runSelectedComponents(); } }); JButton quitAndSaveButton = new JButton("Quit"); quitAndSaveButton.setMnemonic(KeyEvent.VK_Q); quitAndSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); gridC.gridy = 1; JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); //buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS)); //runButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(runButton); //helpButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(helpButton); //settingsButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(settingsButton); //buttonPanel.add(Box.createHorizontalGlue()); //quitAndSaveButton.setAlignmentX(JButton.RIGHT_ALIGNMENT); buttonPanel.add(quitAndSaveButton); gridBagLayout.setConstraints(buttonPanel, gridC); getContentPane().add(buttonPanel); //getContentPane().setPreferredSize(new Dimension(300, 300)); // End program when closing window: addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); }
From source file:io.github.jeremgamer.editor.panels.components.ButtonPanel.java
public ButtonPanel(JFrame frame) { this.frame = frame; this.setSize(new Dimension(395, frame.getHeight() - 27 - 23)); this.setLocation(300, 0); this.setBorder(BorderFactory.createTitledBorder("Edition du bouton")); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); JLabel nameLabel = new JLabel("Nom : "); name.setPreferredSize(new Dimension(this.getWidth() - 285, 30)); name.setEditable(false);/*from w w w. j av a2 s .c om*/ JPanel namePanel = new JPanel(); namePanel.add(nameLabel); namePanel.add(name); JPanel textPanel = new JPanel(); JPanel nameAndTextPanel = new JPanel(); JLabel textLabel = new JLabel("Texte :"); CaretListener caretUpdateText = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); bs.set("text", text.getText()); preview.setText(text.getText()); preview2.setText(text.getText()); } }; text.addCaretListener(caretUpdateText); text.setPreferredSize(new Dimension(this.getWidth() - 283, 30)); textPanel.add(textLabel); textPanel.add(text); nameAndTextPanel.setLayout(new BoxLayout(nameAndTextPanel, BoxLayout.PAGE_AXIS)); nameAndTextPanel.add(namePanel); nameAndTextPanel.add(textPanel); JPanel policePanel = new JPanel(); JLabel policeLabel = new JLabel("Police : "); police.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) e.getSource(); fontStyle = (String) combo.getSelectedItem(); preview.setFont(new Font(fontStyle, Font.PLAIN, fontSize)); preview2.setFont(new Font(fontStyle, Font.PLAIN, fontSize)); bs.set("police", fontStyle); } }); police.setPreferredSize(new Dimension(105, 30)); GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fonts = e.getAllFonts(); for (Font f : fonts) { police.addItem(f.getName()); } police.setSelectedItem("Arial"); policePanel.add(policeLabel); policePanel.add(police); JPanel sizePanel = new JPanel(); size.setPreferredSize(new Dimension(60, 25)); JLabel sizeLabel = new JLabel("Taille : "); sizePanel.add(sizeLabel); sizePanel.add(size); JButton colorButton = new JButton("Couleur"); colorButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { colorFrame.setModal(false); JButton finish = new JButton("Terminer"); finish.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { colorFrame.dispose(); } }); colorFrame.setLayout(new BorderLayout()); colorFrame.add(color, BorderLayout.CENTER); colorFrame.add(finish, BorderLayout.SOUTH); colorFrame.pack(); colorFrame.setLocation(SwingUtilities.windowForComponent(imagedButton).getX() + 325, SwingUtilities.windowForComponent(imagedButton).getY() - colorFrame.getHeight() + 40); colorFrame.setVisible(true); } }); sizePanel.add(colorButton); size.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSpinner spinner = (JSpinner) e.getSource(); fontSize = (int) spinner.getValue(); preview.setFont(new Font(fontStyle, Font.PLAIN, fontSize)); preview2.setFont(new Font(fontStyle, Font.PLAIN, fontSize)); bs.set("size", fontSize); } }); JPanel policeAndSize = new JPanel(); policeAndSize.setLayout(new BoxLayout(policeAndSize, BoxLayout.PAGE_AXIS)); policeAndSize.add(policePanel); policeAndSize.add(sizePanel); JPanel top = new JPanel(); top.add(nameAndTextPanel); top.add(policeAndSize); top.setPreferredSize(new Dimension(395, 20)); this.add(top); JPanel images = new JPanel(); images.setBorder(BorderFactory.createTitledBorder("Images")); images.setLayout(new GridLayout(2, 3)); images.setPreferredSize(new Dimension(395, this.getHeight() - 320)); JPanel imaged = new JPanel(); imaged.setLayout(new BorderLayout()); imaged.setBorder(BorderFactory.createTitledBorder("Icne interne")); imagedButton.setSelected(true); imagedButton.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { if (ev.getStateChange() == ItemEvent.SELECTED) { bs.set("strings", true); preview.setBorderPainted(true); } else if (ev.getStateChange() == ItemEvent.DESELECTED) { bs.set("strings", false); preview.setBorderPainted(false); } } }); JButton browseInternal = new JButton("Parcourir"); browseInternal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { 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), "internal.png"); nameInternal.setText(new File(path).getName()); nameInternal.setPreferredSize(new Dimension(imgBasic.getWidth() - 10, 30)); preview.setIcon(new ImageIcon(path)); preview.repaint(); bs.set("imageInternal", new File(path).getName()); } } }); JPanel northImaged = new JPanel(); northImaged.setLayout(new BorderLayout()); northImaged.add(imagedButton, BorderLayout.NORTH); northImaged.add(browseInternal, BorderLayout.SOUTH); imaged.add(northImaged, BorderLayout.NORTH); imaged.add(nameInternal, BorderLayout.CENTER); JButton removeInternal = null; try { removeInternal = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeInternal.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/internal.png"); file.delete(); nameInternal.setText(""); bs.set("imageInternal", ""); preview.setIcon(null); } }); imaged.add(removeInternal, BorderLayout.SOUTH); images.add(imaged); imgBasic.setBorder(BorderFactory.createTitledBorder("Base")); JButton browseBasic = new JButton("Parcourir"); browseBasic.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { 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), "basic.png"); nameBasic.setText(new File(path).getName()); nameBasic.setPreferredSize(new Dimension(imgBasic.getWidth() - 10, 30)); previewPanel.remove(preview); previewPanel.remove(preview2); previewPanel.add(preview2); color.changePreview(preview2); bs.set("imageBasic", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgBasic.setLayout(new BorderLayout()); imgBasic.add(browseBasic, BorderLayout.NORTH); imgBasic.add(nameBasic, BorderLayout.CENTER); JButton removeBasic = null; try { removeBasic = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeBasic.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/basic.png"); file.delete(); nameBasic.setText(""); bs.set("imageBasic", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgBasic.add(removeBasic, BorderLayout.SOUTH); images.add(imgBasic); imgEntered.setBorder(BorderFactory.createTitledBorder("Survol")); JButton browseEntered = new JButton("Parcourir"); browseEntered.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { 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), "entered.png"); nameEntered.setText(new File(path).getName()); nameEntered.setPreferredSize(new Dimension(imgEntered.getWidth() - 10, 30)); bs.set("imageEntered", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgEntered.setLayout(new BorderLayout()); imgEntered.add(browseEntered, BorderLayout.NORTH); imgEntered.add(nameEntered, BorderLayout.CENTER); JButton removeEntered = null; try { removeEntered = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeEntered.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/entered.png"); file.delete(); nameEntered.setText(""); bs.set("imageEntered", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgEntered.add(removeEntered, BorderLayout.SOUTH); images.add(imgEntered); imgExited.setBorder(BorderFactory.createTitledBorder("Sortie")); JButton browseExited = new JButton("Parcourir"); browseExited.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { 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), "exited.png"); nameExited.setText(new File(path).getName()); nameExited.setPreferredSize(new Dimension(imgExited.getWidth() - 10, 30)); bs.set("imageExited", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgExited.setLayout(new BorderLayout()); imgExited.add(browseExited, BorderLayout.NORTH); imgExited.add(nameExited, BorderLayout.CENTER); JButton removeExited = null; try { removeExited = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeExited.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/exited.png"); file.delete(); nameExited.setText(""); bs.set("imageExited", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgExited.add(removeExited, BorderLayout.SOUTH); images.add(imgExited); imgPressed.setBorder(BorderFactory.createTitledBorder("Clic")); JButton browsePressed = new JButton("Parcourir"); browsePressed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { 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), "pressed.png"); namePressed.setText(new File(path).getName()); namePressed.setPreferredSize(new Dimension(imgPressed.getWidth() - 10, 30)); bs.set("imagePressed", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgPressed.setLayout(new BorderLayout()); imgPressed.add(browsePressed, BorderLayout.NORTH); imgPressed.add(namePressed, BorderLayout.CENTER); JButton removePressed = null; try { removePressed = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removePressed.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/pressed.png"); file.delete(); namePressed.setText(""); bs.set("imagePressed", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgPressed.add(removePressed, BorderLayout.SOUTH); images.add(imgPressed); imgReleased.setBorder(BorderFactory.createTitledBorder("Relachement")); JButton browseReleased = new JButton("Parcourir"); browseReleased.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { 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), "released.png"); nameReleased.setText(new File(path).getName()); nameReleased.setPreferredSize(new Dimension(imgReleased.getWidth() - 10, 30)); bs.set("imageReleased", new File(path).getName()); preview2.update(); previewPanel.repaint(); } } }); imgReleased.setLayout(new BorderLayout()); imgReleased.add(browseReleased, BorderLayout.NORTH); imgReleased.add(nameReleased, BorderLayout.CENTER); JButton removeReleased = null; try { removeReleased = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e1) { e1.printStackTrace(); } removeReleased.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File( "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/released.png"); file.delete(); nameReleased.setText(""); bs.set("imageReleased", ""); preview2.update(); previewPanel.repaint(); if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("") && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("") && bs.getString("imageReleased").equals("")) { previewPanel.remove(preview2); previewPanel.add(preview); } } }); imgReleased.add(removeReleased, BorderLayout.SOUTH); images.add(imgReleased); this.add(images); JPanel action = new JPanel(); action.setPreferredSize(new Dimension(395, -20)); JLabel labelAction = new JLabel("Action : "); action.add(labelAction); actionList.removeAllItems(); actionList.addItem("Aucune"); for (String s : Actions.getActions()) { actionList.addItem(s); } actionList.setPreferredSize(new Dimension(this.getWidth() - 100, 30)); actionList.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { @SuppressWarnings("unchecked") JComboBox<String> combo = (JComboBox<String>) event.getSource(); bs.set("action", combo.getSelectedItem()); } }); action.add(actionList); this.add(action); JScrollPane previewScroll = new JScrollPane(previewPanel); previewScroll.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); previewPanel.setBorder(BorderFactory.createTitledBorder("Aperu")); previewPanel.add(preview); previewScroll.setPreferredSize(new Dimension(395, 40)); previewScroll.setBorder(null); this.add(previewScroll); }
From source file:de.hsos.ecs.richwps.wpsmonitor.boundary.gui.controls.datasource.WpsDialog.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.//from w ww .j a v a 2 s.c o m */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { JPanel jPanel1 = new JPanel(); closeButton = new JButton(); addToMonitorButton = new JButton(); treeScrollPane = new JScrollPane(); wpsTree = new JTree(); JLabel jLabel1 = new JLabel(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle("List of WPS-Servers- and Processes"); setIconImage(new ImageIcon(getClass().getResource("/icons/database.png")).getImage()); setMinimumSize(null); setName("wpsDialog"); // NOI18N setResizable(false); jPanel1.setBorder(BorderFactory.createTitledBorder("")); closeButton.setIcon(new ImageIcon(getClass().getResource("/icons/apply.png"))); // NOI18N closeButton.setText("Close"); closeButton.setName("closeButton"); // NOI18N closeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { closeButtonActionPerformed(evt); } }); addToMonitorButton.setIcon(new ImageIcon(getClass().getResource("/icons/add.png"))); // NOI18N addToMonitorButton.setText("Add WPS with Processes"); addToMonitorButton.setName("addToMonitorButton"); // NOI18N addToMonitorButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { addToMonitorButtonActionPerformed(evt); } }); DefaultMutableTreeNode treeNode1 = new DefaultMutableTreeNode("root"); wpsTree.setModel(new DefaultTreeModel(treeNode1)); wpsTree.setName("wpsTree"); // NOI18N treeScrollPane.setViewportView(wpsTree); jLabel1.setText( "<html><body>Here is a list of all registered data-sources. You can pick up processes and WPS and add your choice to the monitor through the \"Add WPS with Processes\"-Button. If you select only a WPS, all processes of this WPS will also be added. The processes will be saved, but they have no Jobs or a testrequest.</body></html>"); GroupLayout jPanel1Layout = new GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addGroup(jPanel1Layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) .addComponent(addToMonitorButton) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(closeButton)) .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(treeScrollPane, GroupLayout.PREFERRED_SIZE, 630, GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap())); jPanel1Layout .setVerticalGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap() .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(treeScrollPane, GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(addToMonitorButton).addComponent(closeButton)) .addContainerGap())); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addComponent(jPanel1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); pack(); }