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

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

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

JPanel.setVisible介绍

暂无

代码示例

代码示例来源:origin: libgdx/libgdx

private void initializeComponents () {
  setLayout(new GridBagLayout());
    titlePanel = new JPanel(new GridBagLayout());
    add(titlePanel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
      new Insets(3, 0, 3, 0), 0, 0));
      titlePanel.add(label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
        new Insets(3, 6, 3, 6), 0, 0));
      label.setFont(label.getFont().deriveFont(Font.BOLD));
      titlePanel.add(descriptionLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
        GridBagConstraints.NONE, new Insets(3, 6, 3, 6), 0, 0));
      titlePanel.add(advancedButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
        GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
      advancedButton.setVisible(false);
    contentPanel = new JPanel(new GridBagLayout());
    add(contentPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
      new Insets(0, 6, 6, 6), 0, 0));
    contentPanel.setVisible(false);
    advancedPanel = new JPanel(new GridBagLayout());
    add(advancedPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
      new Insets(0, 6, 6, 6), 0, 0));
    advancedPanel.setVisible(false);

代码示例来源:origin: libgdx/libgdx

protected void initializeComponents () {
  setLayout(new GridBagLayout());
    titlePanel = new JPanel(new GridBagLayout());
    add(titlePanel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
      new Insets(3, 0, 3, 0), 0, 0));
      titlePanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
        new Insets(3, 6, 3, 6), 0, 0));
      nameLabel.setFont(nameLabel.getFont().deriveFont(Font.BOLD));
      titlePanel.add(descriptionLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
        GridBagConstraints.NONE, new Insets(3, 6, 3, 6), 0, 0));
      titlePanel.add(advancedButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
        GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
      advancedButton.setVisible(false);
    contentPanel = new JPanel(new GridBagLayout());
    add(contentPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
      new Insets(0, 6, 6, 6), 0, 0));
    contentPanel.setVisible(false);
    advancedPanel = new JPanel(new GridBagLayout());
    add(advancedPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
      new Insets(0, 6, 6, 6), 0, 0));
    advancedPanel.setVisible(false);

代码示例来源:origin: MovingBlocks/Terasology

MyRenderer() {
  setBackground(BACKGROUND);
  setLayout(new BorderLayout());
  pHead.setLayout(new BorderLayout());
  pHead.setBackground(BACKGROUND);
  pHead.add(pList, BorderLayout.LINE_START);
  pHead.add(lActive, BorderLayout.LINE_END);
  pHead.add(pError, BorderLayout.PAGE_END);
  lId.setHorizontalAlignment(SwingConstants.RIGHT);
  lName.setForeground(Color.BLUE);
  lCounters.setForeground(Color.GRAY);
  pList.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 2));
  pList.setBackground(BACKGROUND);
  pList.add(lId);
  pList.add(lName);
  pList.add(lCounters);
  pError.setVisible(false);
  pError.setLayout(new FlowLayout(FlowLayout.LEFT, 4, 2));
  pError.setBackground(BACKGROUND);
  pError.add(lErrorSpacer);
  pError.add(lError);
  lError.setForeground(Color.RED);
  add(pHead, BorderLayout.PAGE_START);
}

代码示例来源:origin: magefree/mage

/**
 * Get the panel where all arrows are being drawn.
 * @return
 */
public synchronized JPanel getArrowsManagerPanel() {
  if (arrowsManagerPanel == null) {
    arrowsManagerPanel = new JPanel();
    arrowsManagerPanel.setVisible(true);
    arrowsManagerPanel.setOpaque(false);
    arrowsManagerPanel.setLayout(null);
  }
  return arrowsManagerPanel;
}

代码示例来源:origin: apache/pdfbox

private void initUI(StyledDocument document)
{
  mainPanel = new JPanel();
  textPane = new JTextPane(document);
  textPane.addMouseMotionListener(this);
  textPane.setFont(new Font("monospaced", Font.PLAIN, 13));
  searcher = new Searcher(textPane);
  JScrollPane scrollPane = new JScrollPane(textPane);
  BoxLayout boxLayout = new BoxLayout(mainPanel, BoxLayout.Y_AXIS);
  mainPanel.setLayout(boxLayout);
  mainPanel.add(searcher.getSearchPanel());
  mainPanel.add(scrollPane);
  searcher.getSearchPanel().setVisible(false);
  mainPanel.addAncestorListener(this);
}

代码示例来源:origin: org.cytoscape/vizmap-gui-impl

protected JPanel getMappingPnl() {
  if (mappingPnl == null) {
    mappingPnl = new JPanel();
    mappingPnl.setBackground(new Color(125, 125, 125));
    mappingPnl.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, new Color(125, 125, 125)));
    mappingPnl.setLayout(new BorderLayout());
    mappingPnl.setVisible(false);
    
    mappingPnl.add(getPropSheetPnl(), BorderLayout.CENTER);
    
    final JPanel bottomPnl = new JPanel();
    bottomPnl.setLayout(new BoxLayout(bottomPnl, BoxLayout.X_AXIS));
    bottomPnl.add(Box.createHorizontalGlue());
    bottomPnl.add(getRemoveMappingBtn());
    bottomPnl.add(Box.createRigidArea(new Dimension(0, PROP_SHEET_ROW_HEIGHT)));
    bottomPnl.setBorder(BorderFactory.createEmptyBorder(0, 4, 4, 4));
    
    mappingPnl.add(bottomPnl, BorderLayout.SOUTH);
    
    mappingPnl.addComponentListener(new ComponentAdapter() {
      @Override
      public void componentShown(final ComponentEvent e) {
        updateMappingPanelSize();
      }
    });
  }
  
  return mappingPnl;
}

代码示例来源:origin: libgdx/libgdx

private void initializeComponents () {
  setLayout(new GridBagLayout());
    titlePanel = new JPanel(new GridBagLayout());
    add(titlePanel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
      new Insets(3, 0, 3, 0), 0, 0));
      titlePanel.add(label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
        new Insets(3, 6, 3, 6), 0, 0));
      label.setFont(label.getFont().deriveFont(Font.BOLD));
      titlePanel.add(descriptionLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
        GridBagConstraints.NONE, new Insets(3, 6, 3, 6), 0, 0));
      titlePanel.add(advancedButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
        GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
      advancedButton.setVisible(false);
    contentPanel = new JPanel(new GridBagLayout());
    add(contentPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
      new Insets(0, 6, 6, 6), 0, 0));
    contentPanel.setVisible(false);
    advancedPanel = new JPanel(new GridBagLayout());
    add(advancedPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
      new Insets(0, 6, 6, 6), 0, 0));
    advancedPanel.setVisible(false);

代码示例来源:origin: runelite/runelite

actionsContainer.setVisible(true);
overallPanel.setVisible(true);
logsContainer.add(box, 0);

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

JPanel mainMenu = new JPanel();
createUserMenu.setVisible(false);

JPanel createUserMenu = new JPanel();
createUserMenu.setVisible(false);

JPanel loginUserMenu = new JPanel();
loginUserMenu.setVisible(false);

代码示例来源:origin: libgdx/libgdx

protected void initializeComponents () {
  setLayout(new GridBagLayout());
    titlePanel = new JPanel(new GridBagLayout());
    add(titlePanel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
      new Insets(3, 0, 3, 0), 0, 0));
      titlePanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
        new Insets(3, 6, 3, 6), 0, 0));
      nameLabel.setFont(nameLabel.getFont().deriveFont(Font.BOLD));
      titlePanel.add(descriptionLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
        GridBagConstraints.NONE, new Insets(3, 6, 3, 6), 0, 0));
      titlePanel.add(advancedButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
        GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
      advancedButton.setVisible(false);
    contentPanel = new JPanel(new GridBagLayout());
    add(contentPanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
      new Insets(0, 6, 6, 6), 0, 0));
    contentPanel.setVisible(false);
    advancedPanel = new JPanel(new GridBagLayout());
    add(advancedPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
      new Insets(0, 6, 6, 6), 0, 0));
    advancedPanel.setVisible(false);

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

public static void main(String args[]){
  JFrame f = new JFrame();
  f.setLayout(new BorderLayout());
  final JPanel p = new JPanel();
  p.add(new JLabel("A Panel"));
  f.add(p, BorderLayout.CENTER);

  //create a button which will hide the panel when clicked.
  JButton b = new JButton("HIDE");
  b.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
        p.setVisible(false);
    }
  });

  f.add(b,BorderLayout.SOUTH);
  f.pack();
  f.setVisible(true);
}

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

private void setProgressComponent (JComponent progressComp, final JLabel progressLabel) {
  assert SwingUtilities.isEventDispatchThread();
  if (progressComp == null) {
    progressBarPanel.removeAll ();
    progressBarPanel.setVisible (false);
  } else {
    if (progressLabel != null) {
      progressLabel.setText (PROGRESS_BAR_DISPLAY_NAME);
      progressLabel.addPropertyChangeListener ("text", new PropertyChangeListener () { // NOI18N
        @Override
        public void propertyChange (PropertyChangeEvent evt) {
          progressLabel.putClientProperty (JComponent.TOOL_TIP_TEXT_KEY, evt.getNewValue ().toString ());
        }
      });
      progressLabel.setToolTipText (PROGRESS_BAR_DISPLAY_NAME);
      progressBarPanel.add (progressLabel, BorderLayout.NORTH);
    }
    progressBarPanel.add (progressComp, BorderLayout.CENTER);
    progressBarPanel.setVisible (true);
  }
}

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

JFrame myFrame = new JFrame();
JPanel panel1 = new JPanel();
Panel1.setVisible(true);
myFrame.add(panel1);
JPanel panel2 = new JPanel();
Panel2.setVisible(false);
myFrame.add(panel2);
//Here you setup your panels and your actionlisteners etc and when
//you wish for your second panel to show up just run the code below.
panel1.setVisible(false);
panel2.setVisible(true);

代码示例来源:origin: libgdx/libgdx

private void initializeComponents () {
  getContentPane().setLayout(new GridBagLayout());
  JPanel leftSidePanel = new JPanel();
  leftSidePanel.setLayout(new GridBagLayout());
  getContentPane().add(leftSidePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    JPanel fontPanel = new JPanel();
    leftSidePanel.add(fontPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
      GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
    fontPanel.setLayout(new GridBagLayout());
      fontPanel.add(fontSizeSpinner, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
        GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0));
      ((JSpinner.DefaultEditor)fontSizeSpinner.getEditor()).getTextField().setColumns(2);
      fontPanel.add(fontScroll, new GridBagConstraints(1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
        GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
      unicodePanel = new JPanel(new GridBagLayout());
      fontPanel.add(unicodePanel, new GridBagConstraints(2, 3, 2, 1, 0.0, 0.0, GridBagConstraints.EAST,
        GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 5), 0, 0));
      glyphCachePanel.setVisible(false);
      renderingPanel.add(glyphCachePanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH,
        GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

代码示例来源:origin: dboissier/mongo4idea

@Override
  public void run(@NotNull ProgressIndicator indicator) {
    try {
      UIUtil.invokeLaterIfNeeded(() -> loadingDecorator.startLoading(false));
      final MongoQueryOptions queryOptions = wayPoint.getQueryOptions();
      if (!useCachedResults) {
        currentResults = mongoManager.findMongoDocuments(
            configuration,
            wayPoint.getCollection(),
            queryOptions);
      }
      UIUtil.invokeLaterIfNeeded(() -> {
        resultPanel.updateResultView(currentResults, pagination);
        rowCountLabel.setText(String.format("%s documents", currentResults.getDocuments().size()));
        initActions(resultPanel.resultTreeTableView);
      });
    } catch (final Exception ex) {
      UIUtil.invokeLaterIfNeeded(() -> {
        errorPanel.invalidate();
        errorPanel.removeAll();
        errorPanel.add(new ErrorPanel(ex), BorderLayout.CENTER);
        errorPanel.validate();
        errorPanel.setVisible(true);
      });
    } finally {
      UIUtil.invokeLaterIfNeeded(loadingDecorator::stopLoading);
    }
  }
});

代码示例来源:origin: org.tinyjee.jgraphx/jgraphx

/**
 * 
 */
protected JComponent createPreview()
{
  JPanel preview = new JPanel();
  preview.setBorder(mxSwingConstants.PREVIEW_BORDER);
  preview.setOpaque(false);
  preview.setVisible(false);
  return preview;
}

代码示例来源:origin: libgdx/libgdx

private void initializeComponents () {
  getContentPane().setLayout(new GridBagLayout());
  JPanel leftSidePanel = new JPanel();
  leftSidePanel.setLayout(new GridBagLayout());
  getContentPane().add(leftSidePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    JPanel fontPanel = new JPanel();
    leftSidePanel.add(fontPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
      GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
    fontPanel.setLayout(new GridBagLayout());
      fontPanel.add(fontSizeSpinner, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
        GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0));
      ((JSpinner.DefaultEditor)fontSizeSpinner.getEditor()).getTextField().setColumns(2);
      fontPanel.add(fontScroll, new GridBagConstraints(1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
        GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
      unicodePanel = new JPanel(new GridBagLayout());
      fontPanel.add(unicodePanel, new GridBagConstraints(2, 3, 2, 1, 0.0, 0.0, GridBagConstraints.EAST,
        GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 5), 0, 0));
      glyphCachePanel.setVisible(false);
      renderingPanel.add(glyphCachePanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH,
        GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial

protected void setOptionsPanel (JPanel optionsPanel, Border parentPanelBorder) {
  if (optionsPanel == null) {
    jPanel1.setVisible(false);
  } else {
    if (parentPanelBorder != null) {
      jPanel1.setBorder(parentPanelBorder);
    }
    jPanel1.removeAll();
    jPanel1.add(optionsPanel, BorderLayout.NORTH);
    jPanel1.setVisible(true);
  }
}

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

private JPanel panel_1 = new JPanel(){
  @Override
  public void paintComponent(Graphics g){
    paintComponents(g);
    panel_1.setBackground(Color.orange);
    panel_1.setVisible(true);

    System.out.println("Just testing");
  }
};

代码示例来源:origin: runelite/runelite

setLayout(new BorderLayout());
final JPanel layoutPanel = new JPanel();
BoxLayout boxLayout = new BoxLayout(layoutPanel, BoxLayout.Y_AXIS);
layoutPanel.setLayout(boxLayout);
overallPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
overallPanel.setLayout(new BorderLayout());
overallPanel.setVisible(false); // this will only become visible when the player gets exp
final JPanel overallInfo = new JPanel();
overallInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR);
overallInfo.setLayout(new GridLayout(2, 1));
overallExpHour.setFont(FontManager.getRunescapeSmallFont());
overallInfo.add(overallExpGained);
overallInfo.add(overallExpHour);
overallPanel.add(overallIcon, BorderLayout.WEST);
overallPanel.add(overallInfo, BorderLayout.CENTER);
final JPanel infoBoxPanel = new JPanel();
infoBoxPanel.setLayout(new BoxLayout(infoBoxPanel, BoxLayout.Y_AXIS));
layoutPanel.add(overallPanel);

相关文章

JPanel类方法