📄 pdfexportdialog.java
字号:
if(bundle!=null){ try{ titleLabel=bundle.getString("labelexporttitle"); authorLabel=bundle.getString("labelexportauthor"); subjectLabel=bundle.getString("labelexportsubject"); keywordsLabel=bundle.getString("labelexportkeywords"); creatorLabel=bundle.getString("labelexportcreator"); }catch (Exception ex){} } //creating the jlabels JLabel titleLbl=new JLabel(titleLabel+" : "), authorLbl=new JLabel(authorLabel+" : "), subjectLbl=new JLabel(subjectLabel+" : "), keywordsLbl=new JLabel(keywordsLabel+" : "), creatorLbl=new JLabel(creatorLabel+" : "); titleLbl.setHorizontalAlignment(SwingConstants.RIGHT); authorLbl.setHorizontalAlignment(SwingConstants.RIGHT); subjectLbl.setHorizontalAlignment(SwingConstants.RIGHT); keywordsLbl.setHorizontalAlignment(SwingConstants.RIGHT); creatorLbl.setHorizontalAlignment(SwingConstants.RIGHT); //creating the textfields final JTextField titleTxt=new JTextField(25), authorTxt=new JTextField(25), subjectTxt=new JTextField(25), keywordsTxt=new JTextField(25), creatorTxt=new JTextField(25); //adding the listener to the textfields CaretListener caretListener=new CaretListener() { public void caretUpdate(CaretEvent evt) { if(evt.getSource().equals(titleTxt)) { title=titleTxt.getText(); }else if(evt.getSource().equals(authorTxt)) { author=authorTxt.getText(); }else if(evt.getSource().equals(subjectTxt)) { subject=subjectTxt.getText(); }else if(evt.getSource().equals(keywordsTxt)) { keywords=keywordsTxt.getText(); }else if(evt.getSource().equals(creatorTxt)) { creator=creatorTxt.getText(); } } }; titleTxt.addCaretListener(caretListener); authorTxt.addCaretListener(caretListener); subjectTxt.addCaretListener(caretListener); keywordsTxt.addCaretListener(caretListener); creatorTxt.addCaretListener(caretListener); //adding the widgets to the panel GridBagLayout gridBag=new GridBagLayout(); pageInfoPanel.setLayout(gridBag); GridBagConstraints c=new GridBagConstraints(); c.fill=GridBagConstraints.HORIZONTAL; c.anchor=GridBagConstraints.EAST; c.gridwidth=1; c.insets=new Insets(2, 4, 2, 0); gridBag.setConstraints(titleLbl, c); pageInfoPanel.add(titleLbl); c.anchor=GridBagConstraints.WEST; c.gridwidth=GridBagConstraints.REMAINDER; c.insets=new Insets(2, 0, 2, 4); gridBag.setConstraints(titleTxt, c); pageInfoPanel.add(titleTxt); c.anchor=GridBagConstraints.EAST; c.gridwidth=1; c.insets=new Insets(2, 4, 2, 0); gridBag.setConstraints(authorLbl, c); pageInfoPanel.add(authorLbl); c.anchor=GridBagConstraints.WEST; c.gridwidth=GridBagConstraints.REMAINDER; c.insets=new Insets(2, 0, 2, 4); gridBag.setConstraints(authorTxt, c); pageInfoPanel.add(authorTxt); c.anchor=GridBagConstraints.EAST; c.gridwidth=1; c.insets=new Insets(2, 4, 2, 0); gridBag.setConstraints(subjectLbl, c); pageInfoPanel.add(subjectLbl); c.anchor=GridBagConstraints.WEST; c.gridwidth=GridBagConstraints.REMAINDER; c.insets=new Insets(2, 0, 2, 4); gridBag.setConstraints(subjectTxt, c); pageInfoPanel.add(subjectTxt); c.anchor=GridBagConstraints.EAST; c.gridwidth=1; c.insets=new Insets(2, 4, 2, 0); gridBag.setConstraints(keywordsLbl, c); pageInfoPanel.add(keywordsLbl); c.anchor=GridBagConstraints.WEST; c.gridwidth=GridBagConstraints.REMAINDER; c.insets=new Insets(2, 0, 2, 4); gridBag.setConstraints(keywordsTxt, c); pageInfoPanel.add(keywordsTxt); c.anchor=GridBagConstraints.EAST; c.gridwidth=1; c.insets=new Insets(2, 4, 2, 0); gridBag.setConstraints(creatorLbl, c); pageInfoPanel.add(creatorLbl); c.anchor=GridBagConstraints.WEST; c.gridwidth=GridBagConstraints.REMAINDER; c.insets=new Insets(2, 0, 2, 4); gridBag.setConstraints(creatorTxt, c); pageInfoPanel.add(creatorTxt); return pageInfoPanel; } /** * the class of the items of the combo box used for choosing a predefined size */ protected static class PredefinedPageSizeItem{ /** * the map associating a size object to the corresponding label */ protected static LinkedHashMap<com.lowagie.text.Rectangle, String> sizeToLabel= new LinkedHashMap<com.lowagie.text.Rectangle, String>(); /** * the labels of the predefined sizes */ protected static String label_11X17="", labelA0="", labelA1="", labelA10="", labelA2="", labelA3="", labelA4="", labelA5="", labelA6="", labelA7="", labelA8="", labelA9="", labelARCH_A="", labelARCH_B="", labelARCH_C="", labelARCH_D="", labelARCH_E="", labelB0="", labelB1="", labelB2="", labelB3="", labelB4="", labelB5="", labelFLSA="", labelFLSE="", labelHALFLETTER="", labelLEDGER="", labelLEGAL="", labelLETTER="", labelNOTE=""; /** * the array of the combo items */ protected static PredefinedPageSizeItem[] items=null; static { //getting the labels ResourceBundle bundle=SVGEditor.getBundle(); if(bundle!=null){ try{ label_11X17=bundle.getString("labelexportpdf_11X17"); labelA0=bundle.getString("labelexportpdfA0"); labelA1=bundle.getString("labelexportpdfA1"); labelA10=bundle.getString("labelexportpdfA10"); labelA2=bundle.getString("labelexportpdfA2"); labelA3=bundle.getString("labelexportpdfA3"); labelA4=bundle.getString("labelexportpdfA4"); labelA5=bundle.getString("labelexportpdfA5"); labelA6=bundle.getString("labelexportpdfA6"); labelA7=bundle.getString("labelexportpdfA7"); labelA8=bundle.getString("labelexportpdfA8"); labelA9=bundle.getString("labelexportpdfA9"); labelARCH_A=bundle.getString("labelexportpdfARCH_A"); labelARCH_B=bundle.getString("labelexportpdfARCH_B"); labelARCH_C=bundle.getString("labelexportpdfARCH_C"); labelARCH_D=bundle.getString("labelexportpdfARCH_D"); labelARCH_E=bundle.getString("labelexportpdfARCH_E"); labelB0=bundle.getString("labelexportpdfB0"); labelB1=bundle.getString("labelexportpdfB1"); labelB2=bundle.getString("labelexportpdfB2"); labelB3=bundle.getString("labelexportpdfB3"); labelB4=bundle.getString("labelexportpdfB4"); labelB5=bundle.getString("labelexportpdfB5"); labelFLSA=bundle.getString("labelexportpdfFLSA"); labelFLSE=bundle.getString("labelexportpdfFLSE"); labelHALFLETTER=bundle.getString("labelexportpdfHALFLETTER"); labelLEDGER=bundle.getString("labelexportpdfLEDGER"); labelLEGAL=bundle.getString("labelexportpdfLEGAL"); labelLETTER=bundle.getString("labelexportpdfLETTER"); labelNOTE=bundle.getString("labelexportpdfNOTE"); }catch (Exception ex){} } //filling the map of the sizes sizeToLabel.put(PageSize._11X17, label_11X17); sizeToLabel.put(PageSize.A0, labelA0); sizeToLabel.put(PageSize.A1, labelA1); sizeToLabel.put(PageSize.A10, labelA10); sizeToLabel.put(PageSize.A2, labelA2); sizeToLabel.put(PageSize.A3, labelA3); sizeToLabel.put(PageSize.A4, labelA4); sizeToLabel.put(PageSize.A5, labelA5); sizeToLabel.put(PageSize.A6, labelA6); sizeToLabel.put(PageSize.A7, labelA7); sizeToLabel.put(PageSize.A8, labelA8); sizeToLabel.put(PageSize.A9, labelA9); sizeToLabel.put(PageSize.ARCH_A, labelARCH_A); sizeToLabel.put(PageSize.ARCH_B, labelARCH_B); sizeToLabel.put(PageSize.ARCH_C, labelARCH_C); sizeToLabel.put(PageSize.ARCH_D, labelARCH_D); sizeToLabel.put(PageSize.ARCH_E, labelARCH_E); sizeToLabel.put(PageSize.B0, labelB0); sizeToLabel.put(PageSize.B1, labelB1); sizeToLabel.put(PageSize.B2, labelB2); sizeToLabel.put(PageSize.B3, labelB3); sizeToLabel.put(PageSize.B4, labelB4); sizeToLabel.put(PageSize.B5, labelB5); sizeToLabel.put(PageSize.FLSA, labelFLSA); sizeToLabel.put(PageSize.FLSE, labelFLSE); sizeToLabel.put(PageSize.HALFLETTER, labelHALFLETTER); sizeToLabel.put(PageSize.LEDGER, labelLEDGER); sizeToLabel.put(PageSize.LEGAL, labelLEGAL); sizeToLabel.put(PageSize.LETTER, labelLETTER); sizeToLabel.put(PageSize.NOTE, labelNOTE); items=new PredefinedPageSizeItem[sizeToLabel.size()]; com.lowagie.text.Rectangle itemSize=null; LinkedList<com.lowagie.text.Rectangle> sizes= new LinkedList<com.lowagie.text.Rectangle>(sizeToLabel.keySet()); //creating all the items according to the size objects that can be found in the map for(int i=0; i<sizes.size(); i++) { itemSize=sizes.get(i); //creating the new combo item items[i]=new PredefinedPageSizeItem(itemSize); } } /** * the size associated with the item */ protected com.lowagie.text.Rectangle size=PageSize.A4; /** * the label of this item */ protected String label=""; /** * the constructor of the class * @param size the size for the item */ private PredefinedPageSizeItem(com.lowagie.text.Rectangle size) { this.size=size; this.label=sizeToLabel.get(size); } /** * @return Returns the size. */ public com.lowagie.text.Rectangle getSize() { return size; } @Override public String toString() { return label; } /** * @return Returns the sizeToLabel. */ protected static LinkedHashMap<com.lowagie.text.Rectangle, String> getPageSizeToLabel() { return sizeToLabel; } /** * returns the combo item corresponding to the given page size * @param pageSize a page size * @return the combo item corresponding to the given page size */ protected static PredefinedPageSizeItem getItem(com.lowagie.text.Rectangle pageSize) { PredefinedPageSizeItem item=null; if(pageSize!=null) { //getting the item that has got the given page size for its size for(int i=0; i<items.length; i++) { if(items[i]!=null && items[i].getSize()!=null && items[i].getSize().equals(pageSize)) { item=items[i]; break; } } } return item; } /** * @return the array of the available predefined page size items */ protected static PredefinedPageSizeItem[] getItems() { return items; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -