本文整理汇总了Java中java.awt.Component.setVisible方法的典型用法代码示例。如果您正苦于以下问题:Java Component.setVisible方法的具体用法?Java Component.setVisible怎么用?Java Component.setVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Component
的用法示例。
在下文中一共展示了Component.setVisible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import java.awt.Component; //导入方法依赖的package包/类
@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;
}
示例2: removeCellOverlayComponent
import java.awt.Component; //导入方法依赖的package包/类
/**
* 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));
}
}
}
示例3: updateCellOverlayComponent
import java.awt.Component; //导入方法依赖的package包/类
/**
* 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 updateCellOverlayComponent(mxCellState state,
mxICellOverlay overlay)
{
if (overlay instanceof Component)
{
Component comp = (Component) overlay;
if (comp.getParent() == null)
{
getGraphControl().add(comp, 0);
}
mxRectangle rect = overlay.getBounds(state);
if (rect != null)
{
comp.setBounds(rect.getRectangle());
comp.setVisible(true);
}
else
{
comp.setVisible(false);
}
}
}
示例4: updateCellOverlayComponent
import java.awt.Component; //导入方法依赖的package包/类
/**
* 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 updateCellOverlayComponent(mxCellState state, mxICellOverlay overlay) {
if (overlay instanceof Component) {
Component comp = (Component) overlay;
if (comp.getParent() == null) {
getGraphControl().add(comp, 0);
}
mxRectangle rect = overlay.getBounds(state);
if (rect != null) {
comp.setBounds(rect.getRectangle());
comp.setVisible(true);
} else {
comp.setVisible(false);
}
}
}
示例5: hideLabelAndLabelFor
import java.awt.Component; //导入方法依赖的package包/类
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);
}
}
}
示例6: updateGutterComponents
import java.awt.Component; //导入方法依赖的package包/类
private boolean updateGutterComponents(List<EditableLine> lines, Document doc,
int startIndex, int endIndex)
{
String text;
try {
text = doc.getText(startIndex, endIndex-startIndex);
}
catch (BadLocationException ex) { // should not happen
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
return false;
}
boolean visibility = !text.trim().equals(""); // NOI18N
int prevSelectedIndex = 0;
boolean changed = false;
Container gutter = getGutter(doc);
for (EditableLine l : lines) {
// make sure the selected index is correct (ascending in the group)
if (l.getSelectedIndex() < prevSelectedIndex)
l.setSelectedIndex(prevSelectedIndex);
else
prevSelectedIndex = l.getSelectedIndex();
// add the component to the gutter if not there yet
Component comp = l.getGutterComponent();
if (comp.getParent() == null)
gutter.add(comp, l.getPosition());
// show/hide the component
if (visibility != l.isVisible()) {
comp.setVisible(visibility);
changed = true;
}
}
return changed;
}
示例7: doShowWaitCursor
import java.awt.Component; //导入方法依赖的package包/类
private static void doShowWaitCursor (Component glassPane, boolean show) {
if (show) {
glassPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
glassPane.setVisible(true);
} else {
glassPane.setVisible(false);
glassPane.setCursor(null);
}
}
示例8: run
import java.awt.Component; //导入方法依赖的package包/类
@Override
public void run() {
try {
JFrame f = (JFrame)WindowManager.getDefault ().getMainWindow ();
Component c = f.getGlassPane ();
c.setVisible ( show );
c.setCursor (show ? Cursor.getPredefinedCursor (Cursor.WAIT_CURSOR) : null);
}
catch (NullPointerException npe) {
Exceptions.printStackTrace(npe);
}
}
示例9: run
import java.awt.Component; //导入方法依赖的package包/类
public void run() {
try {
JFrame f = (JFrame) WindowManager.getDefault().getMainWindow();
Component c = f.getGlassPane();
c.setVisible(show);
c.setCursor(show ? Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR) : null);
} catch (NullPointerException npe) {
Exceptions.printStackTrace(npe);
}
}
示例10: updateVisibility
import java.awt.Component; //导入方法依赖的package包/类
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);
}
}
}
示例11: removeCellOverlayComponent
import java.awt.Component; //导入方法依赖的package包/类
/**
* 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));
}
}
}
示例12: enableComponent
import java.awt.Component; //导入方法依赖的package包/类
public static void enableComponent(Container con, boolean state, Component component) {
for (Component c : con.getComponents()) {
if (c instanceof Container) {
enableComponent((Container) c, state, component);
}
if (component != null && component.equals(c)) {
continue;
}
if (c instanceof JLabel) {
c.setVisible(state);
} else {
c.setEnabled(state);
}
}
}
示例13: paintTabContent
import java.awt.Component; //导入方法依赖的package包/类
@Override
protected void paintTabContent(Graphics g, int index, String text, int x,
int y, int width, int height) {
// substract lower border
height--;
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+2*ICON_X_PAD ) {
buttons.setVisible( false );
} else {
buttons.setVisible( true );
txtWidth = width - (buttonsSize.width + 2*ICON_X_PAD + TXT_X_PAD);
buttons.setLocation(x + txtWidth + TXT_X_PAD+ICON_X_PAD, y + (height - buttonsSize.height)/2 + (TXT_Y_PAD / 2));
}
}
} else {
txtWidth = width - 2 * TXT_X_PAD;
}
// 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);
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);
}
示例14: paintTabContent
import java.awt.Component; //导入方法依赖的package包/类
@Override
protected void paintTabContent(Graphics g, int index, String text, int x,
int y, int width, int height) {
FontMetrics fm = getTxtFontMetrics();
// setting font already here to compute string width correctly
g.setFont(getTxtFont());
int textW = 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 );
textW = width - (buttonsSize.width + ICON_X_PAD + 2*TXT_X_PAD);
buttons.setLocation( x + textW+2*TXT_X_PAD-2, y + (height-buttonsSize.height)/2 );
}
}
} else {
textW = width - 2 * TXT_X_PAD;
}
if (text.length() == 0) {
return;
}
int textHeight = fm.getHeight();
int textY;
int textX = x + TXT_X_PAD;
if (index == 0)
textX = x + 5;
if (textHeight > height) {
textY = (-1 * ((textHeight - height) / 2)) + fm.getAscent()
- 1;
} else {
textY = (height / 2) - (textHeight / 2) + fm.getAscent();
}
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 ) );
textW -= busyIcon.getIconWidth() - 3 - TXT_X_PAD;
busyIcon.paintIcon( displayer, g, textX, y+(height-busyIcon.getIconHeight())/2);
textX += busyIcon.getIconWidth() + 3;
}
int realTextWidth = (int)HtmlRenderer.renderString(text, g, textX, textY, textW, height, getTxtFont(),
UIManager.getColor("textText"), //NOI18N
HtmlRenderer.STYLE_TRUNCATE, false);
realTextWidth = Math.min(realTextWidth, textW);
if( textW > realTextWidth )
textX += (textW - realTextWidth) / 2;
HtmlRenderer.renderString(text, g, textX, textY, textW, height, getTxtFont(),
UIManager.getColor("textText"),
HtmlRenderer.STYLE_TRUNCATE, true);
}
示例15: paintTabContent
import java.awt.Component; //导入方法依赖的package包/类
@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);
}