Java Code Examples for javax.swing.JButton#setVisible()

The following examples show how to use javax.swing.JButton#setVisible() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProgressPanel.java    From jadx with Apache License 2.0 6 votes vote down vote up
public ProgressPanel(final MainWindow mainWindow, boolean showCancelButton) {
	this.showCancelButton = showCancelButton;

	progressLabel = new JLabel();
	progressBar = new JProgressBar(0, 100);
	progressBar.setIndeterminate(true);
	progressBar.setStringPainted(false);
	progressLabel.setLabelFor(progressBar);

	setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
	setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
	setVisible(false);
	add(progressLabel);
	add(progressBar);

	cancelButton = new JButton(ICON_CANCEL);
	cancelButton.setPreferredSize(new Dimension(ICON_CANCEL.getIconWidth(), ICON_CANCEL.getIconHeight()));
	cancelButton.setToolTipText("Cancel background jobs");
	cancelButton.setBorderPainted(false);
	cancelButton.setFocusPainted(false);
	cancelButton.setContentAreaFilled(false);
	cancelButton.addActionListener(e -> mainWindow.cancelBackgroundJobs());
	cancelButton.setVisible(showCancelButton);
	add(cancelButton);
}
 
Example 2
Source File: PreviewPanel.java    From jpexs-decompiler with GNU General Public License v3.0 6 votes vote down vote up
private JPanel createGenericTagButtonsPanel() {
    genericEditButton = new JButton(mainPanel.translate("button.edit"), View.getIcon("edit16"));
    genericEditButton.setMargin(new Insets(3, 3, 3, 10));
    genericEditButton.addActionListener(this::editGenericTagButtonActionPerformed);
    genericSaveButton = new JButton(mainPanel.translate("button.save"), View.getIcon("save16"));
    genericSaveButton.setMargin(new Insets(3, 3, 3, 10));
    genericSaveButton.addActionListener(this::saveGenericTagButtonActionPerformed);
    genericSaveButton.setVisible(false);
    genericCancelButton = new JButton(mainPanel.translate("button.cancel"), View.getIcon("cancel16"));
    genericCancelButton.setMargin(new Insets(3, 3, 3, 10));
    genericCancelButton.addActionListener(this::cancelGenericTagButtonActionPerformed);
    genericCancelButton.setVisible(false);

    ButtonsPanel genericTagButtonsPanel = new ButtonsPanel();
    genericTagButtonsPanel.add(genericEditButton);
    genericTagButtonsPanel.add(genericSaveButton);
    genericTagButtonsPanel.add(genericCancelButton);
    return genericTagButtonsPanel;
}
 
Example 3
Source File: SnippetNavigator.java    From littleluck with Apache License 2.0 6 votes vote down vote up
public SnippetNavigator(SnippetMap snippetMap) {
    this.snippetMap = snippetMap;
    snippetMap.addPropertyChangeListener(new SnippetHighlightListener());

    setLayout(null);

    NO_SNIPPET = getString("CodeViewer.snippets.noCodeHighlighted",
            "No Code highlight selected");

    statusLabel = new JLabel(NO_SNIPPET);
    statusLabel.setHorizontalAlignment(JLabel.CENTER);
    add(statusLabel);

    prevButton = (JButton) add(new NavButton());
    prevButton.setDefaultCapable(false);
    prevButton.setVisible(false);

    nextButton = (JButton) add(new NavButton());
    nextButton.setDefaultCapable(false);
    nextButton.setVisible(false);

    applyDefaults();

}
 
Example 4
Source File: SnippetNavigator.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
public SnippetNavigator(SnippetMap snippetMap) {
    this.snippetMap = snippetMap;
    snippetMap.addPropertyChangeListener(new SnippetHighlightListener());

    setLayout(null);

    NO_SNIPPET = getString("CodeViewer.snippets.noCodeHighlighted",
            "No Code highlight selected");

    statusLabel = new JLabel(NO_SNIPPET);
    statusLabel.setHorizontalAlignment(JLabel.CENTER);
    add(statusLabel);

    prevButton = (JButton) add(new NavButton());
    prevButton.setDefaultCapable(false);
    prevButton.setVisible(false);

    nextButton = (JButton) add(new NavButton());
    nextButton.setDefaultCapable(false);
    nextButton.setVisible(false);

    applyDefaults();

}
 
Example 5
Source File: ChatAreaSendField.java    From Spark with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new IconTextField with Icon.
 *
 * @param text the text to use on the button.
 */
public ChatAreaSendField(String text) {
    setLayout(new GridBagLayout());
    setBackground((Color)UIManager.get("TextPane.background"));
    textField = new ChatInputEditor();
    textField.setBorder(null);
    setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.lightGray));
    button = new JButton();
    
    if (Spark.isMac()) {
        button.setContentAreaFilled(false);
    }

    ResourceUtils.resButton(button, text);

    add(button, new GridBagConstraints(1, 0, 1, 1, 0.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(2, 2, 2, 2), 0, 0));

    button.setVisible(false);
    
    final JScrollPane pane = new JScrollPane(textField);
    pane.setBorder(null);
    add(pane, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    button.setEnabled(false);
}
 
Example 6
Source File: PreviewPanel.java    From jpexs-decompiler with GNU General Public License v3.0 6 votes vote down vote up
private JPanel createMetadataButtonsPanel() {
    metadataEditButton = new JButton(mainPanel.translate("button.edit"), View.getIcon("edit16"));
    metadataEditButton.setMargin(new Insets(3, 3, 3, 10));
    metadataEditButton.addActionListener(this::editMetadataButtonActionPerformed);
    metadataSaveButton = new JButton(mainPanel.translate("button.save"), View.getIcon("save16"));
    metadataSaveButton.setMargin(new Insets(3, 3, 3, 10));
    metadataSaveButton.addActionListener(this::saveMetadataButtonActionPerformed);
    metadataSaveButton.setVisible(false);
    metadataCancelButton = new JButton(mainPanel.translate("button.cancel"), View.getIcon("cancel16"));
    metadataCancelButton.setMargin(new Insets(3, 3, 3, 10));
    metadataCancelButton.addActionListener(this::cancelMetadataButtonActionPerformed);
    metadataCancelButton.setVisible(false);

    ButtonsPanel metadataTagButtonsPanel = new ButtonsPanel();
    metadataTagButtonsPanel.add(metadataEditButton);
    metadataTagButtonsPanel.add(metadataSaveButton);
    metadataTagButtonsPanel.add(metadataCancelButton);
    return metadataTagButtonsPanel;
}
 
Example 7
Source File: Main.java    From btdex with GNU General Public License v3.0 6 votes vote down vote up
private JButton createResetPinButton() {
	resetPinButton = new JButton(i.get(Icons.RESET_PIN));
	resetPinButton.setToolTipText(tr("main_reset_pin"));
	resetPinButton.setVerticalAlignment(SwingConstants.CENTER);
	resetPinButton.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed(ActionEvent e) {
			Welcome welcome = new Welcome(Main.this, true);

			welcome.setLocationRelativeTo(Main.this);
			welcome.setVisible(true);
		}
	});
	resetPinButton.setVisible(!Globals.getInstance().usingLedger());
	return resetPinButton;
}
 
Example 8
Source File: LuckScrollBarUI.java    From littleluck with Apache License 2.0 5 votes vote down vote up
/**
 * <p>设置按钮宽和高为0, 达到隐藏该按钮的效果。</p>
 *
 * <p>Set the button width and height to 0, to hide the button.</p>
 */
protected JButton createIncreaseButton(int orientation)
{
    JButton btn = new JButton();

    btn.setVisible(false);

    btn.setPreferredSize(new Dimension(0, 0));

    return btn;
}
 
Example 9
Source File: SourceTab.java    From FoxTelem with GNU General Public License v3.0 4 votes vote down vote up
private void buildRightPanel(JPanel parent, String layout, JPanel rightPanel) {
		parent.add(rightPanel, layout);
			
		opts = new JPanel();
		rightPanel.add(opts);
		opts.setLayout(new BorderLayout());

		
		//buildTrackedSpacecraftList();

		
		optionsPanel = new JPanel();
		optionsPanel.setBorder(new TitledBorder(null, "Audio Options", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		opts.add(optionsPanel, BorderLayout.CENTER);
		optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS));
		
		filterPanel = new FilterPanel();
		opts.add(filterPanel, BorderLayout.SOUTH);
		
		rdbtnViewFilteredAudio = new JCheckBox("View Filtered Audio");
		optionsPanel.add(rdbtnViewFilteredAudio);
		rdbtnViewFilteredAudio.addItemListener(this);
		rdbtnViewFilteredAudio.setSelected(Config.viewFilteredAudio);
		
		rdbtnMonitorFilteredAudio = new JCheckBox("Monitor Filtered Audio");
		optionsPanel.add(rdbtnMonitorFilteredAudio);
		rdbtnMonitorFilteredAudio.addItemListener(this);
		rdbtnMonitorFilteredAudio.setSelected(Config.monitorFilteredAudio);

		rdbtnSquelchAudio = new JCheckBox("Squelch when no telemetry");
		optionsPanel.add(rdbtnSquelchAudio);
		rdbtnSquelchAudio.addItemListener(this);
		rdbtnSquelchAudio.setSelected(Config.squelchAudio);

		rdbtnFilterOutputAudio = new JCheckBox("LPF Monitored Audio");
		optionsPanel.add(rdbtnFilterOutputAudio);
		rdbtnFilterOutputAudio.addItemListener(this);
		rdbtnFilterOutputAudio.setSelected(Config.filterOutputAudio);
		rdbtnFilterOutputAudio.setVisible(false);
		
//		rdbtnShowFFT = new JCheckBox("Show FFT");
//		rdbtnShowFFT.addItemListener(this);
//		rdbtnShowFFT.setSelected(true);
//		optionsPanel.add(rdbtnShowFFT);
//		rdbtnShowFFT.setVisible(false);
		play = new JButton(">");
		play.addActionListener(this);
		optionsPanel.add(play);
		unpause = new JButton("||");
		unpause.addActionListener(this);
		optionsPanel.add(unpause);
		if (Config.debugValues) {
			play.setVisible(true);
			unpause.setVisible(true);
		}
//		audioOptionsFiller = new Box.Filler(new Dimension(10,10), new Dimension(100,80), new Dimension(100,500));
//		optionsPanel.add(audioOptionsFiller);
		
	//	rdbtnUseLimiter = new JCheckBox("Use FM Limiter");
	//	optionsPanel.add(rdbtnUseLimiter);
	//	rdbtnUseLimiter.addItemListener(this);
	//	rdbtnUseLimiter.setSelected(Config.useLimiter);
	//	rdbtnUseLimiter.setVisible(true);


	//	rdbtnWriteDebugData = new JCheckBox("Debug Values");
	//	optionsPanel.add(rdbtnWriteDebugData);
	//	rdbtnWriteDebugData.addItemListener(this);
	//	rdbtnWriteDebugData.setSelected(Config.debugValues);
	//	rdbtnWriteDebugData.setVisible(true);

//		optionsPanel.setVisible(true);

	}
 
Example 10
Source File: JiraUpdater.java    From netbeans with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 11
Source File: BreakpointsViewButtons.java    From netbeans with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 12
Source File: UnitChooser.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
private void layoutEntries() {
  this.setLayout(new GridBagLayout());
  title = new JTextArea();
  title.setBackground(this.getBackground());
  title.setEditable(false);
  title.setWrapStyleWord(true);
  title.setVisible(false);
  final Insets nullInsets = new Insets(0, 0, 0, 0);
  final Dimension buttonSize = new Dimension(80, 20);
  selectNoneButton = new JButton("None");
  selectNoneButton.setPreferredSize(buttonSize);
  autoSelectButton = new JButton("All");
  autoSelectButton.setPreferredSize(buttonSize);
  add(
      title,
      new GridBagConstraints(
          0,
          0,
          7,
          1,
          0,
          0.5,
          GridBagConstraints.EAST,
          GridBagConstraints.HORIZONTAL,
          nullInsets,
          0,
          0));
  selectNoneButton.addActionListener(e -> selectNone());
  autoSelectButton.addActionListener(e -> autoSelect());
  int rowIndex = 1;
  for (final ChooserEntry entry : entries) {
    entry.createComponents(this, rowIndex);
    rowIndex++;
  }
  add(
      autoSelectButton,
      new GridBagConstraints(
          0,
          rowIndex,
          7,
          1,
          0,
          0.5,
          GridBagConstraints.EAST,
          GridBagConstraints.NONE,
          nullInsets,
          0,
          0));
  rowIndex++;
  add(
      leftToSelect,
      new GridBagConstraints(
          0,
          rowIndex,
          5,
          2,
          0,
          0.5,
          GridBagConstraints.WEST,
          GridBagConstraints.HORIZONTAL,
          nullInsets,
          0,
          0));
  if (match != null) {
    autoSelectButton.setVisible(false);
    selectNoneButton.setVisible(false);
    checkMatches();
  }
}
 
Example 13
Source File: CommonConnUI.java    From mqtt-jmeter with Apache License 2.0 4 votes vote down vote up
public JPanel createProtocolPanel() {
		JPanel protocolPanel = new VerticalPanel();
		protocolPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Protocols"));
		
		JPanel pPanel = new JPanel();
		pPanel.setLayout(new BorderLayout());
		//pPanel.setLayout(new GridLayout(1, 2));

		JPanel pCenter = new JPanel(new FlowLayout(FlowLayout.LEFT));
//		clientNames = new JLabeledChoice("Clients:", clientNamesList.toArray(new String[] {}), true, false);
//		clientNames.addChangeListener(this);
//		pCenter.add(clientNames);

		protocols = new JLabeledChoice("Protocols:", false);
		//JComboBox<String> component = (JComboBox) protocols.getComponentList().get(1);
		//component.setSize(new Dimension(40, component.getHeight()));
		protocols.addChangeListener(this);
		pCenter.add(protocols);

		wsPath.setFont(null);
		wsPath.setVisible(false);
		pCenter.add(wsPath);

		pPanel.add(pCenter, BorderLayout.CENTER);

		dualAuth.setSelected(false);
		dualAuth.setFont(null);
		dualAuth.setVisible(false);
		dualAuth.addChangeListener(this);
		pPanel.add(dualAuth, BorderLayout.SOUTH);

		JPanel panel = new JPanel(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		c.anchor = GridBagConstraints.SOUTHWEST;
		
//		c.gridx = 0; c.gridy = 0; c.gridwidth = 2;
//		tksFilePath.setVisible(false);
//		panel.add(tksFilePath, c);
//
//		c.gridx = 2; c.gridy = 0; c.gridwidth = 1;
//		tksBrowseButton = new JButton(JMeterUtils.getResString("browse"));
//		tksBrowseButton.setActionCommand(TKS_BROWSE);
//		tksBrowseButton.addActionListener(this);
//		tksBrowseButton.setVisible(false);
//		panel.add(tksBrowseButton, c);
//		
//		c.gridx = 3; c.gridy = 0; c.gridwidth = 2;
//		tksPassword.setVisible(false);
//		panel.add(tksPassword, c);

		//c.weightx = 0.0;
		c.gridx = 0; c.gridy = 1; c.gridwidth = 2;
		ccFilePath.setVisible(false);
		panel.add(ccFilePath, c);

		c.gridx = 2; c.gridy = 1; c.gridwidth = 1;
		ccBrowseButton = new JButton(JMeterUtils.getResString("browse"));
		ccBrowseButton.setActionCommand(CC_BROWSE);
		ccBrowseButton.addActionListener(this);
		ccBrowseButton.setVisible(false);
		panel.add(ccBrowseButton, c);
		
		c.gridx = 3; c.gridy = 1; c.gridwidth = 2;
		ccPassword.setVisible(false);
		panel.add(ccPassword, c);
		
		protocolPanel.add(pPanel);
		protocolPanel.add(panel);
		
		return protocolPanel;
	}
 
Example 14
Source File: DomGameFrame.java    From DominionSim with MIT License 4 votes vote down vote up
private JPanel getInfoPanel() {
	JPanel thePanel = new JPanel();
	thePanel.setLayout(new GridBagLayout());
	GridBagConstraints theCons = DomGui.getGridBagConstraints(2);
	theCons.fill=GridBagConstraints.NONE;
    myDrawDeckLabel = new JLabel();
    theCons.gridx++;
    thePanel.add(myDrawDeckLabel, theCons);
    myDiscardLabel = new JLabel();
    theCons.gridx++;
    thePanel.add(myDiscardLabel, theCons);
    //Actions indicator
    JLabel theActionsLabel = new JLabel("Actions:");
    theCons.gridx++;
    thePanel.add(theActionsLabel, theCons);
    myActionsValue=new JLabel();
    theCons.gridx++;
    thePanel.add(myActionsValue, theCons);
    //Buys indicator
	JLabel theBuysLabel = new JLabel("Buys:");
	theCons.gridx++;
	thePanel.add(theBuysLabel, theCons);
	myBuysValue = new JLabel();
	theCons.gridx++;
	thePanel.add(myBuysValue, theCons);
    myVPLabel = new JLabel();
    theCons.gridx++;
    thePanel.add(myVPLabel, theCons);
    myOppsVPLabel = new JLabel();
    theCons.gridx++;
    thePanel.add(myOppsVPLabel, theCons);
    theCons.gridx++;
    JButton theInfoButton = new JButton("Game Info");
    theInfoButton.setActionCommand("Game Info");
    theInfoButton.addActionListener(this);
    thePanel.add(theInfoButton, theCons);
//    theCons.gridx++;
//    myOppTextLabel = new JLabel();
//    thePanel.add(myOppTextLabel, theCons);
    theCons.weightx=100;
	theCons.gridx++;
	thePanel.add(new JLabel(), theCons);
	theCons.weightx=1;
    theCons.gridx++;
    myHintButton = new JButton("Hint!");
    myHintButton.setActionCommand("Hint");
    myHintButton.addActionListener(this);
    myHintButton.setVisible(false);
    thePanel.add(myHintButton, theCons);
    theCons.gridx++;
    myPlayAllTreasurersBTN = new JButton("Play all treasures");
    myPlayAllTreasurersBTN.setActionCommand("Play all treasures");
    myPlayAllTreasurersBTN.addActionListener(this);
    myPlayAllTreasurersBTN.setVisible(false);
    thePanel.add(myPlayAllTreasurersBTN, theCons);
	theCons.gridx++;
    mySpendCoffersBTN = new JButton("$0");
    mySpendCoffersBTN.setActionCommand("Spend coffers");
    mySpendCoffersBTN.setToolTipText("Spend coffers");
    mySpendCoffersBTN.addActionListener(this);
    mySpendCoffersBTN.setVisible(false);
    thePanel.add(mySpendCoffersBTN, theCons);
    theCons.gridx++;
    myUseVillagersBTN = new JButton("V(0)");
    myUseVillagersBTN.setActionCommand("Use Villagers");
    myUseVillagersBTN.setToolTipText("Use Villagers");
    myUseVillagersBTN.addActionListener(this);
    myUseVillagersBTN.setVisible(false);
    thePanel.add(myUseVillagersBTN, theCons);
    theCons.gridx++;
    myPayOffDebtBTN = new JButton("$0");
    myPayOffDebtBTN.setForeground(Color.red);
    myPayOffDebtBTN.setActionCommand("Pay off debt");
    myPayOffDebtBTN.setToolTipText("Pay off debt");
    myPayOffDebtBTN.addActionListener(this);
    myPayOffDebtBTN.setVisible(false);
    thePanel.add(myPayOffDebtBTN, theCons);
    theCons.gridx++;
    myEndActions = new JButton("End Actions");
	myEndActions.setActionCommand("End Actions");
	myEndActions.addActionListener(this);
	thePanel.add(myEndActions, theCons);
    theCons.gridx++;
    myEndTurnBTN = new JButton("End turn");
    myEndTurnBTN.setActionCommand("End turn");
    myEndTurnBTN.addActionListener(this);
    thePanel.add(myEndTurnBTN, theCons);
	return thePanel;
  }
 
Example 15
Source File: ToolAdapterTabbedEditorDialog.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private JButton renderInstallButton(org.esa.snap.core.gpf.descriptor.dependency.Bundle currentBundle,
                                 JPanel bundlePanel) {
    JButton installButton = new JButton() {
        @Override
        public void setText(String text) {
            super.setText(text);
            adjustDimension(this);
        }
    };
    installButton.setText((currentBundle.getLocation() == BundleLocation.REMOTE ?
            "Download and " :
            "") + "Install Now");
    installButton.setToolTipText(currentBundle.getLocation() == BundleLocation.REMOTE ?
                                         currentBundle.getDownloadURL() :
                                         currentBundle.getSource() != null ?
                                                 currentBundle.getSource().toString() : "");
    installButton.setMaximumSize(installButton.getPreferredSize());
    installButton.addActionListener((ActionEvent e) -> {
        newOperatorDescriptor.setBundles(bundleForm.applyChanges());
        org.esa.snap.core.gpf.descriptor.dependency.Bundle modifiedBundle = newOperatorDescriptor.getBundle();
        try (BundleInstaller installer = new BundleInstaller(newOperatorDescriptor)) {
            ProgressHandle progressHandle = ProgressHandleFactory.createSystemHandle("Installing bundle");
            installer.setProgressMonitor(new ProgressHandler(progressHandle, false));
            installer.setCallback(() -> {
                if (modifiedBundle.isInstalled()) {
                    Path path = newOperatorDescriptor.resolveVariables(modifiedBundle.getTargetLocation())
                            .toPath()
                            .resolve(FileUtils.getFilenameWithoutExtension(modifiedBundle.getEntryPoint()));
                    SwingUtilities.invokeLater(() -> {
                        progressHandle.finish();
                        Dialogs.showInformation(String.format("Bundle was installed in location:\n%s", path));
                        installButton.setVisible(false);
                        bundlePanel.revalidate();
                    });
                    String updateVariable = modifiedBundle.getUpdateVariable();
                    if (updateVariable != null) {
                        Optional<SystemVariable> variable = newOperatorDescriptor.getVariables()
                                .stream()
                                .filter(v -> v.getKey().equals(updateVariable))
                                .findFirst();
                        variable.ifPresent(systemVariable -> {
                            systemVariable.setShared(true);
                            systemVariable.setValue(path.toString());
                        });
                        varTable.revalidate();
                    }
                } else {
                    SwingUtilities.invokeLater(() -> {
                        progressHandle.finish();
                        Dialogs.showInformation("Bundle installation failed. \n" +
                                                        "Please see the application log for details.");
                        bundlePanel.revalidate();
                    });
                }
                return null;
            });
            installButton.setVisible(false);
            installer.install(true);
        } catch (Exception ex) {
            logger.warning(ex.getMessage());
        }
    });
    this.downloadAction = () -> {
        tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
        installButton.requestFocusInWindow();
        installButton.doClick();
        return null;
    };
    installButton.setVisible(canInstall(currentBundle));
    return installButton;
}
 
Example 16
Source File: ClassPresenterPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void initComponents() {
    Color borderColor = UIManager.getLookAndFeel().getID().equals("Metal") ? // NOI18N
        UIManager.getColor("Button.darkShadow") : UIManager.getColor("Button.shadow"); // NOI18N
    setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createLineBorder(borderColor), BorderFactory.createEmptyBorder(2, 5, 2, 5)));
    setOpaque(true);
    setBackground(UIUtils.getDarker(UIUtils.getProfilerResultsBackground()));

    headerRenderer = new HeaderRenderer();
    headerRenderer.setIcon(ICON_CLASS);
    headerRenderer.setForeground(UIManager.getColor("ToolTip.foreground")); // NOI18N
    headerRenderer.setFont(UIManager.getFont("ToolTip.font")); // NOI18N
    headerRenderer.setOpaque(false);

    detailsRenderer = new JLabel();
    detailsRenderer.setForeground(UIManager.getColor("ToolTip.foreground")); // NOI18N
    detailsRenderer.setFont(UIManager.getFont("ToolTip.font")); // NOI18N
    detailsRenderer.setOpaque(false);
    
    actionsDivider = new JLabel("  |  "); // NOI18N
    actionsDivider.setForeground(UIManager.getColor("ToolTip.foreground")); // NOI18N
    actionsDivider.setFont(UIManager.getFont("ToolTip.font")); // NOI18N
    actionsDivider.setOpaque(false);

    actionsRenderer = new JButton() {
        protected void fireActionPerformed(ActionEvent e) {
            if (heapFragmentWalker != null) {
                BrowserUtils.performTask(new Runnable() {
                    public void run() {
                        heapFragmentWalker.computeRetainedSizes(true, true);
                    }
                });
            }
        }
        public Dimension getMinimumSize() {
            return getPreferredSize();
        }
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
        public void setVisible(boolean visible) {
            super.setVisible(visible);
            actionsDivider.setVisible(visible);
        }
        public boolean isContentAreaFilled() {
            return !UIUtils.isOracleLookAndFeel() ? false : isFocusOwner();
        }
        public boolean isOpaque() {
            return !UIUtils.isOracleLookAndFeel() ? false : isFocusOwner();
        }
    };
    actionsRenderer.setOpaque(false);
    actionsRenderer.setContentAreaFilled(false);
    actionsRenderer.setBorderPainted(true);
    actionsRenderer.setMargin(new Insets(0, 0, 0, 0));
    actionsRenderer.setBorder(BorderFactory.createEmptyBorder());
    actionsRenderer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    actionsRenderer.setFont(UIManager.getFont("ToolTip.font")); // NOI18N
    actionsRenderer.setText("<html><nobr><a href='#'>" + Bundle.ClassPresenterPanel_RetainedSizesString() + "</a></nobr></html>"); // NOI18N
    actionsRenderer.setVisible(false);

    JPanel detailsContainer = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    detailsContainer.setOpaque(false);
    detailsContainer.add(detailsRenderer);
    detailsContainer.add(actionsDivider);
    detailsContainer.add(actionsRenderer);
    
    setLayout(new GridBagLayout());
    
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    add(headerRenderer, c);
    
    JPanel filler = new JPanel(null);
    filler.setOpaque(false);
    c = new GridBagConstraints();
    c.gridx = 1;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    add(filler, c);
    
    c = new GridBagConstraints();
    c.gridx = 2;
    add(detailsContainer, c);
}
 
Example 17
Source File: JManageDialog.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public JManageDialog(Program program, JFrame jFrame, String title, boolean supportMerge, boolean supportExport) {
	super(program, title, jFrame, Images.DIALOG_SETTINGS.getImage());
	this.supportMerge = supportMerge;

	ListenerClass listener = new ListenerClass();

	//Load
	jLoad = new JButton(GuiShared.get().managerLoad(), Images.FILTER_LOAD.getIcon());
	jLoad.setActionCommand(ManageDialogAction.LOAD.name());
	jLoad.addActionListener(listener);
	jLoad.setHorizontalAlignment(SwingConstants.LEFT);

	//Rename
	jRename = new JButton(GuiShared.get().managerRename(), Images.EDIT_EDIT.getIcon());
	jRename.setActionCommand(ManageDialogAction.RENAME.name());
	jRename.addActionListener(listener);
	jRename.setHorizontalAlignment(SwingConstants.LEFT);

	//Delete
	jDelete = new JButton(GuiShared.get().managerDelete(), Images.EDIT_DELETE.getIcon());
	jDelete.setActionCommand(ManageDialogAction.DELETE.name());
	jDelete.addActionListener(listener);
	jDelete.setHorizontalAlignment(SwingConstants.LEFT);

	//Export
	jExport = new JButton(GuiShared.get().managerExport(), Images.DIALOG_CSV_EXPORT.getIcon());
	jExport.setActionCommand(ManageDialogAction.EXPORT.name());
	jExport.addActionListener(listener);
	jExport.setVisible(supportExport);
	jExport.setHorizontalAlignment(SwingConstants.LEFT);

	//Import
	jImport = new JButton(GuiShared.get().managerImport(), Images.EDIT_IMPORT.getIcon());
	jImport.setActionCommand(ManageDialogAction.IMPORT.name());
	jImport.addActionListener(listener);
	jImport.setVisible(supportExport);
	jImport.setHorizontalAlignment(SwingConstants.LEFT);
	
	//Done
	jClose = new JButton(GuiShared.get().managerClose());
	jClose.setActionCommand(ManageDialogAction.DONE.name());
	jClose.addActionListener(listener);

	//List
	listModel = new DefaultListModel<String>();
	jList = new JList<String>(listModel);
	jList.addMouseListener(listener);
	jList.addListSelectionListener(listener);
	JScrollPane jScrollPanel = new JScrollPane(jList);
	jPanel.add(jScrollPanel);

	layout.setHorizontalGroup(
		layout.createSequentialGroup()
			.addComponent(jScrollPanel, 175, 175, 175)
			.addGroup(layout.createParallelGroup()
				.addComponent(jLoad, 100, 100, 100)
				.addComponent(jRename, 100, 100, 100)
				.addComponent(jDelete, 100, 100, 100)
				.addComponent(jExport, 100, 100, 100)
				.addComponent(jImport, 100, 100, 100)
				.addComponent(jClose, 100, 100, 100)
			)
	);
	layout.setVerticalGroup(
		layout.createParallelGroup()
			.addComponent(jScrollPanel, 250, 250, 250)
			.addGroup(layout.createSequentialGroup()
				.addComponent(jLoad, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jRename, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jDelete, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addGap(15, 15, 15)
				.addComponent(jExport, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jImport, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addGap(0, 0, Integer.MAX_VALUE)
				.addComponent(jClose, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			)
	);
}
 
Example 18
Source File: LuckTitlePanel.java    From littleluck with Apache License 2.0 4 votes vote down vote up
/**
 * <p>安装放大、缩小、关闭按钮<p>
 *
 * <p>Installation Form button<p>
 */
protected void installBtn()
{
    closeBtn = new JButton();

    closeBtn.addMouseListener(new CloseMouseAdapter(closeBtn,
            LuckRootPaneUIBundle.CLOSE_NORMAL_ICON,
            LuckRootPaneUIBundle.CLOSE_ROVER_ICON,
            LuckRootPaneUIBundle.CLOSE_PRESSED_ICON));

    setBtnAtrr(closeBtn);

    add(closeBtn);

    // 如果是Frame则显示退出和放大按钮
    // If the Frame is displayed exits and zoom buttons
    if(initStyle == JRootPane.FRAME)
    {
        minBtn = new JButton();

        minBtn.addMouseListener(new MinMouseAdapter(minBtn,
                LuckRootPaneUIBundle.MIN_NORMAL_ICON,
                LuckRootPaneUIBundle.MIN_ROVER_ICON,
                LuckRootPaneUIBundle.MIN_PRESSED_ICON));

        setBtnAtrr(minBtn);

        add(minBtn);

        maximizeBtn = new JButton();

        maximizeBtn.addMouseListener(new MaximizeMouseAdapter(maximizeBtn,
                LuckRootPaneUIBundle.MAX_NORMAL_ICON,
                LuckRootPaneUIBundle.MAX_ROVER_ICON,
                LuckRootPaneUIBundle.MAX_PRESSED_ICON));

        setBtnAtrr(maximizeBtn);

        add(maximizeBtn);

        // 判断窗体是否可以拉伸
        // Determine whether the form can be stretched
        if(!isResizeableOnInit)
        {
            maximizeBtn.setVisible(false);
        }
    }
}
 
Example 19
Source File: RuleSelectFrame.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * GUIAInitialization
 */
protected void initUI() {
	this.getContentPane().setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));

	// Tab
	tabPane = new JTabbedPane();
	tabPane.setAlignmentX(LEFT_ALIGNMENT);
	this.add(tabPane);

	// Rules
	listboxRule = new JList[GameEngine.MAX_GAMESTYLE];
	for(int i = 0; i < GameEngine.MAX_GAMESTYLE; i++) {
		listboxRule[i] = new JList(extractRuleListFromRuleEntries(i));
		JScrollPane scpaneRule = new JScrollPane(listboxRule[i]);
		scpaneRule.setPreferredSize(new Dimension(380, 250));
		scpaneRule.setAlignmentX(LEFT_ALIGNMENT);
		tabPane.addTab(GameEngine.GAMESTYLE_NAMES[i], scpaneRule);
	}

	//  default Back to button
	JButton btnUseDefault = new JButton(NullpoMinoSwing.getUIText("RuleSelect_UseDefault"));
	btnUseDefault.setMnemonic('D');
	btnUseDefault.addActionListener(this);
	btnUseDefault.setActionCommand("RuleSelect_UseDefault");
	btnUseDefault.setAlignmentX(LEFT_ALIGNMENT);
	btnUseDefault.setMaximumSize(new Dimension(Short.MAX_VALUE, 30));
	btnUseDefault.setVisible(false);
	this.add(btnUseDefault);

	//  buttonKind
	JPanel pButtons = new JPanel();
	pButtons.setLayout(new BoxLayout(pButtons, BoxLayout.X_AXIS));
	pButtons.setAlignmentX(LEFT_ALIGNMENT);
	this.add(pButtons);

	JButton btnOK = new JButton(NullpoMinoSwing.getUIText("RuleSelect_OK"));
	btnOK.setMnemonic('O');
	btnOK.addActionListener(this);
	btnOK.setActionCommand("RuleSelect_OK");
	btnOK.setAlignmentX(LEFT_ALIGNMENT);
	btnOK.setMaximumSize(new Dimension(Short.MAX_VALUE, 30));
	pButtons.add(btnOK);
	this.getRootPane().setDefaultButton(btnOK);

	JButton btnCancel = new JButton(NullpoMinoSwing.getUIText("RuleSelect_Cancel"));
	btnCancel.setMnemonic('C');
	btnCancel.addActionListener(this);
	btnCancel.setActionCommand("RuleSelect_Cancel");
	btnCancel.setAlignmentX(LEFT_ALIGNMENT);
	btnCancel.setMaximumSize(new Dimension(Short.MAX_VALUE, 30));
	pButtons.add(btnCancel);
}
 
Example 20
Source File: SuppliesTrackerPanel.java    From plugins with GNU General Public License v3.0 4 votes vote down vote up
public SuppliesTrackerPanel(final ItemManager itemManager, SuppliesTrackerPlugin plugin, SuppliesTrackerConfig config)
{
	setBorder(new EmptyBorder(6, 6, 6, 6));
	setBackground(ColorScheme.DARK_GRAY_COLOR);
	setLayout(new BorderLayout());
	updatePanel = new UpdatePanel(this);

	// Create layout panel for wrapping
	final JPanel layoutPanel = new JPanel();
	layoutPanel.setLayout(new BoxLayout(layoutPanel, BoxLayout.Y_AXIS));
	add(layoutPanel, BorderLayout.NORTH);

	// Create panel that will contain overall data
	overallPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
	overallPanel.setBackground(ColorScheme.DARKER_GRAY_COLOR);
	overallPanel.setLayout(new BorderLayout());
	overallPanel.setVisible(true);

	// Add icon and contents
	final JPanel overallInfo = new JPanel();
	overallInfo.setBackground(ColorScheme.DARKER_GRAY_COLOR);
	overallInfo.setLayout(new GridLayout(2, 1));
	overallInfo.setBorder(new EmptyBorder(0, 10, 0, 0));
	overallSuppliesUsedLabel.setFont(FontManager.getRunescapeSmallFont());
	overallCostLabel.setFont(FontManager.getRunescapeSmallFont());
	overallInfo.add(overallSuppliesUsedLabel);
	overallInfo.add(overallCostLabel);
	overallPanel.add(overallIcon, BorderLayout.WEST);
	overallPanel.add(overallInfo, BorderLayout.CENTER);

	//Sorts boxes into usage types
	for (ItemType type : ItemType.values())
	{
		SuppliesBox newBox = SuppliesBox.of(itemManager, type.getLabel(), plugin, this, type);
		logsContainer.add(newBox);
		boxList.add(newBox);
	}

	// Create reset all menu
	final JMenuItem reset = new JMenuItem("Reset All");
	reset.addActionListener(e ->
	{
		overallSuppliesUsed = 0;
		overallCost = 0;
		plugin.clearSupplies();
		for (SuppliesBox box : boxList)
		{
			box.clearAll();
		}
		updateOverall();
		logsContainer.repaint();
	});

	// Create popup menu
	final JPopupMenu popupMenu = new JPopupMenu();
	popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5));
	popupMenu.add(reset);
	overallPanel.setComponentPopupMenu(popupMenu);

	// Create Supply Rows wrapper
	logsContainer.setLayout(new BoxLayout(logsContainer, BoxLayout.Y_AXIS));
	layoutPanel.add(overallPanel);
	layoutPanel.add(logsContainer);

	add(updatePanel);
	updatePanel.setVisible(false);
	overallPanel.setVisible(false);
	logsContainer.setVisible(true);

	info = new JButton("Info");
	info.addActionListener(e ->
	{
		overallPanel.setVisible(false);
		logsContainer.setVisible(false);

		remove(updatePanel);
		updatePanel = new UpdatePanel(this);
		add(updatePanel);

		updatePanel.setVisible(true);
		info.setVisible(false);
	});

	layoutPanel.add(info);

	errorPanel.setContent("Supply trackers", "You have not used any supplies yet.");
	if (!config.infoBox())
	{
		logsContainer.setVisible(false);
		updatePanel.setVisible(true);
		info.setVisible(false);
	}
	else
	{
		info.setVisible(true);
		add(errorPanel);
	}
}