List of usage examples for javax.swing JLabel setBackground
@BeanProperty(preferred = true, visualUpdate = true, description = "The background color of the component.") public void setBackground(Color bg)
From source file:org.openmicroscopy.shoola.agents.metadata.util.FilesetInfoDialog.java
/** * Sets the data to display// w ww . j a v a2s . co m * * @param set * The fileset which paths should be shown * @param importType * The import type */ public void setData(Set<FilesetData> set, ImportType importType) { if (set == null) return; JPanel content = new JPanel(); content.setLayout(new GridBagLayout()); content.setBackground(UIUtilities.BACKGROUND_COLOR); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHEAST; if (CollectionUtils.isEmpty(set)) { JLabel l = new JLabel("No information available."); l.setBackground(UIUtilities.BACKGROUND_COLOR); content.add(l, c); } else { int size = 0; FilesetData fsd = set.iterator().next(); if (Fileset.class.isAssignableFrom(fsd.asIObject().getClass())) { size = ((Fileset) fsd.asIObject()).sizeOfUsedFiles(); } String txt = size <= 1 ? "Image file" : "Image files"; JLabel l = new JLabel(size + " " + txt); l.setBackground(UIUtilities.BACKGROUND_COLOR); content.add(l, c); c.gridy++; JSeparator sep = new JSeparator(JSeparator.HORIZONTAL); sep.setBackground(UIUtilities.BACKGROUND_COLOR); content.add(sep, c); c.gridy++; String header = (importType == ImportType.HARDLINK || importType == ImportType.SOFTLINK) ? "Imported with <b>--transfer=" + importType.getSymbol() + "</b> from:" : "Imported from:"; ExpandableTextPane t1 = new ExpandableTextPane(); t1.setBackground(UIUtilities.BACKGROUND_COLOR); t1.setText(header + "<br/>" + getOriginPaths(set)); content.add(t1, c); c.gridy++; JSeparator sep2 = new JSeparator(JSeparator.HORIZONTAL); sep2.setBackground(UIUtilities.BACKGROUND_COLOR); content.add(sep2, c); c.gridy++; ExpandableTextPane t2 = new ExpandableTextPane(); t2.setBackground(UIUtilities.BACKGROUND_COLOR); t2.setText("Path on server:<br/>" + getServerPaths(set)); content.add(t2, c); } setCanvas(new JScrollPane(content)); }
From source file:org.pentaho.ui.xul.swing.tags.SwingTree.java
private TableCellRenderer getCellRenderer(final SwingTreeCol col) { return new DefaultTableCellRenderer() { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { ColumnType colType = col.getColumnType(); if (colType == ColumnType.DYNAMIC) { colType = ColumnType.valueOf(extractDynamicColType(elements.toArray()[row], column)); }// ww w . jav a2 s .co m final XulTreeCell cell = getRootChildren().getItem(row).getRow().getCell(column); switch (colType) { case CHECKBOX: JCheckBox checkbox = new JCheckBox(); if (value instanceof String) { checkbox.setSelected(((String) value).equalsIgnoreCase("true")); //$NON-NLS-1$ } else if (value instanceof Boolean) { checkbox.setSelected((Boolean) value); } else if (value == null) { checkbox.setSelected(false); } if (isSelected) { checkbox.setBackground(Color.LIGHT_GRAY); } checkbox.setEnabled(!cell.isDisabled()); return checkbox; case COMBOBOX: case EDITABLECOMBOBOX: Vector data; final JComboBox comboBox = new JComboBox(); if (cell == null) { } else { data = (cell.getValue() != null) ? (Vector) cell.getValue() : new Vector(); if (data == null) { logger.debug("SwingTreeCell combobox data is null, passed in value: " + value); //$NON-NLS-1$ if (value instanceof Vector) { data = (Vector) value; } } if (data != null) { comboBox.setModel(new DefaultComboBoxModel(data)); try { comboBox.setSelectedIndex(cell.getSelectedIndex()); } catch (Exception e) { logger.error("error setting selected index on the combobox editor"); //$NON-NLS-1$ } } } if (colType == ColumnType.EDITABLECOMBOBOX) { comboBox.setEditable(true); ((JTextComponent) comboBox.getEditor().getEditorComponent()).setText(cell.getLabel()); } if (isSelected) { comboBox.setBackground(Color.LIGHT_GRAY); } comboBox.setEnabled(!cell.isDisabled()); return comboBox; case CUSTOM: return new CustomCellEditorWrapper(cell, customEditors.get(col.getType())); default: JLabel label = new JLabel((String) value); if (isSelected) { label.setOpaque(true); label.setBackground(Color.LIGHT_GRAY); } return label; } } }; }
From source file:org.rdv.ui.ExportDialog.java
private void initComponents(List<String> channels, List<String> fileFormats) { channelModel = new DefaultListModel(); for (int i = 0; i < channels.size(); i++) { String channelName = (String) channels.get(i); Channel channel = RBNBController.getInstance().getChannel(channelName); String mime = channel.getMetadata("mime"); if (mime.equals("application/octet-stream")) { channelModel.addElement(new ExportChannel(channelName)); }/*w ww .j a va2 s .c om*/ } JPanel container = new JPanel(); setContentPane(container); InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = container.getActionMap(); container.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weighty = 0; c.gridwidth = 1; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; JLabel headerLabel = new JLabel("Select the time range and data channels to export."); headerLabel.setBackground(Color.white); headerLabel.setOpaque(true); headerLabel.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray), BorderFactory.createEmptyBorder(10, 10, 10, 10))); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 0, 0, 0); container.add(headerLabel, c); JPanel timeButtonPanel = new JPanel(); timeButtonPanel.setLayout(new BorderLayout()); MouseListener hoverMouseListener = new MouseAdapter() { public void mouseEntered(MouseEvent e) { e.getComponent().setForeground(Color.red); } public void mouseExited(MouseEvent e) { e.getComponent().setForeground(Color.blue); } }; startTimeButton = new JButton(); startTimeButton.setBorder(null); startTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); startTimeButton.setForeground(Color.blue); startTimeButton.addMouseListener(hoverMouseListener); startTimeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { double startTime = DateTimeDialog.showDialog(ExportDialog.this, timeSlider.getStart(), timeSlider.getMinimum(), timeSlider.getEnd()); if (startTime >= 0) { timeSlider.setStart(startTime); } } }); timeButtonPanel.add(startTimeButton, BorderLayout.WEST); durationLabel = new JLabel(); durationLabel.setHorizontalAlignment(JLabel.CENTER); timeButtonPanel.add(durationLabel, BorderLayout.CENTER); endTimeButton = new JButton(); endTimeButton.setBorder(null); endTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); endTimeButton.setForeground(Color.blue); endTimeButton.addMouseListener(hoverMouseListener); endTimeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { double endTime = DateTimeDialog.showDialog(ExportDialog.this, timeSlider.getEnd(), timeSlider.getStart(), timeSlider.getMaximum()); if (endTime >= 0) { timeSlider.setEnd(endTime); } } }); timeButtonPanel.add(endTimeButton, BorderLayout.EAST); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(10, 10, 10, 10); container.add(timeButtonPanel, c); timeSlider = new TimeSlider(); timeSlider.setValueChangeable(false); timeSlider.setValueVisible(false); timeSlider.addTimeAdjustmentListener(new TimeAdjustmentListener() { public void timeChanged(TimeEvent event) { } public void rangeChanged(TimeEvent event) { updateTimeRangeLabel(); } public void boundsChanged(TimeEvent event) { } }); updateTimeRangeLabel(); updateTimeBounds(); List<EventMarker> markers = RBNBController.getInstance().getMarkerManager().getMarkers(); for (EventMarker marker : markers) { timeSlider.addMarker(marker); } c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(timeSlider, c); JLabel numericHeaderLabel = new JLabel("Data Channels:"); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 3; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(numericHeaderLabel, c); numericChannelList = new JList(channelModel); numericChannelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); numericChannelList.setCellRenderer(new CheckListRenderer()); numericChannelList.setVisibleRowCount(10); numericChannelList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { int index = numericChannelList.locationToIndex(e.getPoint()); ExportChannel item = (ExportChannel) numericChannelList.getModel().getElementAt(index); item.setSelected(!item.isSelected()); Rectangle rect = numericChannelList.getCellBounds(index, index); numericChannelList.repaint(rect); checkSelectedChannels(); updateTimeBounds(); } }); JScrollPane scrollPane = new JScrollPane(numericChannelList); c.fill = GridBagConstraints.BOTH; c.weightx = 0; c.weighty = 1; c.gridx = 0; c.gridy = 4; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(scrollPane, c); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.weighty = 0; c.gridx = 0; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 10, 10, 5); container.add(new JLabel("Data file: "), c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 1; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; dataFileTextField = new JTextField(20); c.insets = new java.awt.Insets(0, 0, 10, 5); container.add(dataFileTextField, c); dataFileTextField .setText(UIUtilities.getCurrentDirectory().getAbsolutePath() + File.separator + "data.dat"); dataFileButton = new JButton("Browse"); dataFileButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { File selectedFile = new File(dataFileTextField.getText()); selectedFile = UIUtilities.getFile("OK", "Select export file", selectedFile); if (selectedFile != null) { dataFileTextField.setText(selectedFile.getAbsolutePath()); } } }); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.gridx = 2; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 0, 10, 10); container.add(dataFileButton, c); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.gridx = 0; c.gridy = 6; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 10, 10, 5); container.add(new JLabel("File format: "), c); fileFormatComboBox = new JComboBox(fileFormats.toArray()); fileFormatComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { fileFormatUpdated(); } }); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 1; c.gridy = 6; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 0, 10, 10); container.add(fileFormatComboBox, c); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); Action exportAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = -5356258138620428023L; public void actionPerformed(ActionEvent e) { ok(); } }; exportAction.putValue(Action.NAME, "Export"); inputMap.put(KeyStroke.getKeyStroke("ENTER"), "export"); actionMap.put("export", exportAction); exportButton = new JButton(exportAction); panel.add(exportButton); Action cancelAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = -5868609501314154642L; public void actionPerformed(ActionEvent e) { cancel(); } }; cancelAction.putValue(Action.NAME, "Cancel"); inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel"); actionMap.put("cancel", cancelAction); cancelButton = new JButton(cancelAction); panel.add(cancelButton); c.fill = GridBagConstraints.NONE; c.weightx = 0.5; c.gridx = 0; c.gridy = 7; c.gridwidth = GridBagConstraints.REMAINDER; ; c.anchor = GridBagConstraints.LINE_END; c.insets = new java.awt.Insets(0, 0, 10, 5); container.add(panel, c); pack(); if (getWidth() < 600) { setSize(600, getHeight()); } dataFileTextField.requestFocusInWindow(); setLocationByPlatform(true); }
From source file:org.rdv.ui.ExportVideoDialog.java
private void initComponents() { JPanel container = new JPanel(); setContentPane(container);/*from ww w . j a v a 2 s .c o m*/ InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = container.getActionMap(); container.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weighty = 0; c.gridwidth = 1; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; JLabel headerLabel = new JLabel("Select the time range and video channels to export."); headerLabel.setBackground(Color.white); headerLabel.setOpaque(true); headerLabel.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray), BorderFactory.createEmptyBorder(10, 10, 10, 10))); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 0, 0, 0); container.add(headerLabel, c); JPanel timeButtonPanel = new JPanel(); timeButtonPanel.setLayout(new BorderLayout()); MouseListener hoverMouseListener = new MouseAdapter() { public void mouseEntered(MouseEvent e) { e.getComponent().setForeground(Color.red); } public void mouseExited(MouseEvent e) { e.getComponent().setForeground(Color.blue); } }; startTimeButton = new JButton(); startTimeButton.setBorder(null); startTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); startTimeButton.setForeground(Color.blue); startTimeButton.addMouseListener(hoverMouseListener); startTimeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { double startTime = DateTimeDialog.showDialog(ExportVideoDialog.this, timeSlider.getStart(), timeSlider.getMinimum(), timeSlider.getEnd()); if (startTime >= 0) { timeSlider.setStart(startTime); } } }); timeButtonPanel.add(startTimeButton, BorderLayout.WEST); durationLabel = new JLabel(); durationLabel.setHorizontalAlignment(JLabel.CENTER); timeButtonPanel.add(durationLabel, BorderLayout.CENTER); endTimeButton = new JButton(); endTimeButton.setBorder(null); endTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); endTimeButton.setForeground(Color.blue); endTimeButton.addMouseListener(hoverMouseListener); endTimeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { double endTime = DateTimeDialog.showDialog(ExportVideoDialog.this, timeSlider.getEnd(), timeSlider.getStart(), timeSlider.getMaximum()); if (endTime >= 0) { timeSlider.setEnd(endTime); } } }); timeButtonPanel.add(endTimeButton, BorderLayout.EAST); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(10, 10, 10, 10); container.add(timeButtonPanel, c); timeSlider = new TimeSlider(); timeSlider.setValueChangeable(false); timeSlider.setValueVisible(false); timeSlider.addTimeAdjustmentListener(new TimeAdjustmentListener() { public void timeChanged(TimeEvent event) { } public void rangeChanged(TimeEvent event) { updateTimeRangeLabel(); } public void boundsChanged(TimeEvent event) { } }); updateTimeRangeLabel(); updateTimeBounds(); List<EventMarker> markers = rbnb.getMarkerManager().getMarkers(); for (EventMarker marker : markers) { timeSlider.addMarker(marker); } c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(timeSlider, c); JLabel numericHeaderLabel = new JLabel("Video Channels:"); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 3; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(numericHeaderLabel, c); videoChannelList = new JList(videoChannelModel); videoChannelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); videoChannelList.setCellRenderer(new CheckListRenderer()); videoChannelList.setVisibleRowCount(10); videoChannelList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { int index = videoChannelList.locationToIndex(e.getPoint()); ExportChannel item = (ExportChannel) videoChannelList.getModel().getElementAt(index); item.setSelected(!item.isSelected()); Rectangle rect = videoChannelList.getCellBounds(index, index); videoChannelList.repaint(rect); updateTimeBounds(); } }); JScrollPane scrollPane = new JScrollPane(videoChannelList); c.fill = GridBagConstraints.BOTH; c.weightx = 0; c.weighty = 1; c.gridx = 0; c.gridy = 4; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(scrollPane, c); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.weighty = 0; c.gridx = 0; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 10, 10, 5); container.add(new JLabel("Choose Directory: "), c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 1; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; directoryTextField = new JTextField(20); c.insets = new java.awt.Insets(0, 0, 10, 5); container.add(directoryTextField, c); directoryTextField.setText(UIUtilities.getCurrentDirectory().getAbsolutePath()); directoryButton = new JButton("Browse"); directoryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { File selectedDirectory = UIUtilities.getDirectory("Select export directory"); if (selectedDirectory != null) { directoryTextField.setText(selectedDirectory.getAbsolutePath()); } } }); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.gridx = 2; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 0, 10, 10); container.add(directoryButton, c); exportProgressBar = new JProgressBar(0, 100000); exportProgressBar.setStringPainted(true); exportProgressBar.setValue(0); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 0; c.gridy = 6; c.gridwidth = GridBagConstraints.REMAINDER; ; c.anchor = GridBagConstraints.CENTER; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(exportProgressBar, c); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); Action exportAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = 1547500154252213911L; public void actionPerformed(ActionEvent e) { exportVideo(); } }; exportAction.putValue(Action.NAME, "Export"); inputMap.put(KeyStroke.getKeyStroke("ENTER"), "export"); actionMap.put("export", exportAction); exportButton = new JButton(exportAction); panel.add(exportButton); Action cancelAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = -7440298547807878651L; public void actionPerformed(ActionEvent e) { cancel(); } }; cancelAction.putValue(Action.NAME, "Cancel"); inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel"); actionMap.put("cancel", cancelAction); cancelButton = new JButton(cancelAction); panel.add(cancelButton); c.fill = GridBagConstraints.NONE; c.weightx = 0.5; c.gridx = 0; c.gridy = 7; c.gridwidth = GridBagConstraints.REMAINDER; ; c.anchor = GridBagConstraints.LINE_END; c.insets = new java.awt.Insets(0, 0, 10, 5); container.add(panel, c); pack(); if (getWidth() < 600) { setSize(600, getHeight()); } directoryTextField.requestFocusInWindow(); setLocationByPlatform(true); setVisible(true); }
From source file:org.rdv.ui.ImportDialog.java
private void initComponents() { JPanel container = new JPanel(); setContentPane(container);// w w w .j a va 2 s . c om InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = container.getActionMap(); container.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weighty = 1; c.gridwidth = 1; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; JLabel headerLabel = new JLabel("Please specify the desired source name for the data."); headerLabel.setBackground(Color.white); headerLabel.setOpaque(true); headerLabel.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray), BorderFactory.createEmptyBorder(10, 10, 10, 10))); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 0, 0, 0); container.add(headerLabel, c); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(10, 10, 10, 5); container.add(new JLabel("Source name: "), c); sourceNameTextField = new JTextField(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 1; c.gridy = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(10, 0, 10, 10); container.add(sourceNameTextField, c); importProgressBar = new JProgressBar(0, 100000); importProgressBar.setStringPainted(true); importProgressBar.setValue(0); importProgressBar.setVisible(false); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 0; c.gridy = 2; c.gridwidth = GridBagConstraints.REMAINDER; ; c.anchor = GridBagConstraints.CENTER; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(importProgressBar, c); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); Action importAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = -4719316285523193555L; public void actionPerformed(ActionEvent e) { importData(); } }; importAction.putValue(Action.NAME, "Import"); inputMap.put(KeyStroke.getKeyStroke("ENTER"), "import"); actionMap.put("export", importAction); importButton = new JButton(importAction); getRootPane().setDefaultButton(importButton); panel.add(importButton); Action cancelAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = 7909429022904810958L; public void actionPerformed(ActionEvent e) { cancel(); } }; cancelAction.putValue(Action.NAME, "Cancel"); inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel"); actionMap.put("cancel", cancelAction); cancelButton = new JButton(cancelAction); panel.add(cancelButton); c.fill = GridBagConstraints.NONE; c.weightx = 0.5; c.gridx = 0; c.gridy = 3; c.gridwidth = GridBagConstraints.REMAINDER; ; c.anchor = GridBagConstraints.LINE_END; c.insets = new java.awt.Insets(0, 0, 10, 5); container.add(panel, c); pack(); sourceNameTextField.requestFocusInWindow(); setLocationByPlatform(true); setVisible(true); }
From source file:org.revager.gui.findings_list.FindingsListFrame.java
private void createAttPanel() { GridLayout grid = new GridLayout(4, 1); grid.setVgap(8);//from ww w.j av a 2 s. c o m JPanel attendeeButtons = new JPanel(grid); addResiAtt = GUITools.newImageButton(); addResiAtt.setIcon(Data.getInstance().getIcon("addResiAtt_25x25_0.png")); addResiAtt.setRolloverIcon(Data.getInstance().getIcon("addResiAtt_25x25.png")); addResiAtt.setToolTipText(translate("Add Attendee from the Attendee Pool")); addResiAtt.addActionListener(ActionRegistry.getInstance().get(AddResiAttToProtAction.class.getName())); attendeeButtons.add(addResiAtt); JButton addAttendee = GUITools.newImageButton(); addAttendee.setIcon(Data.getInstance().getIcon("addAttendee_25x25_0.png")); addAttendee.setRolloverIcon(Data.getInstance().getIcon("addAttendee_25x25.png")); addAttendee.setToolTipText(translate("Add Attendee")); addAttendee.addActionListener(ActionRegistry.getInstance().get(AddAttToProtAction.class.getName())); attendeeButtons.add(addAttendee); removeAttendee = GUITools.newImageButton(); removeAttendee.setIcon(Data.getInstance().getIcon("removeAttendee_25x25_0.png")); removeAttendee.setRolloverIcon(Data.getInstance().getIcon("removeAttendee_25x25.png")); removeAttendee.setToolTipText(translate("Remove Attendee")); removeAttendee.addActionListener(ActionRegistry.getInstance().get(RemAttFromProtAction.class.getName())); attendeeButtons.add(removeAttendee); editAttendee = GUITools.newImageButton(); editAttendee.setIcon(Data.getInstance().getIcon("editAttendee_25x25_0.png")); editAttendee.setRolloverIcon(Data.getInstance().getIcon("editAttendee_25x25.png")); editAttendee.setToolTipText(translate("Edit Attendee")); editAttendee.addActionListener(ActionRegistry.getInstance().get(EditAttFromProtAction.class.getName())); attendeeButtons.add(editAttendee); editAttendee.setEnabled(false); removeAttendee.setEnabled(false); presentAttTable.setRowHeight(55); presentAttTable.getColumnModel().getColumn(0).setMaxWidth(55); presentAttTable.setShowHorizontalLines(false); presentAttTable.setShowVerticalLines(true); presentAttTable.setShowGrid(true); presentAttTable.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { ActionRegistry.getInstance().get(EditAttFromProtAction.class.getName()).actionPerformed(null); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }); TableCellRenderer renderer = (table, value, isSelected, hasFocus, row, column) -> { JLabel label = new JLabel((String) value); label.setOpaque(true); label.setBorder(new EmptyBorder(5, 5, 5, 5)); label.setFont(UI.VERY_LARGE_FONT); if (isSelected) { label.setBackground(presentAttTable.getSelectionBackground()); } else { if (row % 2 == 0) { label.setBackground(UI.TABLE_ALT_COLOR); } else { label.setBackground(presentAttTable.getBackground()); } } return label; }; for (int i = 1; i <= 4; i++) { presentAttTable.getColumnModel().getColumn(i).setCellRenderer(renderer); } TableColumn col = presentAttTable.getColumnModel().getColumn(0); col.setCellRenderer((table, value, isSelected, hasFocus, row, column) -> { JPanel localPnl = new JPanel(); localPnl.add(new JLabel(Data.getInstance().getIcon("attendee_40x40.png"))); if (isSelected) { localPnl.setBackground(presentAttTable.getSelectionBackground()); } else { if (row % 2 == 0) { localPnl.setBackground(UI.TABLE_ALT_COLOR); } else { localPnl.setBackground(presentAttTable.getBackground()); } } return localPnl; }); presentAttTable.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { updateAttButtons(); } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }); scrllP = GUITools.setIntoScrollPane(presentAttTable); scrllP.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); scrllP.setToolTipText(translate("Add Attendee to Meeting")); scrllP.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (isAddResiAttPossible()) { ActionRegistry.getInstance().get(AddResiAttToProtAction.class.getName()).actionPerformed(null); } else { ActionRegistry.getInstance().get(AddAttToProtAction.class.getName()).actionPerformed(null); } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }); JLabel labelAttendees = new JLabel(translate("Attendees of the current meeting:")); labelAttendees.setFont(UI.HUGE_FONT_BOLD); GUITools.addComponent(attPanel, gbl, labelAttendees, 0, 0, 2, 1, 1.0, 0.0, 20, 20, 0, 20, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); GUITools.addComponent(attPanel, gbl, scrllP, 0, 1, 1, 1, 1.0, 1.0, 20, 20, 0, 20, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); GUITools.addComponent(attPanel, gbl, attendeeButtons, 1, 1, 1, 1, 0, 0, 20, 0, 20, 20, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); }
From source file:org.sonarlint.intellij.config.global.SonarQubeServerMgmtPanel.java
private JPanel createServerStatus() { JPanel serverStatusPanel = new JPanel(new GridBagLayout()); JLabel serverStatusLabel = new JLabel("Local update: "); updateServerButton = new JButton(); serverStatus = new JLabel(); final HyperlinkLabel link = new HyperlinkLabel(""); link.setIcon(AllIcons.General.Help_small); link.setUseIconAsLink(true);/*from w w w . java 2s.c om*/ link.addHyperlinkListener(new HyperlinkAdapter() { @Override protected void hyperlinkActivated(HyperlinkEvent e) { final JLabel label = new JLabel( "<html>Click to fetch data from the selected SonarQube server, such as the list of projects,<br>" + " rules, quality profiles, etc. This needs to be done before being able to select a project."); label.setBorder(HintUtil.createHintBorder()); label.setBackground(HintUtil.INFORMATION_COLOR); label.setOpaque(true); HintManager.getInstance().showHint(label, RelativePoint.getSouthWestOf(link), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1); } }); JPanel flow1 = new JPanel(new FlowLayout(FlowLayout.LEADING)); flow1.add(serverStatusLabel); flow1.add(serverStatus); JPanel flow2 = new JPanel(new FlowLayout(FlowLayout.LEADING)); flow2.add(updateServerButton); flow2.add(link); serverStatusPanel.add(flow1, new GridBagConstraints(0, 0, 1, 1, 0.5, 1, GridBagConstraints.LINE_START, 0, new Insets(0, 0, 0, 0), 0, 0)); serverStatusPanel.add(flow2, new GridBagConstraints(1, 0, 1, 1, 0.5, 1, GridBagConstraints.LINE_START, 0, new Insets(0, 0, 0, 0), 0, 0)); updateServerButton.setAction(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { actionUpdateServerTask(false); } }); updateServerButton.setText("Update binding"); updateServerButton.setToolTipText("Update local data: quality profile, settings, ..."); JPanel alignedPanel = new JPanel(new BorderLayout()); alignedPanel.add(serverStatusPanel, BorderLayout.NORTH); return alignedPanel; }
From source file:org.ut.biolab.medsavant.client.view.genetics.inspector.stat.StaticGeneInspector.java
private StaticGeneInspector() { JPanel messagePanel = new JPanel(); //messagePanel.setBackground(Color.white); messagePanel.setBorder(ViewUtil.getHugeBorder()); ViewUtil.applyVerticalBoxLayout(messagePanel); JLabel h1 = new JLabel("No Gene Selected"); h1.setFont(ViewUtil.getMediumTitleFont()); String m = "<html><div style=\"text-align: center;\">Choose one from the dropdown box in the Variant Inspector and then click the Inspect button</div></html>"; JLabel h2 = new JLabel(m); h2.setPreferredSize(new Dimension(190, 300)); h2.setMinimumSize(new Dimension(190, 300)); h2.setBackground(Color.red); messagePanel.add(ViewUtil.centerHorizontally(h1)); messagePanel.add(Box.createVerticalStrut(10)); messagePanel.add(ViewUtil.centerHorizontally(h2)); this.setMessage(messagePanel); addSubInspector(new BasicGeneSubInspector()); addSubInspector(new OntologySubInspector()); addSubInspector(new GeneManiaSubInspector()); }
From source file:Proiect.uploadFTP.java
public void actionFTP() { adressf.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent e) { InetAddress thisIp;/*from www.j ava 2 s . c o m*/ try { thisIp = InetAddress.getLocalHost(); titleFTP.setText("Connection: " + thisIp.getHostAddress() + " -> " + adressf.getText()); } catch (UnknownHostException e1) { e1.printStackTrace(); } } }); exit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { saveState(); uploadFTP.dispose(); tree.dispose(); } }); connect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { FTPClient client = new FTPClient(); FileInputStream fis = null; String pass = String.valueOf(passf.getPassword()); try { if (filename == null) { status.setText("File does not exist!"); } else { // Server address client.connect(adressf.getText()); // Login credentials client.login(userf.getText(), pass); if (client.isConnected()) { status.setText("Succesfull transfer!"); // File type client.setFileType(FTP.BINARY_FILE_TYPE); // File location File file = new File(filepath); fis = new FileInputStream(file); // Change the folder on the server client.changeWorkingDirectory(folderf.getText()); // Save the file on the server client.storeFile(filename, fis); } else { status.setText("Transfer failed!"); } } client.logout(); } catch (IOException e1) { Encrypter.printException(e1); } finally { try { if (fis != null) { fis.close(); } client.disconnect(); } catch (IOException e1) { Encrypter.printException(e1); } } } }); browsef.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int retval = chooserf.showOpenDialog(chooserf); if (retval == JFileChooser.APPROVE_OPTION) { status.setText(""); filename = chooserf.getSelectedFile().getName().toString(); filepath = chooserf.getSelectedFile().getPath(); filenf.setText(chooserf.getSelectedFile().getName().toString()); } } }); adv.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tree.setSize(220, uploadFTP.getHeight()); tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY()); tree.setResizable(false); tree.setIconImage(Toolkit.getDefaultToolkit() .getImage(getClass().getClassLoader().getResource("assets/ico.png"))); tree.setUndecorated(true); tree.getRootPane().setBorder(BorderFactory.createLineBorder(Encrypter.color_black, 2)); tree.setVisible(true); tree.setLayout(new BorderLayout()); JLabel labeltree = new JLabel("Server documents"); labeltree.setOpaque(true); labeltree.setBackground(Encrypter.color_light); labeltree.setBorder(BorderFactory.createMatteBorder(8, 10, 10, 0, Encrypter.color_light)); labeltree.setForeground(Encrypter.color_blue); labeltree.setFont(Encrypter.font16); JButton refresh = new JButton(""); ImageIcon refresh_icon = getImageIcon("assets/icons/refresh.png"); refresh.setIcon(refresh_icon); refresh.setBackground(Encrypter.color_light); refresh.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); refresh.setForeground(Encrypter.color_black); refresh.setFont(Encrypter.font16); refresh.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); final FTPClient client = new FTPClient(); DefaultMutableTreeNode top = new DefaultMutableTreeNode(adressf.getText()); DefaultMutableTreeNode files = null; DefaultMutableTreeNode leaf = null; final JTree tree_view = new JTree(top); tree_view.setForeground(Encrypter.color_black); tree_view.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0)); tree_view.putClientProperty("JTree.lineStyle", "None"); tree_view.setBackground(Encrypter.color_light); JScrollPane scrolltree = new JScrollPane(tree_view); scrolltree.setBackground(Encrypter.color_light); scrolltree.getVerticalScrollBar().setPreferredSize(new Dimension(0, 0)); UIManager.put("Tree.textBackground", Encrypter.color_light); UIManager.put("Tree.selectionBackground", Encrypter.color_blue); UIManager.put("Tree.selectionBorderColor", Encrypter.color_blue); tree_view.updateUI(); final String pass = String.valueOf(passf.getPassword()); try { client.connect(adressf.getText()); client.login(userf.getText(), pass); client.enterLocalPassiveMode(); if (client.isConnected()) { try { FTPFile[] ftpFiles = client.listFiles(); for (FTPFile ftpFile : ftpFiles) { files = new DefaultMutableTreeNode(ftpFile.getName()); top.add(files); if (ftpFile.getType() == FTPFile.DIRECTORY_TYPE) { FTPFile[] ftpFiles1 = client.listFiles(ftpFile.getName()); for (FTPFile ftpFile1 : ftpFiles1) { leaf = new DefaultMutableTreeNode(ftpFile1.getName()); files.add(leaf); } } } } catch (IOException e1) { Encrypter.printException(e1); } client.disconnect(); } else { status.setText("Failed connection!"); } } catch (IOException e1) { Encrypter.printException(e1); } finally { try { client.disconnect(); } catch (IOException e1) { Encrypter.printException(e1); } } tree.add(labeltree, BorderLayout.NORTH); tree.add(scrolltree, BorderLayout.CENTER); tree.add(refresh, BorderLayout.SOUTH); uploadFTP.addComponentListener(new ComponentListener() { public void componentMoved(ComponentEvent e) { tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY()); } public void componentShown(ComponentEvent e) { } public void componentResized(ComponentEvent e) { } public void componentHidden(ComponentEvent e) { } }); uploadFTP.addWindowListener(new WindowListener() { public void windowActivated(WindowEvent e) { tree.toFront(); } public void windowOpened(WindowEvent e) { } public void windowIconified(WindowEvent e) { } public void windowDeiconified(WindowEvent e) { } public void windowDeactivated(WindowEvent e) { } public void windowClosing(WindowEvent e) { } public void windowClosed(WindowEvent e) { } }); refresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tree.dispose(); tree.setVisible(true); } }); } }); }
From source file:projectresurrection.Music.java
public void subMenu(int menu) { JPanel panel = (JPanel) ((JViewport) ((JScrollPane) pnlSub.getComponent(3)).getComponent(0)) .getComponent(0);//from w ww. ja v a 2s . c om JLabel header = (JLabel) pnlSub.getComponent(1); JLabel label; panel.removeAll(); int y = 10; switch (menu) { case 0: header.setText("Artists"); panel.setPreferredSize(new Dimension(349, (55 + (artists.size() * 35)))); label = new JLabel("All"); label.setOpaque(true); label.setBackground(new Color(245, 245, 245)); label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { subMenu(ALBUMS); panel.revalidate(); panel.repaint(); } }); panel.add(label); y += 35; List artistList = new ArrayList(artists.keySet()); Collections.sort(artistList); for (int i = 0; i < artistList.size(); i++) { String artist = artistList.get(i).toString(); label = new JLabel(artist); label.setOpaque(true); if (i % 2 == 1) { label.setBackground(new Color(245, 245, 245)); } label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { subMenu(ARTISTS, artist); panel.revalidate(); panel.repaint(); } }); panel.add(label); y += 35; } break; case 1: header.setText("Albums"); panel.setPreferredSize(new Dimension(349, (55 + (albums.size() * 35)))); label = new JLabel("All"); label.setOpaque(true); label.setBackground(new Color(245, 245, 245)); label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { subMenu(SONGS); panel.revalidate(); panel.repaint(); } }); panel.add(label); y += 35; List albumList = new ArrayList(albums.keySet()); Collections.sort(albumList); for (int i = 0; i < albumList.size(); i++) { String album = albumList.get(i).toString(); label = new JLabel(album); label.setOpaque(true); if (i % 2 == 1) { label.setBackground(new Color(245, 245, 245)); } label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { subMenu(ALBUMS, album); panel.revalidate(); panel.repaint(); } }); panel.add(label); y += 35; } break; case 2: header.setText("Songs"); panel.setPreferredSize(new Dimension(349, (20 + (songs.size() * 35)))); List songList = new ArrayList(songs.keySet()); Collections.sort(songList); List fileList = new ArrayList(); for (int i = 0; i < songList.size(); i++) { fileList.add(((List) songs.get(songList.get(i))).get(0)); } for (int i = 0; i < songList.size(); i++) { int num = i; String song = songList.get(i).toString(); label = new JLabel(song); label.setOpaque(true); if (i % 2 == 0) { label.setBackground(new Color(245, 245, 245)); } label.setFont(new Font("Tahoma", Font.PLAIN, 20)); label.setBounds(10, y, 339, 35); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { player.setPlaylist(fileList, num); pnlSub.setVisible(false); pnlPlayer.setVisible(true); try { Thread.sleep(200); } catch (Exception e) { } if (player.isPlaying() == false) { player.toggle(); } } }); panel.add(label); y += 35; } break; } pnlMenu.setVisible(false); pnlSub.setVisible(true); }