Java Code Examples for javax.swing.JLabel#setEnabled()

The following examples show how to use javax.swing.JLabel#setEnabled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableUISupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    DisabledReason disabledReason = null;
    Object displayName = null;

    if (value instanceof Table) {
        Table tableItem = (Table)value;
        disabledReason = tableItem.getDisabledReason();
        if (disabledReason!= null) {
            displayName = NbBundle.getMessage(TableUISupport.class, "LBL_TableNameWithDisabledReason", tableItem.getName(), disabledReason.getDisplayName());
        } else {
            if(tableItem.isTable())
                displayName = tableItem.getName();
            else
                displayName = tableItem.getName() + NbBundle.getMessage(TableUISupport.class, "LBL_DB_VIEW");
        }
    }

    JLabel component = (JLabel)super.getListCellRendererComponent(list, displayName, index, isSelected, cellHasFocus);
    boolean needDisable = (disabledReason instanceof Table.NoPrimaryKeyDisabledReason) || (disabledReason instanceof Table.ExistingNotInSourceDisabledReason) || 
            (filter.equals(FilterAvailable.NEW) && (disabledReason instanceof Table.ExistingDisabledReason)) ||
            (filter.equals(FilterAvailable.UPDATE) && (disabledReason==null));
    component.setEnabled(!needDisable);
    component.setToolTipText(disabledReason != null ? disabledReason.getDescription() : null);

    return component;
}
 
Example 2
Source File: ConfigFilesUIs.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    JLabel component = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
    File file = (File)value;
    String displayNameText = (file != null) ? displayName.getDisplayName(file) : null;
    component.setText(displayNameText);
    if (!(table.getModel() instanceof ConfigFileSelectionTableModel)) {
        return component;
    }
    ConfigFileSelectionTableModel model = (ConfigFileSelectionTableModel)table.getModel();
    String toolTipText = null;
    if (!model.isEnabled(row)) {
        toolTipText = NbBundle.getMessage(ConfigFilesUIs.class, "LBL_FileAlreadyAdded");
    }
    component.setToolTipText(toolTipText);
    component.setEnabled(model.isEnabled(row));
    return component;
}
 
Example 3
Source File: TableUISupport.java    From jeddict with Apache License 2.0 6 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    DisabledReason disabledReason = null;
    Object displayName = null;

    if (value instanceof Table) {
        Table tableItem = (Table) value;
        disabledReason = tableItem.getDisabledReason();
        if (disabledReason != null) {
            displayName = NbBundle.getMessage(TableUISupport.class, "LBL_TableNameWithDisabledReason", tableItem.getName(), disabledReason.getDisplayName());
        } else if (tableItem.isTable()) {
            displayName = tableItem.getName();
        } else {
            displayName = tableItem.getName() + NbBundle.getMessage(TableUISupport.class, "LBL_DB_VIEW");
        }
    }

    JLabel component = (JLabel) super.getListCellRendererComponent(list, displayName, index, isSelected, cellHasFocus);
    boolean needDisable = (disabledReason instanceof Table.NoPrimaryKeyDisabledReason)
            || (disabledReason instanceof Table.ExistingNotInSourceDisabledReason)
            || (disabledReason instanceof Table.ExistingDisabledReason);
    component.setEnabled(!needDisable);
    component.setToolTipText(disabledReason != null ? disabledReason.getDescription() : null);

    return component;
}
 
Example 4
Source File: ResourceReferenceChooser.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
  JLabel renderer = (JLabel)super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
  if(value instanceof PluginTreeNode) {
    renderer.setEnabled(true);
    renderer.setIcon(pluginIcon);
  } else if(value instanceof PluginResourceTreeNode) {
    PluginResourceTreeNode node = (PluginResourceTreeNode)value;
    if(!node.isLeaf() || ((PluginFileFilter)pluginFileFilterBox.getSelectedItem()).pattern.matcher(node.fullPath).find()) {
      renderer.setEnabled(true);
    } else {
      // trick lifted from DefaultTreeCellRenderer to get the right disabled icon
      Icon icon = renderer.getIcon();
      LookAndFeel laf = UIManager.getLookAndFeel();
      Icon disabledIcon = laf.getDisabledIcon(tree, icon);
      if (disabledIcon != null) icon = disabledIcon;
      renderer.setDisabledIcon(icon);
      renderer.setEnabled(false);
    }
  }
  return renderer;
}
 
Example 5
Source File: Utils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                                              boolean cellHasFocus) {
    JLabel renderer = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    renderer.setBorder(BorderFactory.createEmptyBorder(1, 7, 1, 5));

    if (value instanceof ProfilingPoint) {
        boolean enabled = ((ProfilingPoint) value).isEnabled();
        renderer.setText(((ProfilingPoint) value).getName());
        renderer.setIcon(enabled ? ((ProfilingPoint) value).getFactory().getIcon() :
                                   ((ProfilingPoint) value).getFactory().getDisabledIcon());
        renderer.setEnabled(enabled);
    } else if (value instanceof ProfilingPointFactory) {
        renderer.setText(((ProfilingPointFactory) value).getType());
        renderer.setIcon(((ProfilingPointFactory) value).getIcon());
        renderer.setEnabled(true);
    } else {
        renderer.setIcon(null);
        renderer.setEnabled(true);
    }

    return renderer;
}
 
Example 6
Source File: XactDataPane.java    From audiveris with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new {@code XactDataPane} object.
 *
 * @param title  pane title
 * @param parent parent pane if any
 * @param model  underlying model (cannot be null)
 */
public XactDataPane (String title,
                     XactDataPane parent,
                     Param<E> model)
{
    this.parent = parent;

    if (model == null) {
        throw new IllegalArgumentException("Null model for pane '" + title + "'");
    }

    this.model = model;
    this.title = title;
    separator = new JLabel(title);
    separator.setHorizontalAlignment(SwingConstants.LEFT);
    separator.setEnabled(false);
    selBox = new JCheckBox();
    selBox.addActionListener(this);
}
 
Example 7
Source File: MergeBranchForm.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL
 */
private void $$$setupUI$$$() {
    contentPanel = new JPanel();
    contentPanel.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1));
    sourceBranchLabel = new JLabel();
    this.$$$loadLabelText$$$(sourceBranchLabel, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("MergeBranchDialog.Source"));
    contentPanel.add(sourceBranchLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    sourceText = new TextFieldWithBrowseButton.NoPathCompletion();
    contentPanel.add(sourceText, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JLabel label1 = new JLabel();
    label1.setEnabled(true);
    this.$$$loadLabelText$$$(label1, ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("MergeBranchDialog.Target"));
    contentPanel.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    targetCombo = new JComboBox();
    contentPanel.add(targetCombo, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    changesToMergePanel = new JPanel();
    changesToMergePanel.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1));
    contentPanel.add(changesToMergePanel, new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    changesToMergePanel.setBorder(BorderFactory.createTitledBorder(ResourceBundle.getBundle("com/microsoft/alm/plugin/idea/ui/tfplugin").getString("MergeBranchDialog.ChangesToMerge")));
    changesTypeCombo = new JComboBox();
    changesToMergePanel.add(changesTypeCombo, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    changesetsPanel = new JPanel();
    changesetsPanel.setLayout(new CardLayout(0, 0));
    changesToMergePanel.add(changesetsPanel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
    label1.setLabelFor(targetCombo);
}
 
Example 8
Source File: TaskListTopComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Component createNoTasksMessage() {
    JPanel panel = new JPanel( new BorderLayout() );
    if( isMacLaf ) {
        panel.setBackground(macBackground);
    } else {
        Color background = UIManager.getColor("TextArea.background"); //NOI18N
        if( null != background )
            panel.setBackground( background );
    }
    JLabel msg = new JLabel( NbBundle.getMessage(TaskListTopComponent.class, "LBL_NoTasks" ) ); //NOI18N
    msg.setHorizontalAlignment(JLabel.CENTER);
    msg.setEnabled(false);
    msg.setOpaque(false);
    panel.add( msg, BorderLayout.CENTER );
    return panel;
}
 
Example 9
Source File: PackagesView.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private JComponent createComponents() {
    JPanel panel = new JPanel(new BorderLayout()) {
        public void setEnabled(boolean enabled) {
            Component[] components = getComponents();
            for (Component c : components) c.setEnabled(enabled);
        }
    };
    panel.setOpaque(false);

    JLabel waitLabel = new JLabel("Loading probes...", SwingConstants.CENTER);
    waitLabel.setEnabled(false);
    panel.add(waitLabel, BorderLayout.CENTER);
    
    return panel;
}
 
Example 10
Source File: NotificationCenterTopComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void init() {
        initComponents();
        detailsPanel = new JPanel(new GridLayout(1, 1));
        Color color = Utils.getTextBackground();
        detailsPanel.setBackground(new Color(color.getRed(), color.getGreen(), color.getBlue()));
        lblEmptyDetails = new JLabel(NbBundle.getMessage(NotificationCenterTopComponent.class, "LBL_EmptyDetails"), JLabel.CENTER);
        lblEmptyDetails.setFont(italicFont);
        lblEmptyDetails.setEnabled(false);

        JScrollPane scrollPane = new JScrollPane(detailsPanel);
        splitPane.setRightComponent(scrollPane);

        toolBar.setFocusable(false);
        toolBar.setFloatable(false);
        btnSearch = new JToggleButton(ImageUtilities.loadImageIcon("org/netbeans/modules/notifications/resources/find16.png", true));
        btnSearch.setToolTipText(NbBundle.getMessage(NotificationCenterTopComponent.class, "LBL_SearchToolTip"));
        btnSearch.setFocusable(false);
        btnSearch.setSelected(NotificationSettings.isSearchVisible());
        //TODO delete 2 lines then quick search API clear text correctly
//        btnSearch.setToolTipText("Disabled due to Quick Search API defects");
//        btnSearch.setEnabled(false);
        btnSearch.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                setSearchVisible(btnSearch.isSelected());
            }
        });
        toolBar.add(btnSearch);
        toolBar.add(new FiltersMenuButton(notificationManager.getActiveFilter()));

        initLeft();
        showDetails();
    }
 
Example 11
Source File: PlayerFunctions.java    From aurous-app with GNU General Public License v2.0 5 votes vote down vote up
public static void handleSpecialLabels(final boolean isRepeat) {
	final JLabel repeatStatusLabel = ControlPanel.repeat();
	final JLabel shuffleStatusLabel = ControlPanel.shuffle();
	if (isRepeat) {
		if (repeatStatusLabel.isEnabled()) {
			if (repeat == true) {
				repeat = false;
				repeatStatusLabel.setText("Repeat : Off");
				shuffleStatusLabel.setEnabled(true);

			} else {
				repeat = true;
				shuffle = false;
				shuffleStatusLabel.setEnabled(false);
				repeatStatusLabel.setText("Repeat : On");
				shuffleStatusLabel.setText("Shuffle : Off");
			}
		}
	} else {
		if (shuffleStatusLabel.isEnabled()) {
			if (shuffle == true) {
				shuffle = false;
				shuffleStatusLabel.setText("Shuffle : Off");
				repeatStatusLabel.setEnabled(true);

			} else {
				shuffle = true;
				repeat = false;
				repeatStatusLabel.setEnabled(false);
				shuffleStatusLabel.setText("Shuffle : On");
				repeatStatusLabel.setText("Repeat : Off");
			}
		}
	}
}
 
Example 12
Source File: IOLocationTileList.java    From pumpernickel with MIT License 5 votes vote down vote up
public Component getListCellRendererComponent(JList list, IOLocation l,
		int index, boolean isSelected, boolean cellHasFocus) {
	String text = "";
	BufferedImage image;

	text = l.getName();
	image = getGraphicCache().requestThumbnail(l);
	if (image == null) {
		if (l.isDirectory()) {
			image = LocationPane.FOLDER_THUMBNAIL;
		} else {
			image = LocationPane.FILE_THUMBNAIL;
		}
	}

	IOLocationFilter f = null;
	if (list instanceof IOLocationTileList) {
		IOLocationTileList t = (IOLocationTileList) list;
		f = t.getFilter();
	}
	boolean enabled = f == null ? true : f.filter(l) != null;
	JLabel label = getThumbnail();
	label.setEnabled(enabled);
	label.setText(text);
	label.setIcon(new ImageIcon(image));
	label.putClientProperty("selected", new Boolean(isSelected));

	format(l, label);

	return label;
}
 
Example 13
Source File: IrpMasterBean.java    From IrScrutinizer with GNU General Public License v3.0 5 votes vote down vote up
private void checkParam(JTextField textField, JLabel label, String parameterName, String oldValueStr) {
    if (protocol.hasParameter(parameterName)) {
        // TODO: check validity
        textField.setEnabled(true);
        label.setEnabled(true);
        if (!oldValueStr.equals(invalidParameterString))
            textField.setText(oldValueStr);
    } else {
        textField.setEnabled(false);
        label.setEnabled(false);
        textField.setText(null);
    }
}
 
Example 14
Source File: PixelExtractionIOForm.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
public TimeExtractionPane(PropertyContainer container) {
    super(new BorderLayout(0, 5));

    final JCheckBox extractTime = createCheckBoxBinding(container.getProperty("extractTimeFromFilename"));

    final Property datePattern = container.getProperty("dateInterpretationPattern");
    final String dateDN = datePattern.getDescriptor().getDisplayName();
    final JPanel datePanel = new JPanel(new BorderLayout(0, 2));
    final JLabel dateLabel = new JLabel(dateDN + ":");
    final JTextField datePatternField = createTextFieldBinding(datePattern);
    dateLabel.setEnabled(false);
    datePatternField.setEnabled(false);
    datePanel.add(dateLabel, BorderLayout.NORTH);
    datePanel.add(datePatternField, BorderLayout.CENTER);

    final Property filenamePattern = container.getProperty("filenameInterpretationPattern");
    final String filenameDN = filenamePattern.getDescriptor().getDisplayName();
    final JPanel filenamePanel = new JPanel(new BorderLayout(0, 2));
    final JLabel filenameLabel = new JLabel(filenameDN + ":");
    final JTextField filenamePatternField = createTextFieldBinding(filenamePattern);
    filenameLabel.setEnabled(false);
    filenamePatternField.setEnabled(false);
    filenamePanel.add(filenameLabel, BorderLayout.NORTH);
    filenamePanel.add(filenamePatternField, BorderLayout.CENTER);

    extractTime.addChangeListener(e -> {
        final boolean selected = extractTime.isSelected();
        dateLabel.setEnabled(selected);
        datePatternField.setEnabled(selected);
        filenameLabel.setEnabled(selected);
        filenamePatternField.setEnabled(selected);
    });

    add(extractTime, BorderLayout.NORTH);
    add(datePanel, BorderLayout.CENTER);
    add(filenamePanel, BorderLayout.SOUTH);
}
 
Example 15
Source File: NoWebBrowserImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public NoWebBrowserImpl(String cause) {
    JLabel lbl = new JLabel(NbBundle.getMessage(NoWebBrowserImpl.class, "Err_CannotCreateBrowser", cause));
    lbl.setEnabled( false );
    lbl.setHorizontalAlignment( JLabel.CENTER );
    lbl.setVerticalAlignment( JLabel.CENTER );
    component = lbl;
}
 
Example 16
Source File: Main_BottomToolbar.java    From Hotel-Properties-Management-System with GNU General Public License v2.0 4 votes vote down vote up
public Main_BottomToolbar() {

        toolBar = new JToolBar();
        toolBar.setAlignmentX(Component.LEFT_ALIGNMENT);
        toolBar.setAlignmentY(Component.BOTTOM_ALIGNMENT);
        toolBar.setPreferredSize(new Dimension(1200, 25));
        toolBar.setMinimumSize(new Dimension(800, 25));
        toolBar.setAutoscrolls(true);
        toolBar.setFloatable(false);
        toolBar.setRollover(true);

        userIconLabel = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/main_user.png")));
        toolBar.add(userIconLabel);

        //initialize weather api for use.
        liveWeather = new GetLiveWeather();
        
        userLabel = new JLabel();
        userLabel.setMaximumSize(new Dimension(160, 19));
        userLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
        userLabel.setHorizontalTextPosition(SwingConstants.CENTER);
        userLabel.setHorizontalAlignment(SwingConstants.LEFT);
        toolBar.add(userLabel);
        toolBar.addSeparator();

        dateIconLabel = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/main_calendar.png")));
        toolBar.add(dateIconLabel);

        dateLabel = new JLabel("");
        dateLabel.setMaximumSize(new Dimension(160, 19));
        dateLabel.setHorizontalTextPosition(SwingConstants.CENTER);
        dateLabel.setHorizontalAlignment(SwingConstants.LEFT);
        dateLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
        toolBar.add(dateLabel);
        toolBar.addSeparator();

        currencyUsdIcon = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/main_currency.png")));
        toolBar.add(currencyUsdIcon);

        currencyUsdLabel = new JLabel("");
        currencyUsdLabel.setMaximumSize(new Dimension(160, 19));
        currencyUsdLabel.setHorizontalTextPosition(SwingConstants.CENTER);
        currencyUsdLabel.setHorizontalAlignment(SwingConstants.LEFT);
        currencyUsdLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
        toolBar.add(currencyUsdLabel);
        toolBar.addSeparator();

        currencyEuroIcon = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/main_currency_euro.png")));
        toolBar.add(currencyEuroIcon);

        currencyEuroLabel = new JLabel("");
        currencyEuroLabel.setMaximumSize(new Dimension(160, 19));
        currencyEuroLabel.setHorizontalTextPosition(SwingConstants.CENTER);
        currencyEuroLabel.setHorizontalAlignment(SwingConstants.LEFT);
        currencyEuroLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
        toolBar.add(currencyEuroLabel);
        toolBar.addSeparator();

        currencyPoundIcon = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/main_currency_pound.png")));
        toolBar.add(currencyPoundIcon);

        currencyPoundLabel = new JLabel("");
        currencyPoundLabel.setMaximumSize(new Dimension(160, 19));
        currencyPoundLabel.setHorizontalTextPosition(SwingConstants.CENTER);
        currencyPoundLabel.setHorizontalAlignment(SwingConstants.LEFT);
        currencyPoundLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
        toolBar.add(currencyPoundLabel);
        toolBar.addSeparator();

        hotelIconLabel = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/login_hotel.png")));
        toolBar.add(hotelIconLabel);

        hotelNameLabel = new JLabel("");
        hotelNameLabel.setMaximumSize(new Dimension(160, 19));
        hotelNameLabel.setHorizontalTextPosition(SwingConstants.CENTER);
        hotelNameLabel.setHorizontalAlignment(SwingConstants.LEFT);
        hotelNameLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
        toolBar.add(hotelNameLabel);
        toolBar.addSeparator();

        checkBox = new JCheckBox("");
        checkBox.setToolTipText("Enable local weather");
        checkBox.addItemListener(showWeather());
        toolBar.add(checkBox);

        weatherIconLabel = new JLabel(new ImageIcon(getClass().getResource("/com/coder/hms/icons/toolbar_weather.png")));
        toolBar.add(weatherIconLabel);

        weatherLabel = new JLabel("");
        weatherLabel.setPreferredSize(new Dimension(160, 19));
        weatherLabel.setHorizontalTextPosition(SwingConstants.CENTER);
        weatherLabel.setHorizontalAlignment(SwingConstants.LEFT);
        weatherLabel.setFont(new Font("Microsoft Sans Serif", Font.PLAIN, 13));
        weatherLabel.setEnabled(false);
        toolBar.add(weatherLabel);

    }
 
Example 17
Source File: DetailsPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void initComponents() {        
    table = new DetailsTable();
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JViewport viewport = new Viewport(table);

    final JScrollPane tableScroll = new JScrollPane(
                                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tableScroll.setViewport(viewport);
    tableScroll.setBorder(BorderFactory.createEmptyBorder());
    tableScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    tableScroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new HeaderPanel());
    
    scrollBar = new ScrollBar(JScrollBar.VERTICAL) {
        public int getUnitIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableUnitIncrement(vr, getOrientation(), direction);
        }
        public int getBlockIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableBlockIncrement(vr, getOrientation(), direction);
        }
        public void setValues(int newValue, int newExtent, int newMin, int newMax) {
            setEnabled(newExtent < newMax);
            if (isEnabled() && !isSelectionChanging() && isTrackingEnd())
                newValue = newMax - newExtent;
            super.setValues(newValue, newExtent, newMin, newMax);
        }
    };
    tableScroll.setVerticalScrollBar(scrollBar);
    dataContainer = tableScroll;

    JLabel noDataLabel = new JLabel("<No probe selected>", JLabel.CENTER);
    noDataLabel.setEnabled(false);
    noDataContainer = new JPanel(new BorderLayout());
    noDataContainer.setOpaque(false);
    noDataContainer.add(noDataLabel, BorderLayout.CENTER);

    setOpaque(false);
    setLayout(new BorderLayout());
    add(noDataContainer, BorderLayout.CENTER);
}
 
Example 18
Source File: DetailsPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void initComponents() {        
    table = new DetailsTable();
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JViewport viewport = new Viewport(table);

    final JScrollPane tableScroll = new JScrollPane(
                                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tableScroll.setViewport(viewport);
    tableScroll.setBorder(BorderFactory.createEmptyBorder());
    tableScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    tableScroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new HeaderPanel());
    
    scrollBar = new ScrollBar(JScrollBar.VERTICAL) {
        public int getUnitIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableUnitIncrement(vr, getOrientation(), direction);
        }
        public int getBlockIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableBlockIncrement(vr, getOrientation(), direction);
        }
        public void setValues(int newValue, int newExtent, int newMin, int newMax) {
            setEnabled(newExtent < newMax);
            if (isEnabled() && !isSelectionChanging() && isTrackingEnd())
                newValue = newMax - newExtent;
            super.setValues(newValue, newExtent, newMin, newMax);
        }
    };
    tableScroll.setVerticalScrollBar(scrollBar);
    dataContainer = tableScroll;

    JLabel noDataLabel = new JLabel("<No probe selected>", JLabel.CENTER);
    noDataLabel.setEnabled(false);
    noDataContainer = new JPanel(new BorderLayout());
    noDataContainer.setOpaque(false);
    noDataContainer.add(noDataLabel, BorderLayout.CENTER);

    setOpaque(false);
    setLayout(new BorderLayout());
    add(noDataContainer, BorderLayout.CENTER);
}
 
Example 19
Source File: UserActionPanel.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
private JPanel getUserActionButtonPanel(final JDialog parent) {
  final JPanel userActionButtonPanel = new JPanel();
  userActionButtonPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
  userActionButtonPanel.setLayout(new GridBagLayout());

  final int firstRow = 0;
  final int lastRow = validUserActions.size() - 1;
  int row = 0;
  for (final UserActionAttachment uaa : validUserActions) {
    final int topInset = (row == firstRow) ? 0 : 4;
    final int bottomInset = (row == lastRow) ? 0 : 4;
    final boolean canPlayerAffordUserAction = canPlayerAffordUserAction(getCurrentPlayer(), uaa);

    userActionButtonPanel.add(
        getOtherPlayerFlags(uaa),
        new GridBagConstraints(
            0,
            row,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(topInset, 0, bottomInset, 4),
            0,
            0));

    final JButton button =
        getMap()
            .getUiContext()
            .getResourceImageFactory()
            .getResourcesButton(
                new ResourceCollection(getData(), uaa.getCostResources()),
                UserActionText.getInstance().getButtonText(uaa.getText()));
    button.addActionListener(
        ae -> {
          selectUserActionButton.setEnabled(false);
          doneButton.setEnabled(false);
          validUserActions = List.of();
          choice = uaa;
          parent.setVisible(false);
          release();
        });
    button.setEnabled(canPlayerAffordUserAction);
    userActionButtonPanel.add(
        button,
        new GridBagConstraints(
            1,
            row,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(topInset, 4, bottomInset, 4),
            0,
            0));

    final JLabel descriptionLabel = getActionDescriptionLabel(uaa);
    descriptionLabel.setEnabled(canPlayerAffordUserAction);
    userActionButtonPanel.add(
        descriptionLabel,
        new GridBagConstraints(
            2,
            row,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(topInset, 4, bottomInset, 0),
            0,
            0));

    row++;
  }

  return userActionButtonPanel;
}
 
Example 20
Source File: BrowserMenu.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void fillContent( JPanel contentPanel ) {
    contentPanel.setLayout( new GridBagLayout() );

    WebBrowser activeBrowser = selectedBrowser;
    ArrayList<ListItemImpl> defaultItems = new ArrayList<>( browsers.size() );
    ArrayList<ListItemImpl> mobileItems = new ArrayList<>( browsers.size() );
    ArrayList<ListItemImpl> phoneGapItems = new ArrayList<>( browsers.size() );
    ListItem selItem = null;
    for( WebBrowser browser : browsers ) {
        ListItemImpl item = new ListItemImpl( browser );
        if( null != activeBrowser && activeBrowser.getId().equals( browser.getId() ) ) {
            selItem = item;
        }
        if( BrowserFamilyId.PHONEGAP.equals( browser.getBrowserFamily() ) ) {
            phoneGapItems.add( item );
        } else if( browser.getBrowserFamily().isMobile() ) {
            mobileItems.add( item );
        } else {
            defaultItems.add( item );
        }
    }

    addSection( contentPanel, defaultItems, NbBundle.getMessage(BrowserMenu.class, "Header_BROWSER"), 0, null, mobileItems.isEmpty() && phoneGapItems.isEmpty() );
    addSection( contentPanel, mobileItems, NbBundle.getMessage(BrowserMenu.class, "Header_MOBILE"), 2, null, phoneGapItems.isEmpty() );
    addSection( contentPanel, phoneGapItems, NbBundle.getMessage(BrowserMenu.class, "Header_PHONEGAP"), 4, createConfigureButton(), true );

    JPanel panel = createBrighterPanel();
    JLabel label = createLabel( NbBundle.getMessage(BrowserMenu.class, "Hint_NB_Connector"));
    Color lightForeground = UIManager.getColor( "Nb.browser.picker.foreground.light" ); //NOI18N
    if( null != lightForeground )
        label.setForeground( lightForeground );
    if( windowsLaF ) {
        label.setEnabled( false );
        panel.setBorder( BorderFactory.createMatteBorder( 1, 0, 0, 0, windowsSeparatorColor));
    }
    label.setBorder( BorderFactory.createEmptyBorder( 16, 17, 5, 5));
    panel.add( label, BorderLayout.WEST );

    contentPanel.add( panel, new GridBagConstraints( 0, 1, GridBagConstraints.REMAINDER, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0), 0, 0 ));

    if( !defaultItems.isEmpty() && !mobileItems.isEmpty() && !windowsLaF ) {
        contentPanel.add( new JSeparator(JSeparator.VERTICAL),
                new GridBagConstraints( 1, 1, 1, 3, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0,0,0,0), 0, 0 ));
    }

    if( !mobileItems.isEmpty() && !phoneGapItems.isEmpty() && !windowsLaF ) {
        contentPanel.add( new JSeparator(JSeparator.VERTICAL),
                new GridBagConstraints( 3, 1, 1, 3, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.VERTICAL, new Insets(0,0,0,0), 0, 0 ));
    }

    if( !phoneGapItems.isEmpty() ) {
        contentPanel.add( createLabel( NbBundle.getMessage(BrowserMenu.class, "Hint_PhoneGap")),
                new GridBagConstraints( 0, 4, GridBagConstraints.REMAINDER, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10,17,10,10), 0, 0 ));
    }

    if( null != selItem )
        selModel.setSelectedItem( selItem );
    selModel.addChangeListener( this );
}