Search in sources :

Example 16 with RoundBorder

use of net.technicpack.ui.controls.borders.RoundBorder in project LauncherV3 by TechnicPack.

the class InstallerFrame method setupStandardInstall.

private void setupStandardInstall(JPanel panel) {
    panel.setLayout(new GridBagLayout());
    JLabel standardSpiel = new JLabel("<html><body align=\"left\" style='margin-right:10px;'>" + resources.getString("launcher.installer.standardspiel") + "</body></html>");
    standardSpiel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    standardSpiel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    standardSpiel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.add(standardSpiel, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(9, 0, 0, 3), 0, 0));
    panel.add(Box.createGlue(), new GridBagConstraints(0, 1, 3, 1, 1.0, 0.7, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    standardDefaultDirectory = new JCheckBox(resources.getString("launcher.installer.default"));
    standardDefaultDirectory.setOpaque(false);
    standardDefaultDirectory.setHorizontalAlignment(SwingConstants.RIGHT);
    standardDefaultDirectory.setBorder(BorderFactory.createEmptyBorder());
    standardDefaultDirectory.setIconTextGap(0);
    standardDefaultDirectory.setSelectedIcon(resources.getIcon("checkbox_closed.png"));
    standardDefaultDirectory.setIcon(resources.getIcon("checkbox_open.png"));
    standardDefaultDirectory.setFocusPainted(false);
    standardDefaultDirectory.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    standardDefaultDirectory.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    standardDefaultDirectory.setIconTextGap(6);
    standardDefaultDirectory.setSelected(settings.isPortable() || settings.getTechnicRoot().getAbsolutePath().equals(OperatingSystem.getOperatingSystem().getUserDirectoryForApp("technic").getAbsolutePath()));
    standardDefaultDirectory.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            useDefaultDirectoryChanged();
        }
    });
    panel.add(standardDefaultDirectory, new GridBagConstraints(0, 2, 3, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 24, 12, 0), 0, 0));
    JLabel installFolderLabel = new JLabel(resources.getString("launcher.installer.folder"));
    installFolderLabel.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    installFolderLabel.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    panel.add(installFolderLabel, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 24, 0, 8), 0, 0));
    String installDir = OperatingSystem.getOperatingSystem().getUserDirectoryForApp("technic").getAbsolutePath();
    if (!settings.isPortable())
        installDir = settings.getTechnicRoot().getAbsolutePath();
    standardInstallDir = new JTextField(installDir);
    standardInstallDir.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    standardInstallDir.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL);
    standardInstallDir.setHighlighter(null);
    standardInstallDir.setEditable(false);
    standardInstallDir.setCursor(null);
    panel.add(standardInstallDir, new GridBagConstraints(1, 3, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 16));
    standardSelectButton = new RoundedButton(resources.getString("launcher.installer.select"));
    standardSelectButton.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    standardSelectButton.setContentAreaFilled(false);
    standardSelectButton.setHoverForeground(LauncherFrame.COLOR_BLUE);
    standardSelectButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            selectStandard();
        }
    });
    panel.add(standardSelectButton, new GridBagConstraints(2, 3, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 0, 16), 0, 0));
    useDefaultDirectoryChanged();
    panel.add(Box.createGlue(), new GridBagConstraints(0, 4, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    String defaultLocaleText = resources.getString("launcheroptions.language.default");
    if (!resources.isDefaultLocaleSupported()) {
        defaultLocaleText = defaultLocaleText.concat(" (" + resources.getString("launcheroptions.language.unavailable") + ")");
    }
    standardLanguages = new JComboBox();
    standardLanguages.addItem(new LanguageItem(ResourceLoader.DEFAULT_LOCALE, defaultLocaleText, resources));
    for (int i = 0; i < LauncherMain.supportedLanguages.length; i++) {
        standardLanguages.addItem(new LanguageItem(resources.getCodeFromLocale(LauncherMain.supportedLanguages[i]), LauncherMain.supportedLanguages[i].getDisplayName(LauncherMain.supportedLanguages[i]), resources.getVariant(LauncherMain.supportedLanguages[i])));
    }
    if (!settings.getLanguageCode().equalsIgnoreCase(ResourceLoader.DEFAULT_LOCALE)) {
        Locale loc = resources.getLocaleFromCode(settings.getLanguageCode());
        for (int i = 0; i < LauncherMain.supportedLanguages.length; i++) {
            if (loc.equals(LauncherMain.supportedLanguages[i])) {
                standardLanguages.setSelectedIndex(i + 1);
                break;
            }
        }
    }
    standardLanguages.setBorder(new RoundBorder(LauncherFrame.COLOR_SCROLL_THUMB, 1, 10));
    standardLanguages.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    standardLanguages.setUI(new LanguageCellUI(resources, new RoundedBorderFormatter(new LineBorder(Color.black, 1)), LauncherFrame.COLOR_SCROLL_TRACK, LauncherFrame.COLOR_SCROLL_THUMB));
    standardLanguages.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    standardLanguages.setBackground(LauncherFrame.COLOR_SELECTOR_BACK);
    standardLanguages.setRenderer(new LanguageCellRenderer(resources, "globe.png", LauncherFrame.COLOR_SELECTOR_BACK, LauncherFrame.COLOR_WHITE_TEXT));
    standardLanguages.setEditable(false);
    standardLanguages.setFocusable(false);
    standardLanguages.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            standardLanguageChanged();
        }
    });
    panel.add(standardLanguages, new GridBagConstraints(0, 5, 1, 0, 0, 0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, 8, 8, 0), 0, 0));
    RoundedButton install = new RoundedButton(resources.getString("launcher.installer.install"));
    install.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 16));
    install.setContentAreaFilled(false);
    install.setForeground(LauncherFrame.COLOR_BUTTON_BLUE);
    install.setHoverForeground(LauncherFrame.COLOR_BLUE);
    install.setBorder(BorderFactory.createEmptyBorder(5, 17, 10, 17));
    install.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            standardInstall();
        }
    });
    panel.add(install, new GridBagConstraints(1, 5, 2, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.VERTICAL, new Insets(0, 0, 8, 8), 0, 0));
}
Also used : Locale(java.util.Locale) RoundedButton(net.technicpack.ui.controls.RoundedButton) ActionEvent(java.awt.event.ActionEvent) LineBorder(javax.swing.border.LineBorder) LanguageCellRenderer(net.technicpack.ui.controls.lang.LanguageCellRenderer) ActionListener(java.awt.event.ActionListener) LanguageCellUI(net.technicpack.ui.controls.lang.LanguageCellUI) RoundedBorderFormatter(net.technicpack.ui.controls.list.popupformatters.RoundedBorderFormatter) RoundBorder(net.technicpack.ui.controls.borders.RoundBorder) LanguageItem(net.technicpack.ui.listitems.LanguageItem)

Example 17 with RoundBorder

use of net.technicpack.ui.controls.borders.RoundBorder in project LauncherV3 by TechnicPack.

the class ModpackSelector method initComponents.

private void initComponents() {
    setLayout(new BorderLayout());
    setBackground(LauncherFrame.COLOR_SELECTOR_BACK);
    setMaximumSize(new Dimension(287, getMaximumSize().height));
    JPanel header = new JPanel();
    header.setLayout(new GridBagLayout());
    header.setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 4));
    header.setBackground(LauncherFrame.COLOR_SELECTOR_OPTION);
    add(header, BorderLayout.PAGE_START);
    filterContents = new WatermarkTextField(resources.getString("launcher.packselector.filter.hotfix"), LauncherFrame.COLOR_BLUE_DARKER);
    filterContents.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    filterContents.setBorder(new RoundBorder(LauncherFrame.COLOR_BUTTON_BLUE, 1, 8));
    filterContents.setForeground(LauncherFrame.COLOR_BLUE);
    filterContents.setBackground(LauncherFrame.COLOR_FORMELEMENT_INTERNAL);
    filterContents.setSelectedTextColor(Color.black);
    filterContents.setSelectionColor(LauncherFrame.COLOR_BUTTON_BLUE);
    filterContents.setCaretColor(LauncherFrame.COLOR_BUTTON_BLUE);
    filterContents.setColumns(20);
    ((AbstractDocument) filterContents.getDocument()).setDocumentFilter(new DocumentFilter() {

        @Override
        public void insertString(DocumentFilter.FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException {
            if (fb.getDocument().getLength() + string.length() <= MAX_SEARCH_STRING) {
                fb.insertString(offset, string, attr);
            }
        }

        @Override
        public void remove(DocumentFilter.FilterBypass fb, int offset, int length) throws BadLocationException {
            fb.remove(offset, length);
        }

        @Override
        public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
            int finalTextLength = (fb.getDocument().getLength() - length) + text.length();
            if (finalTextLength > MAX_SEARCH_STRING)
                text = text.substring(0, text.length() - (finalTextLength - MAX_SEARCH_STRING));
            fb.replace(offset, length, text, attrs);
        }
    });
    filterContents.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            detectFilterChanges();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            detectFilterChanges();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            detectFilterChanges();
        }
    });
    header.add(filterContents, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(3, 0, 3, 0), 0, 12));
    widgetList = new JPanel();
    widgetList.setOpaque(false);
    widgetList.setLayout(new GridBagLayout());
    scrollPane = new JScrollPane(widgetList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setOpaque(false);
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    scrollPane.getViewport().setOpaque(false);
    scrollPane.getVerticalScrollBar().setUI(new SimpleScrollbarUI(LauncherFrame.COLOR_SCROLL_TRACK, LauncherFrame.COLOR_SCROLL_THUMB));
    scrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(10, 10));
    scrollPane.getVerticalScrollBar().setUnitIncrement(12);
    add(scrollPane, BorderLayout.CENTER);
    widgetList.add(Box.createHorizontalStrut(294), new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    widgetList.add(Box.createGlue(), new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
}
Also used : DocumentListener(javax.swing.event.DocumentListener) SimpleScrollbarUI(net.technicpack.ui.controls.list.SimpleScrollbarUI) DocumentFilter(javax.swing.text.DocumentFilter) DocumentEvent(javax.swing.event.DocumentEvent) AbstractDocument(javax.swing.text.AbstractDocument) AttributeSet(javax.swing.text.AttributeSet) RoundBorder(net.technicpack.ui.controls.borders.RoundBorder) BadLocationException(javax.swing.text.BadLocationException) WatermarkTextField(net.technicpack.ui.controls.WatermarkTextField)

Aggregations

RoundBorder (net.technicpack.ui.controls.borders.RoundBorder)17 RoundedBorderFormatter (net.technicpack.ui.controls.list.popupformatters.RoundedBorderFormatter)7 ActionEvent (java.awt.event.ActionEvent)6 ActionListener (java.awt.event.ActionListener)6 RoundedButton (net.technicpack.ui.controls.RoundedButton)6 MetalComboBoxUI (javax.swing.plaf.metal.MetalComboBoxUI)5 SimpleButtonComboUI (net.technicpack.ui.controls.list.SimpleButtonComboUI)5 BasicComboPopup (javax.swing.plaf.basic.BasicComboPopup)4 Locale (java.util.Locale)3 LineBorder (javax.swing.border.LineBorder)3 PackBuildItem (net.technicpack.launcher.ui.listitems.PackBuildItem)3 LanguageCellRenderer (net.technicpack.ui.controls.lang.LanguageCellRenderer)3 LanguageCellUI (net.technicpack.ui.controls.lang.LanguageCellUI)3 LanguageItem (net.technicpack.ui.listitems.LanguageItem)3 DocumentEvent (javax.swing.event.DocumentEvent)1 DocumentListener (javax.swing.event.DocumentListener)1 AbstractDocument (javax.swing.text.AbstractDocument)1 AttributeSet (javax.swing.text.AttributeSet)1 BadLocationException (javax.swing.text.BadLocationException)1 DocumentFilter (javax.swing.text.DocumentFilter)1