Java Code Examples for javax.swing.JComponent#setVisible()

The following examples show how to use javax.swing.JComponent#setVisible() . These examples are extracted from open source projects. 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 Project: pumpernickel   File: MockComponent.java    License: MIT License 6 votes vote down vote up
/**
 * Temporarily massage this component so it is visible, enabled, unselected,
 * unfocused, etc.
 */
private void storeState(JComponent c) {
	if (c instanceof AbstractButton) {
		AbstractButton b = (AbstractButton) c;
		b.putClientProperty(WAS_SELECTED, new Boolean(b.isSelected()));
		b.putClientProperty(WAS_FOCUS_PAINTED, new Boolean(b.isSelected()));
		b.setSelected(false);
		b.setFocusPainted(false);
	}
	if (c.isEnabled() == false) {
		c.putClientProperty(WAS_ENABLED, new Boolean(c.isEnabled()));
		c.setEnabled(true);
	}
	if (c.isVisible() == false) {
		c.putClientProperty(WAS_VISIBLE, new Boolean(c.isVisible()));
		c.setVisible(true);
	}
	for (int a = 0; a < c.getComponentCount(); a++) {
		if (c.getComponent(a) instanceof JComponent) {
			storeState((JComponent) c.getComponent(a));
		}
	}
}
 
Example 2
Source Project: seaglass   File: SeaGlassRootPaneUI.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets the window title pane -- the JComponent used to provide a plaf a way
 * to override the native operating system's window title pane with one
 * whose look and feel are controlled by the plaf. The plaf creates and sets
 * this value; the default is null, implying a native operating system
 * window title pane.
 *
 * @param root      content the <code>JComponent</code> to use for the
 *                  window title pane.
 * @param titlePane the SeaGlassTitlePane.
 */
private void setTitlePane(JRootPane root, JComponent titlePane) {
    JLayeredPane layeredPane  = root.getLayeredPane();
    JComponent   oldTitlePane = getTitlePane();

    if (oldTitlePane != null) {
        oldTitlePane.setVisible(false);
        layeredPane.remove(oldTitlePane);
    }

    if (titlePane != null) {
        layeredPane.add(titlePane, JLayeredPane.FRAME_CONTENT_LAYER);
        titlePane.setVisible(true);
    }

    this.titlePane = titlePane;
}
 
Example 3
Source Project: netbeans   File: TabbedPane.java    License: Apache License 2.0 6 votes vote down vote up
private void switchTab( int tabIndex ) {
    if( !tabAdded[tabIndex] ) {
        tabContent.add( tabs[tabIndex], new GridBagConstraints(tabIndex, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0, 0) ); //NOI18N
        tabAdded[tabIndex] = true;
    }
    if( selTabIndex >= 0 ) {
        buttons[selTabIndex].setSelected(false);
    }
    JComponent compToShow = tabs[tabIndex];
    JComponent compToHide = selTabIndex >= 0 ? tabs[selTabIndex] : null;
    selTabIndex = tabIndex;
    buttons[selTabIndex].setSelected(true);

    if( null != compToHide )
        compToHide.setVisible( false );
    
    compToShow.setVisible( true );
    compToShow.requestFocusInWindow();
}
 
Example 4
Source Project: netbeans   File: DataView.java    License: Apache License 2.0 6 votes vote down vote up
public void activateSearch() {
    JComponent panel = getBottomPanel();
    
    if (searchPanel == null) {
        SearchUtils.TreeHelper searchHelper = getSearchHelper();
        if (searchHelper == null) searchPanel = SearchUtils.createSearchPanel(getResultsComponent(), getSearchOptions());
        else searchPanel = SearchUtils.createSearchPanel((ProfilerTreeTable)getResultsComponent(), searchHelper, getSearchOptions());
        panel.add(searchPanel);
        Container parent = panel.getParent();
        parent.invalidate();
        parent.revalidate();
        parent.repaint();
    }
    
    panel.setVisible(true);
    
    searchPanel.setVisible(true);
    searchPanel.requestFocusInWindow();
}
 
Example 5
Source Project: visualvm   File: DataView.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void activateFilter() {
    JComponent panel = getBottomPanel();
    
    if (filterPanel == null) {
        filterPanel = FilterUtils.createFilterPanel(getResultsComponent(), getExcludesFilter(), getFilterOptions());
        panel.add(filterPanel);
        Container parent = panel.getParent();
        parent.invalidate();
        parent.revalidate();
        parent.repaint();
    }
    
    panel.setVisible(true);
    
    filterPanel.setVisible(true);
    filterPanel.requestFocusInWindow();
}
 
Example 6
Source Project: pumpernickel   File: CustomizedToolbar.java    License: MIT License 6 votes vote down vote up
public void dragExit(DropTargetEvent dte) {
	if (draggingDefaults) {
		return;
	}
	updateContents(getContents(new Point(-1000, -1000)));
	if (draggingComponent != null) {
		JComponent theComponent = getComponent(draggingComponent);
		Rectangle r = getLayout().getDestinationMap(
				CustomizedToolbar.this).get(theComponent);
		if (r != null) {
			theComponent.setBounds(r);
		}
		if (hideActiveComponents)
			theComponent.setVisible(true);
	}
}
 
Example 7
private void activateFilter() {
    JComponent panel = getBottomPanel();

    if (filterPanel == null) {
        filterPanel = FilterUtils.createFilterPanel(table, null);
        panel.add(filterPanel);
        Container parent = panel.getParent();
        parent.invalidate();
        parent.revalidate();
        parent.repaint();
    }

    panel.setVisible(true);

    filterPanel.setVisible(true);
    filterPanel.requestFocusInWindow();
}
 
Example 8
public MultiDiffPanelController (File file, Revision rev1, Revision rev2, int requestedRightLine) {
    this(null, rev1, rev2, true);
    diffViewPanel = new PlaceholderPanel();
    diffViewPanel.setComponent(getInfoPanelLoading());
    this.requestedRightLine = requestedRightLine;
    this.popupAllowed = false;
    replaceVerticalSplitPane(diffViewPanel);
    initToolbarButtons();
    initNextPrevActions();
    for (JComponent c : new JComponent[] { panel.tgbHeadVsIndex, panel.tgbHeadVsWorking, panel.tgbIndexVsWorking }) {
        c.setVisible(false);
    }
    // mimics refreshSetups()
    Setup s = new Setup(file, rev1, rev2, null);
    GitLocalFileNode fNode = new GitLocalFileNode(Git.getInstance().getRepositoryRoot(file), file);
    EditorCookie cookie = DiffUtils.getEditorCookie(s);
    s.setNode(new DiffLocalNode(fNode, s, cookie, Mode.HEAD_VS_WORKING_TREE));
    Map<File, Setup> localSetups = Collections.singletonMap(file, s);
    setSetups(localSetups, getCookiesFromSetups(localSetups));
    setDiffIndex(s, 0, false);
    dpt = new DiffPrepareTask(setups.values().toArray(new Setup[setups.size()]));
    prepareTask = RP.create(dpt);
    prepareTask.schedule(0);
}
 
Example 9
Source Project: netbeans   File: IssueTopComponent.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates new {@code IssueTopComponent}.
 */
public IssueTopComponent() {
    initComponents();
    instanceContent.add(getActionMap());
    associateLookup(new AbstractLookup(instanceContent));
    
    RepositoryRegistry.getInstance().addPropertyChangeListener(this);
    preparingLabel.setVisible(false);
    newButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            onNewClick();
        }
    });
    JComponent findBar = FindSupport.create(this).getFindBar();
    findBar.setVisible(false);
    issuePanel.add(findBar, BorderLayout.PAGE_END);
}
 
Example 10
public TitledPanel(JComponent titleComponent, JComponent bodyComponent, boolean isCollapsible, boolean isInitiallyCollapsed) {
    super(new BorderLayout());

    final JPanel titleArea = new JPanel(new BorderLayout());
    if (titleComponent != null) {
        titleArea.add(titleComponent, BorderLayout.WEST);
    }
    titleArea.add(getSeparator(), BorderLayout.CENTER);
    if (isCollapsible) {
        titleArea.add(getCollapseButton(bodyComponent, isInitiallyCollapsed), BorderLayout.EAST);
        bodyComponent.setVisible(!isInitiallyCollapsed);
    }
    add(titleArea, BorderLayout.NORTH);

    if (bodyComponent != null) {
        bodyComponent.setBorder(new EmptyBorder(0, 30, 0, 0));
        add(bodyComponent, BorderLayout.CENTER);
    }

    setBorder(new EmptyBorder(4, 8, 4, 8));
}
 
Example 11
Source Project: pumpernickel   File: CollapsibleContainer.java    License: MIT License 6 votes vote down vote up
protected void install() {
	midanimation.acquireUninterruptibly();
	try {
		Insets insets = getInsets();

		int x = insets.left;
		int y = insets.top;
		int width = getWidth() - insets.right - insets.left;

		for (int a = 0; a < components.size(); a++) {
			JComponent jc = components.get(a);
			if (visibleComponents.contains(jc)) {
				int h = heightMap.get(jc);
				jc.setBounds(x, y, width, h);
				jc.validate();
				y += h;
				jc.setVisible(true);
			} else {
				jc.setBounds(0, 0, 0, 0);
				jc.setVisible(false);
			}
		}
	} finally {
		midanimation.release();
	}
}
 
Example 12
Source Project: pumpernickel   File: CustomizedToolbar.java    License: MIT License 5 votes vote down vote up
public void drop(DropTargetDropEvent dtde) {
	if (draggingComponent == null) {
		dtde.rejectDrop();
	} else {

		if (draggingDefaults) {
			setContents(getDefaultContents());
		} else {
			Point p = dtde.getLocation();
			p = SwingUtilities.convertPoint(
					((DropTarget) dtde.getSource()).getComponent(), p,
					CustomizedToolbar.this);

			String[] contents = getContents(p);
			setContents(contents);
			dtde.acceptDrop(DnDConstants.ACTION_MOVE);
			JComponent theComponent = getComponent(draggingComponent);
			Rectangle r = getLayout().getDestinationMap(
					CustomizedToolbar.this).get(theComponent);
			if (r != null) {
				theComponent.setBounds(r);
			}
			if (hideActiveComponents)
				theComponent.setVisible(true);
		}
	}
	dtde.dropComplete(true);
}
 
Example 13
private void installInLayeredPane(JComponent component) {
    JLayeredPane layeredPane = getRootPane().getLayeredPane();
    layeredPane.add(component, JLayeredPane.PALETTE_LAYER, 20);
    Dimension size = component.getPreferredSize();
    component.setSize(size);
    component.setLocation((getWidth() - size.width) / 2,
            (getHeight() - size.height) / 2);
    component.revalidate();
    component.setVisible(true);
}
 
Example 14
Source Project: netbeans   File: StickyWindowSupport.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Add a sticky window to the editor.
 * @param window the JComponent to add to the editor
 */
public void addWindow(JComponent window) {
    Container container = jtc.getParent();
    if(container instanceof JLayeredPane) {
        JLayeredPane pane = (JLayeredPane) container;
        pane.add(window, JLayeredPane.PALETTE_LAYER);
        window.setVisible(true);
    }
}
 
Example 15
private JFrame prepareMainWindow(JFrame splash) {
	JFrame frame = MainFrame.prepare(splash);
	JComponent glassPane = DragLayer.get();
	frame.setGlassPane(glassPane);
	glassPane.setVisible(true);
	setupWindowWideListeners(frame);
	WindowUtils.watchFontSize(frame);

	return frame;
}
 
Example 16
private void showObjectsView() {
    JComponent c = objectsView.getComponent();
    if (c.isVisible()) return;
    
    c.setVisible(true);
    
    component.removeAll();
    component.add(c, BorderLayout.CENTER);
    
    mergedRequest = false;
    
    component.invalidate();
    component.revalidate();
    component.repaint();
}
 
Example 17
Source Project: scelight   File: SettingsGui.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Binds the visibility of the specified component to the specified {@link IBoolSetting} from the specified {@link ISettingsBean}.
 * 
 * @param comp component whose visibility to be bounded
 * @param setting setting to control the visibility of the component
 * @param settings settings bean storing the setting
 */
public static void bindVisibilityToSetting( final JComponent comp, final IBoolSetting setting, final ISettingsBean settings ) {
	final ISettingChangeListener scl = new ISettingChangeListener() {
		@Override
		public void valuesChanged( final ISettingChangeEvent event ) {
			if ( event.affected( setting ) )
				comp.setVisible( event.get( setting ) );
		}
	};
	addBindExecuteScl( scl, settings, setting.selfSet(), comp );
}
 
Example 18
public void setEval (Evaluation eval,
                     boolean barred,
                     boolean enabled)
{
    JComponent comp;

    if (sheet != null) {
        comp = button;
    } else {
        comp = field;
    }

    if (eval != null) {
        Evaluation.Failure failure = eval.failure;
        String text = eval.shape.toString();
        String tip = (failure != null) ? failure.toString()
                : null;

        if (sheet != null) {
            button.setEnabled(enabled);

            if (barred) {
                button.setBackground(Colors.EVALUATION_BARRED);
            } else {
                button.setBackground(null);
            }

            button.setText(text);
            button.setToolTipText(tip);
            button.setIcon(eval.shape.getDecoratedSymbol());
        } else {
            if (barred) {
                field.setBackground(Colors.EVALUATION_BARRED);
            } else {
                field.setBackground(null);
            }

            field.setText(text);
            field.setToolTipText(tip);
            field.setIcon(eval.shape.getDecoratedSymbol());
        }

        comp.setVisible(true);

        if (failure == null) {
            comp.setForeground(EVAL_GOOD_COLOR);
        } else {
            comp.setForeground(EVAL_SOSO_COLOR);
        }

        grade.setVisible(true);
        grade.setText(String.format("%.3f", eval.grade));
    } else {
        grade.setVisible(false);
        comp.setVisible(false);
    }
}
 
Example 19
public DownloadView(Download download) {

        initComponents();

        updateFonts(this, GUI_FONT, download.getMain_panel().getZoom_factor());

        translateLabels(this);

        _download = download;

        slots_spinner.setModel(new SpinnerNumberModel(_download.getMain_panel().getDefault_slots_down(), Download.MIN_WORKERS, Download.MAX_WORKERS, 1));

        ((JSpinner.DefaultEditor) slots_spinner.getEditor()).getTextField().setEditable(false);

        speed_label.setForeground(new Color(0, 128, 255));
        progress_pbar.setMinimum(0);
        progress_pbar.setMaximum(MAX_VALUE);
        progress_pbar.setStringPainted(true);

        status_label.setText("");

        for (JComponent c : new JComponent[]{queue_top_button, queue_bottom_button, queue_up_button, queue_down_button, slots_spinner, slots_label, pause_button, stop_button, speed_label, progress_pbar, keep_temp_checkbox, file_name_label, close_button, copy_link_button, restart_button, file_size_label, open_folder_button}) {

            c.setVisible(false);
        }

    }
 
Example 20
public UploadView(Upload upload) {

        initComponents();

        updateFonts(this, GUI_FONT, upload.getMain_panel().getZoom_factor());

        translateLabels(this);

        _upload = upload;

        slots_spinner.setModel(new SpinnerNumberModel(_upload.getMain_panel().getDefault_slots_up(), MIN_WORKERS, MAX_WORKERS, 1));

        ((JSpinner.DefaultEditor) slots_spinner.getEditor()).getTextField().setEditable(false);

        speed_label.setForeground(new Color(0, 128, 255));

        progress_pbar.setMinimum(0);
        progress_pbar.setMaximum(MAX_VALUE);
        progress_pbar.setStringPainted(true);

        status_label.setText("");

        for (JComponent c : new JComponent[]{queue_up_button, queue_down_button, queue_top_button, queue_bottom_button, cbc_label, slots_spinner, slots_label, pause_button, stop_button, speed_label, progress_pbar, file_name_label, close_button, restart_button, file_size_label}) {

            c.setVisible(false);
        }
    }