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

The following examples show how to use javax.swing.JButton#setFont() . 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: SettlementTransparentPanel.java    From mars-sim with GNU General Public License v3.0 7 votes vote down vote up
public void buildrenameBtn() {

		renameP  = new JPanel(new FlowLayout());
		renameP.setBackground(new Color(0,0,0));//,0));
		renameP.setOpaque(false);
		renameP.setAlignmentX(FlowLayout.CENTER);

		renameBtn = new JButton(Msg.getString("SettlementTransparentPanel.button.rename")); //$NON-NLS-1$
		renameBtn.setPreferredSize(new Dimension(80, 20)); //
		renameBtn.setFont(new Font("Dialog", Font.PLAIN, 12));
//		renameBtn.setForeground(Color.GREEN);
		renameBtn.setContentAreaFilled(false);
		renameBtn.setOpaque(false);
		//renameBtn.setOpaque(false); // text disappeared if setOpaque(false)
//		renameBtn.setBorder(new LineBorder(Color.GREEN), 1, true));
		infoButton.setToolTipText(Msg.getString("SettlementTransparentPanel.tooltip.rename")); //$NON-NLS-1$
		renameBtn.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				openRenameDialog();
			}
		});
		renameP.add(renameBtn);
    }
 
Example 2
Source File: ClosableTab.java    From incubator-iotdb with Apache License 2.0 6 votes vote down vote up
ClosableTab(String name, TabCloseCallBack closeCallBack) {
  setName(name);
  setLayout(null);

  closeTabButton = new JButton("Close");
  closeTabButton.setLocation(720, 5);
  closeTabButton.setSize(new Dimension(70, 30));
  closeTabButton.setFont(closeTabButton.getFont().deriveFont(10.0f));
  add(closeTabButton);
  closeTabButton.addActionListener(new AbstractAction() {
    @Override
    public void actionPerformed(ActionEvent e) {
      closeCallBack.call(name);
    }
  });
}
 
Example 3
Source File: TestDesignUI.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
private JPanel getRTreeInPanel(String labelText, JTree tree) {
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.setBorder(BorderFactory.createEtchedBorder());
    reusableSwitch = new JButton(labelText);
    reusableSwitch.setFont(new Font("Default", Font.BOLD, 12));
    reusableSwitch.setContentAreaFilled(false);

    toolBar.add(new javax.swing.Box.Filler(new java.awt.Dimension(10, 0),
            new java.awt.Dimension(10, 0),
            new java.awt.Dimension(10, 32767)));
    toolBar.add(reusableSwitch);
    toolBar.setPreferredSize(new java.awt.Dimension(toolBar.getPreferredSize().width, 30));

    panel.add(toolBar, BorderLayout.NORTH);
    panel.add(TreeSearch.installFor(tree), BorderLayout.CENTER);
    return panel;
}
 
Example 4
Source File: OptionDialog.java    From nanoleaf-desktop with MIT License 6 votes vote down vote up
public OptionDialog(Component parent, String text, String choice1,
		String choice2, ActionListener action1, ActionListener action2)
{
	JLabel lblText = new JLabel(text);
	lblText.setFont(FONT);
	lblText.setForeground(Color.WHITE);
	contentPanel.add(lblText, "gapx 15 0, cell 0 1,alignx center,aligny bottom");
	
	JButton btnChoice1 = new ModernButton(choice1);
	btnChoice1.setFont(new Font("Tahoma", Font.PLAIN, 18));
	btnChoice1.addActionListener(action1);
	contentPanel.add(btnChoice1, "gapx 0 30, flowx,cell 0 2,alignx center,aligny bottom");
	
	JButton btnChoice2 = new ModernButton(choice2);
	btnChoice2.setFont(new Font("Tahoma", Font.PLAIN, 18));
	btnChoice2.addActionListener(action2);
	contentPanel.add(btnChoice2, "cell 0 2,alignx center");
	
	JLabel spacer = new JLabel(" ");
	contentPanel.add(spacer, "cell 0 3");
	
	finalize(parent);
}
 
Example 5
Source File: JProductsSelector.java    From nordpos with GNU General Public License v3.0 6 votes vote down vote up
public void addProduct(Image img, String name, ActionListener al) {
    
    JButton btn = new JButton();
    btn.applyComponentOrientation(getComponentOrientation());
    btn.setText(name);
    btn.setFont(btn.getFont().deriveFont((float)24));
    btn.setIcon(new ImageIcon(img));
    btn.setFocusPainted(false);
    btn.setFocusable(false);
    btn.setRequestFocusEnabled(false);
    btn.setHorizontalTextPosition(SwingConstants.CENTER);
    btn.setVerticalTextPosition(SwingConstants.BOTTOM);
    btn.setMargin(new Insets(2, 2, 2, 2));
    btn.setMaximumSize(new Dimension(80, 70));
    btn.setPreferredSize(new Dimension(80, 70));
    btn.setMinimumSize(new Dimension(80, 70));
    btn.addActionListener(al);
    flowpanel.add(btn);        
}
 
Example 6
Source File: MetaSetupPanel.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
private void createComponents() {
  connectToLobby = new JButton("Play Online");
  final Font bigButtonFont =
      new Font(
          connectToLobby.getFont().getName(),
          connectToLobby.getFont().getStyle(),
          connectToLobby.getFont().getSize() + 3);
  connectToLobby.setFont(bigButtonFont);
  connectToLobby.setToolTipText(
      "<html>Find Games Online on the Lobby Server. <br>"
          + "TripleA is MEANT to be played Online against other humans. <br>"
          + "Any other way is not as fun!</html>");
  startLocal = new JButton("Start Local Game");
  startLocal.setToolTipText(
      "<html>Start a game on this computer. <br>"
          + "You can play against a friend sitting besides you (hotseat mode), <br>"
          + "or against one of the AIs.</html>");
  startPbf = new JButton("Play By Forum");
  startPbf.setToolTipText(
      "<html>Starts a game which will be posted to an online forum or message board.</html>");
  startPbem = new JButton("Play By Email");
  startPbem.setToolTipText(
      "<html>Starts a game which will be emailed back and forth between all players.</html>");
  hostGame = new JButton("Host Networked Game");
  hostGame.setToolTipText(
      "<html>Hosts a network game, which people can connect to. <br>"
          + "Anyone on a LAN will be able to connect. <br>"
          + "Anyone from the internet can connect as well, but only if the host has "
          + "configured port forwarding correctly.</html>");
  connectToHostedGame = new JButton("Connect to Networked Game");
  connectToHostedGame.setToolTipText(
      "<html>Connects to someone's hosted game, <br>"
          + "so long as you know their IP address.</html>");
  enginePreferences = new JButton("Engine Preferences");
  enginePreferences.setToolTipText("<html>Configure certain options related to the engine.");
  userGuideButton = new JButton("User Guide & Help");
}
 
Example 7
Source File: SNT.java    From SNT with GNU General Public License v3.0 5 votes vote down vote up
protected static JButton smallButton(final String text) {
	final double SCALE = .85;
	final JButton button = new JButton(text);
	final Font font = button.getFont();
	button.setFont(font.deriveFont((float) (font.getSize() * SCALE)));
	final Insets insets = button.getMargin();
	button.setMargin(new Insets((int) (insets.top * SCALE), (int) (insets.left * SCALE),
			(int) (insets.bottom * SCALE), (int) (insets.right * SCALE)));
	return button;
}
 
Example 8
Source File: PinPadPanelImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
private JButton createButton(String label, Font fntButton, Insets marginButton, Rectangle bounds, ActionListener listener) {
   JButton btnNumberOne = new JButton(label);
   btnNumberOne.setMargin(marginButton);
   btnNumberOne.setFont(fntButton);
   btnNumberOne.setBounds(bounds);
   btnNumberOne.addActionListener(listener);
   return btnNumberOne;
}
 
Example 9
Source File: JFontChooser.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
protected JDialog createDialog(Component parent) {
	Frame frame = parent instanceof Frame ? (Frame) parent
			: (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
	JDialog dialog = new JDialog(frame, ("Select Font"), true);

	Action okAction = new DialogOKAction(dialog);
	Action cancelAction = new DialogCancelAction(dialog);

	JButton okButton = new JButton(okAction);
	okButton.setFont(DEFAULT_FONT);
	JButton cancelButton = new JButton(cancelAction);
	cancelButton.setFont(DEFAULT_FONT);

	JPanel buttonsPanel = new JPanel();
	buttonsPanel.setLayout(new GridLayout(2, 1));
	buttonsPanel.add(okButton);
	buttonsPanel.add(cancelButton);
	buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));

	ActionMap actionMap = buttonsPanel.getActionMap();
	actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
	actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
	InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
	inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
	inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));

	JPanel dialogEastPanel = new JPanel();
	dialogEastPanel.setLayout(new BorderLayout());
	dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);

	dialog.getContentPane().add(this, BorderLayout.CENTER);
	dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
	dialog.pack();
	dialog.setLocationRelativeTo(frame);
	return dialog;
}
 
Example 10
Source File: AllFunctionsChoicePanel.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
private JButton buttonForODChoiceFactory(int pixelsFromTop, final String caption, final boolean setOD) {

        JButton ODChoiceButton = new ET_JButton(caption);
        ODChoiceButton.setFont(new Font("SansSerif", Font.PLAIN, 10));
        ODChoiceButton.setBounds(5, pixelsFromTop, 110, 20);
        ODChoiceButton.setMargin(new Insets(0, 0, 0, 0));
        ODChoiceButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                for (AbstractRawDataView rawDataModelView : rawDataModelViews) {
                    DataModelFitFunctionInterface rawRatioDataModel = (DataModelFitFunctionInterface) rawDataModelView.getDataModel();
                    if (meanOnly) {// case of downhole
                        ((RawRatioDataModel) rawRatioDataModel).setOverDispersionSelectedDownHole(setOD);
                    } else {
                        rawRatioDataModel.setOverDispersionSelected(setOD);
                    }
//                    try {
//                        ((FitFunctionDataInterface) rawDataModelView).updateFittedData(true);
//                    } catch (Exception e2) {
//                    }
                }

//                ((AbstractRawDataView) sampleSessionDataView).refreshPanel(true);
                for (int i = 0; i < rawDataModelViews.length; i++) {
                    rawDataModelViews[i].refreshPanel(false, false);
                }
                updateReportTable();
            }
        });

        return ODChoiceButton;
    }
 
Example 11
Source File: Test4759934.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
Example 12
Source File: Test4759934.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
Example 13
Source File: RefreshUrlPage.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
private JButton createButton1(String name, int x, int y) {
	JButton btn = new CustomButton(StringResource.get(name));
	btn.setBackground(ColorResource.getDarkBtnColor());
	btn.setBorderPainted(false);
	btn.setFocusPainted(false);
	btn.setForeground(Color.WHITE);
	btn.setFont(FontResource.getNormalFont());
	Dimension d = btn.getPreferredSize();
	btn.setBounds(x, y, d.width, d.height);
	// btn.addActionListener(this);
	return btn;
}
 
Example 14
Source File: JSList.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
private JButton getClearButton(JTextComponent parent) {
    JButton clear = new JButton(" x ");
    clear.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 14));
    clear.addActionListener((ActionEvent e) -> {
        parent.setText("");
    });
    return clear;
}
 
Example 15
Source File: AnalysisPanelProvider.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
private JPanel initLowerPanel() {
  JPanel inner1 = new JPanel(new BorderLayout());
  inner1.setOpaque(false);

  JPanel analyzerName = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 2));
  analyzerName.setOpaque(false);
  analyzerName.add(new JLabel(MessageUtils.getLocalizedMessage("analysis.label.selected_analyzer")));
  analyzerNameLbl.setText(analysisModel.currentAnalyzer().getClass().getName());
  analyzerName.add(analyzerNameLbl);
  showChainLbl.setText(MessageUtils.getLocalizedMessage("analysis.label.show_chain"));
  showChainLbl.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseClicked(MouseEvent e) {
      listeners.showAnalysisChain(e);
    }
  });
  showChainLbl.setVisible(analysisModel.currentAnalyzer() instanceof CustomAnalyzer);
  analyzerName.add(FontUtils.toLinkText(showChainLbl));
  inner1.add(analyzerName, BorderLayout.PAGE_START);

  JPanel input = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 2));
  input.setOpaque(false);
  inputArea.setRows(3);
  inputArea.setColumns(50);
  inputArea.setLineWrap(true);
  inputArea.setWrapStyleWord(true);
  inputArea.setText(MessageUtils.getLocalizedMessage("analysis.textarea.prompt"));
  input.add(new JScrollPane(inputArea));

  JButton executeBtn = new JButton(FontUtils.elegantIconHtml("&#xe007;",
      MessageUtils.getLocalizedMessage("analysis.button.test")));
  executeBtn.setFont(StyleConstants.FONT_BUTTON_LARGE);
  executeBtn.setMargin(new Insets(3, 3, 3, 3));
  executeBtn.addActionListener(listeners::executeAnalysis);
  input.add(executeBtn);

  stepByStepCB.setText(MessageUtils.getLocalizedMessage("analysis.checkbox.step_by_step"));
  stepByStepCB.setSelected(false);
  stepByStepCB.setOpaque(false);
  stepByStepCB.setVisible(false);
  input.add(stepByStepCB);

  JButton clearBtn = new JButton(MessageUtils.getLocalizedMessage("button.clear"));
  clearBtn.setFont(StyleConstants.FONT_BUTTON_LARGE);
  clearBtn.setMargin(new Insets(5, 5, 5, 5));
  clearBtn.addActionListener(e -> {
    inputArea.setText("");
    operatorRegistry.get(SimpleAnalyzeResultPanelOperator.class).ifPresent(
        SimpleAnalyzeResultPanelOperator::clearTable);
    operatorRegistry.get(StepByStepAnalyzeResultPanelOperator.class).ifPresent(
        StepByStepAnalyzeResultPanelOperator::clearTable);
  });
  input.add(clearBtn);

  inner1.add(input, BorderLayout.CENTER);

  lowerPanel.setOpaque(false);
  lowerPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
  lowerPanel.add(inner1, BorderLayout.PAGE_START);
  lowerPanel.add(this.simpleResult, BorderLayout.CENTER);

  return lowerPanel;
}
 
Example 16
Source File: SpectraBottomPanel.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
SpectraBottomPanel(SpectraVisualizerWindow masterFrame, RawDataFile dataFile) {

    super(new BorderLayout());
    this.dataFile = dataFile;
    this.masterFrame = masterFrame;

    setBackground(Color.white);

    topPanel = new JPanel();
    topPanel.setBackground(Color.white);
    topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS));
    add(topPanel, BorderLayout.CENTER);

    topPanel.add(Box.createHorizontalStrut(10));

    JButton prevScanBtn =
        GUIUtils.addButton(topPanel, leftArrow, null, masterFrame, "PREVIOUS_SCAN");
    prevScanBtn.setBackground(Color.white);
    prevScanBtn.setFont(smallFont);

    topPanel.add(Box.createHorizontalGlue());

    GUIUtils.addLabel(topPanel, "Feature list: ", SwingConstants.RIGHT);

    peakListSelector = new JComboBox<PeakList>();
    peakListSelector.setBackground(Color.white);
    peakListSelector.setFont(smallFont);
    peakListSelector.addActionListener(masterFrame);
    peakListSelector.setActionCommand("PEAKLIST_CHANGE");
    topPanel.add(peakListSelector);


    processingCbx = GUIUtils.addCheckbox(topPanel, "Enable Processing", masterFrame,
        "ENABLE_PROCESSING", "Enables quick scan processing.");
    processingCbx.setBackground(Color.white);
    processingCbx.setFont(smallFont);
    updateProcessingCheckbox();

    processingParametersBtn = GUIUtils.addButton(topPanel, "Spectra processing", null,
        masterFrame, "SET_PROCESSING_PARAMETERS", "Set the parameters for quick spectra processing.");
    processingParametersBtn.setBackground(Color.white);
    processingParametersBtn.setFont(smallFont);
    updateProcessingButton();

    topPanel.add(Box.createHorizontalGlue());

    JButton nextScanBtn = GUIUtils.addButton(topPanel, rightArrow, null, masterFrame, "NEXT_SCAN");
    nextScanBtn.setBackground(Color.white);
    nextScanBtn.setFont(smallFont);

    topPanel.add(Box.createHorizontalStrut(10));

    bottomPanel = new JPanel();
    bottomPanel.setBackground(Color.white);
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));
    add(bottomPanel, BorderLayout.SOUTH);

    bottomPanel.add(Box.createHorizontalGlue());

    GUIUtils.addLabel(bottomPanel, "MS/MS: ", SwingConstants.RIGHT);

    msmsSelector = new JComboBox<String>();
    msmsSelector.setBackground(Color.white);
    msmsSelector.setFont(smallFont);
    bottomPanel.add(msmsSelector);

    JButton showButton = GUIUtils.addButton(bottomPanel, "Show", null, masterFrame, "SHOW_MSMS");
    showButton.setBackground(Color.white);
    showButton.setFont(smallFont);

    bottomPanel.add(Box.createHorizontalGlue());

  }
 
Example 17
Source File: AboutPanel.java    From freecol with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The constructor that will add the items to this panel.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public AboutPanel(FreeColClient freeColClient) {
    super(freeColClient, null, new MigLayout("wrap"));

    // Header with image
    JLabel apLogoLabel = new JLabel(new ImageIcon(ImageLibrary
            .getUnscaledImage("image.flavor.Title")));
    apLogoLabel.setBorder(
        new CompoundBorder(new EmptyBorder(2,2,2,2),
                           new BevelBorder(BevelBorder.LOWERED)));
    add(apLogoLabel, "center");

    // Create available Font choices
    Font fontBold = FontLibrary.createFont(FontLibrary.FontType.NORMAL,
        FontLibrary.FontSize.TINY, Font.BOLD,
        getImageLibrary().getScaleFactor());
    Font fontNormal = FontLibrary.createFont(FontLibrary.FontType.NORMAL,
        FontLibrary.FontSize.TINY, getImageLibrary().getScaleFactor());

    // Version
    JLabel apVersion = Utility.localizedLabel("aboutPanel.version");
    apVersion.setFont(fontBold);
    JLabel apRevision = new JLabel(FreeCol.getRevision());
    apRevision.setFont(fontNormal);
    add(apVersion, "newline 20");
    add(apRevision, "newline");

    // Official Site Link
    JLabel apOfficialSite = Utility.localizedLabel("aboutPanel.officialSite");
    apOfficialSite.setFont(fontBold);
    add(apOfficialSite, "newline 10");
    JButton apSiteURL = Utility.getLinkButton(SITE_URL, null, SITE_URL);
    apSiteURL.addActionListener(this);
    apSiteURL.setFont(fontNormal);
    add(apSiteURL, "newline");

    // SourceForge Project Site Link
    JLabel apSFProject = Utility.localizedLabel("aboutPanel.sfProject");
    apSFProject.setFont(fontBold);
    add(apSFProject, "newline 10");
    JButton apProjectURL = Utility.getLinkButton(PROJECT_URL, null, PROJECT_URL);
    apProjectURL.addActionListener(this);
    apProjectURL.setFont(fontNormal);
    add(apProjectURL, "newline");

    //GitHub Mirror
    JLabel apGitHubButton = Utility.localizedLabel("aboutPanel.github");
    apGitHubButton.setFont(fontBold);
    add(apGitHubButton, "newline 10");
    JButton apGitHubURL = Utility.getLinkButton(GITHUB_URL, null, GITHUB_URL);
    apGitHubURL.addActionListener(this);
    apGitHubURL.setFont(fontNormal);
    add(apGitHubURL, "newline");

    // Manual
    JLabel apManual = Utility.localizedLabel("aboutPanel.manual");
    apManual.setFont(fontBold);
    add(apManual, "newline 10");
    JButton apManualURL = Utility.getLinkButton(MANUAL_URL, null,
                                                MANUAL_URL);
    apManualURL.addActionListener(this);
    add(apManualURL, "newline");

    // License Disclaimer
    JTextArea apLegal = Utility.localizedTextArea("aboutPanel.legalDisclaimer");
    apLegal.setFont(fontNormal);
    add(apLegal, "newline 20, width 300px");

    // Copyright
    JLabel apCopyright = Utility.localizedLabel("aboutPanel.copyright");
    apCopyright.setFont(fontNormal);
    add(apCopyright, "newline 10");

    add(okButton, "newline 20, tag ok");
}
 
Example 18
Source File: ClassPresenterPanel.java    From netbeans with Apache License 2.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 19
Source File: ConnectionTagEditPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Adds a tag UI element for the given String
 *
 * @param tag
 * 		the tag to create
 * @param pos
 * 		the position at which to insert the tag, or -1 to append the component to the end
 */
private void addTag(String tag, int pos) {
	JLabel tagLabel = new JLabel(tag);
	tagLabel.setFont(OPEN_SANS_13);
	tagLabel.setForeground(isEnabled ? TAG_FOREGROUND : TAG_FOREGROUND_DISABLED);
	// Add border for more space
	Border border = BorderFactory.createEmptyBorder(2, editable ? 3 : 10, 3, 11);

	JPanel roundBackground = new JPanel(new BorderLayout()) {
		@Override
		public void paintComponent(Graphics g) {
			super.paintComponent(g);
			Graphics2D g2 = (Graphics2D) g;
			g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
			g2.setPaint(isEnabled ? TAG_BACKGROUND : TAG_BACKGROUND_DISABLED);
			// Prevent it from being cut off
			g2.fill(new RoundRectangle2D.Double(0, 0, getWidth() - 1, getHeight() - 1, 6, 6));
		}
	};

	tagLabel.setBorder(border);
	roundBackground.add(tagLabel, BorderLayout.CENTER);
	JButton removeTag = new JButton(CLOSE_SYMBOL);

	if (editable) {
		roundBackground.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
		roundBackground.setBackground(getBackground());
		removeTag.setFont(CLOSE_FONT.deriveFont(1f * removeTag.getFont().getSize()));
		removeTag.setContentAreaFilled(false);
		removeTag.setBorderPainted(false);
		removeTag.setBorder(BorderFactory.createLineBorder(getBackground()));
		roundBackground.add(removeTag, BorderLayout.WEST);
		tagToValue.put(roundBackground, tag);
		removeTag.addActionListener(e -> SwingTools.invokeLater(() -> {
			tagToValue.remove(roundBackground);
			remove(roundBackground);
			setTags.accept(new ArrayList<>(tagToValue.values()));
			revalidate();
			repaint();
		}));
		add(roundBackground, pos);
	} else {
		JPanel spacer = new JPanel(new BorderLayout());
		spacer.setBackground(getBackground());
		spacer.add(roundBackground, BorderLayout.CENTER);
		// Don't use FlowLayout gaps in view mode since they are also added to the top and left side
		spacer.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5));
		add(spacer, pos);
	}

}
 
Example 20
Source File: RefineryUtilities.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a {@link JButton}.
 *
 * @param label  the label.
 * @param font  the font.
 *
 * @return The button.
 */
public static JButton createJButton(String label, Font font) {

    JButton result = new JButton(label);
    result.setFont(font);
    return result;

}