下面列出了java.awt.CardLayout#show ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Show panel for selected tree item.
*
* @param parentClass the parent class
* @param classSelected the class selected
*/
@Override
public void show(Class<?> parentClass, Class<?> classSelected) {
String key = null;
if (classSelected != null) {
key = classSelected.toString();
} else {
key = EMPTY_PANEL_KEY;
}
PopulateDetailsInterface panel = getPanel(parentClass, key);
if (panel != null) {
CardLayout cl = (CardLayout) (detailsPanel.getLayout());
currentDisplayedPanel = encodePanelKey(key, panel);
cl.show(detailsPanel, currentDisplayedPanel);
SelectedSymbol selectedSymbol = SelectedSymbol.getInstance();
panel.populate(selectedSymbol);
}
repaint();
}
/**
* Sets the scientific study and researcher to display. If either parameter is
* null, display blank pane.
*
* @param study the scientific study.
* @param researcher the researcher.
*/
void setStudyResearcher(ScientificStudy study, Person researcher) {
this.study = study;
this.researcher = researcher;
CardLayout cardLayout = (CardLayout) getLayout();
if ((study == null) || (researcher == null)) {
cardLayout.show(this, Msg.getString("ResearcherPanel.blank")); //$NON-NLS-1$
} else {
cardLayout.show(this, Msg.getString("ResearcherPanel.researcher")); //$NON-NLS-1$
if (researcher.equals(study.getPrimaryResearcher())) {
researcherHeader.setText(Msg.getString("ResearcherPanel.primaryResearcher")); //$NON-NLS-1$
scienceLabel.setText(study.getScience().getName()); // $NON-NLS-1$
} else {
researcherHeader.setText(Msg.getString("ResearcherPanel.collaborativeResearcher")); //$NON-NLS-1$
ScienceType collabScience = study.getCollaborativeResearchers().get(researcher.getIdentifier());
scienceLabel.setText(collabScience.getName()); // $NON-NLS-1$
}
nameButton.setText(researcher.getName());
update();
}
}
/**
* Data source loaded.
*
* @param geometryType the geometry type
* @param isConnectedToDataSourceFlag the is connected to data source flag
*/
@Override
public void dataSourceLoaded(
GeometryTypeEnum geometryType, boolean isConnectedToDataSourceFlag) {
this.geometryType = geometryType;
featureList = DataSourceFactory.getDataSource().getFeatureSource();
userLayerFeatureListMap = DataSourceFactory.getDataSource().getUserLayerFeatureSource();
gridCoverage = DataSourceFactory.getDataSource().getGridCoverageReader();
calculateMapBounds();
CardLayout cardLayout = (CardLayout) mapPanel.getLayout();
if ((geometryType == GeometryTypeEnum.UNKNOWN) || !isConnectedToDataSourceFlag) {
cardLayout.show(mapPanel, NOMAP_PANEL);
} else {
cardLayout.show(mapPanel, MAP_PANEL);
internalRenderStyle();
}
}
/**
* stop simulation
*/
public void stopSimulation(){
CardLayout cl = (CardLayout)(startStopJPanel_.getLayout());
cl.show(startStopJPanel_, "start"); //$NON-NLS-1$
Runnable job = new Runnable() {
public void run() {
VanetSimStart.getSimulationMaster().stopThread();
}
};
new Thread(job).start();
}
private void create() {
setLayout(new BorderLayout());
JPanel boxPanel = new JPanel();
boxPanel.setLayout(new BoxLayout(boxPanel, BoxLayout.Y_AXIS));
cardLayout = new CardLayout();
cardPanel = new JPanel(cardLayout);
cardPanel.setBorder(BorderFactory.createTitledBorder("Resolve Block Conflict"));
ChangeListener listener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
mergeManager.setApplyEnabled(true);
}
};
commentPanel = new CommentsConflictPanel(listener);
cardPanel.add(commentPanel, COMMENT_PANEL_ID);
namePanel = new BlockConflictPanel(listener);
cardPanel.add(namePanel, CONFLICT_PANEL_ID);
cardLayout.show(cardPanel, CONFLICT_PANEL_ID);
countPanel = new ConflictCountPanel();
boxPanel.add(countPanel);
boxPanel.add(Box.createVerticalStrut(10));
boxPanel.add(cardPanel);
add(boxPanel, BorderLayout.CENTER);
add(createUseForAllCheckBox(), BorderLayout.SOUTH);
}
@SuppressWarnings("LeakingThisInConstructor")
WizardDialog(JFrame frame, boolean modal) {
super(frame, "Embedded JFileChooser Demo", modal);
cardLayout = new CardLayout();
cardPanel = new JPanel(cardLayout);
getContentPane().add(cardPanel, BorderLayout.CENTER);
messageLabel = new JLabel("", JLabel.CENTER);
cardPanel.add(chooser, "fileChooser");
cardPanel.add(messageLabel, "label");
cardLayout.show(cardPanel, "fileChooser");
chooser.addActionListener(this);
JPanel buttonPanel = new JPanel();
backButton = new JButton("< Back");
nextButton = new JButton("Next >");
closeButton = new JButton("Close");
buttonPanel.add(backButton);
buttonPanel.add(nextButton);
buttonPanel.add(closeButton);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
backButton.setEnabled(false);
getRootPane().setDefaultButton(nextButton);
backButton.addActionListener(this);
nextButton.addActionListener(this);
closeButton.addActionListener(this);
pack();
setLocationRelativeTo(frame);
}
private void setPlayerCharacterPanelOnTop(ActionEvent e) {
CardLayout cardLayout = (CardLayout) rootInventoryPanel.getLayout();
cardLayout.show(rootInventoryPanel, "player");
playercharacterToggleButton.setFont(Fonts.FONT);
playercharacterToggleButton.setSelected(true);
targetToggleButton.setFont(Fonts.FONT);
targetToggleButton.setSelected(false);
}
@SuppressWarnings("LeakingThisInConstructor")
WizardDialog(JFrame frame, boolean modal) {
super(frame, "Embedded JFileChooser Demo", modal);
cardLayout = new CardLayout();
cardPanel = new JPanel(cardLayout);
getContentPane().add(cardPanel, BorderLayout.CENTER);
messageLabel = new JLabel("", JLabel.CENTER);
cardPanel.add(chooser, "fileChooser");
cardPanel.add(messageLabel, "label");
cardLayout.show(cardPanel, "fileChooser");
chooser.addActionListener(this);
JPanel buttonPanel = new JPanel();
backButton = new JButton("< Back");
nextButton = new JButton("Next >");
closeButton = new JButton("Close");
buttonPanel.add(backButton);
buttonPanel.add(nextButton);
buttonPanel.add(closeButton);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
backButton.setEnabled(false);
getRootPane().setDefaultButton(nextButton);
backButton.addActionListener(this);
nextButton.addActionListener(this);
closeButton.addActionListener(this);
pack();
setLocationRelativeTo(frame);
}
private JComponent createDebugPanel() {
BufferedImage img = (BufferedImage) getClientProperty("debug.ghost.image");
if (img == null)
return this;
final CardLayout cardLayout = new CardLayout();
final JPanel panel = new JPanel(cardLayout);
JPanel imagePanel = new JPanel();
imagePanel.setUI(new PanelImageUI(img));
JPanel paneWrapper = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.NONE;
c.gridx = 0;
c.gridy = 0;
c.weightx = 1;
c.weighty = 1;
paneWrapper.add(this, c);
panel.add(paneWrapper, "real");
panel.add(imagePanel, "debug");
Timer timer = new Timer(2000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
String mode = (System.currentTimeMillis() % 4000) > 2000 ? "real"
: "debug";
cardLayout.show(panel, mode);
}
});
timer.start();
return panel;
}
@SuppressWarnings("LeakingThisInConstructor")
WizardDialog(JFrame frame, boolean modal) {
super(frame, "Embedded JFileChooser Demo", modal);
cardLayout = new CardLayout();
cardPanel = new JPanel(cardLayout);
getContentPane().add(cardPanel, BorderLayout.CENTER);
messageLabel = new JLabel("", JLabel.CENTER);
cardPanel.add(chooser, "fileChooser");
cardPanel.add(messageLabel, "label");
cardLayout.show(cardPanel, "fileChooser");
chooser.addActionListener(this);
JPanel buttonPanel = new JPanel();
backButton = new JButton("< Back");
nextButton = new JButton("Next >");
closeButton = new JButton("Close");
buttonPanel.add(backButton);
buttonPanel.add(nextButton);
buttonPanel.add(closeButton);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
backButton.setEnabled(false);
getRootPane().setDefaultButton(nextButton);
backButton.addActionListener(this);
nextButton.addActionListener(this);
closeButton.addActionListener(this);
pack();
setLocationRelativeTo(frame);
}
private void jcboMachinePLUDeviceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboMachinePLUDeviceActionPerformed
CardLayout cl = (CardLayout) (m_jPLUParams.getLayout());
if (jcboMachinePLUDevice.getSelectedItem().equals("extended")) {
cl.show(m_jPLUParams, "extended");
} else {
cl.show(m_jPLUParams, "empty");
}
}
public void install()
{
selectionModel.addListSelectionListener(this);
currentPage.restoreModels();
CardLayout pages = (CardLayout) pagePanel.getLayout();
pages.show(pagePanel, currentPage.id);
}
/**
* starts simulation
*/
public void startSimulation(){
if(VanetSimStart.getMainControlPanel().getEditPanel().getEditMode() == true) ErrorLog.log(Messages.getString("SimulateControlPanel.simulationNotPossibleInEditMode"), 6, this.getName(), "startSim", null); //$NON-NLS-1$ //$NON-NLS-2$
else {
CardLayout cl = (CardLayout)(startStopJPanel_.getLayout());
cl.show(startStopJPanel_, "pause"); //$NON-NLS-1$
VanetSimStart.getSimulationMaster().startThread();
}
}
/** Go to previous wizard panel. */
public void buttonClickedPrev() {
getCurrentWizardPanel().clearInfo();
displayPanelIndex--;
CardLayout layout = (CardLayout) infoPane.getLayout();
layout.show(infoPane, getCurrentWizardPanel().getPanelName());
nextButton.setEnabled(true);
if (displayPanelIndex == 0) prevButton.setEnabled(false);
}
private void jcboMachineDisplayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcboMachineDisplayActionPerformed
CardLayout cl = (CardLayout) (m_jDisplayParams.getLayout());
if (jcboMachineDisplay.getSelectedItem().equals("extended")) {
cl.show(m_jDisplayParams, "extended");
} else {
cl.show(m_jDisplayParams, "empty");
}
}
private void showView(String sView) {
CardLayout cl = (CardLayout) (m_jPanelContainer.getLayout());
cl.show(m_jPanelContainer, sView);
}
private void showView(String view) {
CardLayout cl = (CardLayout) (getLayout());
cl.show(this, view);
}
private void loadOptions(ActionEvent e) {
ActionToGoalMapping mapp = handle.getActionMappings((ModelHandle2.Configuration) cbConfiguration.getSelectedItem());
List<NetbeansActionMapping> lst = mapp.getActions();
run = null;
debug = null;
for (NetbeansActionMapping m : lst) {
if (ActionProvider.COMMAND_RUN.equals(m.getActionName())) {
run = m;
}
if (ActionProvider.COMMAND_DEBUG.equals(m.getActionName())) {
debug = m;
}
}
if (run == null) {
run = ModelHandle2.getDefaultMapping(ActionProvider.COMMAND_RUN, project);
}
if (debug == null) {
debug = ModelHandle2.getDefaultMapping(ActionProvider.COMMAND_DEBUG, project);
}
/*
if (run == null) {
// disable
Queue<JComponent> comps = new ArrayDeque<>();
comps.add(nestedOptions);
while (!comps.isEmpty()) {
JComponent c = comps.poll();
c.setEnabled(false);
if (c.getComponentCount() > 0) {
Component[] children = c.getComponents();
for (Component cc : children) {
if (cc instanceof JComponent) {
comps.offer((JComponent)cc);
}
}
}
}
} else {
nestedOptions.readOptions(run.getProperties());
}
*/
CardLayout cl = (CardLayout)detailPanel.getLayout();
if (run == null) {
cl.show(detailPanel, "disabled");
} else {
nestedOptions.readOptions(run.getProperties());
cl.show(detailPanel, "jshell");
}
}
private void showCardRight(String card) {
CardLayout cl = (CardLayout) (displayWithPreview.getLayout());
cl.show(displayWithPreview, card);
}
/**
* Activate a certain card in the operation panel.
*
* Currently you can choose between categorized operations and
* a list of filtered operations.
*/
private void showOperationCard(String card) {
CardLayout cl = (CardLayout)(operationCardPanel.getLayout());
cl.show(operationCardPanel, card);
}