Search in sources :

Example 1 with JFontChooser

use of say.swing.JFontChooser in project jadx by skylot.

the class JadxSettingsWindow method makeEditorGroup.

private SettingsGroup makeEditorGroup() {
    JButton fontBtn = new JButton(NLS.str("preferences.select_font"));
    fontBtn.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            JFontChooser fontChooser = new JFontChooser();
            fontChooser.setSelectedFont(settings.getFont());
            int result = fontChooser.showDialog(JadxSettingsWindow.this);
            if (result == JFontChooser.OK_OPTION) {
                Font font = fontChooser.getSelectedFont();
                LOG.info("Selected Font : {}", font);
                settings.setFont(font);
                mainWindow.updateFont(font);
            }
        }
    });
    SettingsGroup other = new SettingsGroup(NLS.str("preferences.editor"));
    other.addRow(NLS.str("preferences.font"), fontBtn);
    return other;
}
Also used : MouseEvent(java.awt.event.MouseEvent) JFontChooser(say.swing.JFontChooser) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) Font(java.awt.Font)

Example 2 with JFontChooser

use of say.swing.JFontChooser in project jadx by skylot.

the class JadxSettingsWindow method makeAppearanceGroup.

private SettingsGroup makeAppearanceGroup() {
    JButton fontBtn = new JButton(NLS.str("preferences.select_font"));
    JButton smaliFontBtn = new JButton(NLS.str("preferences.select_smali_font"));
    EditorTheme[] editorThemes = EditorTheme.getAllThemes();
    JComboBox<EditorTheme> themesCbx = new JComboBox<>(editorThemes);
    for (EditorTheme theme : editorThemes) {
        if (theme.getPath().equals(settings.getEditorThemePath())) {
            themesCbx.setSelectedItem(theme);
            break;
        }
    }
    themesCbx.addActionListener(e -> {
        int i = themesCbx.getSelectedIndex();
        EditorTheme editorTheme = editorThemes[i];
        settings.setEditorThemePath(editorTheme.getPath());
        mainWindow.loadSettings();
    });
    JComboBox<String> lafCbx = new JComboBox<>(LafManager.getThemes());
    lafCbx.setSelectedItem(settings.getLafTheme());
    lafCbx.addActionListener(e -> {
        settings.setLafTheme((String) lafCbx.getSelectedItem());
        mainWindow.loadSettings();
    });
    SettingsGroup group = new SettingsGroup(NLS.str("preferences.appearance"));
    group.addRow(NLS.str("preferences.laf_theme"), lafCbx);
    group.addRow(NLS.str("preferences.theme"), themesCbx);
    JLabel fontLabel = group.addRow(getFontLabelStr(), fontBtn);
    JLabel smaliFontLabel = group.addRow(getSmaliFontLabelStr(), smaliFontBtn);
    fontBtn.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            JFontChooser fontChooser = new JFontChooser();
            fontChooser.setSelectedFont(settings.getFont());
            int result = fontChooser.showDialog(JadxSettingsWindow.this);
            if (result == JFontChooser.OK_OPTION) {
                Font font = fontChooser.getSelectedFont();
                LOG.debug("Selected Font: {}", font);
                settings.setFont(font);
                mainWindow.loadSettings();
                fontLabel.setText(getFontLabelStr());
            }
        }
    });
    smaliFontBtn.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            JFontChooser fontChooser = new JPreferredFontChooser();
            fontChooser.setSelectedFont(settings.getSmaliFont());
            int result = fontChooser.showDialog(JadxSettingsWindow.this);
            if (result == JFontChooser.OK_OPTION) {
                Font font = fontChooser.getSelectedFont();
                LOG.debug("Selected Font: {} for smali", font);
                settings.setSmaliFont(font);
                mainWindow.loadSettings();
                smaliFontLabel.setText(getSmaliFontLabelStr());
            }
        }
    });
    return group;
}
Also used : MouseEvent(java.awt.event.MouseEvent) JComboBox(javax.swing.JComboBox) EditorTheme(jadx.gui.ui.codearea.EditorTheme) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) Font(java.awt.Font) JFontChooser(say.swing.JFontChooser)

Aggregations

Font (java.awt.Font)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 JButton (javax.swing.JButton)2 JFontChooser (say.swing.JFontChooser)2 EditorTheme (jadx.gui.ui.codearea.EditorTheme)1 JComboBox (javax.swing.JComboBox)1 JLabel (javax.swing.JLabel)1