Java Code Examples for java.awt.Component#setVisible()
The following examples show how to use
java.awt.Component#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: MikuMikuStudio File: SkyboxVisualPanel2.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void multipleTexSouthLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexSouthLoadButtonActionPerformed Component view = editorSouth.getCustomEditor(); view.setVisible(true); if (editorSouth.getValue() != null) { Texture tex = (Texture) editorSouth.getValue(); String selected = tex.getKey().getName(); if (selected.toLowerCase().endsWith(".dds")) { if (ddsPreview == null) { ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager()); } ddsPreview.requestPreview(selected, "", 80, 80, southPic, null); } else { Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0)); southPic.setIcon(newicon); } } }
Example 2
Source Project: blog-codes File: mxGraphComponent.java License: Apache License 2.0 | 6 votes |
/** * Notified when an overlay has been removed from the graph. This * implementation removes the given overlay from its parent if it is a * component inside a component hierarchy. */ protected void removeCellOverlayComponent(mxICellOverlay overlay, Object cell) { if (overlay instanceof Component) { Component comp = (Component) overlay; if (comp.getParent() != null) { comp.setVisible(false); comp.getParent().remove(comp); eventSource.fireEvent(new mxEventObject(mxEvent.REMOVE_OVERLAY, "cell", cell, "overlay", overlay)); } } }
Example 3
Source Project: Cognizant-Intelligent-Test-Scripter File: SlideContainer.java License: Apache License 2.0 | 6 votes |
@Override public Component add(Component comp) { setsize(comp.getPreferredSize()); Component[] comps = getComponents(); if (comps.length > 0) { oldComponent = comps[0]; } if (comp.equals(oldComponent)) { return super.add(comp); } if (oldComponent != null) { putLayer((JComponent) oldComponent, JLayeredPane.DEFAULT_LAYER); } Component returnResult = super.add(comp); putLayer((JComponent) comp, JLayeredPane.DRAG_LAYER); comp.setSize(getPreferredSize()); comp.setVisible(true); comp.setLocation(0, 0 - getPreferredSize().height); slideFromTop(comp, oldComponent); return returnResult; }
Example 4
Source Project: MikuMikuStudio File: SkyboxVisualPanel2.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void singleTexLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_singleTexLoadButtonActionPerformed Component view = editorSingle.getCustomEditor(); view.setVisible(true); if (editorSingle.getValue() != null) { Texture tex = (Texture) editorSingle.getValue(); String selected = tex.getKey().getName(); if (selected.toLowerCase().endsWith(".dds")) { if (ddsPreview == null) { ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager()); } ddsPreview.requestPreview(selected, "", 80, 80, singlePic, null); } else { Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0)); singlePic.setIcon(newicon); } } }
Example 5
Source Project: MikuMikuStudio File: SkyboxVisualPanel2.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void multipleTexTopLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexTopLoadButtonActionPerformed Component view = editorTop.getCustomEditor(); view.setVisible(true); if (editorTop.getValue() != null) { Texture tex = (Texture) editorTop.getValue(); String selected = tex.getKey().getName(); if (selected.toLowerCase().endsWith(".dds")) { if (ddsPreview == null) { ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager()); } ddsPreview.requestPreview(selected, "", 80, 80, topPic, null); } else { Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0)); topPic.setIcon(newicon); } } }
Example 6
Source Project: mars-sim File: MainDesktopPane.java License: GNU General Public License v3.0 | 5 votes |
public void centerJIF(Component comp) { Dimension desktopSize = getSize(); Dimension jInternalFrameSize = comp.getSize(); int width = (desktopSize.width - jInternalFrameSize.width) / 2; int height = (desktopSize.height - jInternalFrameSize.height) / 2; comp.setLocation(width, height); comp.setVisible(true); }
Example 7
Source Project: portecle File: FPortecle.java License: GNU General Public License v2.0 | 5 votes |
/** * Set cursor to free and enable application input. Called after a call to setCursorBusy. */ private void setCursorFree() { // Accept mouse events Component glassPane = getRootPane().getGlassPane(); glassPane.setVisible(false); // Revert cursor to default glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); }
Example 8
Source Project: FlatLaf File: FlatWindowResizer.java License: Apache License 2.0 | 5 votes |
private void updateVisibility() { boolean visible = isWindowResizable(); if( visible == getComponent( 0 ).isVisible() ) return; for( Component c : getComponents() ) c.setVisible( visible ); }
Example 9
Source Project: netbeans File: Util.java License: Apache License 2.0 | 5 votes |
public static void hideLabelAndLabelFor(JComponent component, String lab) { JLabel label = findLabel(component, lab); if (label != null) { label.setVisible(false); Component c = label.getLabelFor(); if (c != null) { c.setVisible(false); } } }
Example 10
Source Project: visualvm File: JExtendedSplitPane.java License: GNU General Public License v2.0 | 5 votes |
private void updateVisibility() { Component divider = getDivider(); // null UI, not yet set if (divider == null) return; if (leftComponent == null || rightComponent == null) return; boolean leftVisible = leftComponent.isVisible(); boolean rightVisible = rightComponent.isVisible(); if (leftVisible && rightVisible) { if (!divider.isVisible()) { JExtendedSplitPane.super.setDividerSize(customDividerSize); divider.setVisible(true); setDividerLocation(dividerLocation); } if (!isVisible()) setVisible(true); } else if (!leftVisible && !rightVisible) { if (isVisible()) setVisible(false); } else { if (divider.isVisible()) { JExtendedSplitPane.super.setDividerSize(0); divider.setVisible(false); setDividerLocation(0); } if (!isVisible()) setVisible(true); } if (getParent() != null) getParent().doLayout(); }
Example 11
Source Project: pcgen File: Main.java License: GNU Lesser General Public License v2.1 | 5 votes |
/** * @param args the command line arguments */ public static void main(String[] args) { Logging.log(Level.INFO, "Starting PCGen v" + PCGenPropBundle.getVersionNumber() //$NON-NLS-1$ + PCGenPropBundle.getAutobuildString()); Thread.setDefaultUncaughtExceptionHandler(new LoggingUncaughtExceptionHandler()); DeadlockDetectorTask deadlockDetectorTask = new DeadlockDetectorTask(new PCGenLoggingDeadlockHandler()); deadlockDetectorTask.initialize(); logSystemProps(); configFactory = new PropertyContextFactory(getConfigPath()); configFactory.registerAndLoadPropertyContext(ConfigurationSettings.getInstance()); parseCommands(args); if (startNameGen) { Component dialog = new RandomNameDialog(null, null); dialog.setVisible(true); System.exit(0); } if (exportSheet == null) { startupWithGUI(); } else { startupWithoutGUI(); shutdown(); } }
Example 12
Source Project: pcgen File: Main.java License: GNU Lesser General Public License v2.1 | 5 votes |
/** * @param args the command line arguments */ public static void main(String[] args) { Logging.log(Level.INFO, "Starting PCGen v" + PCGenPropBundle.getVersionNumber() //$NON-NLS-1$ + PCGenPropBundle.getAutobuildString()); Thread.setDefaultUncaughtExceptionHandler(new LoggingUncaughtExceptionHandler()); DeadlockDetectorTask deadlockDetectorTask = new DeadlockDetectorTask(new PCGenLoggingDeadlockHandler()); deadlockDetectorTask.initialize(); logSystemProps(); configFactory = new PropertyContextFactory(getConfigPath()); configFactory.registerAndLoadPropertyContext(ConfigurationSettings.getInstance()); parseCommands(args); if (startNameGen) { Component dialog = new RandomNameDialog(null, null); dialog.setVisible(true); System.exit(0); } if (exportSheet == null) { startupWithGUI(); } else { startupWithoutGUI(); shutdown(); } }
Example 13
Source Project: atdl4j File: AbstractSwingWidget.java License: MIT License | 5 votes |
public void setVisible(boolean visible) { for ( Component control : getComponents() ) { if (control != null) { control.setVisible( visible ); } } }
Example 14
Source Project: Swing9patch File: CoolPopupFactory.java License: Apache License 2.0 | 5 votes |
/** * <p> * Makes the <code>Popup</code> visible. If the <code>Popup</code> is * currently visible, this has no effect.<br> * * 本方法的结构完全copy自父类方法,但添加了component.repaint();的调用. * </p> */ public void show() { Component component = getComponent(); if (component != null) { component.setVisible(true); //此行代码必须要有,否则可能是因为没有关闭双缓存(getRootPane(). //setUseTrueDoubleBuffering(false),这个方法是包内可见,所以本类里没法调用 //),而导致界面没有重绘:要不就是UI没有绘出来,要不就是出现空白的popup(没有内容组件) component.repaint(); } }
Example 15
Source Project: netbeans File: JExtendedSplitPane.java License: Apache License 2.0 | 5 votes |
private void updateVisibility() { Component firstComponent = getFirstComponent(); Component secondComponent = getSecondComponent(); Component divider = getDivider(); if ((firstComponent == null) || (secondComponent == null) || (divider == null)) { return; } if (firstComponent.isVisible() && secondComponent.isVisible()) { if (!divider.isVisible()) { super.setDividerSize(dividerSize); divider.setVisible(true); setDividerLocation(dividerLocation); } if (!isVisible()) { setVisible(true); } } else if (!firstComponent.isVisible() && !secondComponent.isVisible()) { if (isVisible()) { setVisible(false); } } else { if (divider.isVisible()) { super.setDividerSize(0); divider.setVisible(false); setDividerLocation(0); } if (!isVisible()) { setVisible(true); } } }
Example 16
Source Project: Java-MP3-player File: JPanelsSliding.java License: MIT License | 5 votes |
public void previous(direct direct) { Component currentComp=getCurrentComponent(this); Component previousComp=getPreviousComponent(this); previousComp.setVisible(true); JPanelSlidingListener sl=new JPanelSlidingListener(10, currentComp, previousComp, direct); Timer t=new Timer(40,sl); sl.timer=t; t.start(); refresh(); }
Example 17
Source Project: Bytecoder File: JTabbedPane.java License: Apache License 2.0 | 4 votes |
/** * Removes the tab at <code>index</code>. * After the component associated with <code>index</code> is removed, * its visibility is reset to true to ensure it will be visible * if added to other containers. * @param index the index of the tab to be removed * @exception IndexOutOfBoundsException if index is out of range * {@code (index < 0 || index >= tab count)} * * @see #addTab * @see #insertTab */ @SuppressWarnings("deprecation") public void removeTabAt(int index) { checkIndex(index); Component component = getComponentAt(index); boolean shouldChangeFocus = false; int selected = getSelectedIndex(); String oldName = null; /* if we're about to remove the visible component */ if (component == visComp) { shouldChangeFocus = (SwingUtilities.findFocusOwner(visComp) != null); visComp = null; } if (accessibleContext != null) { /* if we're removing the selected page */ if (index == selected) { /* fire an accessible notification that it's unselected */ pages.get(index).firePropertyChange( AccessibleContext.ACCESSIBLE_STATE_PROPERTY, AccessibleState.SELECTED, null); oldName = accessibleContext.getAccessibleName(); } accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, component, null); } // Force the tabComponent to be cleaned up. setTabComponentAt(index, null); pages.remove(index); // NOTE 4/15/2002 (joutwate): // This fix is implemented using client properties since there is // currently no IndexPropertyChangeEvent. Once // IndexPropertyChangeEvents have been added this code should be // modified to use it. putClientProperty("__index_to_remove__", Integer.valueOf(index)); /* if the selected tab is after the removal */ if (selected > index) { setSelectedIndexImpl(selected - 1, false); /* if the selected tab is the last tab */ } else if (selected >= getTabCount()) { setSelectedIndexImpl(selected - 1, false); Page newSelected = (selected != 0) ? pages.get(selected - 1) : null; changeAccessibleSelection(null, oldName, newSelected); /* selected index hasn't changed, but the associated tab has */ } else if (index == selected) { fireStateChanged(); changeAccessibleSelection(null, oldName, pages.get(index)); } // We can't assume the tab indices correspond to the // container's children array indices, so make sure we // remove the correct child! if (component != null) { Component[] components = getComponents(); for (int i = components.length; --i >= 0; ) { if (components[i] == component) { super.remove(i); component.setVisible(true); clearAccessibleParent(component); break; } } } if (shouldChangeFocus) { SwingUtilities2.tabbedPaneChangeFocusTo(getSelectedComponent()); } revalidate(); repaint(); }
Example 18
Source Project: netbeans File: WinClassicViewTabDisplayerUI.java License: Apache License 2.0 | 4 votes |
@Override protected void paintTabContent(Graphics g, int index, String text, int x, int y, int width, int height) { // substract lower border height--; y -= 2; //align to center FontMetrics fm = getTxtFontMetrics(); // setting font already here to compute string width correctly g.setFont(getTxtFont()); int txtWidth = width; if (isSelected(index)) { Component buttons = getControlButtons(); if( null != buttons ) { Dimension buttonsSize = buttons.getPreferredSize(); if( width < buttonsSize.width+ICON_X_PAD ) { buttons.setVisible( false ); } else { buttons.setVisible( true ); txtWidth = width - (buttonsSize.width + ICON_X_PAD + TXT_X_PAD); buttons.setLocation( x + txtWidth+TXT_X_PAD, y + (height-buttonsSize.height)/2+1 ); } } } else { txtWidth = width - 2 * TXT_X_PAD; } if( isUseStretchingTabs() ) { // draw bump (dragger) drawBump(g, index, x + 4, y + 6, BUMP_WIDTH, height - 8); } boolean slidedOut = false; WinsysInfoForTabbedContainer winsysInfo = displayer.getContainerWinsysInfo(); if( null != winsysInfo && winsysInfo.isSlidedOutContainer() ) slidedOut = false; if( isTabBusy( index ) && !slidedOut ) { Icon busyIcon = BusyTabsSupport.getDefault().getBusyIcon( isSelected( index ) ); txtWidth -= busyIcon.getIconWidth() + 3 + TXT_X_PAD; busyIcon.paintIcon( displayer, g, x+TXT_X_PAD, y+(height-busyIcon.getIconHeight())/2+1); x += busyIcon.getIconWidth() + 3; } // draw text in right color Color txtC = UIManager.getColor("TabbedPane.foreground"); //NOI18N HtmlRenderer.renderString(text, g, x + TXT_X_PAD, y + fm.getAscent() + TXT_Y_PAD, txtWidth, height, getTxtFont(), txtC, HtmlRenderer.STYLE_TRUNCATE, true); }
Example 19
Source Project: Bytecoder File: JTabbedPane.java License: Apache License 2.0 | 4 votes |
/** * Inserts a new tab for the given component, at the given index, * represented by the given title and/or icon, either of which may * be {@code null}. * * @param title the title to be displayed on the tab * @param icon the icon to be displayed on the tab * @param component the component to be displayed when this tab is clicked. * @param tip the tooltip to be displayed for this tab * @param index the position to insert this new tab * ({@code > 0 and <= getTabCount()}) * * @throws IndexOutOfBoundsException if the index is out of range * ({@code < 0 or > getTabCount()}) * * @see #addTab * @see #removeTabAt */ public void insertTab(String title, Icon icon, Component component, String tip, int index) { int newIndex = index; // If component already exists, remove corresponding // tab so that new tab gets added correctly // Note: we are allowing component=null because of compatibility, // but we really should throw an exception because much of the // rest of the JTabbedPane implementation isn't designed to deal // with null components for tabs. int removeIndex = indexOfComponent(component); if (component != null && removeIndex != -1) { removeTabAt(removeIndex); if (newIndex > removeIndex) { newIndex--; } } int selectedIndex = getSelectedIndex(); pages.add( newIndex, new Page(this, title != null? title : "", icon, null, component, tip)); if (component != null) { addImpl(component, null, -1); component.setVisible(false); } else { firePropertyChange("indexForNullComponent", -1, index); } if (pages.size() == 1) { setSelectedIndex(0); } if (selectedIndex >= newIndex) { setSelectedIndexImpl(selectedIndex + 1, false); } if (!haveRegistered && tip != null) { ToolTipManager.sharedInstance().registerComponent(this); haveRegistered = true; } if (accessibleContext != null) { accessibleContext.firePropertyChange( AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, null, component); } revalidate(); repaint(); }
Example 20
Source Project: wpcleaner File: BasicWindow.java License: Apache License 2.0 | 2 votes |
/** * Make a component visible or invisible. * * @param component Component. * @param enabled True to make the component visible. */ protected void setVisibleStatus(Component component, boolean enabled) { if (component != null) { component.setVisible(enabled); } }