Java Code Examples for javax.swing.JLabel#LEADING

The following examples show how to use javax.swing.JLabel#LEADING . 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: ViewElementString.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
public ViewElementString(RobotOverlord ro,StringEntity e) {
	super(ro);
	this.e=e;

	e.addObserver(this);
	
	field = new FocusTextField(20);
	field.setText(e.get());
	field.getDocument().addDocumentListener(this);
	field.addFocusListener(this);
	
	JLabel label=new JLabel(e.getName(),JLabel.LEADING);
	label.setLabelFor(field);

	panel.setLayout(new BorderLayout());
	panel.add(label,BorderLayout.LINE_START);
	panel.add(field,BorderLayout.LINE_END);
}
 
Example 2
Source File: ViewElementSlider.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
public ViewElementSlider(RobotOverlord ro,IntEntity e,int top,int bottom) {
	super(ro);
	this.e=e;

	e.addObserver(this);
	
	field = new JSlider();
	field.setMaximum(top);
	field.setMinimum(bottom);
	field.setMinorTickSpacing(1);
	field.setValue(e.get());
	field.addChangeListener(this);
	field.addFocusListener(this);

	JLabel label = new JLabel(e.getName(),JLabel.LEADING);
	value = new JLabel(Integer.toString(field.getValue()),JLabel.RIGHT);
	Dimension dim = new Dimension(30,1);
	value.setMinimumSize(dim);
	value.setPreferredSize(dim);
	value.setMaximumSize(dim);
	
	panel.setLayout(new BorderLayout());
	panel.add(label,BorderLayout.LINE_START);
	panel.add(field,BorderLayout.CENTER);
	panel.add(value,BorderLayout.LINE_END);
}
 
Example 3
Source File: ProbePresenter.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public ProbePresenter(TracerProbe p, TracerProbeDescriptor d) {
        super(d.getProbeName(), d.getProbeIcon(), JLabel.LEADING);
        
        // --- ToolTips support
        // Note: cannot use setToolTipText here, breaks mouseListener on parent
//        setToolTipText(d.getProbeDescription());
        // Let's store the tooltip in client property and resolve it from parent
        putClientProperty("ToolTipHelper", d.getProbeDescription()); // NOI18N
        // ---
        
        setIconTextGap(7);
        setBorder(BorderFactory.createCompoundBorder(
                    BorderFactory.createMatteBorder(0, 1, 1, 1, Color.LIGHT_GRAY),
                    BorderFactory.createEmptyBorder(5, 10, 5, 10)
                ));
    }
 
Example 4
Source File: ViewElementComboBox.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
public ViewElementComboBox(RobotOverlord ro,IntEntity e,String [] listOptions) {
	super(ro);
	this.e=e;
	
	e.addObserver(this);
	
	field = new JComboBox<String>(listOptions);
	field.setSelectedIndex(e.get());
	field.addActionListener(this);
	field.addFocusListener(this);

	JLabel label=new JLabel(e.getName(),JLabel.LEADING);
	label.setLabelFor(field);

	panel.setLayout(new BorderLayout());
	panel.setBorder(new EmptyBorder(0,0,0,1));
	panel.add(label,BorderLayout.LINE_START);
	panel.add(field,BorderLayout.LINE_END);
}
 
Example 5
Source File: ViewElementSliderDouble.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
public ViewElementSliderDouble(RobotOverlord ro,DoubleEntity e,int top,int bottom) {
	super(ro);
	this.e=e;

	e.addObserver(this);
	
	field = new JSlider();
	field.setMaximum(top);
	field.setMinimum(bottom);
	field.setMinorTickSpacing(1);
	field.setValue((int)Math.floor(e.get()));
	field.addChangeListener(this);
	field.addFocusListener(this);

	JLabel label = new JLabel(e.getName(),JLabel.LEADING);
	value = new JLabel(Integer.toString(field.getValue()),JLabel.RIGHT);
	Dimension dim = new Dimension(30,1);
	value.setMinimumSize(dim);
	value.setPreferredSize(dim);
	value.setMaximumSize(dim);
	
	panel.setLayout(new BorderLayout());
	panel.add(label,BorderLayout.LINE_START);
	panel.add(field,BorderLayout.CENTER);
	panel.add(value,BorderLayout.LINE_END);
}
 
Example 6
Source File: PluggableTreeTableView.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
PluginContainer(HeapViewPlugin plugin, final PluginPresenter pluginPresenter) {
    super(new BorderLayout());
    
    this.plugin = plugin;
    
    JButton closeButton = CloseButton.create(new Runnable() {
        public void run() { pluginPresenter.setSelected(false); }
    });
    closeButton.setFocusable(true);
    
    JPanel detailHeader = new JPanel(null);
    detailHeader.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, SEPARATOR_COLOR));
    detailHeader.setLayout(new BoxLayout(detailHeader, BoxLayout.LINE_AXIS));
    detailHeader.setBackground(UIUtils.getDarker(UIUtils.getProfilerResultsBackground()));
    JLabel captionL = new JLabel(plugin.getName(), plugin.getIcon(), JLabel.LEADING);
    captionL.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    detailHeader.add(captionL);            
    detailHeader.add(Box.createGlue());
    detailHeader.add(closeButton);
    
    add(detailHeader, BorderLayout.NORTH);
    setVisible(pluginPresenter.isSelected());
}
 
Example 7
Source File: ViewElementColor.java    From Robot-Overlord-App with GNU General Public License v2.0 6 votes vote down vote up
private JSlider addField(float value,JPanel parent,String labelName,GridBagConstraints gbc) {
	JSlider field = new JSlider();
	field.setMaximum(255);
	field.setMinimum(0);
	field.setMinorTickSpacing(1);
	field.setValue((int)(value*255));
	field.addChangeListener(this);
	field.addFocusListener(this);

	JLabel label = new JLabel(labelName,JLabel.LEADING);
	
	JPanel panel = new JPanel(new BorderLayout());
	panel.add(label,BorderLayout.LINE_START);
	panel.add(field,BorderLayout.LINE_END);
	
	parent.add(panel,gbc);
	
	return field;
}
 
Example 8
Source File: NodeObjectsView.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private void initUI() {
    HeapViewerRenderer renderer = objectsView.getNodeRenderer(viewNode);
    name = renderer.getShortName();
    description = renderer.toString();
    icon = renderer.getIcon();
    
    toolbar = ProfilerToolbar.create(false);
    
    toolbar.addSpace(3);
    JLabel nodePresenter = new JLabel(name, icon, JLabel.LEADING);
    nodePresenter.setToolTipText(description);
    toolbar.add(nodePresenter);
    toolbar.addSpace(5);
    
    if (objectsView.hasPlugins()) {
        toolbar.addSeparator();
        toolbar.addSpace(5);

        toolbar.add(new GrayLabel(Bundle.NodeObjectsView_Details()));
        toolbar.addSpace(2);
        
        toolbar.add(objectsView.getToolbar());
    }
    
    component = new ViewContainer(objectsView.getComponent(), viewNode);
    
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            objectsView.selectNode(viewNode);
            objectsView.getComponent().requestFocusInWindow();
        }
    });
}
 
Example 9
Source File: JTitlePanel.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Constructs a titled panel.
 *
 * @param title the title
 * @param content the JComponent that contains the content
 * @param outerBorder the outer border
 */
public JTitlePanel(String title, Icon icon, JComponent content, Border outerBorder) {
    setLayout(new BorderLayout());

    label = new JLabel(title, icon, JLabel.LEADING);
    label.setForeground(Color.WHITE);

    GradientPanel titlePanel = new GradientPanel(Color.BLACK);
    titlePanel.setLayout(new BorderLayout());
    titlePanel.add(label, BorderLayout.WEST);
    int borderOffset = 2;
    if(icon == null) {
    	borderOffset += 1;
    }
    titlePanel.setBorder(BorderFactory.createEmptyBorder(borderOffset, 4, borderOffset, 1));
    add(titlePanel, BorderLayout.NORTH);
    
    JPanel northPanel = new JPanel();
    northPanel.setLayout(new BorderLayout());
    northPanel.add(content,BorderLayout.NORTH);
    northPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    add(northPanel, BorderLayout.CENTER);

    if (outerBorder == null) {
        setBorder(BorderFactory.createLineBorder(Color.GRAY));
    } else {
        setBorder(BorderFactory.createCompoundBorder(outerBorder,
                BorderFactory.createLineBorder(Color.GRAY)));
    }
}
 
Example 10
Source File: ToggleButtonMenuItem.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public ToggleButtonMenuItem(String text, Icon icon) {
    super(sizeText(text));
    setLayout(null);

    selectedIcon = createSelectedIcon(icon);
    unselectedIcon = createUnselectedIcon(icon);

    label = new JLabel(unselectedIcon, JLabel.LEADING);
    add(label, BorderLayout.WEST);
}
 
Example 11
Source File: ToggleButtonMenuItem.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public ToggleButtonMenuItem(String text, Icon icon) {
    super(sizeText(text));
    setLayout(null);

    selectedIcon = createSelectedIcon(icon);
    unselectedIcon = createUnselectedIcon(icon);

    label = new JLabel(unselectedIcon, JLabel.LEADING);
    add(label, BorderLayout.WEST);
}
 
Example 12
Source File: ViewElementFilename.java    From Robot-Overlord-App with GNU General Public License v2.0 5 votes vote down vote up
public ViewElementFilename(RobotOverlord ro,StringEntity e) {
	super(ro);
	this.e=e;
	
	//this.setBorder(BorderFactory.createLineBorder(Color.RED));
			
	field = new JTextField(15);
	field.setEditable(false);
	field.setText(e.get());
	field.setMargin(new Insets(1,0,1,0));
	//pathAndFileName.setBorder(BorderFactory.createLoweredBevelBorder());
	
	JLabel label=new JLabel(e.getName(),JLabel.LEADING);
	label.setLabelFor(field);

	JButton choose = new JButton("...");
	choose.addActionListener(this);
	choose.setMargin(new Insets(0, 5, 0, 5));
	choose.addFocusListener(this);
	
	panel.setLayout(new GridBagLayout());

	GridBagConstraints gbc = new GridBagConstraints();
	gbc.weightx=0;
	gbc.gridy=0;
	gbc.fill = GridBagConstraints.HORIZONTAL;
	//gbc.gridheight = GridBagConstraints.REMAINDER;
	gbc.insets.right=5;
	panel.add(label,gbc);
	gbc.weightx=1;
	gbc.insets.left=0;
	gbc.insets.right=0;
	panel.add(field,gbc);
	gbc.weightx=0;
	panel.add(choose,gbc);
}
 
Example 13
Source File: ProbePresenter.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public ProbePresenter(TracerProbe p, TracerProbeDescriptor d) {
    super(d.getProbeName(), d.getProbeIcon(), JLabel.LEADING);
    
    // --- ToolTips support
    // Let's store the tooltip in client property and resolve it from parent
    putClientProperty("ToolTipHelper", d.getProbeDescription()); // NOI18N
    // ---
    
    setIconTextGap(7);
    setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createMatteBorder(0, 0, 1, 1, Color.LIGHT_GRAY),
                BorderFactory.createEmptyBorder(5, 10, 5, 10)
            ));
}
 
Example 14
Source File: ClassMethodSelector.java    From netbeans with Apache License 2.0 4 votes vote down vote up
ProjectSelector() {
    projectListModel = new DefaultListModel();
    final FilteredListModel<Lookup.Provider> filteredProjects = new FilteredListModel<Lookup.Provider>(projectListModel) {
        protected boolean matchesFilter(Lookup.Provider proj, GenericFilter filter) {
            return filter.passes(ProjectUtilities.getDisplayName(proj));
        }
    };
    final HintRenderer hintRenderer = new HintRenderer();
    projectList = new JList(filteredProjects) {
        public Dimension getPreferredScrollableViewportSize() {
            Dimension dim = super.getPreferredScrollableViewportSize();
            dim.width = LIST_WIDTH;
            return dim;
        }
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            
            if (getModel().getSize() == 0) {
                hintRenderer.setup(true, getSize());
                hintRenderer.paint(g);
            }
        }
    };
    projectList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    filteredProjects.setSelectionModel(projectList.getSelectionModel());
    projectList.setCellRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            DefaultListCellRenderer c = (DefaultListCellRenderer)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            Lookup.Provider val = (Lookup.Provider)value;
            c.setText(ProjectUtilities.getDisplayName(val));
            c.setIcon(ProjectUtilities.getIcon(val));
            return c;
        }
    });
    projectList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) projectSelected();
        }
    });
    
    JLabel projectsLabel = new JLabel(Bundle.ClassMethodSelector_capProjects(), JLabel.LEADING);
    projectsLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    JToolBar projectsTools = new FilteringToolbar(Bundle.ClassMethodSelector_lblFilterItems()) {
        protected void filterChanged() {
            filteredProjects.setFilter(getFilter());
        }
    };
    
    setOpaque(false);
    setLayout(new BorderLayout());
    add(projectsLabel, BorderLayout.NORTH);
    add(new JScrollPane(projectList), BorderLayout.CENTER);
    add(projectsTools, BorderLayout.SOUTH);
}
 
Example 15
Source File: TablesSelector.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void populatePopup() {
    JPanel content = new JPanel(new BorderLayout());
    
    JLabel hint = new JLabel(SELECT_TABLES, JLabel.LEADING);
    hint.setBorder(BorderFactory.createEmptyBorder(0, 0, 6, 0));
    content.add(hint, BorderLayout.NORTH);

    final SelectedTablesModel tablesModel = new SelectedTablesModel();
    final ProfilerTable tablesTable = new ProfilerTable(tablesModel, true, false, null);
    tablesTable.setColumnToolTips(new String[] {
        COLUMN_SELECTED_TOOLTIP,
        COLUMN_TABLE_TOOLTIP });
    tablesTable.setMainColumn(1);
    tablesTable.setFitWidthColumn(1);
    tablesTable.setDefaultSortOrder(1, SortOrder.ASCENDING);
    tablesTable.setSortColumn(1);
    tablesTable.setFixedColumnSelection(0); // #268298 - make sure SPACE always hits the Boolean column
    tablesTable.setColumnRenderer(0, new CheckBoxRenderer());
    LabelRenderer projectRenderer = new LabelRenderer();
    tablesTable.setColumnRenderer(1, projectRenderer);
    int w = new JLabel(tablesTable.getColumnName(0)).getPreferredSize().width;
    tablesTable.setDefaultColumnWidth(0, w + 15);
    int h = tablesTable.getRowHeight() * 8;
    h += tablesTable.getTableHeader().getPreferredSize().height;
    projectRenderer.setText("A LONGEST EXPECTED TABLE NAME A LONGEST EXPECTED TABLE NAME"); // NOI18N
    Dimension prefSize = new Dimension(w + projectRenderer.getPreferredSize().width, h);
    tablesTable.setPreferredScrollableViewportSize(prefSize);
    ProfilerTableContainer tableContainer = new ProfilerTableContainer(tablesTable, true, null);
    JPanel tableContent = new JPanel(new BorderLayout());
    tableContent.setBorder(BorderFactory.createEmptyBorder(0, 0, 4, 0));
    tableContent.add(tableContainer, BorderLayout.CENTER);
    content.add(tableContent, BorderLayout.CENTER);

    JToolBar controls = new FilteringToolbar(FILTER_TABLES) {
        protected void filterChanged() {
            if (isAll()) tablesTable.setRowFilter(null);
            else tablesTable.setRowFilter(new RowFilter() {
                public boolean include(RowFilter.Entry entry) {
                    return passes(entry.getStringValue(1));
                }
            });
        }
    };
    
    controls.add(Box.createHorizontalStrut(2));
    controls.addSeparator();
    controls.add(Box.createHorizontalStrut(3));
    
    selectAll = new SmallButton(" " + ACT_SELECT_ALL + " ") { // NOI18N
        protected void fireActionPerformed(ActionEvent e) {
            super.fireActionPerformed(e);
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    selected.clear();
                    tablesModel.fireTableDataChanged();
                    doSelectionChanged(selected);
                }
            });
        }
    };
    controls.add(selectAll);
    unselectAll = new SmallButton(" " + ACT_UNSELECT_ALL + " ") { // NOI18N
        protected void fireActionPerformed(ActionEvent e) {
            super.fireActionPerformed(e);
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    selected.clear();
                    selected.addAll(Arrays.asList(tables));
                    tablesModel.fireTableDataChanged();
                    doSelectionChanged(selected);
                }
            });
        }
    };
    controls.add(unselectAll);

    content.add(controls, BorderLayout.SOUTH);

    panel = content;
    
    updateSelectionButtons();
}
 
Example 16
Source File: ProjectsSelector.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void populatePopup() {
    JPanel content = new JPanel(new BorderLayout());
    
    JLabel hint = new JLabel(Bundle.ProjectsSelector_selectProjects(), JLabel.LEADING);
    hint.setBorder(BorderFactory.createEmptyBorder(0, 0, 6, 0));
    content.add(hint, BorderLayout.NORTH);

    final SelectedProjectsModel projectsModel = new SelectedProjectsModel();
    final ProfilerTable projectsTable = new ProfilerTable(projectsModel, true, false, null);
    projectsTable.setColumnToolTips(new String[] {
        Bundle.ProjectsSelector_columnSelectedToolTip(),
        Bundle.ProjectsSelector_columnProjectToolTip() });
    projectsTable.setMainColumn(1);
    projectsTable.setFitWidthColumn(1);
    projectsTable.setDefaultSortOrder(1, SortOrder.ASCENDING);
    projectsTable.setSortColumn(1);
    projectsTable.setFixedColumnSelection(0); // #268298 - make sure SPACE always hits the Boolean column
    projectsTable.setColumnRenderer(0, new CheckBoxRenderer());
    LabelRenderer projectRenderer = new ProjectRenderer();
    projectsTable.setColumnRenderer(1, projectRenderer);
    int w = new JLabel(projectsTable.getColumnName(0)).getPreferredSize().width;
    projectsTable.setDefaultColumnWidth(0, w + 15);
    int h = projectsTable.getRowHeight() * 8;
    h += projectsTable.getTableHeader().getPreferredSize().height;
    projectRenderer.setText("A longest expected project name A longest expected project name"); // NOI18N
    Dimension prefSize = new Dimension(w + projectRenderer.getPreferredSize().width, h);
    projectsTable.setPreferredScrollableViewportSize(prefSize);
    ProfilerTableContainer tableContainer = new ProfilerTableContainer(projectsTable, true, null);
    JPanel tableContent = new JPanel(new BorderLayout());
    tableContent.setBorder(BorderFactory.createEmptyBorder(0, 0, 4, 0));
    tableContent.add(tableContainer, BorderLayout.CENTER);
    content.add(tableContent, BorderLayout.CENTER);

    JToolBar controls = new FilteringToolbar(Bundle.ProjectsSelector_filterProjects()) {
        protected void filterChanged() {
            if (isAll()) projectsTable.setRowFilter(null);
            else projectsTable.setRowFilter(new RowFilter() {
                public boolean include(RowFilter.Entry entry) {
                    return passes(entry.getStringValue(1));
                }
            });
        }
    };

    content.add(controls, BorderLayout.SOUTH);

    panel = content;
}
 
Example 17
Source File: ReferencesBrowserControllerUI.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void initColumnsData() {
        columnWidths = new int[columnCount - 1]; // Width of the first column fits to width
        columnNames = new String[columnCount];
        columnToolTips = new String[columnCount];
        columnRenderers = new TableCellRenderer[columnCount];

        columnNames[0] = Bundle.ReferencesBrowserControllerUI_FieldColumnName();
        columnToolTips[0] = Bundle.ReferencesBrowserControllerUI_FieldColumnDescr();

        columnNames[1] = Bundle.ReferencesBrowserControllerUI_TypeColumnName();
        columnToolTips[1] = Bundle.ReferencesBrowserControllerUI_TypeColumnDescr();

        columnNames[2] = Bundle.ReferencesBrowserControllerUI_FullTypeColumnName();
        columnToolTips[2] = Bundle.ReferencesBrowserControllerUI_FullTypeColumnDescr();

        columnNames[3] = Bundle.ReferencesBrowserControllerUI_ValueColumnName();
        columnToolTips[3] = Bundle.ReferencesBrowserControllerUI_ValueColumnDescr();

        columnNames[4] = Bundle.ReferencesBrowserControllerUI_SizeColumnName();
        columnToolTips[4] = Bundle.ReferencesBrowserControllerUI_SizeColumnDescr();

        if (retainedSizeSupported) {
            columnNames[5] = Bundle.ReferencesBrowserControllerUI_RetainedSizeColumnName();
            columnToolTips[5] = Bundle.ReferencesBrowserControllerUI_RetainedSizeColumnDescr();
        }

        int unitWidth = getFontMetrics(getFont()).charWidth('W'); // NOI18N // initial width of data columns

//        FieldTreeCellRenderer treeCellRenderer = new FieldTreeCellRenderer();
//        treeCellRenderer.setLeafIcon(null);
//        treeCellRenderer.setClosedIcon(null);
//        treeCellRenderer.setOpenIcon(null);

        LabelTableCellRenderer dataCellRendererL = new LabelTableCellRenderer(JLabel.LEADING);
        LabelTableCellRenderer dataCellRendererT = new LabelTableCellRenderer(JLabel.TRAILING);

        // method / class / package name
        columnRenderers[0] = null;

        columnWidths[1 - 1] = unitWidth * 18;
        columnRenderers[1] = dataCellRendererL;

        columnWidths[2 - 1] = unitWidth * 28;
        columnRenderers[2] = dataCellRendererL;

        columnWidths[3 - 1] = unitWidth * 20;
        columnRenderers[3] = new FieldTableCellRenderer();

        columnWidths[4 - 1] = unitWidth * 7;
        columnRenderers[4] = dataCellRendererT;

        if (retainedSizeSupported) {
            columnWidths[5 - 1] = unitWidth * 7;
            columnRenderers[5] = dataCellRendererT;
        }
    }
 
Example 18
Source File: ClassMethodSelector.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
ProjectSelector() {
    projectListModel = new DefaultListModel();
    final FilteredListModel<Lookup.Provider> filteredProjects = new FilteredListModel<Lookup.Provider>(projectListModel) {
        protected boolean matchesFilter(Lookup.Provider proj, GenericFilter filter) {
            return filter.passes(ProjectUtilities.getDisplayName(proj));
        }
    };
    final HintRenderer hintRenderer = new HintRenderer();
    projectList = new JList(filteredProjects) {
        public Dimension getPreferredScrollableViewportSize() {
            Dimension dim = super.getPreferredScrollableViewportSize();
            dim.width = LIST_WIDTH;
            return dim;
        }
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            
            if (getModel().getSize() == 0) {
                hintRenderer.setup(true, getSize());
                hintRenderer.paint(g);
            }
        }
    };
    projectList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    filteredProjects.setSelectionModel(projectList.getSelectionModel());
    projectList.setCellRenderer(new DefaultListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            DefaultListCellRenderer c = (DefaultListCellRenderer)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            Lookup.Provider val = (Lookup.Provider)value;
            c.setText(ProjectUtilities.getDisplayName(val));
            c.setIcon(ProjectUtilities.getIcon(val));
            return c;
        }
    });
    projectList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) projectSelected();
        }
    });
    
    JLabel projectsLabel = new JLabel(Bundle.ClassMethodSelector_capProjects(), JLabel.LEADING);
    projectsLabel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));
    JToolBar projectsTools = new FilteringToolbar(Bundle.ClassMethodSelector_lblFilterItems()) {
        protected void filterChanged() {
            filteredProjects.setFilter(getFilter());
        }
    };
    
    setOpaque(false);
    setLayout(new BorderLayout());
    add(projectsLabel, BorderLayout.NORTH);
    add(new JScrollPane(projectList), BorderLayout.CENTER);
    add(projectsTools, BorderLayout.SOUTH);
}
 
Example 19
Source File: TablesSelector.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void populatePopup() {
    JPanel content = new JPanel(new BorderLayout());
    
    JLabel hint = new JLabel(SELECT_TABLES, JLabel.LEADING);
    hint.setBorder(BorderFactory.createEmptyBorder(0, 0, 6, 0));
    content.add(hint, BorderLayout.NORTH);

    final SelectedTablesModel tablesModel = new SelectedTablesModel();
    final ProfilerTable tablesTable = new ProfilerTable(tablesModel, true, false, null);
    tablesTable.setColumnToolTips(new String[] {
        COLUMN_SELECTED_TOOLTIP,
        COLUMN_TABLE_TOOLTIP });
    tablesTable.setMainColumn(1);
    tablesTable.setFitWidthColumn(1);
    tablesTable.setDefaultSortOrder(1, SortOrder.ASCENDING);
    tablesTable.setSortColumn(1);
    tablesTable.setFixedColumnSelection(0); // #268298 - make sure SPACE always hits the Boolean column
    tablesTable.setColumnRenderer(0, new CheckBoxRenderer());
    LabelRenderer projectRenderer = new LabelRenderer();
    tablesTable.setColumnRenderer(1, projectRenderer);
    int w = new JLabel(tablesTable.getColumnName(0)).getPreferredSize().width;
    tablesTable.setDefaultColumnWidth(0, w + 15);
    int h = tablesTable.getRowHeight() * 8;
    h += tablesTable.getTableHeader().getPreferredSize().height;
    projectRenderer.setText("A LONGEST EXPECTED TABLE NAME A LONGEST EXPECTED TABLE NAME"); // NOI18N
    Dimension prefSize = new Dimension(w + projectRenderer.getPreferredSize().width, h);
    tablesTable.setPreferredScrollableViewportSize(prefSize);
    ProfilerTableContainer tableContainer = new ProfilerTableContainer(tablesTable, true, null);
    JPanel tableContent = new JPanel(new BorderLayout());
    tableContent.setBorder(BorderFactory.createEmptyBorder(0, 0, 4, 0));
    tableContent.add(tableContainer, BorderLayout.CENTER);
    content.add(tableContent, BorderLayout.CENTER);

    JToolBar controls = new FilteringToolbar(FILTER_TABLES) {
        protected void filterChanged() {
            if (isAll()) tablesTable.setRowFilter(null);
            else tablesTable.setRowFilter(new RowFilter() {
                public boolean include(RowFilter.Entry entry) {
                    return passes(entry.getStringValue(1));
                }
            });
        }
    };
    
    controls.add(Box.createHorizontalStrut(2));
    controls.addSeparator();
    controls.add(Box.createHorizontalStrut(3));
    
    selectAll = new SmallButton(" " + ACT_SELECT_ALL + " ") { // NOI18N
        protected void fireActionPerformed(ActionEvent e) {
            super.fireActionPerformed(e);
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    selected.clear();
                    tablesModel.fireTableDataChanged();
                    doSelectionChanged(selected);
                }
            });
        }
    };
    controls.add(selectAll);
    unselectAll = new SmallButton(" " + ACT_UNSELECT_ALL + " ") { // NOI18N
        protected void fireActionPerformed(ActionEvent e) {
            super.fireActionPerformed(e);
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    selected.clear();
                    selected.addAll(Arrays.asList(tables));
                    tablesModel.fireTableDataChanged();
                    doSelectionChanged(selected);
                }
            });
        }
    };
    controls.add(unselectAll);

    content.add(controls, BorderLayout.SOUTH);

    panel = content;
    
    updateSelectionButtons();
}
 
Example 20
Source File: FieldsBrowserControllerUI.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void initColumnsData() {
        columnWidths = new int[columnCount - 1]; // Width of the first column fits to width
        columnNames = new String[columnCount];
        columnToolTips = new String[columnCount];
        columnRenderers = new TableCellRenderer[columnCount];

        columnNames[0] = Bundle.FieldsBrowserControllerUI_FieldColumnName();
        columnToolTips[0] = Bundle.FieldsBrowserControllerUI_FieldColumnDescr();

        columnNames[1] = Bundle.FieldsBrowserControllerUI_TypeColumnName();
        columnToolTips[1] = Bundle.FieldsBrowserControllerUI_TypeColumnDescr();

        columnNames[2] = Bundle.FieldsBrowserControllerUI_FullTypeColumnName();
        columnToolTips[2] = Bundle.FieldsBrowserControllerUI_FullTypeColumnDescr();

        columnNames[3] = Bundle.FieldsBrowserControllerUI_ValueColumnName();
        columnToolTips[3] = Bundle.FieldsBrowserControllerUI_ValueColumnDescr();

        columnNames[4] = Bundle.FieldsBrowserControllerUI_SizeColumnName();
        columnToolTips[4] = Bundle.FieldsBrowserControllerUI_SizeColumnDescr();

        if (retainedSizeSupported) {
            columnNames[5] = Bundle.FieldsBrowserControllerUI_RetainedSizeColumnName();
            columnToolTips[5] = Bundle.FieldsBrowserControllerUI_RetainedSizeColumnDescr();
        }

        int unitWidth = getFontMetrics(getFont()).charWidth('W'); // NOI18N // initial width of data columns

//        FieldTreeCellRenderer treeCellRenderer = new FieldTreeCellRenderer(false);
//        treeCellRenderer.setLeafIcon(null);
//        treeCellRenderer.setClosedIcon(null);
//        treeCellRenderer.setOpenIcon(null);

        LabelTableCellRenderer dataCellRendererL = new LabelTableCellRenderer(JLabel.LEADING);
        LabelTableCellRenderer dataCellRendererT = new LabelTableCellRenderer(JLabel.TRAILING);

        // method / class / package name
        columnRenderers[0] = null;

        columnWidths[1 - 1] = unitWidth * 18;
        columnRenderers[1] = dataCellRendererL;

        columnWidths[2 - 1] = unitWidth * 28;
        columnRenderers[2] = dataCellRendererL;

        columnWidths[3 - 1] = unitWidth * 20;
        columnRenderers[3] = new FieldTableCellRenderer();

        columnWidths[4 - 1] = unitWidth * 7;
        columnRenderers[4] = dataCellRendererT;

        if (retainedSizeSupported) {
            columnWidths[5 - 1] = unitWidth * 7;
            columnRenderers[5] = dataCellRendererT;
        }
    }