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

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

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

JPanel.remove介绍

暂无

代码示例

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

public void moveEffect (int newIndex) {
  appliedEffectsPanel.remove(this);
  effectPanels.remove(this);
  appliedEffectsPanel.add(this, constrains, newIndex);
  effectPanels.add(newIndex, this);
}

代码示例来源:origin: kiegroup/optaplanner

@Override
public void resetPanel(CloudBalance cloudBalance) {
  maximumComputerCpuPower = 0;
  maximumComputerMemory = 0;
  maximumComputerNetworkBandwidth = 0;
  for (CloudComputer computer : cloudBalance.getComputerList()) {
    if (computer.getCpuPower() > maximumComputerCpuPower) {
      maximumComputerCpuPower = computer.getCpuPower();
    }
    if (computer.getMemory() > maximumComputerMemory) {
      maximumComputerMemory = computer.getMemory();
    }
    if (computer.getNetworkBandwidth() > maximumComputerNetworkBandwidth) {
      maximumComputerNetworkBandwidth = computer.getNetworkBandwidth();
    }
  }
  for (CloudComputerPanel computerPanel : computerToPanelMap.values()) {
    if (computerPanel.getComputer() != null) {
      computersPanel.remove(computerPanel);
    }
  }
  computerToPanelMap.clear();
  computersPanel.removeAll();
  unassignedPanel = new CloudComputerPanel(this, null);
  computersPanel.add(unassignedPanel);
  computerToPanelMap.put(null, unassignedPanel);
  updatePanel(cloudBalance);
}

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

public void moveEffect (int newIndex) {
  appliedEffectsPanel.remove(this);
  effectPanels.remove(this);
  appliedEffectsPanel.add(this, constrains, newIndex);
  effectPanels.add(newIndex, this);
}

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

private void onSearch()
{
  //only show slots that match our search text
  uiActionSlots.forEach(slot ->
  {
    if (slotContainsText(slot, searchBar.getText()))
    {
      super.add(slot);
    }
    else
    {
      super.remove(slot);
    }
    revalidate();
  });
}

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

private void addVarLog(VarType type, String name, String old, String neew)
{
  if (!type.getCheckBox().isSelected())
  {
    return;
  }
  int tick = client.getTickCount();
  SwingUtilities.invokeLater(() ->
  {
    if (tick != lastTick)
    {
      lastTick = tick;
      JLabel header = new JLabel("Tick " + tick);
      header.setFont(FontManager.getRunescapeSmallFont());
      header.setBorder(new CompoundBorder(
        BorderFactory.createMatteBorder(0, 0, 1, 0, ColorScheme.LIGHT_GRAY_COLOR),
        BorderFactory.createEmptyBorder(3, 6, 0, 0)
      ));
      tracker.add(header);
    }
    tracker.add(new JLabel(String.format("%s %s changed: %s -> %s", type.getName(), name, old, neew)));
    // Cull very old stuff
    for (; tracker.getComponentCount() > MAX_LOG_ENTRIES; )
    {
      tracker.remove(0);
    }
    tracker.revalidate();
  });
}

代码示例来源:origin: ballerina-platform/ballerina-lang

private JComboBox<String> createComboBox(final JPanel panel, final String selected) {
  final JComboBox<String> typeBox = new ComboBox<>();
  final ConfigurableTypes[] types = ConfigurableTypes.values();
  for (final ConfigurableTypes type : types) {
    typeBox.addItem(type.getTyp());
  }
  typeBox.setSelectedItem(selected);
  typeBox.addItemListener(e -> {
    if (e.getStateChange() == ItemEvent.SELECTED) {
      final int idx = getComponentIndex(panel);
      if (e.getItem().equals(ConfigurableTypes.ARTIFACT.getTyp())) {
        rootPanel.add(createArtifactRow("", "", "", ""), idx);
        rootPanel.remove(panel);
        rows.remove(idx);
      } else if (e.getItem().equals(ConfigurableTypes.RAWCOMMAND.getTyp())) {
        rootPanel.add(createCommandRow("", ""), idx);
        rootPanel.remove(panel);
        rows.remove(idx);
      } else if (e.getItem().equals(ConfigurableTypes.EXE.getTyp())) {
        rootPanel.add(createExeRow("", "", ""), idx);
        rootPanel.remove(panel);
        rows.remove(idx);
      } else {
        LOG.error("Unknown type : " + e.getItem());
      }
    }
  });
  return typeBox;
}

代码示例来源:origin: kiegroup/optaplanner

@Override
public void updatePanel(CloudBalance cloudBalance) {
  Set<CloudComputer> deadCloudComputerSet = new LinkedHashSet<>(computerToPanelMap.keySet());
  deadCloudComputerSet.remove(null);
  for (CloudComputer computer : cloudBalance.getComputerList()) {
    deadCloudComputerSet.remove(computer);
    CloudComputerPanel computerPanel = computerToPanelMap.get(computer);
    if (computerPanel == null) {
      computerPanel = new CloudComputerPanel(this, computer);
      computersPanel.add(computerPanel);
      computerToPanelMap.put(computer, computerPanel);
    }
    computerPanel.clearProcesses();
  }
  unassignedPanel.clearProcesses();
  for (CloudProcess process : cloudBalance.getProcessList()) {
    CloudComputer computer = process.getComputer();
    CloudComputerPanel computerPanel = computerToPanelMap.get(computer);
    computerPanel.addProcess(process);
  }
  for (CloudComputer deadComputer : deadCloudComputerSet) {
    CloudComputerPanel deadComputerPanel = computerToPanelMap.remove(deadComputer);
    computersPanel.remove(deadComputerPanel);
  }
  for (CloudComputerPanel computerPanel : computerToPanelMap.values()) {
    computerPanel.update();
  }
  // If computersPanel.add() or computersPanel.remove() was called, the component needs to be validated.
  computersPanel.validate();
}

代码示例来源:origin: kiegroup/optaplanner

if (tooBigLabel == null) {
  tooBigLabel = new JLabel("The dataset is too big to show.");
  machineListPanel.add(tooBigLabel);
  machineListPanel.remove(tooBigLabel);
  tooBigLabel = null;
  if (machinePanel == null) {
    machinePanel = new MrMachinePanel(this, resourceList, machine);
    machineListPanel.add(machinePanel);
    machineToPanelMap.put(machine, machinePanel);
  machineListPanel.remove(deadMachinePanel);

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

container.remove(pluginToolbar);
container.add(pluginToolbar);

代码示例来源:origin: kiegroup/optaplanner

if (employeePanel == null) {
  employeePanel = new EmployeePanel(this, shiftDateList, shiftList, employee);
  employeeListPanel.add(employeePanel);
  employeeToPanelMap.put(employee, employeePanel);
employeeListPanel.remove(deadEmployeePanel);

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

boxes.remove(box);
  updateOverall();
  logsContainer.remove(box);
  logsContainer.repaint();
logsContainer.add(box, 0);
  logsContainer.remove(boxes.remove(0));

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

void updateOffer(ItemComposition item, BufferedImage itemImage, GrandExchangeOffer newOffer, int slot)
{
  /* If slot was previously filled, and is now empty, remove it from the list */
  if (newOffer == null || newOffer.getState() == GrandExchangeOfferState.EMPTY)
  {
    if (offerSlotPanels[slot] != null)
    {
      offerPanel.remove(offerSlotPanels[slot]);
      offerSlotPanels[slot] = null;
      revalidate();
      repaint();
    }
    removeTopMargin();
    updateEmptyOffersPanel();
    return;
  }
  /* If slot was empty, and is now filled, add it to the list */
  if (offerSlotPanels[slot] == null)
  {
    GrandExchangeOfferSlot newSlot = new GrandExchangeOfferSlot();
    offerSlotPanels[slot] = newSlot;
    offerPanel.add(newSlot, constraints);
    constraints.gridy++;
  }
  offerSlotPanels[slot].updateOffer(item, itemImage, newOffer);
  removeTopMargin();
  revalidate();
  repaint();
  updateEmptyOffersPanel();
}

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

/** Setter for user's component.
 * @param c user's component
 */
public void setRightComponent(Component c) {
  if (rightComponent != null) {
    rightPanel.remove(rightComponent);
  }
  rightComponent = c;
  rightPanel.add(rightComponent, BorderLayout.CENTER);
  //            validate();
}

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

private void createPacks(int numPacks) {
  while (packPanels.size() > numPacks) {
    pnlPacks.remove(packPanels.get(packPanels.size() - 1));
    packPanels.remove(packPanels.size() - 1);
    pnlPacks.add(setPanel);
    pack.setPreferredSize(new Dimension(50, 25));
    pack.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));
    setPanel.add(pack);
    setPanel.add(searchButton);

代码示例来源:origin: org.scijava/ui-behaviour

public void setButtonPanelVisible( final boolean visible )
{
  panelEditor.remove( panelButtons );
  if ( visible )
    panelEditor.add( panelButtons, BorderLayout.SOUTH );
}

代码示例来源:origin: net.java.abeille/abeille

/**
 * Sets the one and only panel for this dialog
 */
public void setPrimaryPanel(JComponent primaryPanel) {
  if (m_primaryPanel != null) {
    m_contentpane.remove(m_primaryPanel);
  }
  m_primaryPanel = primaryPanel;
  m_contentpane.add(primaryPanel, BorderLayout.CENTER);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** Setter for user's component. 
     * @param c user's component
     */
    public void setRightComponent(Component c) {
      if (rightComponent != null)
        rightPanel.remove(rightComponent);
      rightComponent = c;
      rightPanel.add(rightComponent, BorderLayout.CENTER);
//            validate();
    }
    /** Getter for user's component.

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** Setter for user's component. 
     * @param c user's component
     */
    public void setRightComponent(Component c) {
      if (rightComponent != null)
        rightPanel.remove(rightComponent);
      rightComponent = c;
      rightPanel.add(rightComponent, BorderLayout.CENTER);
//            validate();
    }
    /** Getter for user's component.

代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client

@Override
protected void showProgress(double fraction) {
  if (fraction < 0.0) {
    previewPanel.add(waitPanel);
  } else if (fraction >= 1.0) {
    worker = null;
    previewPanel.remove(waitPanel);
  }
}

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

private void setMainContent(Component c)
{
  if (mainContent != null)
    mainPanel.remove(mainContent);
  mainContent = c;
  mainPanel.add(mainContent, BorderLayout.CENTER);
  mainPanel.revalidate();
  mainPanel.repaint();
} //}}}

相关文章

JPanel类方法