List of usage examples for javax.swing JComponent getFont
@Transient
public Font getFont()
From source file:com.limegroup.gnutella.gui.LicenseWindow.java
protected void createValid() { GridBagConstraints c = new GridBagConstraints(); JComponent label = new JLabel(getDetailsString()); Font f = label.getFont(); label.setFont(new Font(f.getName(), Font.BOLD, f.getSize())); c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHWEST; DETAILS.add(label, c);/*from w ww.j a va 2 s . c o m*/ JTextArea text = newTextArea(LICENSE.getLicenseDescription(URN)); c.gridwidth = GridBagConstraints.RELATIVE; c.gridheight = 2; c.weighty = 1; c.weightx = .7; c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; DETAILS.add(text, c); if (LICENSE.getLicenseDeed(URN) != null) { label = new URLLabel(LICENSE.getLicenseDeed(URN), getDeedString()); } else { label = new JLabel(); label.setVisible(false); } c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = 1; c.weighty = 0; c.weightx = .3; c.anchor = GridBagConstraints.NORTHWEST; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(0, 0, 3, 0); DETAILS.add(label, c); label = new URLLabel(LICENSE.getLicenseURI(), getVerificationString()); DETAILS.add(label, c); }
From source file:net.pms.newgui.NetworkTab.java
public JComponent build() { FormLayout layout = new FormLayout("left:pref, 2dlu, p, 2dlu , p, 2dlu, p, 2dlu, pref:grow", "p, 0dlu, p, 0dlu, p, 3dlu, p, 3dlu, p, 3dlu,p, 3dlu, p, 15dlu, p, 3dlu,p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p,3dlu, p, 3dlu, p, 15dlu, p,3dlu, p, 3dlu, p, 15dlu, p, 3dlu, p"); PanelBuilder builder = new PanelBuilder(layout); builder.setBorder(Borders.DLU4_BORDER); builder.setOpaque(true);/*from w ww . ja va 2 s . c o m*/ CellConstraints cc = new CellConstraints(); smcheckBox = new JCheckBox(Messages.getString("NetworkTab.3")); smcheckBox.setContentAreaFilled(false); smcheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { PMS.getConfiguration().setMinimized((e.getStateChange() == ItemEvent.SELECTED)); } }); if (PMS.getConfiguration().isMinimized()) { smcheckBox.setSelected(true); } JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(1, 1, 9)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.addLabel(Messages.getString("NetworkTab.0"), cc.xy(1, 7)); final KeyedComboBoxModel kcbm = new KeyedComboBoxModel( new Object[] { "bg", "ca", "zhs", "zht", "cz", "da", "nl", "en", "fi", "fr", "de", "el", "is", "it", "ja", "no", "pl", "pt", "br", "ro", "ru", "sl", "es", "sv" }, new Object[] { "Bulgarian", "Catalan", "Chinese (Simplified)", "Chinese (Traditional)", "Czech", "Danish", "Dutch", "English", "Finnish", "French", "German", "Greek", "Icelandic", "Italian", "Japanese", "Norwegian", "Polish", "Portuguese", "Portuguese (Brazilian)", "Romanian", "Russian", "Slovenian", "Spanish", "Swedish" }); langs = new JComboBox(kcbm); langs.setEditable(false); //langs.setSelectedIndex(0); String defaultLang = null; if (configuration.getLanguage() != null && configuration.getLanguage().length() > 0) { defaultLang = configuration.getLanguage(); } else { defaultLang = Locale.getDefault().getLanguage(); } if (defaultLang == null) { defaultLang = "en"; } kcbm.setSelectedKey(defaultLang); if (langs.getSelectedIndex() == -1) { langs.setSelectedIndex(0); } langs.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { configuration.setLanguage((String) kcbm.getSelectedKey()); } } }); builder.add(langs, cc.xyw(3, 7, 7)); builder.add(smcheckBox, cc.xyw(1, 9, 9)); JButton service = new JButton(Messages.getString("NetworkTab.4")); service.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (PMS.get().installWin32Service()) { JOptionPane.showMessageDialog( (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())), Messages.getString("NetworkTab.11") + Messages.getString("NetworkTab.12"), "Information", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog( (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())), Messages.getString("NetworkTab.14"), "Error", JOptionPane.ERROR_MESSAGE); } } }); builder.add(service, cc.xy(1, 11)); if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) { service.setEnabled(false); } host = new JTextField(PMS.getConfiguration().getServerHostname()); host.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { configuration.setHostname(host.getText()); PMS.get().getFrame().setReloadable(true); } }); // host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ; port = new JTextField(configuration.getServerPort() != 5001 ? "" + configuration.getServerPort() : ""); port.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { try { String p = port.getText(); if (StringUtils.isEmpty(p)) { p = "5001"; } int ab = Integer.parseInt(p); configuration.setServerPort(ab); PMS.get().getFrame().setReloadable(true); } catch (NumberFormatException nfe) { } } }); cmp = builder.addSeparator(Messages.getString("NetworkTab.22"), cc.xyw(1, 21, 9)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); ArrayList<String> names = new ArrayList<String>(); names.add(""); ArrayList<String> interfaces = new ArrayList<String>(); interfaces.add(""); Enumeration<NetworkInterface> enm; try { enm = NetworkInterface.getNetworkInterfaces(); while (enm.hasMoreElements()) { NetworkInterface ni = enm.nextElement(); // check for interface has at least one ip address. if (ni.getInetAddresses().hasMoreElements()) { names.add(ni.getName()); String displayName = ni.getDisplayName(); if (displayName == null) { displayName = ni.getName(); } interfaces.add(displayName.trim()); } } } catch (SocketException e1) { logger.error(null, e1); } final KeyedComboBoxModel networkInterfaces = new KeyedComboBoxModel(names.toArray(), interfaces.toArray()); networkinterfacesCBX = new JComboBox(networkInterfaces); networkInterfaces.setSelectedKey(configuration.getNetworkInterface()); networkinterfacesCBX.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { configuration.setNetworkInterface((String) networkInterfaces.getSelectedKey()); //host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ; PMS.get().getFrame().setReloadable(true); } } }); ip_filter = new JTextField(PMS.getConfiguration().getIpFilter()); ip_filter.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { configuration.setIpFilter(ip_filter.getText()); PMS.get().getFrame().setReloadable(true); } }); builder.addLabel(Messages.getString("NetworkTab.20"), cc.xy(1, 23)); builder.add(networkinterfacesCBX, cc.xyw(3, 23, 7)); builder.addLabel(Messages.getString("NetworkTab.23"), cc.xy(1, 25)); builder.add(host, cc.xyw(3, 25, 7)); builder.addLabel(Messages.getString("NetworkTab.24"), cc.xy(1, 27)); builder.add(port, cc.xyw(3, 27, 7)); builder.addLabel(Messages.getString("NetworkTab.30"), cc.xy(1, 29)); builder.add(ip_filter, cc.xyw(3, 29, 7)); cmp = builder.addSeparator(Messages.getString("NetworkTab.31"), cc.xyw(1, 31, 9)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); newHTTPEngine = new JCheckBox(Messages.getString("NetworkTab.32")); newHTTPEngine.setSelected(PMS.getConfiguration().isHTTPEngineV2()); newHTTPEngine.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { PMS.getConfiguration().setHTTPEngineV2((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(newHTTPEngine, cc.xyw(1, 33, 9)); preventSleep = new JCheckBox(Messages.getString("NetworkTab.33")); preventSleep.setSelected(PMS.getConfiguration().isPreventsSleep()); preventSleep.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { PMS.getConfiguration().setPreventsSleep((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(preventSleep, cc.xyw(1, 35, 9)); cmp = builder.addSeparator(Messages.getString("NetworkTab.34"), cc.xyw(1, 37, 9)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); JPanel panel = builder.getPanel(); JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); return scrollPane; }
From source file:net.pms.encoders.AviSynthMEncoder.java
@Override public JComponent config() { FormLayout layout = new FormLayout("left:pref, 0:grow", "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 12dlu, p, 3dlu, 0:grow"); PanelBuilder builder = new PanelBuilder(layout); builder.border(Borders.EMPTY);//from www . j a va2 s . co m builder.opaque(false); CellConstraints cc = new CellConstraints(); JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(2, 1, 1)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); multithreading = new JCheckBox(Messages.getString("MEncoderVideo.35"), configuration.getAvisynthMultiThreading()); multithreading.setContentAreaFilled(false); multithreading.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setAvisynthMultiThreading((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(GuiUtil.getPreferredSizeComponent(multithreading), cc.xy(2, 3)); interframe = new JCheckBox(Messages.getString("AviSynthMEncoder.13"), configuration.getAvisynthInterFrame()); interframe.setContentAreaFilled(false); interframe.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { configuration.setAvisynthInterFrame(interframe.isSelected()); if (configuration.getAvisynthInterFrame()) { JOptionPane.showMessageDialog( SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame()), Messages.getString("AviSynthMEncoder.16"), Messages.getString("Dialog.Information"), JOptionPane.INFORMATION_MESSAGE); } } }); builder.add(GuiUtil.getPreferredSizeComponent(interframe), cc.xy(2, 5)); interframegpu = new JCheckBox(Messages.getString("AviSynthMEncoder.15"), configuration.getAvisynthInterFrameGPU()); interframegpu.setContentAreaFilled(false); interframegpu.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setAvisynthInterFrameGPU((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(GuiUtil.getPreferredSizeComponent(interframegpu), cc.xy(2, 7)); convertfps = new JCheckBox(Messages.getString("AviSynthMEncoder.3"), configuration.getAvisynthConvertFps()); convertfps.setContentAreaFilled(false); convertfps.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setAvisynthConvertFps((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(GuiUtil.getPreferredSizeComponent(convertfps), cc.xy(2, 9)); String aviSynthScriptInstructions = Messages.getString("AviSynthMEncoder.4") + Messages.getString("AviSynthMEncoder.5") + Messages.getString("AviSynthMEncoder.6") + Messages.getString("AviSynthMEncoder.7") + Messages.getString("AviSynthMEncoder.8"); JTextArea aviSynthScriptInstructionsContainer = new JTextArea(aviSynthScriptInstructions); aviSynthScriptInstructionsContainer.setEditable(false); aviSynthScriptInstructionsContainer.setBorder(BorderFactory.createEtchedBorder()); aviSynthScriptInstructionsContainer.setBackground(new Color(255, 255, 192)); aviSynthScriptInstructionsContainer.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(new Color(130, 135, 144)), BorderFactory.createEmptyBorder(3, 5, 3, 5))); builder.add(aviSynthScriptInstructionsContainer, cc.xy(2, 11)); String clip = configuration.getAvisynthScript(); if (clip == null) { clip = ""; } StringBuilder sb = new StringBuilder(); StringTokenizer st = new StringTokenizer(clip, PMS.AVS_SEPARATOR); int i = 0; while (st.hasMoreTokens()) { if (i > 0) { sb.append("\n"); } sb.append(st.nextToken()); i++; } textArea = new JTextArea(sb.toString()); textArea.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { StringBuilder sb = new StringBuilder(); StringTokenizer st = new StringTokenizer(textArea.getText(), "\n"); int i = 0; while (st.hasMoreTokens()) { if (i > 0) { sb.append(PMS.AVS_SEPARATOR); } sb.append(st.nextToken()); i++; } configuration.setAvisynthScript(sb.toString()); } }); JScrollPane pane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); pane.setPreferredSize(new Dimension(500, 350)); builder.add(pane, cc.xy(2, 13)); configuration.addConfigurationListener(new ConfigurationListener() { @Override public void configurationChanged(ConfigurationEvent event) { if (event.getPropertyName() == null) { return; } if ((!event.isBeforeUpdate()) && event.getPropertyName().equals(PmsConfiguration.KEY_GPU_ACCELERATION)) { interframegpu.setEnabled(configuration.isGPUAcceleration()); } } }); return builder.getPanel(); }
From source file:net.pms.newgui.StatusTab.java
public JComponent build() { // Apply the orientation for the locale ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale()); String colSpec = FormLayoutUtil.getColSpec("pref, 30dlu, fill:pref:grow, 30dlu, pref", orientation); // 1 2 3 4 5 FormLayout layout = new FormLayout(colSpec, // 1 2 3 4 5 // ////////////////////////////////////////////////// "p," // Detected Media Renderers --------------------// 1 + "9dlu," // // + "fill:p:grow," // <renderers> // 3 + "3dlu," // // + "p," // ---------------------------------------------// 5 + "3dlu," // | | // + "p," // Connected | Memory Usage |<bitrate> // 7 + "3dlu," // | | // + "p," // <icon> | <statusbar> | // 9 ////////////////////////////////////////////////// );/*from w ww.ja v a 2 s . c o m*/ PanelBuilder builder = new PanelBuilder(layout); builder.border(Borders.DIALOG); builder.opaque(true); CellConstraints cc = new CellConstraints(); // Renderers JComponent cmp = builder.addSeparator(Messages.getString("StatusTab.9"), FormLayoutUtil.flip(cc.xyw(1, 1, 5), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); Font bold = cmp.getFont().deriveFont(Font.BOLD); Color fgColor = new Color(68, 68, 68); cmp.setFont(bold); renderers = new JPanel(new GuiUtil.WrapLayout(FlowLayout.CENTER, 20, 10)); JScrollPane rsp = new JScrollPane(renderers, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); rsp.setBorder(BorderFactory.createEmptyBorder()); rsp.setPreferredSize(new Dimension(0, 260)); rsp.getHorizontalScrollBar().setLocation(0, 250); builder.add(rsp, cc.xyw(1, 3, 5)); cmp = builder.addSeparator(null, FormLayoutUtil.flip(cc.xyw(1, 5, 5), colSpec, orientation)); // Connected jl = new JLabel(Messages.getString("StatusTab.3")); builder.add(jl, FormLayoutUtil.flip(cc.xy(1, 7, "center, top"), colSpec, orientation)); jl.setFont(bold); jl.setForeground(fgColor); imagePanel = buildImagePanel("/resources/images/icon-status-connecting.png"); builder.add(imagePanel, FormLayoutUtil.flip(cc.xy(1, 9), colSpec, orientation)); // Memory memBarUI = new GuiUtil.SegmentedProgressBarUI(Color.white, Color.gray); memBarUI.setActiveLabel("{}", Color.white, 0); memBarUI.setActiveLabel("{}", Color.red, 90); memBarUI.addSegment("", memColor); memBarUI.addSegment("", bufColor); memBarUI.setTickMarks(getTickMarks(), "{}"); memoryProgressBar = new GuiUtil.CustomUIProgressBar(0, 100, memBarUI); memoryProgressBar.setStringPainted(true); memoryProgressBar.setForeground(new Color(75, 140, 181)); memoryProgressBar.setString(Messages.getString("StatusTab.5")); JLabel mem = builder .addLabel( "<html><b>" + Messages.getString("StatusTab.6") + "</b> (" + Messages.getString("StatusTab.12") + ")</html>", FormLayoutUtil.flip(cc.xy(3, 7), colSpec, orientation)); mem.setForeground(fgColor); builder.add(memoryProgressBar, FormLayoutUtil.flip(cc.xyw(3, 9, 1), colSpec, orientation)); // Bitrate String bitColSpec = "left:pref, 3dlu, right:pref:grow"; PanelBuilder bitrateBuilder = new PanelBuilder(new FormLayout(bitColSpec, "p, 1dlu, p, 1dlu, p")); bitrateLabel = new JLabel("<html><b>" + Messages.getString("StatusTab.13") + "</b> (" + Messages.getString("StatusTab.11") + ")</html>"); bitrateLabel.setForeground(fgColor); bitrateBuilder.add(bitrateLabel, FormLayoutUtil.flip(cc.xy(1, 1), bitColSpec, orientation)); currentBitrateLabel = new JLabel(Messages.getString("StatusTab.14")); currentBitrateLabel.setForeground(fgColor); bitrateBuilder.add(currentBitrateLabel, FormLayoutUtil.flip(cc.xy(1, 3), bitColSpec, orientation)); currentBitrate = new JLabel("0"); currentBitrate.setForeground(fgColor); bitrateBuilder.add(currentBitrate, FormLayoutUtil.flip(cc.xy(3, 3), bitColSpec, orientation)); peakBitrateLabel = new JLabel(Messages.getString("StatusTab.15")); peakBitrateLabel.setForeground(fgColor); bitrateBuilder.add(peakBitrateLabel, FormLayoutUtil.flip(cc.xy(1, 5), bitColSpec, orientation)); peakBitrate = new JLabel("0"); peakBitrate.setForeground(fgColor); bitrateBuilder.add(peakBitrate, FormLayoutUtil.flip(cc.xy(3, 5), bitColSpec, orientation)); builder.add(bitrateBuilder.getPanel(), FormLayoutUtil.flip(cc.xywh(5, 7, 1, 3, "left, top"), colSpec, orientation)); JPanel panel = builder.getPanel(); // Apply the orientation to the panel and all components in it panel.applyComponentOrientation(orientation); JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setBorder(BorderFactory.createEmptyBorder()); startMemoryUpdater(); return scrollPane; }
From source file:net.pms.newgui.GeneralTab.java
public JComponent build() { // Apply the orientation for the locale Locale locale = new Locale(configuration.getLanguage()); ComponentOrientation orientation = ComponentOrientation.getOrientation(locale); String colSpec = FormLayoutUtil.getColSpec(COL_SPEC, orientation); FormLayout layout = new FormLayout(colSpec, ROW_SPEC); PanelBuilder builder = new PanelBuilder(layout); builder.setBorder(Borders.DLU4_BORDER); builder.setOpaque(true);//from w w w . j a va2 s. co m CellConstraints cc = new CellConstraints(); smcheckBox = new JCheckBox(Messages.getString("NetworkTab.3")); smcheckBox.setContentAreaFilled(false); smcheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setMinimized((e.getStateChange() == ItemEvent.SELECTED)); } }); if (configuration.isMinimized()) { smcheckBox.setSelected(true); } JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), FormLayoutUtil.flip(cc.xyw(1, 1, 9), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.addLabel(Messages.getString("NetworkTab.0"), FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation)); final KeyedComboBoxModel kcbm = new KeyedComboBoxModel( new Object[] { "ar", "bg", "ca", "zhs", "zht", "cz", "da", "nl", "en", "fi", "fr", "de", "el", "iw", "is", "it", "ja", "ko", "no", "pl", "pt", "br", "ro", "ru", "sl", "es", "sv", "tr" }, new Object[] { "Arabic", "Bulgarian", "Catalan", "Chinese (Simplified)", "Chinese (Traditional)", "Czech", "Danish", "Dutch", "English", "Finnish", "French", "German", "Greek", "Hebrew", "Icelandic", "Italian", "Japanese", "Korean", "Norwegian", "Polish", "Portuguese", "Portuguese (Brazilian)", "Romanian", "Russian", "Slovenian", "Spanish", "Swedish", "Turkish" }); langs = new JComboBox(kcbm); langs.setEditable(false); String defaultLang = null; if (configuration.getLanguage() != null && configuration.getLanguage().length() > 0) { defaultLang = configuration.getLanguage(); } else { defaultLang = Locale.getDefault().getLanguage(); } if (defaultLang == null) { defaultLang = "en"; } kcbm.setSelectedKey(defaultLang); if (langs.getSelectedIndex() == -1) { langs.setSelectedIndex(0); } langs.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { configuration.setLanguage((String) kcbm.getSelectedKey()); } } }); builder.add(langs, FormLayoutUtil.flip(cc.xyw(3, 7, 7), colSpec, orientation)); builder.add(smcheckBox, FormLayoutUtil.flip(cc.xyw(1, 9, 9), colSpec, orientation)); JButton service = new JButton(Messages.getString("NetworkTab.4")); service.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (PMS.get().installWin32Service()) { JOptionPane.showMessageDialog( (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())), Messages.getString("NetworkTab.11") + Messages.getString("NetworkTab.12"), Messages.getString("Dialog.Information"), JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog( (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())), Messages.getString("NetworkTab.14"), Messages.getString("Dialog.Error"), JOptionPane.ERROR_MESSAGE); } } }); builder.add(service, FormLayoutUtil.flip(cc.xy(1, 11), colSpec, orientation)); if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) { service.setEnabled(false); } JButton checkForUpdates = new JButton(Messages.getString("NetworkTab.8")); checkForUpdates.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { LooksFrame frame = (LooksFrame) PMS.get().getFrame(); frame.checkForUpdates(); } }); builder.add(checkForUpdates, FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation)); autoUpdateCheckBox = new JCheckBox(Messages.getString("NetworkTab.9")); autoUpdateCheckBox.setContentAreaFilled(false); autoUpdateCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setAutoUpdate((e.getStateChange() == ItemEvent.SELECTED)); } }); if (configuration.isAutoUpdate()) { autoUpdateCheckBox.setSelected(true); } builder.add(autoUpdateCheckBox, FormLayoutUtil.flip(cc.xyw(7, 13, 3), colSpec, orientation)); if (!Build.isUpdatable()) { checkForUpdates.setEnabled(false); autoUpdateCheckBox.setEnabled(false); } host = new JTextField(configuration.getServerHostname()); host.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { configuration.setHostname(host.getText()); } }); port = new JTextField(configuration.getServerPort() != 5001 ? "" + configuration.getServerPort() : ""); port.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { try { String p = port.getText(); if (StringUtils.isEmpty(p)) { p = "5001"; } int ab = Integer.parseInt(p); configuration.setServerPort(ab); } catch (NumberFormatException nfe) { logger.debug("Could not parse port from \"" + port.getText() + "\""); } } }); cmp = builder.addSeparator(Messages.getString("NetworkTab.22"), FormLayoutUtil.flip(cc.xyw(1, 21, 9), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); final KeyedComboBoxModel networkInterfaces = createNetworkInterfacesModel(); networkinterfacesCBX = new JComboBox(networkInterfaces); networkInterfaces.setSelectedKey(configuration.getNetworkInterface()); networkinterfacesCBX.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { configuration.setNetworkInterface((String) networkInterfaces.getSelectedKey()); } } }); ip_filter = new JTextField(configuration.getIpFilter()); ip_filter.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { configuration.setIpFilter(ip_filter.getText()); } }); maxbitrate = new JTextField(configuration.getMaximumBitrate()); maxbitrate.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { PMS.getConfiguration().setMaximumBitrate(maxbitrate.getText()); } }); builder.addLabel(Messages.getString("NetworkTab.20"), FormLayoutUtil.flip(cc.xy(1, 23), colSpec, orientation)); builder.add(networkinterfacesCBX, FormLayoutUtil.flip(cc.xyw(3, 23, 7), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.23"), FormLayoutUtil.flip(cc.xy(1, 25), colSpec, orientation)); builder.add(host, FormLayoutUtil.flip(cc.xyw(3, 25, 7), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.24"), FormLayoutUtil.flip(cc.xy(1, 27), colSpec, orientation)); builder.add(port, FormLayoutUtil.flip(cc.xyw(3, 27, 7), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.30"), FormLayoutUtil.flip(cc.xy(1, 29), colSpec, orientation)); builder.add(ip_filter, FormLayoutUtil.flip(cc.xyw(3, 29, 7), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.35"), FormLayoutUtil.flip(cc.xy(1, 31), colSpec, orientation)); builder.add(maxbitrate, FormLayoutUtil.flip(cc.xyw(3, 31, 7), colSpec, orientation)); cmp = builder.addSeparator(Messages.getString("NetworkTab.31"), FormLayoutUtil.flip(cc.xyw(1, 33, 9), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); newHTTPEngine = new JCheckBox(Messages.getString("NetworkTab.32")); newHTTPEngine.setSelected(configuration.isHTTPEngineV2()); newHTTPEngine.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setHTTPEngineV2((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(newHTTPEngine, FormLayoutUtil.flip(cc.xyw(1, 35, 9), colSpec, orientation)); preventSleep = new JCheckBox(Messages.getString("NetworkTab.33")); preventSleep.setSelected(configuration.isPreventsSleep()); preventSleep.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setPreventsSleep((e.getStateChange() == ItemEvent.SELECTED)); } }); builder.add(preventSleep, FormLayoutUtil.flip(cc.xyw(1, 37, 9), colSpec, orientation)); JCheckBox fdCheckBox = new JCheckBox(Messages.getString("NetworkTab.38")); fdCheckBox.setContentAreaFilled(false); fdCheckBox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { configuration.setRendererForceDefault((e.getStateChange() == ItemEvent.SELECTED)); } }); if (configuration.isRendererForceDefault()) { fdCheckBox.setSelected(true); } builder.addLabel(Messages.getString("NetworkTab.36"), FormLayoutUtil.flip(cc.xy(1, 39), colSpec, orientation)); ArrayList<RendererConfiguration> allConfs = RendererConfiguration.getAllRendererConfigurations(); ArrayList<Object> keyValues = new ArrayList<Object>(); ArrayList<Object> nameValues = new ArrayList<Object>(); keyValues.add(""); nameValues.add(Messages.getString("NetworkTab.37")); if (allConfs != null) { for (RendererConfiguration renderer : allConfs) { if (renderer != null) { keyValues.add(renderer.getRendererName()); nameValues.add(renderer.getRendererName()); } } } final KeyedComboBoxModel renderersKcbm = new KeyedComboBoxModel( (Object[]) keyValues.toArray(new Object[keyValues.size()]), (Object[]) nameValues.toArray(new Object[nameValues.size()])); renderers = new JComboBox(renderersKcbm); renderers.setEditable(false); String defaultRenderer = configuration.getRendererDefault(); renderersKcbm.setSelectedKey(defaultRenderer); if (renderers.getSelectedIndex() == -1) { renderers.setSelectedIndex(0); } builder.add(renderers, FormLayoutUtil.flip(cc.xyw(3, 39, 7), colSpec, orientation)); builder.add(fdCheckBox, FormLayoutUtil.flip(cc.xyw(1, 41, 9), colSpec, orientation)); cmp = builder.addSeparator(Messages.getString("NetworkTab.34"), FormLayoutUtil.flip(cc.xyw(1, 43, 9), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); pPlugins = new JPanel(new GridLayout()); builder.add(pPlugins, FormLayoutUtil.flip(cc.xyw(1, 45, 9), colSpec, orientation)); JPanel panel = builder.getPanel(); // Apply the orientation to the panel and all components in it panel.applyComponentOrientation(orientation); JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); return scrollPane; }
From source file:net.pms.encoders.TsMuxeRVideo.java
@Override public JComponent config() { // Apply the orientation for the locale Locale locale = new Locale(configuration.getLanguage()); ComponentOrientation orientation = ComponentOrientation.getOrientation(locale); String colSpec = FormLayoutUtil.getColSpec(COL_SPEC, orientation); FormLayout layout = new FormLayout(colSpec, ROW_SPEC); PanelBuilder builder = new PanelBuilder(layout); builder.setBorder(Borders.EMPTY_BORDER); builder.setOpaque(false);/* www . j av a2 s. co m*/ CellConstraints cc = new CellConstraints(); JComponent cmp = builder.addSeparator(Messages.getString("TSMuxerVideo.3"), FormLayoutUtil.flip(cc.xyw(2, 1, 1), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); tsmuxerforcefps = new JCheckBox(Messages.getString("TSMuxerVideo.2")); tsmuxerforcefps.setContentAreaFilled(false); if (configuration.isTsmuxerForceFps()) { tsmuxerforcefps.setSelected(true); } tsmuxerforcefps.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setTsmuxerForceFps(e.getStateChange() == ItemEvent.SELECTED); } }); builder.add(tsmuxerforcefps, FormLayoutUtil.flip(cc.xy(2, 3), colSpec, orientation)); muxallaudiotracks = new JCheckBox(Messages.getString("TSMuxerVideo.19")); muxallaudiotracks.setContentAreaFilled(false); if (configuration.isMuxAllAudioTracks()) { muxallaudiotracks.setSelected(true); } muxallaudiotracks.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setMuxAllAudioTracks(e.getStateChange() == ItemEvent.SELECTED); } }); builder.add(muxallaudiotracks, FormLayoutUtil.flip(cc.xy(2, 5), colSpec, orientation)); JPanel panel = builder.getPanel(); // Apply the orientation to the panel and all components in it panel.applyComponentOrientation(orientation); return panel; }
From source file:net.pms.encoders.FFmpegVideo.java
protected JComponent config(String languageLabel) { FormLayout layout = new FormLayout("left:pref, 0:grow", "p, 3dlu, p, 3dlu, p, 3dlu, p"); PanelBuilder builder = new PanelBuilder(layout); builder.setBorder(Borders.EMPTY_BORDER); builder.setOpaque(false);//from w ww . j a va2 s . c om CellConstraints cc = new CellConstraints(); JComponent cmp = builder.addSeparator(Messages.getString(languageLabel), cc.xyw(2, 1, 1)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); multiThreadingCheckBox = new JCheckBox(Messages.getString("MEncoderVideo.35")); multiThreadingCheckBox.setContentAreaFilled(false); if (configuration.isFfmpegMultithreading()) { multiThreadingCheckBox.setSelected(true); } multiThreadingCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setFfmpegMultithreading(e.getStateChange() == ItemEvent.SELECTED); } }); builder.add(multiThreadingCheckBox, cc.xy(2, 3)); videoRemuxCheckBox = new JCheckBox(Messages.getString("FFmpeg.0")); videoRemuxCheckBox.setContentAreaFilled(false); if (configuration.isFFmpegMuxWhenCompatible()) { videoRemuxCheckBox.setSelected(true); } videoRemuxCheckBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setFFmpegMuxWhenCompatible(e.getStateChange() == ItemEvent.SELECTED); } }); builder.add(videoRemuxCheckBox, cc.xy(2, 5)); return builder.getPanel(); }
From source file:net.pms.newgui.NavigationShareTab.java
public JComponent build() { // Apply the orientation for the locale ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale()); String colSpec = FormLayoutUtil.getColSpec(PANEL_COL_SPEC, orientation); // Set basic layout FormLayout layout = new FormLayout(colSpec, PANEL_ROW_SPEC); PanelBuilder builder = new PanelBuilder(layout); builder.border(Borders.DLU4);/* w w w. j ava 2s . c o m*/ builder.opaque(true); CellConstraints cc = new CellConstraints(); // Init all gui components initSimpleComponents(cc); sharedPanel = initSharedFoldersGuiComponents(cc).build(); // Build gui with initialized components if (!configuration.isHideAdvancedOptions()) { JComponent cmp = builder.addSeparator(Messages.getString("FoldTab.13"), FormLayoutUtil.flip(cc.xyw(1, 1, 12), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.add(GuiUtil.getPreferredSizeComponent(thumbgenCheckBox), FormLayoutUtil.flip(cc.xyw(1, 3, 3), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.16"), FormLayoutUtil.flip(cc.xyw(4, 3, 2), colSpec, orientation)); builder.add(seekpos, FormLayoutUtil.flip(cc.xy(6, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(image_thumb), FormLayoutUtil.flip(cc.xyw(9, 3, 4), colSpec, orientation)); builder.addLabel(Messages.getString("FoldTab.26"), FormLayoutUtil.flip(cc.xyw(1, 5, 3), colSpec, orientation)); builder.add(audiothumbnail, FormLayoutUtil.flip(cc.xyw(4, 5, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(mplayer_thumb), FormLayoutUtil.flip(cc.xyw(9, 5, 4), colSpec, orientation)); builder.addLabel(Messages.getString("FoldTab.27"), FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation)); builder.add(defaultThumbFolder, FormLayoutUtil.flip(cc.xyw(4, 7, 2), colSpec, orientation)); builder.add(select, FormLayoutUtil.flip(cc.xy(6, 7), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(dvdiso_thumb), FormLayoutUtil.flip(cc.xyw(9, 7, 4), colSpec, orientation)); cmp = builder.addSeparator(Messages.getString("NetworkTab.59"), FormLayoutUtil.flip(cc.xyw(1, 9, 12), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.addLabel(Messages.getString("FoldTab.18"), FormLayoutUtil.flip(cc.xyw(1, 11, 3), colSpec, orientation)); builder.add(sortmethod, FormLayoutUtil.flip(cc.xyw(4, 11, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(ignorethewordthe), FormLayoutUtil.flip(cc.xyw(9, 11, 4), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(prettifyfilenames), FormLayoutUtil.flip(cc.xyw(1, 13, 5), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(episodeTitles), FormLayoutUtil.flip(cc.xyw(9, 13, 4), colSpec, orientation)); cmp = builder.addSeparator(Messages.getString("NetworkTab.60"), FormLayoutUtil.flip(cc.xyw(1, 15, 12), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.add(GuiUtil.getPreferredSizeComponent(hideextensions), FormLayoutUtil.flip(cc.xyw(1, 17, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(hideengines), FormLayoutUtil.flip(cc.xyw(4, 17, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(hideemptyfolders), FormLayoutUtil.flip(cc.xyw(9, 17, 4), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(itunes), FormLayoutUtil.flip(cc.xy(1, 19), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(iphoto), FormLayoutUtil.flip(cc.xyw(4, 19, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(aperture), FormLayoutUtil.flip(cc.xyw(9, 19, 4), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(cacheenable), FormLayoutUtil.flip(cc.xy(1, 21), colSpec, orientation)); builder.add(cachereset, FormLayoutUtil.flip(cc.xyw(4, 21, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(isShowFolderMediaLibrary), FormLayoutUtil.flip(cc.xyw(9, 21, 4), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(archive), FormLayoutUtil.flip(cc.xyw(1, 23, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(isShowFolderServerSettings), FormLayoutUtil.flip(cc.xyw(4, 23, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(isShowFolderTranscode), FormLayoutUtil.flip(cc.xyw(9, 23, 4), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(isShowFolderLiveSubtitles), FormLayoutUtil.flip(cc.xyw(1, 25, 3), colSpec, orientation)); builder.addLabel(Messages.getString("FoldTab.37"), FormLayoutUtil.flip(cc.xyw(4, 25, 2), colSpec, orientation)); builder.add(atzLimit, FormLayoutUtil.flip(cc.xy(6, 25), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(isShowFolderNewMedia), FormLayoutUtil.flip(cc.xyw(9, 25, 4), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(resume), FormLayoutUtil.flip(cc.xy(1, 27), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(isShowFolderRecentlyPlayed), FormLayoutUtil.flip(cc.xyw(9, 27, 4), colSpec, orientation)); builder.addLabel(Messages.getString("FoldTab.72"), FormLayoutUtil.flip(cc.xy(1, 29), colSpec, orientation)); builder.add(fullyPlayedAction, FormLayoutUtil.flip(cc.xyw(4, 29, 3), colSpec, orientation)); builder.add(fullyPlayedOutputDirectory, FormLayoutUtil.flip(cc.xyw(9, 29, 2), colSpec, orientation)); builder.add(selectFullyPlayedOutputDirectory, FormLayoutUtil.flip(cc.xyw(11, 29, 2), colSpec, orientation)); builder.add(sharedPanel, FormLayoutUtil.flip(cc.xyw(1, 31, 12), colSpec, orientation)); } else { builder.add(sharedPanel, FormLayoutUtil.flip(cc.xyw(1, 1, 12), colSpec, orientation)); } builder.add(sharedPanel, FormLayoutUtil.flip(cc.xyw(1, 31, 12), colSpec, orientation)); JPanel panel = builder.getPanel(); // Apply the orientation to the panel and all components in it panel.applyComponentOrientation(orientation); JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setBorder(BorderFactory.createEmptyBorder()); return scrollPane; }
From source file:net.pms.newgui.NavigationShareTab.java
private PanelBuilder initSharedFoldersGuiComponents(CellConstraints cc) { // Apply the orientation for the locale ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale()); String colSpec = FormLayoutUtil.getColSpec(SHARED_FOLDER_COL_SPEC, orientation); FormLayout layoutFolders = new FormLayout(colSpec, SHARED_FOLDER_ROW_SPEC); PanelBuilder builderFolder = new PanelBuilder(layoutFolders); builderFolder.opaque(true);/*from w w w.j a v a2 s .c o m*/ JComponent cmp = builderFolder.addSeparator(Messages.getString("FoldTab.7"), FormLayoutUtil.flip(cc.xyw(1, 1, 7), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); folderTableModel = new SharedFoldersTableModel(); sharedFolders = new JTable(folderTableModel); JPopupMenu popupMenu = new JPopupMenu(); JMenuItem menuItemMarkPlayed = new JMenuItem(Messages.getString("FoldTab.75")); JMenuItem menuItemMarkUnplayed = new JMenuItem(Messages.getString("FoldTab.76")); menuItemMarkPlayed.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String path = (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0); TableFilesStatus.setDirectoryFullyPlayed(path, true); } }); menuItemMarkUnplayed.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String path = (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0); TableFilesStatus.setDirectoryFullyPlayed(path, false); } }); popupMenu.add(menuItemMarkPlayed); popupMenu.add(menuItemMarkUnplayed); sharedFolders.setComponentPopupMenu(popupMenu); /* An attempt to set the correct row height adjusted for font scaling. * It sets all rows based on the font size of cell (0, 0). The + 4 is * to allow 2 pixels above and below the text. */ DefaultTableCellRenderer cellRenderer = (DefaultTableCellRenderer) sharedFolders.getCellRenderer(0, 0); FontMetrics metrics = cellRenderer.getFontMetrics(cellRenderer.getFont()); sharedFolders.setRowHeight(metrics.getLeading() + metrics.getMaxAscent() + metrics.getMaxDescent() + 4); sharedFolders.setIntercellSpacing(new Dimension(8, 2)); final JPanel tmpsharedPanel = sharedPanel; addButton.setToolTipText(Messages.getString("FoldTab.9")); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser chooser; try { chooser = new JFileChooser(); } catch (Exception ee) { chooser = new JFileChooser(new RestrictedFileSystemView()); } chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = chooser.showOpenDialog((Component) e.getSource()); if (returnVal == JFileChooser.APPROVE_OPTION) { int firstSelectedRow = sharedFolders.getSelectedRow(); if (firstSelectedRow >= 0) { ((SharedFoldersTableModel) sharedFolders.getModel()).insertRow(firstSelectedRow, new Object[] { chooser.getSelectedFile().getAbsolutePath(), true }); } else { ((SharedFoldersTableModel) sharedFolders.getModel()) .addRow(new Object[] { chooser.getSelectedFile().getAbsolutePath(), true }); } } } }); builderFolder.add(addButton, FormLayoutUtil.flip(cc.xy(2, 3), colSpec, orientation)); removeButton.setToolTipText(Messages.getString("FoldTab.36")); removeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int[] rows = sharedFolders.getSelectedRows(); if (rows.length > 0) { if (rows.length > 1) { if (JOptionPane.showConfirmDialog(tmpsharedPanel, String.format(Messages.getString("SharedFolders.ConfirmRemove"), rows.length), Messages.getString("Dialog.Confirm"), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) { return; } } for (int i = rows.length - 1; i >= 0; i--) { PMS.get().getDatabase().removeMediaEntriesInFolder( (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0)); ((SharedFoldersTableModel) sharedFolders.getModel()).removeRow(rows[i]); } } } }); builderFolder.add(removeButton, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation)); arrowDownButton.setToolTipText(Messages.getString("SharedFolders.ArrowDown")); arrowDownButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (int i = 0; i < sharedFolders.getRowCount() - 1; i++) { if (sharedFolders.isRowSelected(i)) { Object value1 = sharedFolders.getValueAt(i, 0); boolean value2 = (boolean) sharedFolders.getValueAt(i, 1); sharedFolders.setValueAt(sharedFolders.getValueAt(i + 1, 0), i, 0); sharedFolders.setValueAt(value1, i + 1, 0); sharedFolders.setValueAt(sharedFolders.getValueAt(i + 1, 1), i, 1); sharedFolders.setValueAt(value2, i + 1, 1); sharedFolders.changeSelection(i + 1, 1, false, false); break; } } } }); builderFolder.add(arrowDownButton, FormLayoutUtil.flip(cc.xy(4, 3), colSpec, orientation)); arrowUpButton.setToolTipText(Messages.getString("SharedFolders.ArrowUp")); arrowUpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (int i = 1; i < sharedFolders.getRowCount(); i++) { if (sharedFolders.isRowSelected(i)) { Object value1 = sharedFolders.getValueAt(i, 0); boolean value2 = (boolean) sharedFolders.getValueAt(i, 1); sharedFolders.setValueAt(sharedFolders.getValueAt(i - 1, 0), i, 0); sharedFolders.setValueAt(value1, i - 1, 0); sharedFolders.setValueAt(sharedFolders.getValueAt(i - 1, 1), i, 1); sharedFolders.setValueAt(value2, i - 1, 1); sharedFolders.changeSelection(i - 1, 1, false, false); break; } } } }); builderFolder.add(arrowUpButton, FormLayoutUtil.flip(cc.xy(5, 3), colSpec, orientation)); scanButton.setToolTipText(Messages.getString("FoldTab.2")); scanBusyIcon.start(); scanBusyDisabledIcon.start(); scanButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (configuration.getUseCache()) { DLNAMediaDatabase database = PMS.get().getDatabase(); if (database != null) { if (database.isScanLibraryRunning()) { int option = JOptionPane.showConfirmDialog(looksFrame, Messages.getString("FoldTab.10"), Messages.getString("Dialog.Question"), JOptionPane.YES_NO_OPTION); if (option == JOptionPane.YES_OPTION) { database.stopScanLibrary(); looksFrame.setStatusLine(Messages.getString("FoldTab.41")); scanButton.setEnabled(false); scanButton.setToolTipText(Messages.getString("FoldTab.41")); } } else { database.scanLibrary(); scanButton.setIcon(scanBusyIcon); scanButton.setRolloverIcon(scanBusyRolloverIcon); scanButton.setPressedIcon(scanBusyPressedIcon); scanButton.setDisabledIcon(scanBusyDisabledIcon); scanButton.setToolTipText(Messages.getString("FoldTab.40")); } } } } }); /* * Hide the scan button in basic mode since it's better to let it be done in * realtime. */ if (!configuration.isHideAdvancedOptions()) { builderFolder.add(scanButton, FormLayoutUtil.flip(cc.xy(6, 3), colSpec, orientation)); } scanButton.setEnabled(configuration.getUseCache()); isScanSharedFoldersOnStartup = new JCheckBox(Messages.getString("NetworkTab.StartupScan"), configuration.isScanSharedFoldersOnStartup()); isScanSharedFoldersOnStartup.setToolTipText(Messages.getString("NetworkTab.StartupScanTooltip")); isScanSharedFoldersOnStartup.setContentAreaFilled(false); isScanSharedFoldersOnStartup.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { configuration.setScanSharedFoldersOnStartup((e.getStateChange() == ItemEvent.SELECTED)); } }); builderFolder.add(isScanSharedFoldersOnStartup, FormLayoutUtil.flip(cc.xy(7, 3), colSpec, orientation)); updateSharedFolders(); JScrollPane pane = new JScrollPane(sharedFolders); Dimension d = sharedFolders.getPreferredSize(); pane.setPreferredSize(new Dimension(d.width, sharedFolders.getRowHeight() * 2)); builderFolder.add(pane, FormLayoutUtil.flip(cc.xyw(1, 5, 7, CellConstraints.DEFAULT, CellConstraints.FILL), colSpec, orientation)); return builderFolder; }
From source file:org.mwc.cmap.xyplot.views.XYPlotView.java
protected void bitmapToClipBoard(JComponent component) { Point size = _plotControl.getSize(); final BufferedImage img = new BufferedImage(size.x, size.y, BufferedImage.TYPE_INT_ARGB); Graphics g = img.getGraphics(); g.setColor(component.getForeground()); g.setFont(component.getFont()); component.setSize(size.x, size.y);//from w w w . j a v a 2 s . c om component.paint(g); Transferable t = new Transferable() { public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[] { DataFlavor.imageFlavor }; } public boolean isDataFlavorSupported(DataFlavor flavor) { if (flavor == DataFlavor.imageFlavor) return true; return false; } public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { if (isDataFlavorSupported(flavor)) { return img; } return null; } }; ClipboardOwner co = new ClipboardOwner() { public void lostOwnership(java.awt.datatransfer.Clipboard clipboard, Transferable contents) { } }; java.awt.datatransfer.Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard(); cb.setContents(t, co); }