List of usage examples for java.awt GraphicsEnvironment getAvailableFontFamilyNames
public abstract String[] getAvailableFontFamilyNames();
From source file:ja.lingo.application.gui.main.settings.appearance.AppearanceGui.java
public AppearanceGui(Model model) { model.addApplicationModelListener(new ModelAdapter() { public void settingsUpdated(Preferences preferences) { setSelectedFontSize(preferences.getFontSize()); setSelectedFontFace(preferences.getFontFace()); dropZoneCheckBox.setSelected(preferences.isDropZoneVisible()); memoryBarCheckBox.setSelected(preferences.isMemoryBarVisible()); }/*from w w w . j a v a 2 s . c o m*/ }); dropZoneCheckBox = new JCheckBox(resources.text("showDropZone")); fontSizeComboBox = new JComboBox(new Integer[] { 12, 13, DEFAULT_FONT_SIZE, 15, 16, 17 }); memoryBarCheckBox = new JCheckBox(resources.text("showMemoryBar")); JPanel fontSizePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, Gaps.GAP5, 0)); fontSizePanel.add(resources.label("fontSize")); fontSizePanel.add(fontSizeComboBox); fontSizePanel.add(resources.label("requiresRestart")); gui = new JPanel(new TableLayout(new double[][] { { TableLayout.PREFERRED }, { TableLayout.PREFERRED, // 0: font face Gaps.GAP5, TableLayout.PREFERRED, // 2: font size Gaps.GAP5, TableLayout.PREFERRED, // 4: drop-zone Gaps.GAP5, TableLayout.PREFERRED, // 6: memory bar } })); JPanel fontFacePanel = new JPanel(new FlowLayout(FlowLayout.LEFT, Gaps.GAP5, 0)); fontFacePanel.add(resources.label("fontFace")); GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment(); fontFaceComboBox = new JComboBox(gEnv.getAvailableFontFamilyNames()); fontFaceComboBox.setMaximumRowCount(10); fontFacePanel.add(fontFaceComboBox); fontFacePanel.add(resources.label("requiresRestart")); gui.add(fontFacePanel, "0, 0"); gui.add(fontSizePanel, "0, 2"); gui.add(dropZoneCheckBox, "0, 4"); gui.add(memoryBarCheckBox, "0, 6"); Gaps.applyBorder5(gui); ActionBinder.bind(this); }
From source file:MainClass.java
public void actionPerformed(ActionEvent e) { JTextPane editor = (JTextPane) getEditor(e); int p0 = editor.getSelectionStart(); StyledDocument doc = getStyledDocument(editor); Element paragraph = doc.getCharacterElement(p0); AttributeSet as = paragraph.getAttributes(); family = StyleConstants.getFontFamily(as); fontSize = StyleConstants.getFontSize(as); formatText = new JDialog(new JFrame(), "Font and Size", true); formatText.getContentPane().setLayout(new BorderLayout()); JPanel choosers = new JPanel(); choosers.setLayout(new GridLayout(2, 1)); JPanel fontFamilyPanel = new JPanel(); fontFamilyPanel.add(new JLabel("Font")); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fontNames = ge.getAvailableFontFamilyNames(); fontFamilyChooser = new JComboBox(); for (int i = 0; i < fontNames.length; i++) { fontFamilyChooser.addItem(fontNames[i]); }/*w ww . j a va 2 s.co m*/ fontFamilyChooser.setSelectedItem(family); fontFamilyPanel.add(fontFamilyChooser); choosers.add(fontFamilyPanel); JPanel fontSizePanel = new JPanel(); fontSizePanel.add(new JLabel("Size")); fontSizeChooser = new JComboBox(); fontSizeChooser.setEditable(true); fontSizeChooser.addItem(new Float(4)); fontSizeChooser.addItem(new Float(8)); fontSizeChooser.addItem(new Float(12)); fontSizeChooser.addItem(new Float(16)); fontSizeChooser.addItem(new Float(20)); fontSizeChooser.addItem(new Float(24)); fontSizeChooser.setSelectedItem(new Float(fontSize)); fontSizePanel.add(fontSizeChooser); choosers.add(fontSizePanel); JButton ok = new JButton("OK"); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { accept = true; formatText.dispose(); family = (String) fontFamilyChooser.getSelectedItem(); fontSize = Float.parseFloat(fontSizeChooser.getSelectedItem().toString()); } }); JButton cancel = new JButton("Cancel"); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { formatText.dispose(); } }); JPanel buttons = new JPanel(); buttons.add(ok); buttons.add(cancel); formatText.getContentPane().add(choosers, BorderLayout.CENTER); formatText.getContentPane().add(buttons, BorderLayout.SOUTH); formatText.pack(); formatText.setVisible(true); MutableAttributeSet attr = null; if (editor != null && accept) { attr = new SimpleAttributeSet(); StyleConstants.setFontFamily(attr, family); StyleConstants.setFontSize(attr, (int) fontSize); setCharacterAttributes(editor, attr, false); } }
From source file:com.itemanalysis.jmetrik.gui.JmetrikPreferencesManager.java
private String getDefaultFont() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fontNames = ge.getAvailableFontFamilyNames(); for (String s : fontNames) { if (s.equals("Courier")) return "Courier"; if (s.equals("Courier New")) return "Courier New"; if (s.equals("Menlo")) return "Menlo"; if (s.equals("Monaco")) return "Monaco"; if (s.equals("Lucida Sans Typewriter")) return "Lucida Sans Typewriter"; }/*www .ja v a2 s. co m*/ return "Lucida Sans Typewriter";//preferred default font }
From source file:forseti.JUtil.java
public static synchronized Image generarImagenMensaje(String mensaje, String nombreFuente, int tamanioFuente) { Frame f = new Frame(); f.addNotify();//from w w w.j a v a 2s. co m GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); env.getAvailableFontFamilyNames(); Font fuente = new Font(nombreFuente, Font.PLAIN, tamanioFuente); FontMetrics medidas = f.getFontMetrics(fuente); int anchoMensaje = medidas.stringWidth(mensaje); int lineaBaseX = anchoMensaje / 10; int ancho = anchoMensaje + 2 * (lineaBaseX + tamanioFuente); int alto = tamanioFuente * 7 / 2; int lineaBaseY = alto * 8 / 10; Image imagenMensaje = f.createImage(ancho, alto); Graphics2D g2d = (Graphics2D) imagenMensaje.getGraphics(); g2d.setFont(fuente); g2d.translate(lineaBaseX, lineaBaseY); g2d.setPaint(Color.lightGray); AffineTransform origTransform = g2d.getTransform(); g2d.shear(-0.95, 0); g2d.scale(1, 3); g2d.drawString(mensaje, 0, 0); g2d.setTransform(origTransform); g2d.setPaint(Color.black); g2d.drawString(mensaje, 0, 0); return (imagenMensaje); }
From source file:ExText.java
public void initialize(String[] args) { // Initialize the window, menubar, etc. super.initialize(args); exampleFrame.setTitle("Java 3D Text Example"); ////from ww w . j a v a 2s . com // Add a menubar menu to change node parameters // Font --> // Menu m = new Menu("Font3D"); // Get a list of available fonts GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fontNames = ge.getAvailableFontFamilyNames(); fonts = new NameValue[fontNames.length]; Font newFont = null; // Add those fonts to a list and build the font menu if (debug) System.err.println("Loading fonts..."); for (int i = 0; i < fontNames.length; i++) { if (debug) System.err.println(" " + fontNames[i]); newFont = new Font(fontNames[i], Font.PLAIN, 1); fonts[i] = new NameValue(fontNames[i], newFont); } fontMenu = new CheckboxMenu("Font", fonts, currentFont, this); m.add(fontMenu); exampleMenuBar.add(m); }
From source file:org.omegat.util.StaticUtils.java
/** * Returns the names of all font families available. *//*from www . j a v a2 s.c o m*/ public static String[] getFontNames() { GraphicsEnvironment graphics; graphics = GraphicsEnvironment.getLocalGraphicsEnvironment(); return graphics.getAvailableFontFamilyNames(); }
From source file:org.polymap.styler.ui.TextSymbolizerEditorComposite.java
/** * This is a callback that will allow us to create the viewer and initialize * it./*from w w w.j av a 2 s . c o m*/ */ public TextSymbolizerEditorComposite(Composite parent, StyleChangeListenerInterface scl, SymbolizerWrapper _symbolizer_w) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); font_family_combo_items = ge.getAvailableFontFamilyNames(); symbolizer_w = _symbolizer_w; final Display display = parent.getDisplay(); log.info("creating style editor layout"); //$NON-NLS-1$ style_change_listener = scl; if (symbolizer_w.hasLabel()) { // TODO chek if needed Composite label_composite = LayoutHelper.subpart(parent, Messages.get().LABEL, 2); /* Text label = new Text(label_composite,SWT.BORDER); label.setSize(50,label.getSize().y); label.setText(symbolizer_w.getLabel()); label.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent event) { style_change_listener .label_changed(((Text) event.widget) .getText() ,false ); } }); */ Combo label_combo = new Combo(label_composite, SWT.NONE); label_combo.setItems(symbolizer_w.getFeatureAttributes()); label_combo.setText(symbolizer_w.getLabel()); label_combo.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent event) { style_change_listener.label_changed(((Combo) event.widget).getText(), true); } }); //label_combo.select(1); //label_combo.addModifyListener(new ModifyListener() { // Text attrs = new Text(label_composite,SWT.BORDER); //attrs.setText("" + symbolizer_w.get) } Composite font_composite = LayoutHelper.subpart(parent, Messages.get().FONT, 3); new FontAlignEditorComposite(parent, scl, symbolizer_w); /* Combo font_align_v_combo = new Combo(font_composite, SWT.NONE); font_align_v_combo.setItems(align_v_combo_items); font_align_v_combo.select( symbolizer_w.getLabelPlacementY()); font_align_v_combo.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent event) { // TODO Auto-generated method stub switch (((Combo) event.widget).getSelectionIndex()) { case 0: align_v_str = "t"; //$NON-NLS-1$ break; case 1: align_v_str = "m"; //$NON-NLS-1$ break; case 2: align_v_str = "b"; //$NON-NLS-1$ break; } style_change_listener.font_align_changed(align_h_str + align_v_str); } }); Combo font_align_h_combo = new Combo(font_composite, SWT.NONE); font_align_h_combo.setItems(align_h_combo_items); font_align_h_combo.select(symbolizer_w.getLabelPlacementX()); font_align_h_combo.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent event) { // TODO Auto-generated method stub switch (((Combo) event.widget).getSelectionIndex()) { case 0: align_h_str = "l"; //$NON-NLS-1$ break; case 1: align_h_str = "c"; //$NON-NLS-1$ break; case 2: align_h_str = "r"; //$NON-NLS-1$ break; } style_change_listener.font_align_changed(align_h_str + align_v_str); } }); */ Combo font_weight_combo = new Combo(LayoutHelper.describingGroup(font_composite, Messages.get().WEIGHT), SWT.DROP_DOWN | SWT.READ_ONLY); font_weight_combo.setItems(font_weight_combo_items); font_weight_combo.select(0); font_weight_combo.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent event) { // TODO Auto-generated method stub style_change_listener.font_weight_changed( font_weight_combo_items4sld[((Combo) event.widget).getSelectionIndex()]); } }); Combo font_size_combo = new Combo(LayoutHelper.describingGroup(font_composite, Messages.get().SIZE), SWT.NONE); font_size_combo.setItems(width_combo_items); font_size_combo.setText("" + symbolizer_w.getFont().getSize()); //$NON-NLS-1$ font_size_combo.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent event) { // TODO Auto-generated method stub int val = Integer.parseInt(((Combo) event.widget).getText()); style_change_listener.font_size_changed(val); } }); Combo font_family_combo = new Combo(LayoutHelper.describingGroup(font_composite, Messages.get().FAMILY), SWT.NONE); font_family_combo.setItems(font_family_combo_items); font_family_combo.setText(symbolizer_w.getFont().getFamily().get(0).toString()); font_family_combo.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent event) { // TODO Auto-generated method stub style_change_listener.font_family_changed(((Combo) event.widget).getText()); } }); /*Button mod_font_color_btn = new Button(font_composite, SWT.PUSH); mod_font_color_btn.setText(Messages.get().COLOR); mod_font_color_btn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { style_change_listener.font_color_changed((new ColorDialog( new Shell(display))).open()); } }); */ /* final Button mod_font_color_btn = new Button(font_composite, SWT.PUSH); mod_font_color_btn.setText(Messages.get().COLOR); mod_font_color_btn.setImage( ImageHelper.createColorRectImage(SLD.color(symbolizer_w.getTextFill().getColor())) ); mod_font_color_btn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ColorDialog dialog=new ColorDialog( new Shell(display)); dialog.setRGB(ColorHelper.Color2RGB(SLD.color(symbolizer_w.getTextFill().getColor() ) )); RGB res=dialog.open(); mod_font_color_btn.setImage(ImageHelper.createColorRectImage(res)); style_change_listener.font_color_changed(res); } }); */ /* HALO Section */ Composite halo_composite = LayoutHelper.subpart(parent, Messages.get().HALO, 3); Button halo_active = new Button(halo_composite, SWT.CHECK); halo_active.setData(symbolizer_w); halo_active.setSelection(symbolizer_w.hasHalo()); final Spinner halo_opacity_spinner = LayoutHelper.createPercentageSpinner( LayoutHelper.describingGroup(halo_composite, Messages.get().OPACITY), (int) (symbolizer_w.getHaloOpacity() * 100)); final Combo halo_radius_combo = new Combo( LayoutHelper.describingGroup(halo_composite, Messages.get().RADIUS), SWT.NONE); final Button mod_halo_color_btn = new Button( LayoutHelper.describingGroup(halo_composite, Messages.get().COLOR), SWT.PUSH); halo_active.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button thisButton = (Button) e.widget; if (thisButton.getSelection()) { ((SymbolizerWrapper) (e.widget.getData())).addDefaultHalo(); mod_halo_color_btn.setImage( ImageHelper.createColorRectImage(SLD.color(symbolizer_w.getHaloFill().getColor()))); halo_opacity_spinner.setSelection( (int) (((SymbolizerWrapper) (e.widget.getData())).getHaloOpacity() * 100)); halo_radius_combo.setText("" + ((SymbolizerWrapper) (e.widget.getData())).getHaloRadius()); mod_halo_color_btn.setEnabled(true); halo_opacity_spinner.setEnabled(true); halo_radius_combo.setEnabled(true); } else { ((SymbolizerWrapper) (e.widget.getData())).setHalo(null); mod_halo_color_btn.setEnabled(false); halo_opacity_spinner.setEnabled(false); halo_radius_combo.setEnabled(false); } } }); halo_opacity_spinner.setEnabled(symbolizer_w.hasHalo()); halo_opacity_spinner.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent event) { style_change_listener.halo_opacity_changed(((Spinner) event.widget).getSelection() / 100.0); } }); if (symbolizer_w.hasHalo()) mod_halo_color_btn .setImage(ImageHelper.createColorRectImage(SLD.color(symbolizer_w.getHaloFill().getColor()))); else mod_halo_color_btn.setEnabled(false); mod_halo_color_btn.setText(""); mod_halo_color_btn.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ColorDialog dialog = new ColorDialog(new Shell(display)); dialog.setRGB(ColorHelper.Color2RGB(SLD.color(symbolizer_w.getHaloFill().getColor()))); RGB res = dialog.open(); mod_halo_color_btn.setImage(ImageHelper.createColorRectImage(res)); style_change_listener.halo_color_changed(res); } }); halo_radius_combo.setItems(halo_radius_combo_items); halo_radius_combo.setText("" + symbolizer_w.getFont().getSize()); //$NON-NLS-1$ halo_radius_combo.setEnabled(symbolizer_w.hasHalo()); halo_radius_combo.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent event) { // TODO Auto-generated method stub double val = Double.parseDouble(((Combo) event.widget).getText()); style_change_listener.halo_width_changed(val); } }); }
From source file:org.tinymediamanager.ui.settings.GeneralSettingsPanel.java
/** * Instantiates a new general settings panel. *//* w w w .j av a 2s . com*/ public GeneralSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("left:max(200px;min):grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(200px;default):grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelUI = new JPanel(); panelUI.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.ui"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelUI, "2, 2, 3, 1, fill, fill"); panelUI.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); LocaleComboBox actualLocale = null; // cbLanguage = new JComboBox(Utils.getLanguages().toArray()); Locale settingsLang = Utils.getLocaleFromLanguage(Globals.settings.getLanguage()); for (Locale l : Utils.getLanguages()) { LocaleComboBox localeComboBox = new LocaleComboBox(l); locales.add(localeComboBox); if (l.equals(settingsLang)) { actualLocale = localeComboBox; } } JLabel lblUiLanguage = new JLabel(BUNDLE.getString("Settings.language")); panelUI.add(lblUiLanguage, "2, 2"); cbLanguage = new JComboBox(locales.toArray()); panelUI.add(cbLanguage, "4, 2"); if (actualLocale != null) { cbLanguage.setSelectedItem(actualLocale); } JSeparator separator = new JSeparator(); separator.setOrientation(SwingConstants.VERTICAL); panelUI.add(separator, "8, 2, 1, 7"); JLabel lblFontFamily = new JLabel(BUNDLE.getString("Settings.fontfamily")); //$NON-NLS-1$ panelUI.add(lblFontFamily, "10, 2, right, default"); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); cbFontFamily = new JComboBox(env.getAvailableFontFamilyNames()); cbFontFamily.setSelectedItem(Globals.settings.getFontFamily()); int index = cbFontFamily.getSelectedIndex(); if (index < 0) { cbFontFamily.setSelectedItem("Dialog"); index = cbFontFamily.getSelectedIndex(); } if (index < 0) { cbFontFamily.setSelectedIndex(0); } panelUI.add(cbFontFamily, "12, 2, fill, default"); JLabel lblFontSize = new JLabel(BUNDLE.getString("Settings.fontsize")); //$NON-NLS-1$ panelUI.add(lblFontSize, "10, 4, right, default"); cbFontSize = new JComboBox(DEFAULT_FONT_SIZES); cbFontSize.setSelectedItem(Globals.settings.getFontSize()); index = cbFontSize.getSelectedIndex(); if (index < 0) { cbFontSize.setSelectedIndex(0); } panelUI.add(cbFontSize, "12, 4, fill, default"); JPanel panel = new JPanel(); panelUI.add(panel, "2, 6, 5, 1, fill, fill"); panel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JLabel lblMissingTranslation = new JLabel(BUNDLE.getString("tmm.helptranslate")); panel.add(lblMissingTranslation, "1, 1, 5, 1"); lblLinkTransifex = new LinkLabel("https://www.transifex.com/projects/p/tinymediamanager/"); panel.add(lblLinkTransifex, "1, 3, 5, 1"); lblLinkTransifex.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { TmmUIHelper.browseUrl(lblLinkTransifex.getNormalText()); } catch (Exception e) { LOGGER.error(e.getMessage()); MessageManager.instance .pushMessage(new Message(MessageLevel.ERROR, lblLinkTransifex.getNormalText(), "message.erroropenurl", new String[] { ":", e.getLocalizedMessage() }));//$NON-NLS-2$ } } }); tpFontHint = new JTextPane(); tpFontHint.setOpaque(false); TmmFontHelper.changeFont(tpFontHint, 0.833); tpFontHint.setText(BUNDLE.getString("Settings.fonts.hint")); //$NON-NLS-1$ panelUI.add(tpFontHint, "10, 6, 5, 1"); lblLanguageHint = new JLabel(""); TmmFontHelper.changeFont(lblLanguageHint, Font.BOLD); panelUI.add(lblLanguageHint, "2, 8, 5, 1"); lblFontChangeHint = new JLabel(""); TmmFontHelper.changeFont(lblFontChangeHint, Font.BOLD); panelUI.add(lblFontChangeHint, "10, 8, 5, 1"); JPanel panelMemory = new JPanel(); panelMemory.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.memoryborder"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMemory, "2, 4, fill, fill"); panelMemory.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow(4)"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(20dlu;default)"), ColumnSpec.decode("left:default:grow(5)"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblMemoryT = new JLabel(BUNDLE.getString("Settings.memory")); //$NON-NLS-1$ panelMemory.add(lblMemoryT, "2, 1"); sliderMemory = new JSlider(); sliderMemory.setPaintLabels(true); sliderMemory.setPaintTicks(true); sliderMemory.setSnapToTicks(true); sliderMemory.setMajorTickSpacing(512); sliderMemory.setMinorTickSpacing(128); sliderMemory.setMinimum(256); sliderMemory.setMaximum(1536); sliderMemory.setValue(512); panelMemory.add(sliderMemory, "4, 1, fill, default"); lblMemory = new JLabel("512"); //$NON-NLS-1$ panelMemory.add(lblMemory, "6, 1, right, default"); JLabel lblMb = new JLabel("MB"); panelMemory.add(lblMb, "7, 1, left, default"); tpMemoryHint = new JTextPane(); tpMemoryHint.setOpaque(false); tpMemoryHint.setText(BUNDLE.getString("Settings.memory.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(tpMemoryHint, 0.833); panelMemory.add(tpMemoryHint, "2, 3, 6, 1, fill, fill"); JPanel panelProxySettings = new JPanel(); panelProxySettings.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.proxy"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelProxySettings, "4, 4, fill, fill"); panelProxySettings.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new 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, })); JLabel lblProxyHost = new JLabel(BUNDLE.getString("Settings.proxyhost")); //$NON-NLS-1$ panelProxySettings.add(lblProxyHost, "2, 2, right, default"); tfProxyHost = new JTextField(); lblProxyHost.setLabelFor(tfProxyHost); panelProxySettings.add(tfProxyHost, "4, 2, fill, default"); tfProxyHost.setColumns(10); JLabel lblProxyPort = new JLabel(BUNDLE.getString("Settings.proxyport")); //$NON-NLS-1$ panelProxySettings.add(lblProxyPort, "2, 4, right, default"); tfProxyPort = new JTextField(); lblProxyPort.setLabelFor(tfProxyPort); panelProxySettings.add(tfProxyPort, "4, 4, fill, default"); tfProxyPort.setColumns(10); JLabel lblProxyUser = new JLabel(BUNDLE.getString("Settings.proxyuser")); //$NON-NLS-1$ panelProxySettings.add(lblProxyUser, "2, 6, right, default"); tfProxyUsername = new JTextField(); lblProxyUser.setLabelFor(tfProxyUsername); panelProxySettings.add(tfProxyUsername, "4, 6, fill, default"); tfProxyUsername.setColumns(10); JLabel lblProxyPassword = new JLabel(BUNDLE.getString("Settings.proxypass")); //$NON-NLS-1$ panelProxySettings.add(lblProxyPassword, "2, 8, right, default"); tfProxyPassword = new JPasswordField(); lblProxyPassword.setLabelFor(tfProxyPassword); panelProxySettings.add(tfProxyPassword, "4, 8, fill, default"); JPanel panelMediaPlayer = new JPanel(); panelMediaPlayer.setBorder( new TitledBorder(null, "MediaPlayer", TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMediaPlayer, "2, 6, fill, fill"); panelMediaPlayer.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); tpMediaPlayer = new JTextPane(); tpMediaPlayer.setOpaque(false); TmmFontHelper.changeFont(tpMediaPlayer, 0.833); tpMediaPlayer.setText(BUNDLE.getString("Settings.mediaplayer.hint")); //$NON-NLS-1$ panelMediaPlayer.add(tpMediaPlayer, "2, 2, 3, 1, fill, fill"); tfMediaPlayer = new JTextField(); panelMediaPlayer.add(tfMediaPlayer, "2, 4, fill, default"); tfMediaPlayer.setColumns(10); btnSearchMediaPlayer = new JButton(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$ btnSearchMediaPlayer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper.selectFile(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$ if (file != null && Utils.isRegularFile(file) || Platform.isMac()) { tfMediaPlayer.setText(file.toAbsolutePath().toString()); } } }); panelMediaPlayer.add(btnSearchMediaPlayer, "4, 4"); JPanel panelCache = new JPanel(); panelCache.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.cache"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelCache, "4, 6, fill, fill"); panelCache.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); chckbxImageCache = new JCheckBox(BUNDLE.getString("Settings.imagecache"));//$NON-NLS-1$ panelCache.add(chckbxImageCache, "2, 2, 3, 1"); JLabel lblImageCacheQuality = new JLabel(BUNDLE.getString("Settings.imagecachetype"));//$NON-NLS-1$ panelCache.add(lblImageCacheQuality, "2, 4, right, default"); cbImageCacheQuality = new JComboBox(ImageCache.CacheType.values()); panelCache.add(cbImageCacheQuality, "4, 4, fill, default"); JPanel panelAnalytics = new JPanel(); panelAnalytics.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.analytics.border"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelAnalytics, "2, 8, fill, fill"); panelAnalytics.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, })); chckbxAnalytics = new JCheckBox(BUNDLE.getString("Settings.analytics"));//$NON-NLS-1$ panelAnalytics.add(chckbxAnalytics, "2, 2"); JTextPane tpAnalyticsDescription = new JTextPane(); tpAnalyticsDescription.setText(BUNDLE.getString("Settings.analytics.desc"));//$NON-NLS-1$ tpAnalyticsDescription.setOpaque(false); panelAnalytics.add(tpAnalyticsDescription, "2, 4, fill, fill"); JPanel panelMisc = new JPanel(); panelMisc.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.misc"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelMisc, "4, 8, fill, fill"); panelMisc.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, })); chckbxDeleteTrash = new JCheckBox(BUNDLE.getString("Settings.deletetrash")); panelMisc.add(chckbxDeleteTrash, "2, 2, 3, 1"); initDataBindings(); initMemorySlider(); // listen to changes of the combo box ItemListener listener = new ItemListener() { public void itemStateChanged(ItemEvent e) { checkChanges(); } }; cbLanguage.addItemListener(listener); cbFontSize.addItemListener(listener); cbFontFamily.addItemListener(listener); }
From source file:spectrogram.Spectrogram.java
/** * Select a font that a) looks good and b) is available on this system (Macs were getting me) * @return name of the font/*www. j a va2 s. c om*/ */ private String getAGoodFont() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fontNames = ge.getAvailableFontFamilyNames(); String ret = ""; for (int idx = 0; idx < fontNames.length && ret.isEmpty(); idx++) { String font = fontNames[idx]; if (font.equalsIgnoreCase("DejaVu Sans")) { ret = fontNames[idx]; } } for (int idx = 0; idx < fontNames.length && ret.isEmpty(); idx++) { String font = fontNames[idx]; if (font.toLowerCase().contains("century schoolbook l")) { ret = fontNames[idx]; } } if (ret.isEmpty()) { ret = "Serif"; } return ret; }