本文整理汇总了Java中javax.swing.JButton.setVisible方法的典型用法代码示例。如果您正苦于以下问题:Java JButton.setVisible方法的具体用法?Java JButton.setVisible怎么用?Java JButton.setVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JButton
的用法示例。
在下文中一共展示了JButton.setVisible方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createButton
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Helper method used to create a button inside a JPanel
* @param action action associated to that button
* @return created component
*/
private JComponent createButton(AbstractAction action) {
JPanel panel = new JPanel(); // Use gridbag as centers by default
JButton button = new JButton(action);
button.setHorizontalTextPosition(SwingConstants.CENTER);
button.setVerticalTextPosition(SwingConstants.BOTTOM);
button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
button.addMouseListener(rollover);
if (action == buttonAction[3]) {
button.setVisible(false);
}
if (action == buttonAction[0]) {
button.setEnabled(false);
}
//if (action == buttonAction[2]) button.setEnabled(false);
//if (action == buttonAction[4]) button.setEnabled(false);
panel.add(button);
return panel;
}
示例2: CardPanel
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Creates a new CardPanel
*
* @param game
*/
public CardPanel(GameProxy game) {
this.cards = new ArrayList<>();
this.chosenCards = new ArrayList<>();
this.game = game;
initComponents();
playTris = new JButton();
playTris.setText("Gioca il tris");
playTris.setVisible(false);
playTris.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
playTrisActionPerformed(evt);
}
});
this.add(playTris);
playTris.setBounds(1015, 100, 125, 50);
}
示例3: createButton
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Helper method used to create a button inside a JPanel
* @param action action associated to that button
* @return created component
*/
private JComponent createButton(AbstractAction action) {
JPanel panel = new JPanel(); // Use gridbag as centers by default
JButton button = new JButton(action);
button.setHorizontalTextPosition(SwingConstants.CENTER);
button.setVerticalTextPosition(SwingConstants.BOTTOM);
button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
button.addMouseListener(rollover);
if (action == buttonAction[3]) {
button.setVisible(false);
}
if (action == buttonAction[0]) {
button.setEnabled(false);
}
//if(action == buttonAction[2]) button.setEnabled(false);
//if(action == buttonAction[4]) button.setEnabled(false);
panel.add(button);
return panel;
}
示例4: initAndCreateRootComponent
import javax.swing.JButton; //导入方法依赖的package包/类
@Override
protected JComponent initAndCreateRootComponent() throws Exception
{
initSettings();
initServer();
saveButton = new JButton(CurrentLocale.get("button.save"));
saveButton.addActionListener(new SaveActionListener());
saveButton.setVisible(false);
ignoreChangesButton = new JButton(CurrentLocale.get("button.cancel"));
ignoreChangesButton.addActionListener(new CancelActionListener());
ignoreChangesButton.setVisible(false);
final JPanel all = new JPanel();
all.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
all.setBackground(getBackgroundColour());
all.add(saveButton);
all.add(ignoreChangesButton);
return all;
}
示例5: main
import javax.swing.JButton; //导入方法依赖的package包/类
public static void main(String[] args){
dimension = Integer.parseInt(args[0]);
size = Integer.parseInt(args[1]);
//margin = (args[2].equals("1")) ? size : 0;
bigDim = dimension + 4;
dim = dimension * size;
frame = new JFrame();
frame.setSize(dim+2*margin, dim+2*margin+size/2);
frame.getContentPane().add(new Knight());
frame.setLocationRelativeTo(null);
frame.setBackground(Color.LIGHT_GRAY);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
JButton btnNext = new JButton();
btnNext.setVisible(true);
frame.add(btnNext);
btnNext.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
step++;
}
});
start();
}
示例6: createGUI
import javax.swing.JButton; //导入方法依赖的package包/类
private static void createGUI() {
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button = new JButton("Default button");
button.setDefaultCapable(true);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ButtonClickCount++;
}
});
frame.add(button);
button.setVisible(false);
frame.getRootPane().setDefaultButton(button);
frame.setSize(200, 200);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
示例7: DirectPeerPool
import javax.swing.JButton; //导入方法依赖的package包/类
public DirectPeerPool(Properties param) {
params = new Properties();
params.putAll(param);
serverMode = P2PClientFactory.P2P_SERVER_MODE.equals(params.getProperty(P2PClientFactory.P2P_MODE_KEY));
inviteButton = new JButton(Resources.getString("Peer2Peer.connect")); //$NON-NLS-1$
inviteButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.setVisible(true);
}
});
inviteButton.setEnabled(false);
inviteButton.setVisible(P2PClientFactory.P2P_SERVER_MODE.equals(params.getProperty(P2PClientFactory.P2P_MODE_KEY)));
}
示例8: setAllowMultiple
import javax.swing.JButton; //导入方法依赖的package包/类
public void setAllowMultiple(boolean val) {
allowMultiple = val;
if (multipleButtons != null) {
for (JButton b : multipleButtons) {
b.setVisible(allowMultiple);
}
}
}
示例9: actionPerformed
import javax.swing.JButton; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent event)
{
// check event source and lay out content pane correspondingly
for (JButton button : buttons)
{
if (event.getSource() == button)
button.setVisible(false); // hide the button that was clicked
else
button.setVisible(true); // show other buttons
}
layout.layoutContainer(getContentPane()); // lay out content pane
}
示例10: add
import javax.swing.JButton; //导入方法依赖的package包/类
public void add(TrnControllerGUI g) {
guiList.add(g);
JLabel L = new JLabel(g.getId());
stylizeInfoLabel_Bold(L);
idList.add(L);
L.setBounds(30, yCount + 8, 100, 24);
contentPane.add(L);
JButton B = new JButton("VIEW");
stylizeButton(B);
buttonList.add(B);
B.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) { //finds the index of the button and sets the same index controller gui to visible
int i = buttonList.indexOf(B);
TrnControllerGUI I = guiList.get(i);
I.setVisible(true);
}
});
B.setBounds(150, yCount, 70, 37);
B.setVisible(true);
B.setEnabled(true);
contentPane.add(B);
yCount = yCount + 50;
if (yCount >= (height - 50)) { //increases size of frame if the buttons need more space
height = height + 50;
logoHeight = logoHeight + 50;
frame.setBounds(100, 500, 450, height);
icon_logo.setBounds(330, logoHeight, 100, 100);
}
frame.repaint();
}
示例11: trainPoofByName
import javax.swing.JButton; //导入方法依赖的package包/类
public void trainPoofByName(String name) {
JButton B;
JLabel L;
Point P;
TrnControllerGUI G;
int j, y;
int i = -1;
for (JLabel l : idList) { //finds the index of JLabel that has the same id as the id to delete
if (l.getText().equals(name)) {
i = idList.indexOf(l);
break;
}
}
if (i != -1) { //moves all the other buttons up on the gui
for (j = (i + 1); j < idList.size(); j++) {
B = buttonList.get(j);
P = B.getLocation();
y = (int)P.getY();
B.setBounds(150, y - 50, 70, 37);
L = idList.get(j);
L.setBounds(30, y - 42, 100, 24);
}
B = buttonList.remove(i); //sets the label, button, and deleted controller object to null
B.setVisible(false);
B = null;
L = idList.remove(i);
L.setVisible(false);
L = null;
G = guiList.remove(i);
G = null;
}
}
示例12: createNotificationPanel
import javax.swing.JButton; //导入方法依赖的package包/类
private static JPanel createNotificationPanel(final URL url) {
JPanel panel = new JPanel();
JLabel msgLabel = new JLabel("<html>" + NbBundle.getMessage(JiraUpdater.class, "MSG_PROJECT_NEEDS_JIRA")); // NOI18N
JButton linkButton = new org.netbeans.modules.bugtracking.commons.LinkButton();
org.openide.awt.Mnemonics.setLocalizedText(linkButton, NbBundle.getMessage(JiraUpdater.class, "MSG_PROJECT_NEEDS_JIRA_LINK")); // NOI18N
if (url != null) {
linkButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
HtmlBrowser.URLDisplayer displayer = HtmlBrowser.URLDisplayer.getDefault ();
if (displayer != null) {
displayer.showURL(url);
} else {
// XXX nice error message?
Support.LOG.warning("No URLDisplayer found."); // NOI18N
}
}
});
} else {
linkButton.setVisible(false);
}
GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setHorizontalGroup(
layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(msgLabel, GroupLayout.PREFERRED_SIZE, 470, Short.MAX_VALUE)
.addComponent(linkButton))
.addContainerGap()
);
layout.setVerticalGroup(
layout.createSequentialGroup()
.addContainerGap()
.addComponent(msgLabel)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(linkButton)
.addContainerGap(25, Short.MAX_VALUE)
);
return panel;
}
示例13: createGroupSelectionButton
import javax.swing.JButton; //导入方法依赖的package包/类
public static synchronized JButton createGroupSelectionButton() {
final JButton button = VariablesViewButtons.createButton(
"org/netbeans/modules/debugger/resources/breakpointsView/BreakpointGroups_options_16.png",
NbBundle.getMessage (BreakpointsViewButtons.class, "Hint_Select_bp_groups")
);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final Properties props = Properties.getDefault().getProperties("Breakpoints");
String[] groupNames = (String[]) props.getArray("Grouping", new String[] { Group.CUSTOM.name() });
String brkpGroup;
if (groupNames.length == 0) {
brkpGroup = Group.NO.name();
} else if (groupNames.length > 1) {
brkpGroup = Group.NESTED.name();
} else {
brkpGroup = groupNames[0];
}
JPopupMenu menu = new JPopupMenu(NbBundle.getMessage (BreakpointsViewButtons.class, "Lbl_bp_groups"));
for (Group group : Group.values()) {
menu.add(createJRadioButtonMenuItem(group, brkpGroup));
}
menu.addSeparator();
menu.add(createCheckBoxMenuItem("LBL_BreakpointsFromOpenProjectsOnly", BreakpointGroup.PROP_FROM_OPEN_PROJECTS, props));
if (currentSessionHaveProjects()) {
menu.add(createCheckBoxMenuItem("LBL_BreakpointsFromCurrentDebugSessionOnly", BreakpointGroup.PROP_FROM_CURRENT_SESSION_PROJECTS, props));
}
menu.show(button, 16, 0);
}
});
button.setVisible(false);
RequestProcessor.getDefault().post(new Runnable() {
@Override
public void run() {
boolean groupableBreakpoints = false;
Breakpoint[] brkps = DebuggerManager.getDebuggerManager().getBreakpoints();
for (Breakpoint b : brkps) {
if (b.getGroupProperties() != null) {
groupableBreakpoints = true;
break;
}
}
if (groupableBreakpoints) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
button.setVisible(true);
}
});
} else {
final boolean[] gb = new boolean[] { groupableBreakpoints };
DebuggerManager.getDebuggerManager().addDebuggerListener(new DebuggerManagerAdapter() {
@Override
public void breakpointAdded(Breakpoint breakpoint) {
if (!gb[0] && breakpoint.getGroupProperties() != null) {
gb[0] = true;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
button.setVisible(true);
}
});
}
}
});
}
}
});
return button;
}
示例14: initGUI
import javax.swing.JButton; //导入方法依赖的package包/类
/**
* Initialize all gui related stuff
*/
private void initGUI() {
// Sets default title, close operation and dimensions
this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
this.setIconImage(JMTImageLoader.loadImage("Results").getImage());
this.centerWindow(CommonConstants.MAX_GUI_WIDTH_JSIM_RESULTS, CommonConstants.MAX_GUI_HEIGHT_JSIM_RESULTS);
// Creates all tabs
JTabbedPane mainPanel = new JTabbedPane();
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(mainPanel, BorderLayout.CENTER);
addTabPane(mainPanel, SimulationDefinition.MEASURE_QL, DESCRIPTION_QUEUE_LENGTH, results.getQueueLengthMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_QT, DESCRIPTION_QUEUE_TIME, results.getQueueTimeMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_RP, DESCRIPTION_RESPONSE_TIME, results.getResponseTimeMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_RD, DESCRIPTION_RESIDENCE_TIME, results.getResidenceTimeMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_U, DESCRIPTION_UTILIZATION, results.getUtilizationMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_X, DESCRIPTION_THROUGHPUT, results.getThroughputMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_DR, DESCRIPTION_DROP_RATE, results.getDropRateMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_S_CN, DESCRIPTION_SYSTEM_CUSTOMER_NUMBER, results.getSystemCustomerNumberMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_S_RP, DESCRIPTION_SYSTEM_RESPONSE_TIME, results.getSystemResponseTimeMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_S_X, DESCRIPTION_SYSTEM_THROUGHPUT, results.getSystemThroughputMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_S_DR, DESCRIPTION_SYSTEM_DROP_RATE, results.getSystemDropRateMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_S_P, DESCRIPTION_SYSTEM_POWER, results.getSystemPowerMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_RP_PER_SINK, DESCRIPTION_RESPONSE_TIME_PER_SINK, results.getResponsetimePerSinkMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_X_PER_SINK, DESCRIPTION_THROUGHPUT_PER_SINK, results.getThroughputPerSinkMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_FCR_TW, DESCRIPTION_FCR_TOTAL_WEIGHT, results.getFCRTotalWeightMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_FCR_MO, DESCRIPTION_FCR_MEMORY_OCCUPATION, results.getFCRMemoryOccupationMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_FJ_CN, DESCRIPTION_FJ_CUSTOMER_NUMBER, results.getFJCustomerNumberMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_FJ_RP, DESCRIPTION_FJ_RESPONSE_TIME, results.getFJResponseTimeMeasures());
addTabPane(mainPanel, SimulationDefinition.MEASURE_FX, DESCRIPTION_FIRING_THROUGHPUT, results.getFiringThroughputMeasures());
// Creates bottom toolbar
JToolBar toolbar = new JToolBar();
toolbar.setFloatable(false);
toolbar.setRollover(true);
start = new JButton();
toolbar.add(start);
start.setVisible(false);
pause = new JButton();
toolbar.add(pause);
pause.setVisible(false);
stop = new JButton();
toolbar.add(stop);
stop.setVisible(false);
// Adds a progress bar
progressBar = new JProgressBar();
progressBar.setStringPainted(true);
progressBar.setForeground(Color.BLUE);
UIManager.put("ProgressBar.selectionForeground", Color.WHITE);
setProgressBar(results.getProgress(), results.getElapsedTime());
toolbar.add(progressBar);
// Add close window button
JButton close = new JButton();
close.setIcon(JMTImageLoader.loadImage("Close"));
close.setFocusPainted(false);
close.setContentAreaFilled(false);
close.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
close.setRolloverIcon(JMTImageLoader.loadImage("CloseRO"));
close.setPressedIcon(JMTImageLoader.loadImage("CloseP"));
close.setVisible(true);
close.setToolTipText("Closes this window");
close.addActionListener(new ActionListener() {
// Fires a window closing event
public void actionPerformed(ActionEvent e) {
ResultsWindow.this.dispatchEvent(new WindowEvent(ResultsWindow.this, WindowEvent.WINDOW_CLOSING));
}
});
toolbar.add(close);
// Adds toolbar
this.getContentPane().add(toolbar, BorderLayout.SOUTH);
// Adds listener for progressBar
results.setProgressListener(new MeasureDefinition.ProgressListener() {
public void progressChanged(double progress, long elapsedTime) {
setProgressBar(progress, elapsedTime);
}
});
}
示例15: insereBotoes
import javax.swing.JButton; //导入方法依赖的package包/类
private void insereBotoes() {
arrayBotoesBebidas.add(btn_Bebida1);
arrayBotoesBebidas.add(btn_Bebida2);
arrayBotoesBebidas.add(btn_Bebida3);
arrayBotoesBebidas.add(btn_Bebida4);
arrayBotoesBebidas.add(btn_Bebida5);
arrayBotoesBebidas.add(btn_Bebida6);
arrayBotoesBebidas.add(btn_Bebida7);
arrayBotoesBebidas.add(btn_Bebida8);
arrayBotoesBebidas.add(btn_Bebida9);
arrayBotoesBebidas.add(btn_Bebida10);
arrayBotoesBebidas.add(btn_Bebida11);
arrayBotoesBebidas.add(btn_Bebida12);
arrayBotoesBebidas.add(btn_Bebida13);
arrayBotoesBebidas.add(btn_Bebida14);
arrayBotoesBebidas.add(btn_Bebida15);
arrayBotoesBebidas.add(btn_Bebida16);
arrayBotoesBebidas.add(btn_Bebida17);
arrayBotoesBebidas.add(btn_Bebida18);
arrayBotoesBebidas.add(btn_Bebida19);
arrayBotoesBebidas.add(btn_Bebida20);
arrayBotoesLanches.add(btn_Lanche1);
arrayBotoesLanches.add(btn_Lanche2);
arrayBotoesLanches.add(btn_Lanche3);
arrayBotoesLanches.add(btn_Lanche4);
arrayBotoesLanches.add(btn_Lanche5);
arrayBotoesLanches.add(btn_Lanche6);
arrayBotoesLanches.add(btn_Lanche7);
arrayBotoesLanches.add(btn_Lanche8);
arrayBotoesLanches.add(btn_Lanche9);
arrayBotoesLanches.add(btn_Lanche10);
arrayBotoesLanches.add(btn_Lanche11);
arrayBotoesLanches.add(btn_Lanche12);
arrayBotoesLanches.add(btn_Lanche13);
arrayBotoesLanches.add(btn_Lanche14);
arrayBotoesLanches.add(btn_Lanche15);
arrayBotoesLanches.add(btn_Lanche16);
arrayBotoesLanches.add(btn_Lanche17);
arrayBotoesLanches.add(btn_Lanche18);
arrayBotoesLanches.add(btn_Lanche19);
arrayBotoesLanches.add(btn_Lanche20);
for (JButton lanche : arrayBotoesLanches) {
lanche.setVisible(false);
}
for (JButton bebidas : arrayBotoesBebidas) {
bebidas.setVisible(false);
}
}