List of usage examples for java.awt Font getSize
public int getSize()
From source file:org.tinymediamanager.ui.movies.settings.MovieTrailerSettingsPanel.java
public MovieTrailerSettingsPanel() { // data init/*from ww w . j ava 2s . c o m*/ List<String> enabledTrailerProviders = settings.getMovieTrailerScrapers(); int selectedIndex = -1; int counter = 0; for (MediaScraper scraper : MovieList.getInstance().getAvailableTrailerScrapers()) { TrailerScraper trailerScraper = new TrailerScraper(scraper); if (enabledTrailerProviders.contains(trailerScraper.getScraperId())) { trailerScraper.active = true; if (selectedIndex < 0) { selectedIndex = counter; } } scrapers.add(trailerScraper); counter++; } // UI init setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelTrailerScrapers = new JPanel(); panelTrailerScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.trailer"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$ add(panelTrailerScrapers, "2, 2, fill, fill"); panelTrailerScrapers.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); final JScrollPane scrollPaneScraperDetails = new JScrollPane(); scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPaneScraperDetails.setBorder(null); panelTrailerScrapers.add(scrollPaneScraperDetails, "8, 1, 1, 2, fill, fill"); JPanel panelScraperDetails = new JPanel(); scrollPaneScraperDetails.setViewportView(panelScraperDetails); panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default:grow"), }, new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); { // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }"; tpScraperDescription = new JTextPane(); tpScraperDescription.setOpaque(false); tpScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top"); } panelScraperOptions = new ScrollablePanel(); panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top"); JScrollPane scrollPaneScraper = new JScrollPane(); panelTrailerScrapers.add(scrollPaneScraper, "2, 2, 5, 1, fill, fill"); tableTrailerScraper = new JTable(); tableTrailerScraper.setRowHeight(29); scrollPaneScraper.setViewportView(tableTrailerScraper); JSeparator separator = new JSeparator(); panelTrailerScrapers.add(separator, "2, 4, 7, 1"); checkBox = new JCheckBox(BUNDLE.getString("Settings.trailer.preferred")); //$NON-NLS-1$ panelTrailerScrapers.add(checkBox, "2, 6, 7, 1"); JLabel lblTrailerSource = new JLabel(BUNDLE.getString("Settings.trailer.source")); //$NON-NLS-1$ panelTrailerScrapers.add(lblTrailerSource, "4, 8, right, default"); cbTrailerSource = new JComboBox<>(); cbTrailerSource.setModel(new DefaultComboBoxModel<>(MovieTrailerSources.values())); panelTrailerScrapers.add(cbTrailerSource, "6, 8, fill, default"); JLabel lblTrailerQuality = new JLabel(BUNDLE.getString("Settings.trailer.quality")); //$NON-NLS-1$ panelTrailerScrapers.add(lblTrailerQuality, "4, 10, right, default"); cbTrailerQuality = new JComboBox<>(); cbTrailerQuality.setModel(new DefaultComboBoxModel<>(MovieTrailerQuality.values())); panelTrailerScrapers.add(cbTrailerQuality, "6, 10, fill, default"); chckbxAutomaticTrailerDownload = new JCheckBox(BUNDLE.getString("Settings.trailer.automaticdownload")); //$NON-NLS-1$ panelTrailerScrapers.add(chckbxAutomaticTrailerDownload, "2, 12, 7, 1"); JLabel lblAutomaticTrailerDownloadHint = new JLabel( BUNDLE.getString("Settings.trailer.automaticdownload.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(lblAutomaticTrailerDownloadHint, 0.833); panelTrailerScrapers.add(lblAutomaticTrailerDownloadHint, "4, 14, 5, 1"); initDataBindings(); // adjust table columns // Checkbox and Logo shall have minimal width TableColumnResizer.setMaxWidthForColumn(tableTrailerScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableTrailerScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableTrailerScraper, 5); tableTrailerScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); TrailerScraper changedScraper = scrapers.get(row); if (changedScraper.active) { settings.addMovieTrailerScraper(changedScraper.getScraperId()); } else { settings.removeMovieTrailerScraper(changedScraper.getScraperId()); } } } }); // implement selection listener to load settings tableTrailerScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableTrailerScraper.convertRowIndexToModel(tableTrailerScraper.getSelectedRow()); if (index > -1) { panelScraperOptions.removeAll(); if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) { panelScraperOptions .add(new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider())); } panelScraperOptions.revalidate(); } } }); // select default movie scraper if (selectedIndex < 0) { selectedIndex = 0; } if (counter > 0) { tableTrailerScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } }
From source file:savant.plugin.Tool.java
@Override public void init(JPanel panel) { mainPanel = panel;/*from w w w .j a va2 s . c om*/ panel.setLayout(new CardLayout()); JPanel settingsPanel = new ToolSettingsPanel(this); panel.add(new JScrollPane(settingsPanel), "Settings"); JPanel waitCard = new JPanel(); waitCard.setLayout(new GridBagLayout()); // Left side filler. GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(5, 100, 0, 100); waitCard.add(new JLabel(getDescriptor().getName()), gbc); progressBar = new JProgressBar(); progressBar.setPreferredSize(new Dimension(240, progressBar.getPreferredSize().height)); waitCard.add(progressBar, gbc); progressInfo = new JLabel(); progressInfo.setAlignmentX(1.0f); Font f = progressInfo.getFont(); f = f.deriveFont(f.getSize() - 2.0f); progressInfo.setFont(f); waitCard.add(progressInfo, gbc); cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (toolProc != null) { Process p = toolProc; toolProc = null; p.destroy(); } showCard("Settings"); } }); gbc.fill = GridBagConstraints.NONE; waitCard.add(cancelButton, gbc); // Console output at the bottom. console = new JTextArea(); console.setFont(f); console.setLineWrap(false); console.setEditable(false); JScrollPane consolePane = new JScrollPane(console); consolePane.setPreferredSize(new Dimension(800, 200)); gbc.weighty = 1.0; gbc.insets = new Insets(30, 5, 5, 5); gbc.fill = GridBagConstraints.BOTH; waitCard.add(consolePane, gbc); panel.add(waitCard, "Progress"); }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.legend.SmartLegendTitle.java
private Block createFlankedShapeLegendItem(FlankedShapeLegendItem item) { BlockContainer result = null;/* w w w.ja v a 2 s . c om*/ LegendGraphic lg = new CustomLegendGraphic(item.getShape(), item.getFillPaint()); lg.setFillPaintTransformer(item.getFillPaintTransformer()); lg.setShapeFilled(item.isShapeFilled()); lg.setLine(item.getLine()); lg.setLineStroke(item.getLineStroke()); lg.setLinePaint(item.getLinePaint()); lg.setLineVisible(item.isLineVisible()); lg.setShapeVisible(item.isShapeVisible()); lg.setShapeOutlineVisible(item.isShapeOutlineVisible()); lg.setOutlinePaint(item.getOutlinePaint()); lg.setOutlineStroke(item.getOutlineStroke()); lg.setPadding(this.getLegendItemGraphicPadding()); LegendItemBlockContainer legendItem = new LegendItemBlockContainer(new BorderArrangement(), item.getDataset(), item.getSeriesKey()); Font textFont = item.getLabelFont(); if (textFont == null) { textFont = getItemFont(); } Paint textPaint = item.getLabelPaint(); if (textPaint == null) { textPaint = getItemPaint(); } ColoredBlockContainer graphicsContainer = new ColoredBlockContainer(new Color(0, 0, 0, 0), new BorderArrangement()); LabelBlock labelBlock; Font smallerTextFont = textFont.deriveFont(textFont.getSize() * .8f); Font labelTextFont = textFont; labelBlock = new LabelBlock(item.getLeftShapeLabel(), smallerTextFont, textPaint); graphicsContainer.add(labelBlock, RectangleEdge.LEFT); graphicsContainer.add(lg, null); labelBlock = new LabelBlock(item.getRightShapeLabel(), smallerTextFont, textPaint); graphicsContainer.add(labelBlock, RectangleEdge.RIGHT); legendItem.add(graphicsContainer, getLegendItemGraphicEdge()); labelBlock = new LabelBlock(item.getLabel(), labelTextFont, textPaint); labelBlock.setPadding(getItemLabelPadding()); legendItem.add(labelBlock); legendItem.setToolTipText(item.getToolTipText()); legendItem.setURLText(item.getURLText()); result = new BlockContainer(new CenterArrangement()); result.add(legendItem); return result; }
From source file:burp.BurpExtender.java
private void createTitle(String text, Container cont) { JLabel title = new JLabel(text); title.setForeground(new Color(229, 137, 0)); Font f = title.getFont(); title.setFont(new Font(f.getName(), Font.BOLD, f.getSize() + 2)); callbacks.customizeUiComponent(title); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 0;// ww w .j a v a 2 s.c o m gbc.gridx = 0; gbc.insets = new Insets(8, 10, 0, 0); gbc.anchor = GridBagConstraints.WEST; cont.add(title, gbc); }
From source file:edu.ku.brc.specify.plugins.TaxonLabelFormatting.java
@Override public void initialize(Properties propertiesArg, boolean isViewModeArg) { super.initialize(propertiesArg, isViewModeArg); String plName = "TaxonLabelFormatter"; PickListDBAdapterIFace adapter = PickListDBAdapterFactory.getInstance().create(plName, false); if (adapter == null || adapter.getPickList() == null) { throw new RuntimeException("PickList Adapter [" + plName + "] cannot be null!"); }//from www. j a v a 2 s .c o m formatCBX = new ValComboBox(adapter); formatCBX.getComboBox().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doFormatting(); } }); formatCBX.getComboBox().addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { doFormatting(); } }); newAgentBtn = createButton(""); // Label set when new Resource Bundle is installed (below) searchPanel = new DBObjSearchPanel("Search", "AgentNameSearch", "AgentNameSearch", "edu.ku.brc.specify.datamodel.Agent", "agentId", SwingConstants.BOTTOM); searchPanel.getScrollPane().setMinimumSize(new Dimension(100, 200)); searchPanel.getScrollPane().setPreferredSize(new Dimension(100, 150)); ((FormViewObj) searchPanel.getForm()).getPanel().setBorder(null); try { UIRegistry.loadAndPushResourceBundle("specify_plugins"); newAgentBtn.setText(getResourceString("NewAgent")); authorsList = new JList(new DefaultListModel()); authorsList.setVisibleRowCount(10); authorsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { Object selObj = authorsList.getSelectedValue(); if (selObj != null) { } updateEnabledState(); } } }); JScrollPane scrollPane = new JScrollPane(authorsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); mapToBtn = createIconBtn("Map", "ADD_AUTHOR_NAME_TT", new ActionListener() { public void actionPerformed(ActionEvent ae) { Object agent = searchPanel.getSelectedObject(); ((DefaultListModel) authorsList.getModel()).addElement(agent); doFormatting(); } }); unmapBtn = createIconBtn("Unmap", "REMOVE_AUTHOR_NAME_TT", new ActionListener() { public void actionPerformed(ActionEvent ae) { int index = authorsList.getSelectedIndex(); if (index > -1) { DefaultListModel model = (DefaultListModel) authorsList.getModel(); model.remove(index); updateEnabledState(); doFormatting(); } } }); upBtn = createIconBtn("ReorderUp", "MOVE_AUTHOR_NAME_UP", new ActionListener() { public void actionPerformed(ActionEvent ae) { DefaultListModel model = (DefaultListModel) authorsList.getModel(); int index = authorsList.getSelectedIndex(); Object item = authorsList.getSelectedValue(); model.remove(index); model.insertElementAt(item, index - 1); authorsList.setSelectedIndex(index - 1); updateEnabledState(); } }); downBtn = createIconBtn("ReorderDown", "MOVE_AUTHOR_NAME_DOWN", new ActionListener() { public void actionPerformed(ActionEvent ae) { DefaultListModel model = (DefaultListModel) authorsList.getModel(); int index = authorsList.getSelectedIndex(); Object item = authorsList.getSelectedValue(); model.remove(index); model.insertElementAt(item, index + 1); authorsList.setSelectedIndex(index + 1); updateEnabledState(); } }); PanelBuilder bldr = new PanelBuilder(new FormLayout("p, 5px, p, 5px, f:p:g, 2px, p", "p, 4px, p, 2px, f:p:g, 4px, p, 4px, p, 2px, p, 2px, p, 2px, p"), this); CellConstraints cc = new CellConstraints(); PanelBuilder upDownPanel = new PanelBuilder(new FormLayout("p", "p, 2px, p, f:p:g")); upDownPanel.add(upBtn, cc.xy(1, 1)); upDownPanel.add(downBtn, cc.xy(1, 3)); PanelBuilder middlePanel = new PanelBuilder(new FormLayout("c:p:g", "f:p:g, p, 2px, p, f:p:g")); middlePanel.add(mapToBtn, cc.xy(1, 2)); middlePanel.add(unmapBtn, cc.xy(1, 4)); PanelBuilder rwPanel = new PanelBuilder(new FormLayout("p, 2px, f:p:g", "p")); refWorkLabel = createLabel(getResourceString("NONE")); rwPanel.add(createI18NFormLabel("REFERENCEWORK"), cc.xy(1, 1)); rwPanel.add(refWorkLabel, cc.xy(3, 1)); int y = 1; bldr.add(rwPanel.getPanel(), cc.xywh(1, y, 7, 1)); y += 2; bldr.add(searchPanel, cc.xywh(1, y, 1, 3)); bldr.addSeparator(getResourceString("Authors"), cc.xy(5, y)); y += 2; bldr.add(middlePanel.getPanel(), cc.xy(3, y)); bldr.add(scrollPane, cc.xywh(5, y, 1, 3)); bldr.add(upDownPanel.getPanel(), cc.xy(7, y)); y += 2; PanelBuilder newAgentPanel = new PanelBuilder(new FormLayout("f:p:g,p", "p")); newAgentPanel.add(newAgentBtn, cc.xy(2, 1)); bldr.add(newAgentPanel.getPanel(), cc.xy(1, y)); y += 2; JLabel fmtLabel = createLabel(getResourceString("LABELFORMAT")); bldr.add(fmtLabel, cc.xy(1, y)); y += 2; bldr.add(formatCBX, cc.xywh(1, y, 7, 1)); y += 2; Font plain = fmtLabel.getFont(); specialLabel = new SpecialLabel(plain, new Font(plain.getName(), Font.ITALIC, plain.getSize())); specialLabel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); bldr.add(createLabel(getResourceString("SAMPLEOUTPUT") + ":"), cc.xywh(1, y, 7, 1)); y += 2; bldr.add(specialLabel, cc.xywh(1, y, 7, 1)); searchPanel.setOKBtn(mapToBtn); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaxonLabelFormatting.class, ex); log.error(ex); ex.printStackTrace(); } UIRegistry.popResourceBundle(); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.BarLineChartExpression.java
private String convertFontToString(final Font font) { if (font == null) { return null; }/* w ww.ja v a 2 s. c o m*/ final String fontName = font.getFamily(); final int fontSize = font.getSize(); final int fontStyle = font.getStyle(); final String fontStyleText; if ((fontStyle & (Font.BOLD | Font.ITALIC)) == (Font.BOLD | Font.ITALIC)) { fontStyleText = "BOLDITALIC"; } else if ((fontStyle & Font.BOLD) == Font.BOLD) { fontStyleText = "BOLD"; } else if ((fontStyle & Font.ITALIC) == Font.ITALIC) { fontStyleText = "ITALIC"; } else { fontStyleText = "PLAIN"; } return (fontName + "-" + fontStyleText + "-" + fontSize); }
From source file:net.landora.video.infopanel.VideoInfoPanel.java
@Override public void loadContext(MultiValueMap context) { Collection col = context.getCollection(VideoMetadata.class); VideoMetadata md = (VideoMetadata) UIUtils.select(col); byte[] data = md.getPosterImage(); if (data == null) { lblPicture.setIcon(null);//from w w w. j av a 2 s . c om } else { try { Image img = ImageIO.read(new ByteArrayInputStream(data)); lblPicture.setIcon(new ImageIcon(img)); } catch (IOException ex) { lblPicture.setIcon(null); LoggerFactory.getLogger(getClass()).warn("Error loading image.", ex); } } Map<String, String> values = md.getAllInformation(false); StringBuilder buffer = new StringBuilder(); buffer.append("<html>"); Font font = lblPicture.getFont(); buffer.append("<head>"); buffer.append("<style type=\"text/css\">"); buffer.append(" { margin-top: 0px; margin-bottom: 0px; margin-right: 0px; margin-left: 0px; }"); buffer.append("table { border-collapse:collapse; }"); buffer.append(" td { "); buffer.append(" font-family: \""); buffer.append(font.getFamily()); buffer.append("\"; font-size: "); buffer.append(font.getSize() - 2); buffer.append("px; "); buffer.append(" }\n"); buffer.append(" td.label { "); buffer.append("text-align: right; "); buffer.append("font-weight:bold; "); buffer.append("white-space:nowrap; "); buffer.append(" font-family: \""); buffer.append(font.getFamily()); buffer.append("\"; font-size: "); buffer.append(font.getSize() - 2); buffer.append("px; "); buffer.append("} "); buffer.append("</style>"); buffer.append("</head>"); buffer.append("<body>"); buffer.append("<table>"); boolean first = true; for (Map.Entry<String, String> entry : values.entrySet()) { buffer.append("<tr><td class=\"label\">"); buffer.append(StringEscapeUtils.escapeHtml(entry.getKey())); buffer.append("</td><td>"); buffer.append(StringEscapeUtils.escapeHtml(entry.getValue())); buffer.append("</td></tr>"); } buffer.append("</table>"); buffer.append("</body>"); buffer.append("</html>"); txtInfo.setContentType("text/html"); txtInfo.setText(buffer.toString()); }
From source file:FontChooser.java
public void setFont(Font font) throws IllegalArgumentException { if (font == null) { throw new IllegalArgumentException("Null Font passed"); }/*from w w w.j a v a 2 s . c o m*/ _familyName = font.getFamily(); _isBold = font.isBold(); _isItalic = font.isItalic(); _size = font.getSize(); }
From source file:org.tellervo.desktop.prefs.Prefs.java
/** * Code a font into a string//from w ww.j a v a 2 s . c o m * * @param f * @return */ public static final String stringifyFont(Font f) { StringBuffer sb = new StringBuffer(); sb.append(f.getFontName()); sb.append('-'); int s = sb.length(); if ((f.getStyle() & Font.BOLD) != 0) { sb.append("BOLD"); } if ((f.getStyle() & Font.ITALIC) != 0) { sb.append("ITALIC"); } if (sb.length() > s) { sb.append('-'); } sb.append(f.getSize()); return sb.toString(); }
From source file:tvbrowser.ui.filter.dlgs.EditFilterDlg.java
public EditFilterDlg(JFrame parent, FilterList filterList, UserFilter filter) { super(parent, true); UiUtilities.registerForClosing(this); mFilterList = filterList;/*from w w w .j av a 2 s . co m*/ mParent = parent; mFilter = filter; JPanel contentPane = (JPanel) getContentPane(); contentPane.setLayout(new BorderLayout(7, 7)); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); if (filter == null) { setTitle(mLocalizer.msg("titleNew", "Create filter")); } else { setTitle(mLocalizer.msg("titleEdit", "Edit filter {0}", filter.toString())); mFilterName = filter.toString(); } JPanel northPanel = new JPanel(); northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS)); mFilterNameTF = new JTextField(new PlainDocument() { public void insertString(int offset, String str, AttributeSet a) throws BadLocationException { str = str.replaceAll("[\\p{Punct}&&[^_]]", "_"); super.insertString(offset, str, a); } }, "", 30); mFilterNameTF.getDocument().addDocumentListener(this); JPanel panel = new JPanel(new BorderLayout(7, 7)); panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 7, 0)); panel.add(new JLabel(mLocalizer.msg("filterName", "Filter name:")), BorderLayout.WEST); JPanel panel1 = new JPanel(new BorderLayout()); panel1.add(mFilterNameTF, BorderLayout.WEST); panel.add(panel1, BorderLayout.CENTER); northPanel.add(panel); mFilterRuleTF = new JTextField(); mFilterRuleTF.getDocument().addDocumentListener(this); mFilterRuleTF.addCaretListener(this); panel = new JPanel(new BorderLayout(7, 7)); panel1 = new JPanel(new BorderLayout()); panel.add(new JLabel(mLocalizer.msg("ruleString", "Filter rule:")), BorderLayout.WEST); JLabel exampleLb = new JLabel( mLocalizer.msg("ruleExample", "example: component1 or (component2 and not component3)")); Font f = exampleLb.getFont(); exampleLb.setFont(new Font(f.getName(), Font.ITALIC | Font.PLAIN, f.getSize())); panel1.add(exampleLb, BorderLayout.WEST); panel.add(panel1, BorderLayout.CENTER); northPanel.add(panel); northPanel.add(mFilterRuleTF); mFilterRuleErrorLb = new JLabel(); mFilterRuleErrorLb.setForeground(Color.red); panel = new JPanel(new BorderLayout(7, 7)); panel.add(mFilterRuleErrorLb, BorderLayout.WEST); mColLb = new JLabel("0"); panel.add(mColLb, BorderLayout.EAST); northPanel.add(panel); JPanel filterComponentsPanel = new JPanel(new BorderLayout(7, 7)); filterComponentsPanel.add(DefaultComponentFactory.getInstance().createSeparator( mLocalizer.msg("componentsTitle", "Available filter components:")), BorderLayout.NORTH); JPanel btnPanel = new JPanel(new BorderLayout()); panel1 = new JPanel(new GridLayout(0, 1, 0, 7)); mNewBtn = new JButton(mLocalizer.msg("newButton", "new")); mEditBtn = new JButton(Localizer.getLocalization(Localizer.I18N_EDIT)); mRemoveBtn = new JButton(Localizer.getLocalization(Localizer.I18N_DELETE)); mNewBtn.addActionListener(this); mEditBtn.addActionListener(this); mRemoveBtn.addActionListener(this); panel1.add(mNewBtn); panel1.add(mEditBtn); panel1.add(mRemoveBtn); btnPanel.add(panel1, BorderLayout.NORTH); mComponentTableModel = new FilterTableModel(); mRuleTableBox = new JTable(mComponentTableModel); mRuleTableBox.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { updateBtns(); } }); mRuleTableBox.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() >= 2) { int row = mRuleTableBox.rowAtPoint(e.getPoint()); if (mRuleTableBox.getSelectedRow() == row && mEditBtn.isEnabled()) { actionPerformed(new ActionEvent(mEditBtn, ActionEvent.ACTION_PERFORMED, mEditBtn.getActionCommand())); } } } }); mRuleTableBox.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); mRuleTableBox.setShowGrid(false); mRuleTableBox.setShowVerticalLines(true); mRuleTableBox.getColumnModel().getColumn(0).setPreferredWidth(125); mRuleTableBox.getColumnModel().getColumn(1).setPreferredWidth(320); // mRuleTableBox.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // Dispatchs the KeyEvent to the RootPane for Closing the Dialog. // Needed for Java 1.4. mRuleTableBox.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { mRuleTableBox.getRootPane().dispatchEvent(e); } } }); JPanel ruleListBoxPanel = new JPanel(new BorderLayout()); ruleListBoxPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 7, 0)); ruleListBoxPanel.add(new JScrollPane(mRuleTableBox), BorderLayout.CENTER); filterComponentsPanel.add(btnPanel, BorderLayout.EAST); filterComponentsPanel.add(ruleListBoxPanel, BorderLayout.CENTER); ButtonBarBuilder2 bottomBar = Utilities.createFilterButtonBar(); mOkBtn = new JButton(Localizer.getLocalization(Localizer.I18N_OK)); mOkBtn.addActionListener(this); getRootPane().setDefaultButton(mOkBtn); mCancelBtn = new JButton(Localizer.getLocalization(Localizer.I18N_CANCEL)); mCancelBtn.addActionListener(this); bottomBar.addButton(new JButton[] { mOkBtn, mCancelBtn }); contentPane.add(northPanel, BorderLayout.NORTH); contentPane.add(filterComponentsPanel, BorderLayout.CENTER); contentPane.add(bottomBar.getPanel(), BorderLayout.SOUTH); if (mFilter != null) { mFilterNameTF.setText(mFilter.toString()); mFilterRuleTF.setText(mFilter.getRule()); } FilterComponent[] fc = FilterComponentList.getInstance().getAvailableFilterComponents(); Arrays.sort(fc, new FilterComponent.NameComparator()); for (FilterComponent element : fc) { mComponentTableModel.addElement(element); } updateBtns(); Settings.layoutWindow("editFilterDlg", this, new Dimension(600, 300)); setVisible(true); }