Java Code Examples for javax.swing.JLabel.LEADING

The following are Jave code examples for showing how to use LEADING of the javax.swing.JLabel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: ProbePresenter.java   View Source Code Vote up 5 votes
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 2
Project: incubator-netbeans   File: ToggleButtonMenuItem.java   View Source Code Vote up 5 votes
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 3
Project: incubator-netbeans   File: FieldsBrowserControllerUI.java   View Source Code Vote up 4 votes
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;
        }
    }
 
Example 4
Project: incubator-netbeans   File: ReferencesBrowserControllerUI.java   View Source Code Vote up 4 votes
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 5
Project: incubator-netbeans   File: ProjectsSelector.java   View Source Code Vote up 4 votes
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 6
Project: incubator-netbeans   File: ClassMethodSelector.java   View Source Code Vote up 4 votes
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);
}