private JPanel createPopularPhrasePanel(int index) { JPanel popularPhrasePanel = new JPanel(); popularPhrasePanel.setLayout( new FormLayout( new ColumnSpec[] { ColumnSpec.decode("default"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.DEFAULT_COLSPEC, ColumnSpec.decode("default") }, new RowSpec[] {FormFactory.DEFAULT_ROWSPEC})); popularPhrasePanel.add(new JLabel("" + (index + 1)), "1, 1"); textFields.add(new JTextField(PROPERTIES.getPopularPhrase(index))); popularPhrasePanel.add(textFields.get(index), "3, 1"); JButton playButton = new JButton(Icon.getIcon("/icons/control_play.png")); playButton.addActionListener( a -> speeker.speek(Arrays.asList(textFields.get(index).getText()))); popularPhrasePanel.add(playButton, "5, 1"); return popularPhrasePanel; }
private void initConfigPanel(JFrame parent) { JPanel configPanel = new JPanel(); configPanel.setBorder(new EmptyBorder(10, 10, 10, 10)); getContentPane().add(configPanel, BorderLayout.CENTER); configPanel.setLayout( new FormLayout( new ColumnSpec[] { ColumnSpec.decode("default:grow"), ColumnSpec.decode("default:grow"), ColumnSpec.decode("default:grow"), ColumnSpec.decode("right:default"), ColumnSpec.decode("right:default"), ColumnSpec.decode("right:default") }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, RowSpec.decode("default:grow"), })); StringSeparator lafSeparator = new StringSeparator(MESSAGES.get("laf")); configPanel.add(lafSeparator, "1, 7, 5, 1"); LookAndFeel[] allLafs = LookAndFeel.getAll(); lafComboBox = new JComboBox<>(allLafs); LookAndFeel selectedLaf = Arrays.stream(allLafs) .filter(l -> l.getName().equals(PROPERTIES.getLaf())) .findFirst() .get(); lafComboBox.setSelectedItem(selectedLaf); configPanel.add(lafComboBox, "3, 9, 3, 1"); StringSeparator splashScreenSeparator = new StringSeparator(MESSAGES.get("splash_screen")); configPanel.add(splashScreenSeparator, "1, 7, 5, 1"); JLabel lblSplashScreenEnabled = new JLabel(MESSAGES.get("enabled")); configPanel.add(lblSplashScreenEnabled, "3, 9"); chckbxSplashScreenEnabled = new JCheckBox(); chckbxSplashScreenEnabled.setSelected(PROPERTIES.isSplashScreenEnabled()); configPanel.add(chckbxSplashScreenEnabled, "4, 9"); StringSeparator welcomeScreenSeparator = new StringSeparator(MESSAGES.get("welcome_screen")); configPanel.add(welcomeScreenSeparator, "1, 11, 5, 1"); JLabel lblShowWelcomeScreen = new JLabel(MESSAGES.get("enabled")); configPanel.add(lblShowWelcomeScreen, "4, 13"); chckbxWelcomeScreenEnabled = new JCheckBox(); chckbxWelcomeScreenEnabled.setSelected(PROPERTIES.isWelcomeScreenEnabled()); configPanel.add(chckbxWelcomeScreenEnabled, "5, 13"); StringSeparator startMinimizedSeparator = new StringSeparator(MESSAGES.get("start_minimized")); configPanel.add(startMinimizedSeparator, "1, 15, 5, 1"); JLabel lblStartMinized = new JLabel(MESSAGES.get("enabled")); configPanel.add(lblStartMinized, "4, 17"); chckbxStartMinimized = new JCheckBox(); chckbxStartMinimized.setSelected(PROPERTIES.isStartMinimized()); configPanel.add(chckbxStartMinimized, "5, 17"); StringSeparator nativeHookSeparator = new StringSeparator(MESSAGES.get("native_hook")); configPanel.add(nativeHookSeparator, "1, 19, 5, 1"); nativeHookLabel = new JLabel(getNativeHookText(nativeHookKeyCodes)); configPanel.add(nativeHookLabel, "2, 23"); JButton btnRecordNativeHook = new JButton(Icon.getIcon("/icons/pencil.png")); configPanel.add(btnRecordNativeHook, "4, 23, 2, 1, fill, default"); btnRecordNativeHook.addActionListener( e -> { RecordNativeHookDialog dialog = new RecordNativeHookDialog(parent); dialog.setVisible(true); if (dialog.isOkButtonPressed()) { nativeHookKeyCodes = dialog.getNativeHookKeyCodes(); nativeHookLabel.setText(getNativeHookText(nativeHookKeyCodes)); } dialog.dispose(); }); StringSeparator suggestionsSeparator = new StringSeparator(MESSAGES.get("suggestions")); configPanel.add(suggestionsSeparator, "1, 25, 5, 1"); JLabel lblSuggestions = new JLabel(MESSAGES.get("enabled")); configPanel.add(lblSuggestions, "2, 27, 3, 1, right, center"); chckbxShowSuggestions = new JCheckBox(); chckbxShowSuggestions.setSelected(PROPERTIES.isSuggestionsEnabled()); configPanel.add(chckbxShowSuggestions, "5, 27"); }