Example usage for javax.swing JButton setFont

List of usage examples for javax.swing JButton setFont

Introduction

In this page you can find the example usage for javax.swing JButton setFont.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.")
public void setFont(Font font) 

Source Link

Document

Sets the font for this component.

Usage

From source file:org.datacleaner.widgets.properties.MultipleInputColumnsPropertyWidget.java

@Inject
public MultipleInputColumnsPropertyWidget(ComponentBuilder componentBuilder,
        ConfiguredPropertyDescriptor propertyDescriptor) {
    super(componentBuilder, propertyDescriptor);
    // setBorder(WidgetUtils.BORDER_LIST_ITEM);
    _checkBoxes = new LinkedHashMap<>();
    _checkBoxDecorations = new IdentityHashMap<>();
    _firstUpdate = true;/*www .j  a v a2  s. c o  m*/
    _dataType = propertyDescriptor.getTypeArgument(0);
    getAnalysisJobBuilder().addSourceColumnChangeListener(this);
    getAnalysisJobBuilder().addTransformerChangeListener(this);

    setLayout(new VerticalLayout(2));

    _searchDatastoreTextField = WidgetFactory.createTextField("Search/filter columns");
    _searchDatastoreTextField.setBorder(
            new CompoundBorder(WidgetUtils.BORDER_CHECKBOX_LIST_INDENTATION, WidgetUtils.BORDER_THIN));
    _searchDatastoreTextField.getDocument().addDocumentListener(new DCDocumentListener() {
        @Override
        protected void onChange(DocumentEvent event) {
            String text = _searchDatastoreTextField.getText();
            if (StringUtils.isNullOrEmpty(text)) {
                // when there is no search query, set all datastores
                // visible
                for (JCheckBox cb : _checkBoxes.values()) {
                    cb.setVisible(true);
                }
            } else {
                // do a case insensitive search
                text = text.trim().toLowerCase();
                for (JCheckBox cb : _checkBoxes.values()) {
                    String name = cb.getText().toLowerCase();
                    cb.setVisible(name.contains(text));
                }
            }
        }
    });

    if (_dataType == null || _dataType == Object.class) {
        _notAvailableCheckBox = new DCCheckBox<>(
                "<html><font color=\"gray\">- no columns available -</font></html>", false);
    } else {
        _notAvailableCheckBox = new DCCheckBox<>("<html><font color=\"gray\">- no <i>"
                + LabelUtils.getDataTypeLabel(_dataType) + "</i> columns available -</font></html>", false);
    }
    _notAvailableCheckBox.setEnabled(false);

    _buttonPanel = new DCPanel();
    _buttonPanel.setLayout(new HorizontalLayout(2));
    _buttonPanel.setBorder(WidgetUtils.BORDER_CHECKBOX_LIST_INDENTATION);

    JButton selectAllButton = WidgetFactory.createDefaultButton("Select all");
    selectAllButton.setFont(WidgetUtils.FONT_SMALL);
    selectAllButton.addActionListener(selectAllActionListener);
    _buttonPanel.add(selectAllButton);

    JButton selectNoneButton = WidgetFactory.createDefaultButton("Select none");
    selectNoneButton.setFont(WidgetUtils.FONT_SMALL);
    selectNoneButton.addActionListener(selectNoneActionListener);
    _buttonPanel.add(selectNoneButton);

    if (propertyDescriptor.isArray()) {
        if (_dataType == String.class || _dataType == Object.class) {
            final JButton expressionColumnButton = WidgetFactory
                    .createSmallButton(IconUtils.MODEL_COLUMN_EXPRESSION);
            expressionColumnButton.setToolTipText("Create expression/value based column");
            expressionColumnButton
                    .addActionListener(AddExpressionBasedColumnActionListener.forMultipleColumns(this));
            _buttonPanel.add(expressionColumnButton);
        }

        final JButton reorderColumnsButton = WidgetFactory.createSmallButton(IconUtils.ACTION_REORDER_COLUMNS);
        reorderColumnsButton.setToolTipText("Reorder columns");
        reorderColumnsButton.addActionListener(new ReorderColumnsActionListener(this));
        _buttonPanel.add(reorderColumnsButton);
    }

    add(_buttonPanel);
    add(_searchDatastoreTextField);
}

From source file:org.eobjects.datacleaner.panels.OpenAnalysisJobPanel.java

public OpenAnalysisJobPanel(final FileObject file, final AnalyzerBeansConfiguration configuration,
        final OpenAnalysisJobActionListener openAnalysisJobActionListener) {
    super(WidgetUtils.BG_COLOR_LESS_BRIGHT, WidgetUtils.BG_COLOR_LESS_BRIGHT);
    _file = file;/*from   w  ww  . ja  v a2  s.  c o  m*/
    _openAnalysisJobActionListener = openAnalysisJobActionListener;

    setLayout(new BorderLayout());
    setBorder(WidgetUtils.BORDER_LIST_ITEM);

    final AnalysisJobMetadata metadata = getMetadata(configuration);
    final String jobName = metadata.getJobName();
    final String jobDescription = metadata.getJobDescription();
    final String datastoreName = metadata.getDatastoreName();

    final boolean isDemoJob = isDemoJob(metadata);

    final DCPanel labelListPanel = new DCPanel();
    labelListPanel.setLayout(new VerticalLayout(4));
    labelListPanel.setBorder(new EmptyBorder(4, 4, 4, 0));

    final String title;
    final String filename = file.getName().getBaseName();
    if (Strings.isNullOrEmpty(jobName)) {
        final String extension = FileFilters.ANALYSIS_XML.getExtension();
        if (filename.toLowerCase().endsWith(extension)) {
            title = filename.substring(0, filename.length() - extension.length());
        } else {
            title = filename;
        }
    } else {
        title = jobName;
    }

    final JButton titleButton = new JButton(title);
    titleButton.setFont(WidgetUtils.FONT_HEADER1);
    titleButton.setForeground(WidgetUtils.BG_COLOR_BLUE_MEDIUM);
    titleButton.setHorizontalAlignment(SwingConstants.LEFT);
    titleButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, WidgetUtils.BG_COLOR_MEDIUM));
    titleButton.setToolTipText("Open job");
    titleButton.setOpaque(false);
    titleButton.setMargin(new Insets(0, 0, 0, 0));
    titleButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    titleButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isDemoDatastoreConfigured(datastoreName, configuration)) {
                _openAnalysisJobActionListener.openFile(_file);
            }
        }
    });

    final JButton executeButton = new JButton(executeIcon);
    executeButton.setOpaque(false);
    executeButton.setToolTipText("Execute job directly");
    executeButton.setMargin(new Insets(0, 0, 0, 0));
    executeButton.setBorderPainted(false);
    executeButton.setHorizontalAlignment(SwingConstants.RIGHT);
    executeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (isDemoDatastoreConfigured(datastoreName, configuration)) {
                final ImageIcon executeIconLarge = ImageManager.get().getImageIcon(IconUtils.ACTION_EXECUTE);
                final String question = "Are you sure you want to execute the job\n'" + title + "'?";
                final int choice = JOptionPane.showConfirmDialog(null, question, "Execute job?",
                        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, executeIconLarge);
                if (choice == JOptionPane.YES_OPTION) {
                    final Injector injector = _openAnalysisJobActionListener.openAnalysisJob(_file);
                    if (injector != null) {
                        final ResultWindow resultWindow = injector.getInstance(ResultWindow.class);
                        resultWindow.open();
                        resultWindow.startAnalysis();
                    }
                }
            }
        }
    });

    final DCPanel titlePanel = new DCPanel();
    titlePanel.setLayout(new BorderLayout());
    titlePanel.add(DCPanel.around(titleButton), BorderLayout.CENTER);
    titlePanel.add(executeButton, BorderLayout.EAST);

    labelListPanel.add(titlePanel);

    if (!Strings.isNullOrEmpty(jobDescription)) {
        String desc = StringUtils.replaceWhitespaces(jobDescription, " ");
        desc = StringUtils.replaceAll(desc, "  ", " ");
        final JLabel label = new JLabel(desc);
        label.setFont(WidgetUtils.FONT_SMALL);
        labelListPanel.add(label);
    }

    final Icon icon;
    {
        if (!StringUtils.isNullOrEmpty(datastoreName)) {
            final JLabel label = new JLabel(" " + datastoreName);
            label.setFont(WidgetUtils.FONT_SMALL);
            labelListPanel.add(label);

            final Datastore datastore = configuration.getDatastoreCatalog().getDatastore(datastoreName);
            if (isDemoJob) {
                icon = demoBadgeIcon;
            } else {
                icon = IconUtils.getDatastoreSpecificAnalysisJobIcon(datastore);
            }
        } else {
            icon = ImageManager.get().getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_LARGE);
        }
    }

    final JLabel iconLabel = new JLabel(icon);
    iconLabel.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight()));

    add(iconLabel, BorderLayout.WEST);
    add(labelListPanel, BorderLayout.CENTER);
}

From source file:org.eobjects.datacleaner.widgets.properties.MultipleInputColumnsPropertyWidget.java

@Inject
public MultipleInputColumnsPropertyWidget(AbstractBeanJobBuilder<?, ?, ?> beanJobBuilder,
        ConfiguredPropertyDescriptor propertyDescriptor) {
    super(beanJobBuilder, propertyDescriptor);
    setBorder(new EtchedBorder(EtchedBorder.LOWERED));
    _checkBoxes = new LinkedHashMap<InputColumn<?>, DCCheckBox<InputColumn<?>>>();
    _checkBoxDecorations = new IdentityHashMap<DCCheckBox<InputColumn<?>>, JComponent>();
    _firstUpdate = true;/*from  ww  w.  jav a  2 s  .c  o  m*/
    _dataType = propertyDescriptor.getTypeArgument(0);
    getAnalysisJobBuilder().getSourceColumnListeners().add(this);
    getAnalysisJobBuilder().getTransformerChangeListeners().add(this);
    setLayout(new VerticalLayout(2));

    _searchDatastoreTextField = WidgetFactory.createTextField("Search/filter columns");
    _searchDatastoreTextField.setBorder(new CompoundBorder(_indentBorder, WidgetUtils.BORDER_THIN));
    _searchDatastoreTextField.getDocument().addDocumentListener(new DCDocumentListener() {
        @Override
        protected void onChange(DocumentEvent event) {
            String text = _searchDatastoreTextField.getText();
            if (StringUtils.isNullOrEmpty(text)) {
                // when there is no search query, set all datastores
                // visible
                for (JCheckBox cb : _checkBoxes.values()) {
                    cb.setVisible(true);
                }
            } else {
                // do a case insensitive search
                text = text.trim().toLowerCase();
                for (JCheckBox cb : _checkBoxes.values()) {
                    String name = cb.getText().toLowerCase();
                    cb.setVisible(name.indexOf(text) != -1);
                }
            }
        }
    });

    _notAvailableCheckBox = new DCCheckBox<InputColumn<?>>("<html><font color=\"gray\">- no <i>"
            + LabelUtils.getDataTypeLabel(_dataType) + "</i> columns available -</font></html>", false);
    _notAvailableCheckBox.setEnabled(false);

    _buttonPanel = new DCPanel();
    _buttonPanel.setLayout(new HorizontalLayout(2));
    _buttonPanel.setBorder(_indentBorder);

    JButton selectAllButton = new JButton("Select all");
    selectAllButton.setFont(WidgetUtils.FONT_SMALL);
    selectAllButton.addActionListener(selectAllActionListener);
    _buttonPanel.add(selectAllButton);

    JButton selectNoneButton = new JButton("Select none");
    selectNoneButton.setFont(WidgetUtils.FONT_SMALL);
    selectNoneButton.addActionListener(selectNoneActionListener);
    _buttonPanel.add(selectNoneButton);

    if (propertyDescriptor.isArray()) {
        if (_dataType == String.class || _dataType == Object.class) {
            final JButton expressionColumnButton = WidgetFactory
                    .createSmallButton(IconUtils.BUTTON_EXPRESSION_COLUMN_IMAGEPATH);
            expressionColumnButton.setToolTipText("Create expression/value based column");
            expressionColumnButton
                    .addActionListener(AddExpressionBasedColumnActionListener.forMultipleColumns(this));
            _buttonPanel.add(expressionColumnButton);
        }

        final JButton reorderColumnsButton = WidgetFactory
                .createSmallButton(IconUtils.BUTTON_REORDER_COLUMN_IMAGEPATH);
        reorderColumnsButton.setToolTipText("Reorder columns");
        reorderColumnsButton.addActionListener(new ReorderColumnsActionListener(this));
        _buttonPanel.add(reorderColumnsButton);
    }

    add(_buttonPanel);
    add(_searchDatastoreTextField);
}

From source file:org.openmicroscopy.shoola.util.ui.UIUtilities.java

/**
 * Creates a button looking like an hyper-link.
 * //from   w  ww  . j a v a2s.  co  m
 * @param text The text to display
 * @return See above.
 */
public static JButton createHyperLinkButton(String text) {
    if (text == null || text.trim().length() == 0)
        text = "hyperlink";
    JButton b = new JButton(text);
    Font f = b.getFont();
    b.setFont(f.deriveFont(f.getStyle(), f.getSize() - 2));
    b.setOpaque(false);
    b.setForeground(UIUtilities.HYPERLINK_COLOR);
    unifiedButtonLookAndFeel(b);
    return b;
}

From source file:Proiect.uploadFTP.java

public void actionFTP() {
    adressf.addCaretListener(new CaretListener() {
        public void caretUpdate(CaretEvent e) {
            InetAddress thisIp;//from   w  w w.j av a2s  .  c  om
            try {
                thisIp = InetAddress.getLocalHost();
                titleFTP.setText("Connection: " + thisIp.getHostAddress() + " -> " + adressf.getText());
            } catch (UnknownHostException e1) {
                e1.printStackTrace();
            }
        }
    });

    exit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            saveState();
            uploadFTP.dispose();
            tree.dispose();
        }
    });

    connect.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            FTPClient client = new FTPClient();
            FileInputStream fis = null;
            String pass = String.valueOf(passf.getPassword());
            try {
                if (filename == null) {
                    status.setText("File does not exist!");
                } else {
                    // Server address
                    client.connect(adressf.getText());
                    // Login credentials
                    client.login(userf.getText(), pass);
                    if (client.isConnected()) {
                        status.setText("Succesfull transfer!");
                        // File type
                        client.setFileType(FTP.BINARY_FILE_TYPE);
                        // File location
                        File file = new File(filepath);
                        fis = new FileInputStream(file);
                        // Change the folder on the server
                        client.changeWorkingDirectory(folderf.getText());
                        // Save the file on the server
                        client.storeFile(filename, fis);
                    } else {
                        status.setText("Transfer failed!");
                    }
                }
                client.logout();
            } catch (IOException e1) {
                Encrypter.printException(e1);
            } finally {
                try {
                    if (fis != null) {
                        fis.close();
                    }
                    client.disconnect();
                } catch (IOException e1) {
                    Encrypter.printException(e1);
                }
            }
        }
    });

    browsef.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int retval = chooserf.showOpenDialog(chooserf);
            if (retval == JFileChooser.APPROVE_OPTION) {
                status.setText("");
                filename = chooserf.getSelectedFile().getName().toString();
                filepath = chooserf.getSelectedFile().getPath();
                filenf.setText(chooserf.getSelectedFile().getName().toString());
            }
        }
    });

    adv.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            tree.setSize(220, uploadFTP.getHeight());
            tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY());
            tree.setResizable(false);
            tree.setIconImage(Toolkit.getDefaultToolkit()
                    .getImage(getClass().getClassLoader().getResource("assets/ico.png")));
            tree.setUndecorated(true);
            tree.getRootPane().setBorder(BorderFactory.createLineBorder(Encrypter.color_black, 2));
            tree.setVisible(true);
            tree.setLayout(new BorderLayout());

            JLabel labeltree = new JLabel("Server documents");
            labeltree.setOpaque(true);
            labeltree.setBackground(Encrypter.color_light);
            labeltree.setBorder(BorderFactory.createMatteBorder(8, 10, 10, 0, Encrypter.color_light));
            labeltree.setForeground(Encrypter.color_blue);
            labeltree.setFont(Encrypter.font16);

            JButton refresh = new JButton("");
            ImageIcon refresh_icon = getImageIcon("assets/icons/refresh.png");
            refresh.setIcon(refresh_icon);
            refresh.setBackground(Encrypter.color_light);
            refresh.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
            refresh.setForeground(Encrypter.color_black);
            refresh.setFont(Encrypter.font16);
            refresh.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

            final FTPClient client = new FTPClient();
            DefaultMutableTreeNode top = new DefaultMutableTreeNode(adressf.getText());
            DefaultMutableTreeNode files = null;
            DefaultMutableTreeNode leaf = null;

            final JTree tree_view = new JTree(top);
            tree_view.setForeground(Encrypter.color_black);
            tree_view.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
            tree_view.putClientProperty("JTree.lineStyle", "None");
            tree_view.setBackground(Encrypter.color_light);
            JScrollPane scrolltree = new JScrollPane(tree_view);
            scrolltree.setBackground(Encrypter.color_light);
            scrolltree.getVerticalScrollBar().setPreferredSize(new Dimension(0, 0));

            UIManager.put("Tree.textBackground", Encrypter.color_light);
            UIManager.put("Tree.selectionBackground", Encrypter.color_blue);
            UIManager.put("Tree.selectionBorderColor", Encrypter.color_blue);

            tree_view.updateUI();

            final String pass = String.valueOf(passf.getPassword());
            try {
                client.connect(adressf.getText());
                client.login(userf.getText(), pass);
                client.enterLocalPassiveMode();
                if (client.isConnected()) {
                    try {
                        FTPFile[] ftpFiles = client.listFiles();
                        for (FTPFile ftpFile : ftpFiles) {
                            files = new DefaultMutableTreeNode(ftpFile.getName());
                            top.add(files);
                            if (ftpFile.getType() == FTPFile.DIRECTORY_TYPE) {
                                FTPFile[] ftpFiles1 = client.listFiles(ftpFile.getName());
                                for (FTPFile ftpFile1 : ftpFiles1) {
                                    leaf = new DefaultMutableTreeNode(ftpFile1.getName());
                                    files.add(leaf);
                                }
                            }
                        }
                    } catch (IOException e1) {
                        Encrypter.printException(e1);
                    }
                    client.disconnect();
                } else {
                    status.setText("Failed connection!");
                }
            } catch (IOException e1) {
                Encrypter.printException(e1);
            } finally {
                try {
                    client.disconnect();
                } catch (IOException e1) {
                    Encrypter.printException(e1);
                }
            }

            tree.add(labeltree, BorderLayout.NORTH);
            tree.add(scrolltree, BorderLayout.CENTER);
            tree.add(refresh, BorderLayout.SOUTH);

            uploadFTP.addComponentListener(new ComponentListener() {

                public void componentMoved(ComponentEvent e) {
                    tree.setLocation(uploadFTP.getX() + 405, uploadFTP.getY());
                }

                public void componentShown(ComponentEvent e) {
                }

                public void componentResized(ComponentEvent e) {
                }

                public void componentHidden(ComponentEvent e) {
                }
            });

            uploadFTP.addWindowListener(new WindowListener() {
                public void windowActivated(WindowEvent e) {
                    tree.toFront();
                }

                public void windowOpened(WindowEvent e) {
                }

                public void windowIconified(WindowEvent e) {
                }

                public void windowDeiconified(WindowEvent e) {
                }

                public void windowDeactivated(WindowEvent e) {
                }

                public void windowClosing(WindowEvent e) {
                }

                public void windowClosed(WindowEvent e) {
                }
            });

            refresh.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    tree.dispose();
                    tree.setVisible(true);
                }
            });
        }
    });

}

From source file:wsattacker.sso.openid.attacker.gui.MainGui.java

@Override
public void actionPerformed(ActionEvent e) {
    JButton pressedButton = (JButton) e.getSource();
    //System.out.println("pressed button: " + pressedButton.getText());

    if (pressedButton == lastPressedButton) {
        // do nothing
        return;/*from  w w  w .jav a 2s . c o m*/
    }

    // remove selection from LAST pressed button
    lastPressedButton.setFont(defaultFont);
    lastPressedButton = pressedButton;

    // add selection to pressed button
    pressedButton.setFont(boldUnderline);

    JXTaskPane taskPaneOfPressedButton = (JXTaskPane) SwingUtilities.getAncestorOfClass(JXTaskPane.class,
            pressedButton);

    if (taskPaneOfPressedButton.getTitle().equals("Attacker IdP")) {

        switch (pressedButton.getText()) {
        case "Server Configuration":
            splitPane.setRightComponent(attackerIdpServerConfigurationGui);

            break;
        case "HTML Discovery":
            splitPane.setRightComponent(attackerIdpHtmlConfigurationGui);
            break;
        case "XRDS Discovery":
            splitPane.setRightComponent(attackerIdpXrdsConfigurationGui);
            break;
        case "Valid Data":
            splitPane.setRightComponent(attackerIdpValidDataGui);
            break;
        case "Attack Data":
            splitPane.setRightComponent(attackerIdpAttackDataGui);
            break;
        case "Attack Overview":
            splitPane.setRightComponent(attackerIdpAttackOverviewGui);
            break;
        }
    } else {
        switch (pressedButton.getText()) {
        case "Server Configuration":
            splitPane.setRightComponent(analyzerIdpServerConfigurationGui);

            break;
        case "HTML Discovery":
            splitPane.setRightComponent(analyzerIdpHtmlConfigurationGui);
            break;
        case "XRDS Discovery":
            splitPane.setRightComponent(analyzerIdpXrdsConfigurationGui);
            break;
        case "Valid Data":
            splitPane.setRightComponent(analyzerIdpValidDataGui);
            break;
        case "Attack Data":
            splitPane.setRightComponent(analyzerIdpAttackDataGui);
            break;
        case "Parameter Overview":
            splitPane.setRightComponent(analyzerIdpAttackOverviewGui);
            break;
        case "Automated Analysis":
            splitPane.setRightComponent(evaluationGui);
            break;
        case "Reports":
            splitPane.setRightComponent(reportGui);
            break;
        case "Log":
            splitPane.setRightComponent(logGui);
            break;
        }
    }
}