javax.swing.JComponent.setVisible()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(153)

本文整理了Java中javax.swing.JComponent.setVisible()方法的一些代码示例,展示了JComponent.setVisible()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComponent.setVisible()方法的具体详情如下:
包路径:javax.swing.JComponent
类名称:JComponent
方法名:setVisible

JComponent.setVisible介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

private JPanel panel = new JPanel();
private JScrollPane sp = new JScrollPane(panel);
  panel.add(new JLabel(name, JLabel.LEFT));
  panel.add(jtf);
  list.add(jtf);
  internaFrame.add(sp);
  internaFrame.pack();
  internaFrame.setVisible(true);
  desktopPane.add(internaFrame);
  JFrame frmtest = new JFrame();
  frmtest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frmtest.add(desktopPane);
  frmtest.pack();
  frmtest.setVisible(true);
  list.get(0).requestFocusInWindow();

代码示例来源:origin: stackoverflow.com

private static final int           TOP               = 0x03;
private static final int           BOTTOM            = 0x04;
private final JPanel               basePanel         = new JPanel();
private final ParentType           parent;
private final Object               lock              = new Object();
  glassPane = new JPanel();
  glassPane.setOpaque(false);
  glassPane.addMouseListener(new MouseAdapter() {
  basePanel.setLayout(new BorderLayout());
  if (useSlideButton) {
    final JPanel statusPanel = new JPanel();
    basePanel.add(statusPanel, BorderLayout.SOUTH);
    statusPanel.add(new JButton("Slide Left") {
      private static final long serialVersionUID = 9204819004142223529L;
    statusPanel.add(new JButton("Slide Right") {
    ((JWindow) w).setGlassPane(glassPane);
  glassPane.setVisible(true);

代码示例来源:origin: stackoverflow.com

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

  public class SpecialButton extends JButton{
    SpecialButton(){
      super();
      JButton jbtnMid = new JButton();
      JLabel jlblMid = new JLabel(new ImageIcon(this.getClass().getResource("/Images/arrowUpIcon.png")));
      jbtnMid .add(jlblMid);
      this.add(jbtnMid);
      this.setVisible(true);
    }
  }

代码示例来源:origin: net.sf.tinylaf/tinylaf

/**
 * 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 content
 *            the <code>JComponent</code> to use for the window title
 *            pane.
 */
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;
  root.validate();
  root.repaint();
}

代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit

public void register(DockableWindowManagerImpl.Entry entry)
{
  this.entry = entry;
  dockableName = entry.factory.name;
  
  setTitle(entry.shortTitle());
  getContentPane().add(BorderLayout.CENTER,entry.win);
  pack();
  Container parent = dockableWindowManager.getView();
  GUIUtilities.loadGeometry(this, parent, dockableName);
  GUIUtilities.addSizeSaver(this, parent, dockableName);
  KeyListener listener = dockableWindowManager.closeListener(dockableName);
  addKeyListener(listener);
  getContentPane().addKeyListener(listener);
  menu.addKeyListener(listener);
  entry.win.addKeyListener(listener);
  setVisible(true);
  if (! entry.win.isVisible())
    entry.win.setVisible(true);
} //}}}

代码示例来源:origin: jfree/jcommon

/**
 * Closes the toolbar.
 */
private void closeToolbar() {
  if (this.currentToolbar != null) {
    if (this.currentToolbar.getParent() != this.toolbarContainer) {
      // ha!, the toolbar is floating ...
      // Log.debug (currentToolbar.getParent());
      final Window w = SwingUtilities.windowForComponent(this.currentToolbar);
      if (w != null) {
        w.setVisible(false);
        w.dispose();
      }
    }
    this.currentToolbar.setVisible(false);
  }
}

代码示例来源:origin: stackoverflow.com

JFrame f = new JFrame();
f.setLayout(new FlowLayout());
f.getContentPane().setBackground(new Color(0xffffc0));
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
panel.setBackground(new Color(0xffffc0));
panel.add(new TransparentTextArea(0));
jif.add(panel);
jif.setVisible(true);
f.add(jif);
f.pack();
f.setVisible(true);

代码示例来源:origin: stackoverflow.com

import java.awt.*;
import javax.swing.*;

class RemoveControls {

  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        JPanel p = new JPanel(new GridLayout());
        p.setPreferredSize(new Dimension(300,120));

        JDesktopPane dtp = new JDesktopPane();
        p.add(dtp);

        JInternalFrame jif = new JInternalFrame("JIF",
          false, //resizable
          false, //closable
          false, //maximizable
          false); //iconifiable
        jif.setVisible(true);
        jif.setSize(200,100);
        dtp.add(jif);

        JOptionPane.showMessageDialog(null, p);
      }
    });
  }
}

代码示例来源:origin: org.jfree/jcommon

/**
 * Closes the toolbar.
 */
private void closeToolbar() {
  if (this.currentToolbar != null) {
    if (this.currentToolbar.getParent() != this.toolbarContainer) {
      // ha!, the toolbar is floating ...
      // Log.debug (currentToolbar.getParent());
      final Window w = SwingUtilities.windowForComponent(this.currentToolbar);
      if (w != null) {
        w.setVisible(false);
        w.dispose();
      }
    }
    this.currentToolbar.setVisible(false);
  }
}

代码示例来源:origin: stackoverflow.com

layeredPane.addMouseListener( this );
layeredPane.addMouseMotionListener( this );
getContentPane().add(layeredPane);
chessBoard = new JPanel();
chessBoard.setLayout( new GridLayout(8, 8) );
chessBoard.setPreferredSize( boardSize );
chessBoard.setBounds(0, 0, boardSize.width, boardSize.height);
layeredPane.add(chessBoard, JLayeredPane.DEFAULT_LAYER);
    JPanel square = new JPanel( new BorderLayout() );
    square.setBackground( (i + j) % 2 == 0 ? Color.red : Color.white );
    chessBoard.add( square );
chessPiece.setVisible(false);
layeredPane.remove(chessPiece);
chessPiece.setVisible(true);
frame.setDefaultCloseOperation( DISPOSE_ON_CLOSE );
frame.setResizable( false );
frame.pack();
frame.setLocationRelativeTo( null );
frame.setVisible(true);

代码示例来源:origin: org.jfree/com.springsource.org.jfree

/**
 * Closes the toolbar.
 */
private void closeToolbar() {
  if (this.currentToolbar != null) {
    if (this.currentToolbar.getParent() != this.toolbarContainer) {
      // ha!, the toolbar is floating ...
      // Log.debug (currentToolbar.getParent());
      final Window w = SwingUtilities.windowForComponent(this.currentToolbar);
      if (w != null) {
        w.setVisible(false);
        w.dispose();
      }
    }
    this.currentToolbar.setVisible(false);
  }
}

代码示例来源:origin: stackoverflow.com

this.add(one);
this.add(two);
  this.setSize(160, 100);
  this.setLocation(x, y);
  this.setVisible(true);
  this.addComponentListener(new ComponentAdapter() {
JFrame f = new JFrame("JDPTest");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(this);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame("JInternalFrame Usage Demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setVisible(true);
jdpDesktop.add(frame);
try {
  frame.setSelected(true);

代码示例来源:origin: stackoverflow.com

final JFrame frame = new JFrame();
JPanel panel = new JPanel();
JButton button1 = new JButton();
label.setVisible(false);
frame.add(panel);
panel.add(button1);
panel.add(label);
frame.setVisible(true);
    label.setVisible(true);

代码示例来源:origin: stackoverflow.com

import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class BtnDisabled {

  public static void main(String[] args) {

    JFrame frame = new JFrame("");
    JLabel label = new JLabel("You and Me");
    label.setVisible(false);
    JPanel panel = new JPanel();
    panel.add(label);

    JButton btn = new JButton("W");
  btn.addActionListener(e -> {
    if (!label.isVisible()) {
      label.setVisible(true);
    }
  });
    panel.add(btn);
    frame.add(panel);
    frame.setSize(new Dimension(500, 500));

    frame.setVisible(true);
  }
}

代码示例来源:origin: stackoverflow.com

JFrame fw = new JFrame();
fw.setSize(400, 200); // for screenshot
fw.setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel p5 = new JPanel(new GridBagLayout());
p5.setVisible(true);
fw.add(p5);
fw.setVisible(true); //should be done after all components are added

代码示例来源:origin: stackoverflow.com

import javax.swing.*;

public class RecursiveJPanelTest
{
public static void main(String[] arg)
{
JFrame window = new JFrame();
JPanel top = new JPanel();
JPanel within = new JPanel();

window. setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);

window.setSize(400, 200);
top.setSize(400, 200);
within.setSize(400, 200);

window.add(top);
top.add(within);
within.add(new JButton("Button"));

window.validate();
window.setVisible(true);
top.setVisible(true);
within.setVisible(true);
}
}

代码示例来源:origin: stackoverflow.com

JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel=new JPanel();
JButton Open = new JButton("Open a file...");
Open.addActionListener(new ActionListener() {
     JFileChooser fc= new JFileChooser();
     fc.showOpenDialog(null);
     fc.setVisible(true);
panel.add(Open);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);

代码示例来源:origin: stackoverflow.com

this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(300, 300);
this.setVisible(true);
TopPanel = new JPanel();
BottomPanel = new JPanel();
add(TopPanel, BorderLayout.CENTER);
add(BottomPanel, BorderLayout.SOUTH);
JButton Easy = new JButton("Easy");
JButton Medium = new JButton("Medium");
JButton Difficult = new JButton("Difficult");
Easy.setVisible(true);
BottomPanel.add(Easy);
BottomPanel.add(Medium);
BottomPanel.add(Difficult);

代码示例来源:origin: stackoverflow.com

public static JFrame start= new JFrame("TRDServerCreator");
  start.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  start.setLocationRelativeTo(null);
  start.setResizable(false);
  JPanel cont= new JPanel();
  start.add(cont);
  n1.setVisible(true);
  JLabel n2=new JLabel("Pls select the Verison of your New Server");
  n2.setVisible(true);
  cont.add(n1,n2);
  start.setVisible(true);

相关文章

JComponent类方法