List of usage examples for javax.swing JPanel setBorder
@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.") public void setBorder(Border border)
From source file:com.adito.upgrade.GUIUpgrader.java
public GUIUpgrader() { super(new BorderLayout()); JPanel info = new JPanel(new BorderLayout(2, 2)); // info.setBackground(Color.white); // info.setForeground(Color.black); // info.setOpaque(true); info.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); JLabel l = new JLabel("<html><p>This utility upgrades configuration from " + "one version 0.1.16 installation to another " + "0.2.5+ installation. You may choose which resources you " + "wish to be copied. If resources with the same name already " + "exist they will be left as is."); l.setIcon(new ImageIcon(GUIUpgrader.class.getResource("upgrader-48x48.png"))); info.add(l, BorderLayout.CENTER); info.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH); mainPanel = new JPanel(new BorderLayout()); add(info, BorderLayout.NORTH); add(mainPanel, BorderLayout.CENTER); // Installations panel JPanel installations = new JPanel(new GridBagLayout()); installations.setBorder(BorderFactory.createTitledBorder("Installations")); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(2, 2, 2, 2); gbc.weightx = 2.0;/* w w w . ja va 2 s .c o m*/ UIUtil.jGridBagAdd(installations, new JLabel("Source"), gbc, GridBagConstraints.REMAINDER); gbc.weightx = 1.0; source = new JTextField(); source.getDocument().addDocumentListener(this); UIUtil.jGridBagAdd(installations, source, gbc, GridBagConstraints.RELATIVE); browseSource = new JButton("Browse"); browseSource.setMnemonic('b'); browseSource.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(source.getText()); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Select source installation directory (0.16.1)"); if (chooser.showOpenDialog(GUIUpgrader.this) == JFileChooser.APPROVE_OPTION) { source.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); gbc.weightx = 0.0; UIUtil.jGridBagAdd(installations, browseSource, gbc, GridBagConstraints.REMAINDER); gbc.weightx = 2.0; UIUtil.jGridBagAdd(installations, new JLabel("Target"), gbc, GridBagConstraints.REMAINDER); gbc.weightx = 1.0; target = new JTextField(System.getProperty("user.dir")); target.getDocument().addDocumentListener(this); UIUtil.jGridBagAdd(installations, target, gbc, GridBagConstraints.RELATIVE); browseTarget = new JButton("Browse"); browseTarget.setMnemonic('r'); browseTarget.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(target.getText()); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Select target installation directory (0.2.5+)"); if (chooser.showOpenDialog(GUIUpgrader.this) == JFileChooser.APPROVE_OPTION) { target.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); gbc.weightx = 0.0; UIUtil.jGridBagAdd(installations, browseTarget, gbc, GridBagConstraints.REMAINDER); mainPanel.add(installations, BorderLayout.NORTH); // Upgrade selection upgradeSelectionPanel = new JPanel(); upgradeSelectionPanel.setBorder(BorderFactory.createTitledBorder("Upgrades")); upgradeSelectionPanel.setLayout(new BoxLayout(upgradeSelectionPanel, BoxLayout.Y_AXIS)); mainPanel.add(upgradeSelectionPanel, BorderLayout.CENTER); }
From source file:com.floreantpos.ui.views.order.modifier.TicketItemModifierTableView.java
private JPanel createItemDescriptionPanel() { MenuItem menuItem = modifierSelectionModel.getMenuItem(); JPanel itemDescriptionPanel = new JPanel(new MigLayout("inset 0,center")); String description = menuItem.getDescription(); if (StringUtils.isEmpty(description) && menuItem.getImage() == null) { return itemDescriptionPanel; }/*w w w. ja v a2 s . com*/ itemDescriptionPanel.setBorder(BorderFactory.createTitledBorder("-")); JLabel lblDescription = new JLabel(); lblDescription.setText("<html><body>" + description + "</body></html>"); JLabel pictureLabel = new JLabel(menuItem.getImage()); itemDescriptionPanel.add(pictureLabel); itemDescriptionPanel.add(lblDescription); return itemDescriptionPanel; }
From source file:de.tbuchloh.kiskis.gui.dialogs.PropertyEditor.java
/** * Overridden!// www .j a va2 s. co m * * @see de.tbuchloh.kiskis.gui.dialogs.KisKisDialog#createMainPanel() */ @Override protected Component createMainPanel() { final JPanel panel = new JPanel(new BorderLayout(5, 15)); panel.setBorder(LnFHelper.createDefaultBorder()); panel.add(createNameBox(), BorderLayout.NORTH); panel.add(createTable()); return panel; }
From source file:de.tbuchloh.kiskis.gui.dialogs.PropertyEditor.java
private Component createTable() { final JPanel p = new SimpleInternalFrame(M.getString("table.label")); final JPanel inset = new JPanel(new BorderLayout()); inset.setBorder(LnFHelper.createDefaultBorder()); _properties = new OrderableListWidget(); _properties.addContentListener(this); _properties.addSpecialAction(_newAction); _properties.addSpecialAction(_editAction, true); _properties.addSpecialAction(_deleteAction); _properties.setCellRenderer(new PropertyListRenderer()); _properties.setData(_type.getProperties()); inset.add(_properties);//from w w w .j a va2 s . c o m p.add(inset); return p; }
From source file:net.pandoragames.far.ui.swing.RenameFilesPanel.java
private void init(SwingConfig config, ComponentRepository componentRepository) { this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.setBorder( BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); JLabel patternLabel = new JLabel(localizer.localize("label.find-pattern")); this.add(patternLabel); filenamePattern = new JTextField(); filenamePattern.setPreferredSize(/*from ww w . j av a 2 s.c o m*/ new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight())); filenamePattern .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight())); filenamePattern.setAlignmentX(Component.LEFT_ALIGNMENT); UndoHistory findUndoManager = new UndoHistory(); findUndoManager.registerUndoHistory(filenamePattern); findUndoManager.registerSnapshotHistory(filenamePattern); componentRepository.getReplaceCommand().addResetable(findUndoManager); filenamePattern.getDocument().addDocumentListener(new DocumentChangeListener() { public void documentUpdated(DocumentEvent e, String text) { dataModel.setPatternString(text); updateFileTable(); } }); componentRepository.getResetDispatcher().addToBeCleared(filenamePattern); this.add(filenamePattern); JCheckBox caseBox = new JCheckBox(localizer.localize("label.ignore-case")); caseBox.setSelected(true); caseBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { dataModel.setIgnoreCase((ItemEvent.SELECTED == event.getStateChange())); updateFileTable(); } }); this.add(caseBox); JCheckBox regexBox = new JCheckBox(localizer.localize("label.regular-expression")); regexBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { dataModel.setRegexPattern((ItemEvent.SELECTED == event.getStateChange())); updateFileTable(); } }); this.add(regexBox); JPanel extensionPanel = new JPanel(); extensionPanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-extension"))); extensionPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); extensionPanel.setAlignmentX(Component.LEFT_ALIGNMENT); extensionPanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 60)); extensionPanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 100)); ButtonGroup extensionGroup = new ButtonGroup(); JRadioButton protectButton = new JRadioButton(localizer.localize("label.protect-extension")); protectButton.setSelected(true); protectButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dataModel.setProtectExtension(true); updateFileTable(); } }); extensionGroup.add(protectButton); extensionPanel.add(protectButton); JRadioButton includeButton = new JRadioButton(localizer.localize("label.include-extension")); includeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dataModel.setExtensionOnly(false); dataModel.setProtectExtension(false); updateFileTable(); } }); extensionGroup.add(includeButton); extensionPanel.add(includeButton); JRadioButton onlyButton = new JRadioButton(localizer.localize("label.only-extension")); onlyButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dataModel.setExtensionOnly(true); updateFileTable(); } }); extensionGroup.add(onlyButton); extensionPanel.add(onlyButton); this.add(extensionPanel); this.add(Box.createVerticalGlue()); this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING))); // replace JLabel replaceLabel = new JLabel(localizer.localize("label.replacement-pattern")); this.add(replaceLabel); replacePattern = new JTextField(); replacePattern.setPreferredSize( new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight())); replacePattern .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight())); replacePattern.setAlignmentX(Component.LEFT_ALIGNMENT); UndoHistory undoManager = new UndoHistory(); undoManager.registerUndoHistory(replacePattern); undoManager.registerSnapshotHistory(replacePattern); componentRepository.getReplaceCommand().addResetable(undoManager); replacePattern.getDocument().addDocumentListener(new DocumentChangeListener() { public void documentUpdated(DocumentEvent e, String text) { dataModel.setReplacementString(text); updateFileTable(); } }); componentRepository.getResetDispatcher().addToBeCleared(replacePattern); this.add(replacePattern); // treat case JPanel modifyCasePanel = new JPanel(); modifyCasePanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-case"))); modifyCasePanel.setLayout(new BoxLayout(modifyCasePanel, BoxLayout.Y_AXIS)); modifyCasePanel.setAlignmentX(Component.LEFT_ALIGNMENT); modifyCasePanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 100)); modifyCasePanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 200)); ButtonGroup modifyCaseGroup = new ButtonGroup(); ActionListener radioButtonListener = new ActionListener() { public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); dataModel.setTreatCase(RenameForm.CASEHANDLING.valueOf(cmd)); updateFileTable(); } }; JRadioButton lowerButton = new JRadioButton(localizer.localize("label.to-lower-case")); lowerButton.setActionCommand(RenameForm.CASEHANDLING.LOWER.name()); lowerButton.addActionListener(radioButtonListener); modifyCaseGroup.add(lowerButton); modifyCasePanel.add(lowerButton); JRadioButton upperButton = new JRadioButton(localizer.localize("label.to-upper-case")); upperButton.setActionCommand(RenameForm.CASEHANDLING.UPPER.name()); upperButton.addActionListener(radioButtonListener); modifyCaseGroup.add(upperButton); modifyCasePanel.add(upperButton); JRadioButton keepButton = new JRadioButton(localizer.localize("label.preserve-case")); keepButton.setActionCommand(RenameForm.CASEHANDLING.PRESERVE.name()); keepButton.setSelected(true); keepButton.addActionListener(radioButtonListener); modifyCaseGroup.add(keepButton); modifyCasePanel.add(keepButton); this.add(modifyCasePanel); // prevent case conflict JCheckBox caseConflictBox = new JCheckBox(localizer.localize("label.prevent-case-conflict")); caseConflictBox.setAlignmentX(Component.LEFT_ALIGNMENT); caseConflictBox.setSelected(true); caseConflictBox.setEnabled(!SwingConfig.isWindows()); // disabled on windows caseConflictBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { dataModel.setPreventCaseConflict((ItemEvent.SELECTED == event.getStateChange())); updateFileTable(); } }); this.add(caseConflictBox); this.add(Box.createVerticalGlue()); }
From source file:JSplash.java
private void init() { JPanel pnlImage = new JPanel(); ImageIcon image = new ImageIcon(getClass().getResource("img/logo.jpg")); JLabel lblBack = new JLabel(image); Border raisedbevel = BorderFactory.createRaisedBevelBorder(); Border loweredbevel = BorderFactory.createLoweredBevelBorder(); lblBack.setBounds(0, 0, image.getIconWidth(), image.getIconHeight()); getLayeredPane().add(lblBack, new Integer(Integer.MIN_VALUE)); pnlImage.setLayout(null);/*from www.j av a 2 s .c o m*/ pnlImage.setOpaque(false); pnlImage.setBorder(BorderFactory.createCompoundBorder(raisedbevel, loweredbevel)); pnlImage.add(this.lblVersion); this.lblVersion.setForeground(Color.white); this.lblVersion.setFont(new Font("Dialog", Font.PLAIN, 12)); this.lblVersion.setBounds(15, 69, 120, 20); setContentPane(pnlImage); setSize(image.getIconWidth(), image.getIconHeight()); }
From source file:io.github.jeremgamer.editor.panels.IconFrame.java
public IconFrame(JFrame parent) { this.setModal(true); this.setResizable(false); ArrayList<BufferedImage> icons = new ArrayList<BufferedImage>(); try {//from w w w . j a va 2s . c o m icons.add(ImageIO.read(ImageGetter.class.getResource("icon16.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon32.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon64.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon128.png"))); } catch (IOException e1) { e1.printStackTrace(); } this.setIconImages((List<? extends Image>) icons); this.setTitle("Icnes"); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.LINE_AXIS)); content.setBorder(BorderFactory.createTitledBorder("")); try { remove128.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); remove64.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); remove32.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); remove16.setIcon(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png")))); } catch (IOException e) { e.printStackTrace(); } browse128.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), "128.png"); try { x128.repaint(); x128.getGraphics().drawImage(ImageIO.read(new File(path)), 0 + 10, 0 + 20, 128, 128, null); } catch (IOException e) { e.printStackTrace(); } } } }); remove128.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File("projects/" + Editor.getProjectName() + "/128.png"); file.delete(); x128.repaint(); } }); browse64.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), "64.png"); try { x64.repaint(); x64.getGraphics().drawImage(ImageIO.read(new File(path)), 32 + 10, 32 + 20, 64, 64, null); } catch (IOException e) { e.printStackTrace(); } } } }); remove64.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File("projects/" + Editor.getProjectName() + "/64.png"); file.delete(); x64.repaint(); } }); browse32.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), "32.png"); try { x32.repaint(); x32.getGraphics().drawImage(ImageIO.read(new File(path)), 48 + 10, 48 + 20, 32, 32, null); } catch (IOException e) { e.printStackTrace(); } } } }); remove32.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File("projects/" + Editor.getProjectName() + "/32.png"); file.delete(); x32.repaint(); } }); browse16.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), "16.png"); try { x16.repaint(); x16.getGraphics().drawImage(ImageIO.read(new File(path)), 56 + 10, 56 + 20, 16, 16, null); } catch (IOException e) { e.printStackTrace(); } } } }); remove16.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { File file = new File("projects/" + Editor.getProjectName() + "/16.png"); file.delete(); x16.repaint(); } }); content.add(x128); content.add(x64); content.add(x32); content.add(x16); this.setContentPane(content); this.pack(); this.setLocationRelativeTo(parent); this.setVisible(true); }
From source file:com.intuit.tank.tools.debugger.FindReplaceDialog.java
/** * Constructs a new find dialog according to the specified type of dialog requested. The dialog can be either a FIND * dialog, either a REPLACE dialog. In both cases, components displayed remain the sames, but the ones specific to * replace feature are grayed out./*from w w w. jav a2 s . c o m*/ * * @param parent * The window holder * @param type * The type of the dialog: FindReplace.FIND or FindReplace.REPLACE * @param modal * Displays dialog as a modal window if true */ public FindReplaceDialog(AgentDebuggerFrame parent, DialogType type) { super(parent, type == DialogType.REPLACE ? "Replace" : "Find", true); this.parent = parent; cbSearch = new JComboBox(); cbSearch.setEditable(true); cbReplace = new JComboBox(); cbReplace.setEditable(true); KeyHandler handler = new KeyHandler(); tfSearchEditor = (JTextField) cbSearch.getEditor().getEditorComponent(); tfSearchEditor.addKeyListener(handler); tfReplaceEditor = (JTextField) cbReplace.getEditor().getEditorComponent(); tfReplaceEditor.addKeyListener(handler); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); getContentPane().setLayout(gridbag); ((JPanel) getContentPane()).setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); int gridX = 0; int gridY = 0; JLabel findLabel = new JLabel("Find"); buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0); constraints.anchor = GridBagConstraints.WEST; gridbag.setConstraints(findLabel, constraints); getContentPane().add(findLabel); gridX++; buildConstraints(constraints, gridX, gridY, 1, 1, 100, 0); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(cbSearch, constraints); getContentPane().add(cbSearch); gridX++; btnFind = new JButton("Find"); btnFind.setToolTipText("Find text in scripts"); btnFind.setMnemonic('F'); btnFind.addActionListener(this); buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0); constraints.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(btnFind, constraints); getContentPane().add(btnFind); getRootPane().setDefaultButton(btnFind); gridX++; btnCancel = new JButton("Cancel"); btnCancel.setMnemonic('C'); btnCancel.addActionListener(this); buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0); constraints.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(btnCancel, constraints); getContentPane().add(btnCancel); gridY++; gridX = 0; if (type == DialogType.REPLACE) { JLabel replaceLabel = new JLabel("Replace"); buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0); constraints.anchor = GridBagConstraints.WEST; gridbag.setConstraints(replaceLabel, constraints); getContentPane().add(replaceLabel); gridX++; buildConstraints(constraints, gridX, gridY, 1, 1, 100, 0); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(cbReplace, constraints); getContentPane().add(cbReplace); gridX++; btnReplace = new JButton("Replace"); btnReplace.setToolTipText("REplace in script"); btnReplace.setMnemonic('R'); btnReplace.addActionListener(this); buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0); constraints.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(btnReplace, constraints); getContentPane().add(btnReplace); gridX++; btnReplaceAll = new JButton("Replace All"); btnReplaceAll.addActionListener(this); buildConstraints(constraints, gridX, gridY, 1, 1, 0, 0); constraints.anchor = GridBagConstraints.CENTER; gridbag.setConstraints(btnReplaceAll, constraints); getContentPane().add(btnReplaceAll); btnReplace.addKeyListener(handler); btnReplaceAll.addKeyListener(handler); gridY++; gridX = 0; } TitledBorder border = new TitledBorder("Options"); JPanel panel = new JPanel(new GridLayout(1, 4)); panel.setBorder(border); checkboxWrap = new JCheckBox("Wrap Search"); panel.add(checkboxWrap); checkboxMatchCase = new JCheckBox("Case sensitive"); panel.add(checkboxMatchCase); checkboxRegexp = new JCheckBox("Regular expressions"); panel.add(checkboxRegexp); buildConstraints(constraints, gridX, gridY, 4, 1, 100, 100); constraints.anchor = GridBagConstraints.WEST; gridbag.setConstraints(panel, constraints); getContentPane().add(panel); FontMetrics fm = getFontMetrics(getFont()); cbSearch.setPreferredSize(new Dimension(18 * fm.charWidth('m'), (int) cbSearch.getPreferredSize().height)); cbReplace .setPreferredSize(new Dimension(18 * fm.charWidth('m'), (int) cbReplace.getPreferredSize().height)); pack(); // setResizable(false); WindowUtil.centerOnParent(this); // patch by MJB 8/1/2002 btnFind.addKeyListener(handler); btnCancel.addKeyListener(handler); checkboxMatchCase.addKeyListener(handler); checkboxRegexp.addKeyListener(handler); }
From source file:dk.dma.epd.common.prototype.gui.notification.ChatServicePanel.java
/** * Updates the chat message panel in the Swing event thread *//*from w w w. java2 s .c o m*/ public void updateChatMessagePanel() { // Ensure that we operate in the Swing event thread if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { updateChatMessagePanel(); } }); return; } // Set the title header titleHeader.setText(chatData != null ? NameUtils.getName(chatData.getId(), NameFormat.MEDIUM) : " "); titleHeader.setVisible(chatData != null); // Only enable send-function when there is chat data, and hence a target sendBtn.setEnabled(chatData != null); messageText.setEditable(chatData != null); // Remove all components from the messages panel messagesPanel.removeAll(); Insets insets = new Insets(0, 2, 2, 2); Insets insets2 = new Insets(6, 2, 0, 2); if (chatData != null && chatData.getMessageCount() > 0) { // First, add a filler component int y = 0; messagesPanel.add(new JLabel(""), new GridBagConstraints(0, y++, 1, 1, 0.0, 1.0, NORTH, VERTICAL, insets, 0, 0)); // Add the messages long lastMessageTime = 0; for (EPDChatMessage message : chatData.getMessages()) { // Check if we need to add a time label if (message.getSendDate().getTime() - lastMessageTime > PRINT_DATE_INTERVAL) { JLabel dateLabel = new JLabel( String.format(message.isOwnMessage() ? "Sent to %s" : "Received %s", Formatter.formatShortDateTimeNoTz(new Date(message.getSendDate().getTime())))); dateLabel.setFont(dateLabel.getFont().deriveFont(9.0f).deriveFont(Font.PLAIN)); dateLabel.setHorizontalAlignment(SwingConstants.CENTER); dateLabel.setForeground(Color.LIGHT_GRAY); messagesPanel.add(dateLabel, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets2, 0, 0)); } // Add a chat message field JPanel msg = new JPanel(); msg.setBorder(new ChatMessageBorder(message)); JLabel msgLabel = new ChatMessageLabel(message.getMsg(), message.isOwnMessage()); msg.add(msgLabel); messagesPanel.add(msg, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, NORTH, HORIZONTAL, insets, 0, 0)); lastMessageTime = message.getSendDate().getTime(); } // Scroll to the bottom validate(); scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getMaximum()); messagesPanel.repaint(); } else if (chatData == null && noDataComponent != null) { // The noDataComponent may e.g. be a message messagesPanel.add(noDataComponent, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0)); } }
From source file:com.google.code.facebook.graph.sna.applet.FacebookGraphApplet.java
/** * create an instance of a simple graph with controls to * demo the zoom features.//from w ww .ja va 2s . co m * */ @Override public void init() { super.init(); // create a simple graph for the demo fetchUserGraph(); final Collection<? extends Entity<FieldEnum, ConnectionEnum>> vertices = graph.getVertices(); // a Map for the labels Map<Entity<FieldEnum, ConnectionEnum>, String> map = new HashMap<Entity<FieldEnum, ConnectionEnum>, String>(); Iterator<? extends Entity<FieldEnum, ConnectionEnum>> iterator = vertices.iterator(); while (iterator.hasNext()) { Entity<FieldEnum, ConnectionEnum> entity = iterator.next(); map.put(entity, entity.getLabel()); } FRLayout<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>> layout = new FRLayout<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>( (Graph<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>) graph); layout.setMaxIterations(100); vv = new VisualizationViewer<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>(layout, new Dimension(2000, 2000)); Transformer<Entity<FieldEnum, ConnectionEnum>, Paint> vpf = new PickableVertexPaintTransformer<Entity<FieldEnum, ConnectionEnum>>( vv.getPickedVertexState(), Color.white, Color.yellow); vv.getRenderContext().setVertexFillPaintTransformer(vpf); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<EdgeAdapter<ConnectionEnum>>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.setBackground(Color.white); // a Map for the Icons final Map<Entity<FieldEnum, ConnectionEnum>, Icon> iconMap = new HashMap<Entity<FieldEnum, ConnectionEnum>, Icon>(); new Thread(new Runnable() { public void run() { Iterator<? extends Entity<FieldEnum, ConnectionEnum>> iterator = vertices.iterator(); while (iterator.hasNext()) { try { Entity<FieldEnum, ConnectionEnum> entity = iterator.next(); // Icon icon = // new LayeredIcon(new ImageIcon("http://facebookgraph.appspot.com/proxy?url=" + entity.getPicture(PictureType.SQUARE), "Profile Picture").getImage()); // iconMap.put(entity, icon); Image image = getImageFromEntity(entity); if (image != null && image.getWidth(null) > 0 && image.getHeight(null) > 0) { Icon icon = new LayeredIcon(image); iconMap.put(entity, icon); if ((iconMap.size() % 5) == 0) { vv.repaint(); } } } catch (Exception ex) { ex.printStackTrace(); } } vv.repaint(); } }).start(); final Transformer<Entity<FieldEnum, ConnectionEnum>, String> vertexStringerImpl = new VertexStringerImpl<Entity<FieldEnum, ConnectionEnum>>( map); Transformer<EdgeAdapter<ConnectionEnum>, String> edgeStringerImpl = new Transformer<EdgeAdapter<ConnectionEnum>, String>() { public String transform(EdgeAdapter<ConnectionEnum> edge) { return edge.toString(); } }; vv.getRenderContext().setEdgeLabelTransformer(edgeStringerImpl); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); // features on and off. For a real application, use VertexIconAndShapeFunction instead. final VertexIconShapeTransformer<Entity<FieldEnum, ConnectionEnum>> vertexImageShapeFunction = new VertexIconShapeTransformer<Entity<FieldEnum, ConnectionEnum>>( new EllipseVertexShapeTransformer<Entity<FieldEnum, ConnectionEnum>>()); final DefaultVertexIconTransformer<Entity<FieldEnum, ConnectionEnum>> vertexIconFunction = new DefaultVertexIconTransformer<Entity<FieldEnum, ConnectionEnum>>(); vertexImageShapeFunction.setIconMap(iconMap); vertexIconFunction.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction); vv.getRenderContext().setVertexIconTransformer(vertexIconFunction); // Get the pickedState and add a listener that will decorate the // Vertex images with a checkmark icon when they are picked PickedState<Entity<FieldEnum, ConnectionEnum>> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener(vertexIconFunction)); // add a listener for ToolTips vv.setVertexToolTipTransformer(new Transformer<Entity<FieldEnum, ConnectionEnum>, String>() { @Override public String transform(Entity<FieldEnum, ConnectionEnum> entity) { return entity.getDescription(); } }); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JComboBox modeBox = graphMouse.getModeComboBox(); JPanel modePanel = new JPanel(); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); controls.add(modePanel); content.add(controls, BorderLayout.SOUTH); this.viewSupport = new MagnifyImageLensSupport<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>( vv); // new ViewLensSupport<Number,Number>(vv, new HyperbolicShapeTransformer(vv, // vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), // new ModalLensGraphMouse()); this.modelSupport = new LayoutLensSupport<Entity<FieldEnum, ConnectionEnum>, EdgeAdapter<ConnectionEnum>>( vv); graphMouse.addItemListener(modelSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(viewSupport.getGraphMouse().getModeListener()); ButtonGroup radio = new ButtonGroup(); JRadioButton none = new JRadioButton("None"); none.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (viewSupport != null) { viewSupport.deactivate(); } if (modelSupport != null) { modelSupport.deactivate(); } } }); none.setSelected(true); JRadioButton hyperView = new JRadioButton("View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JRadioButton hyperModel = new JRadioButton("Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { modelSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); radio.add(none); radio.add(hyperView); radio.add(hyperModel); JMenuBar menubar = new JMenuBar(); JMenu modeMenu = graphMouse.getModeMenu(); menubar.add(modeMenu); JPanel lensPanel = new JPanel(new GridLayout(2, 0)); lensPanel.setBorder(BorderFactory.createTitledBorder("Lens")); lensPanel.add(none); lensPanel.add(hyperView); lensPanel.add(hyperModel); controls.add(lensPanel); }