/** Returns the tool bar for the panel. */ protected JComponent getToolBar() { JToolBar tbarDir = new JToolBar(); JButton btnNew = new JButton(); // m_btnSave = new JButton("Save File"); // i118n // btnNew.setText("New Label"); btnNew.setText(Util.getAdmLabel("_adm_New_Label")); btnNew.setActionCommand("new"); // m_btnSave.setActionCommand("save"); ActionListener alTool = new ActionListener() { public void actionPerformed(ActionEvent e) { doAction(e); } }; btnNew.addActionListener(alTool); // m_btnSave.addActionListener(alTool); tbarDir.setFloatable(false); tbarDir.add(btnNew); /*tbarDir.add(new JLabel(" ")); tbarDir.add(m_btnSave);*/ return tbarDir; }
/** Initialisation */ private void initComponents() { setBackground(new java.awt.Color(114, 159, 255)); addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { closeDialog(); } }); getContentPane().setLayout(new java.awt.BorderLayout()); JPanel actionPanel = new JPanel(); actionPanel.setLayout(new java.awt.GridLayout(1, 0)); detailedArea.setEditable(false); detailedArea.setVisible(true); detailedArea.setSize(500, 300); detailedArea.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11)); StringWriter opDetail = new StringWriter(); actionPrint(new PrintWriter(opDetail)); detailedArea.setText(new String(opDetail.getBuffer())); JScrollPane scroll = new JScrollPane(detailedArea); actionPanel.add(scroll); getContentPane().add(actionPanel, "Center"); northToolBar = new javax.swing.JToolBar(); northToolBar.setLayout(new java.awt.FlowLayout()); northToolBar.setFloatable(false); jbn_Print = new javax.swing.JButton(); jbn_Print.setText(" Print "); jbn_Print.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbn_PrintActionPerformed(); } }); northToolBar.add(jbn_Print); jbn_OK = new javax.swing.JButton(); jbn_OK.setText(" Close "); jbn_OK.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbn_OKActionPerformed(); } }); northToolBar.add(jbn_OK); getContentPane().add(northToolBar, "South"); }
// Initializes this component. private void jbInit() { fileChooser.setFileFilter(new ScriptFileFilter()); this.getContentPane().setLayout(null); Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>(); JLabel slowLabel = new JLabel("Slow"); slowLabel.setFont(Utilities.thinLabelsFont); JLabel fastLabel = new JLabel("Fast"); fastLabel.setFont(Utilities.thinLabelsFont); labelTable.put(1, slowLabel); labelTable.put(5, fastLabel); speedSlider.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { SpeedSlider_stateChanged(e); } }); speedSlider.setLabelTable(labelTable); speedSlider.setMajorTickSpacing(1); speedSlider.setPaintTicks(true); speedSlider.setPaintLabels(true); speedSlider.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0)); speedSlider.setPreferredSize(new Dimension(95, 50)); speedSlider.setMinimumSize(new Dimension(95, 50)); speedSlider.setToolTipText("Speed"); speedSlider.setMaximumSize(new Dimension(95, 50)); final Dimension buttonSize = new Dimension(39, 39); loadProgramButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { loadProgramButton_actionPerformed(); } }); loadProgramButton.setMaximumSize(buttonSize); loadProgramButton.setMinimumSize(buttonSize); loadProgramButton.setPreferredSize(buttonSize); loadProgramButton.setSize(buttonSize); loadProgramButton.setToolTipText("Load Program"); loadProgramButton.setIcon(loadProgramIcon); ffwdButton.setMaximumSize(buttonSize); ffwdButton.setMinimumSize(buttonSize); ffwdButton.setPreferredSize(buttonSize); ffwdButton.setToolTipText("Run"); ffwdButton.setIcon(ffwdIcon); ffwdButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ffwdButton_actionPerformed(); } }); stopButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { stopButton_actionPerformed(); } }); stopButton.setMaximumSize(buttonSize); stopButton.setMinimumSize(buttonSize); stopButton.setPreferredSize(buttonSize); stopButton.setToolTipText("Stop"); stopButton.setIcon(stopIcon); rewindButton.setMaximumSize(buttonSize); rewindButton.setMinimumSize(buttonSize); rewindButton.setPreferredSize(buttonSize); rewindButton.setToolTipText("Reset"); rewindButton.setIcon(rewindIcon); rewindButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { rewindButton_actionPerformed(); } }); scriptButton.setMaximumSize(buttonSize); scriptButton.setMinimumSize(buttonSize); scriptButton.setPreferredSize(buttonSize); scriptButton.setToolTipText("Load Script"); scriptButton.setIcon(scriptIcon); scriptButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { scriptButton_actionPerformed(); } }); breakButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { breakButton_actionPerformed(); } }); breakButton.setMaximumSize(buttonSize); breakButton.setMinimumSize(buttonSize); breakButton.setPreferredSize(buttonSize); breakButton.setToolTipText("Open breakpoint panel"); breakButton.setIcon(breakIcon); breakpointWindow.addBreakpointListener(this); singleStepButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { singleStepButton_actionPerformed(); } }); singleStepButton.setMaximumSize(buttonSize); singleStepButton.setMinimumSize(buttonSize); singleStepButton.setPreferredSize(buttonSize); singleStepButton.setSize(buttonSize); singleStepButton.setToolTipText("Single Step"); singleStepButton.setIcon(singleStepIcon); stepOverButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { stepOverButton_actionPerformed(); } }); stepOverButton.setMaximumSize(buttonSize); stepOverButton.setMinimumSize(buttonSize); stepOverButton.setPreferredSize(buttonSize); stepOverButton.setSize(buttonSize); stepOverButton.setToolTipText("Step Over"); stepOverButton.setIcon(stepOverIcon); animationCombo.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { animationCombo_actionPerformed(); } }); formatCombo.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { formatCombo_actionPerformed(); } }); additionalDisplayCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { additionalDisplayCombo_actionPerformed(); } }); messageLbl.setFont(Utilities.statusLineFont); messageLbl.setBorder(BorderFactory.createLoweredBevelBorder()); messageLbl.setBounds(new Rectangle(0, 667, CONTROLLER_WIDTH - 8, 25)); toolBar = new JToolBar(); toolBar.setSize(new Dimension(TOOLBAR_WIDTH, TOOLBAR_HEIGHT)); toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); toolBar.setFloatable(false); toolBar.setLocation(0, 0); toolBar.setBorder(BorderFactory.createEtchedBorder()); arrangeToolBar(); this.getContentPane().add(toolBar, null); toolBar.revalidate(); toolBar.repaint(); repaint(); // Creating the menu bar menuBar = new JMenuBar(); arrangeMenu(); setJMenuBar(menuBar); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.getContentPane().add(messageLbl, null); setControllerSize(); // sets the frame to be visible. setVisible(true); }
public void createGUI() { setLayout(new BorderLayout()); toolBar = new JToolBar("options", JToolBar.HORIZONTAL); toolBar.setFloatable(false); toolBar.setOpaque(true); toolBar.setBackground(new Color(154, 12, 12)); toolBar.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); selectAllCB = new JCheckBox("Select All"); selectAllCB.setVisible(false); selectAllCB.setForeground(Color.white); selectAllCB.addActionListener(this); refreshBut = new JButton(new ImageIcon(this.getClass().getResource("/images/reloadIcon.png"))); refreshBut.setVisible(false); refreshBut.setToolTipText("Refresh"); refreshBut.setForeground(new Color(20, 88, 49)); refreshBut.addActionListener(this); backBut = new JButton(new ImageIcon(this.getClass().getResource("/images/backIcon.png"))); backBut.setVisible(false); backBut.setToolTipText("Back"); backBut.setForeground(new Color(20, 88, 49)); backBut.addActionListener(this); deleteBut = new JButton(new ImageIcon(this.getClass().getResource("/images/trashIcon.png"))); deleteBut.setToolTipText("Delete"); deleteBut.setForeground(Color.red); deleteBut.setVisible(false); deleteBut.addActionListener(this); deleteBut.setBackground(Color.red); restoreBut = new JButton(new ImageIcon(this.getClass().getResource("/images/restoreIcon.png"))); restoreBut.setToolTipText("Restore"); restoreBut.setForeground(Color.blue); restoreBut.setVisible(false); restoreBut.addActionListener(this); toolBar.addSeparator(new Dimension(10, 5)); toolBar.add(selectAllCB); toolBar.add(backBut); toolBar.add(refreshBut); toolBar.add(deleteBut); toolBar.add(restoreBut); add(toolBar, "North"); JPanel centPan = new JPanel(new GridBagLayout()); centPan.setBackground(new Color(52, 86, 70)); JLabel label = new JLabel("Select A Category From Left Pane"); label.setFont(new Font("arial", Font.BOLD, 35)); label.setForeground(Color.yellow); centPan.add(label); contentPan = new JScrollPane(centPan); contentPan.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); add(contentPan, "Center"); contentPan.repaint(); db = new Database(); // inboxSet = db.getData("SELECT * FROM messages WHERE tag='inbox' ORDER BY msg_id // desc"); // sentmailSet = db.getData("SELECT * FROM messages WHERE tag='sentmail' ORDER BY msg_id // desc"); // draftSet = db.getData("SELECT * FROM messages WHERE tag='draft' ORDER BY msg_id // desc"); // outboxSet = db.getData("SELECT * FROM messages WHERE tag='outbox' ORDER BY msg_id // desc"); // trashSet = db.getData("SELECT * FROM messages,trash WHERE messages.tag='trash' and // messages.msg_id=trash.msg_id ORDER BY deleted_at desc"); }
// initializes the internal component of the translator protected void jbInit() { this.getContentPane().setLayout(new GridBagLayout()); loadButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { loadButton_actionPerformed(e); } }); loadButton.setMaximumSize(new Dimension(39, 39)); loadButton.setMinimumSize(new Dimension(39, 39)); loadButton.setPreferredSize(new Dimension(39, 39)); loadButton.setSize(new Dimension(39, 39)); loadButton.setToolTipText("Load Source File"); loadButton.setIcon(loadIcon); saveButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { saveButton_actionPerformed(e); } }); saveButton.setMaximumSize(new Dimension(39, 39)); saveButton.setMinimumSize(new Dimension(39, 39)); saveButton.setPreferredSize(new Dimension(39, 39)); saveButton.setSize(new Dimension(39, 39)); saveButton.setToolTipText("Save Destination File"); saveButton.setIcon(saveIcon); singleStepButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { singleStepButton_actionPerformed(e); } }); singleStepButton.setMaximumSize(new Dimension(39, 39)); singleStepButton.setMinimumSize(new Dimension(39, 39)); singleStepButton.setPreferredSize(new Dimension(39, 39)); singleStepButton.setSize(new Dimension(39, 39)); singleStepButton.setToolTipText("Single Step"); singleStepButton.setIcon(singleStepIcon); ffwdButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { ffwdButton_actionPerformed(e); } }); ffwdButton.setMaximumSize(new Dimension(39, 39)); ffwdButton.setMinimumSize(new Dimension(39, 39)); ffwdButton.setPreferredSize(new Dimension(39, 39)); ffwdButton.setSize(new Dimension(39, 39)); ffwdButton.setToolTipText("Fast Forward"); ffwdButton.setIcon(ffwdIcon); rewindButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { rewindButton_actionPerformed(e); } }); rewindButton.setMaximumSize(new Dimension(39, 39)); rewindButton.setMinimumSize(new Dimension(39, 39)); rewindButton.setPreferredSize(new Dimension(39, 39)); rewindButton.setSize(new Dimension(39, 39)); rewindButton.setToolTipText("Rewind"); rewindButton.setIcon(rewindIcon); stopButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { stopButton_actionPerformed(e); } }); stopButton.setMaximumSize(new Dimension(39, 39)); stopButton.setMinimumSize(new Dimension(39, 39)); stopButton.setPreferredSize(new Dimension(39, 39)); stopButton.setSize(new Dimension(39, 39)); stopButton.setToolTipText("Stop"); stopButton.setIcon(stopIcon); fullTranslationButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fullTranslationButton_actionPerformed(e); } }); fullTranslationButton.setMaximumSize(new Dimension(39, 39)); fullTranslationButton.setMinimumSize(new Dimension(39, 39)); fullTranslationButton.setPreferredSize(new Dimension(39, 39)); fullTranslationButton.setSize(new Dimension(39, 39)); fullTranslationButton.setToolTipText("Fast Translation"); fullTranslationButton.setIcon(fullTranslationIcon); messageLbl.setFont(Utilities.statusLineFont); messageLbl.setLineWrap(true); messageLbl.setEditable(false); messageLbl.setCursor(null); messageLbl.setOpaque(false); messageLbl.setFocusable(false); messageLblPane.setBorder(BorderFactory.createLoweredBevelBorder()); // messageLblPane.setBounds(new Rectangle(0, 672, TRANSLATOR_WIDTH - 8, 20)); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 0; c.gridwidth = 3; c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 2; this.getContentPane().add(messageLblPane, c); // arrowLabel.setBounds(new Rectangle(290, 324, 88, 71)); arrowLabel.setIcon(arrowIcon); // source.setVisibleRows(31); // destination.setVisibleRows(31); // source.setBounds(new Rectangle(35,100,source.getWidth(),source.getHeight())); // destination.setBounds(new Rectangle(375,100,destination.getWidth(),destination.getHeight())); c.fill = GridBagConstraints.BOTH; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = 1; c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 1; this.getContentPane().add(source, c); c.fill = GridBagConstraints.NONE; c.ipadx = 0; c.ipady = 0; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.anchor = GridBagConstraints.CENTER; c.gridx = 1; c.gridy = 1; this.getContentPane().add(arrowLabel, c); c.fill = GridBagConstraints.BOTH; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = 1; c.anchor = GridBagConstraints.CENTER; c.gridx = 2; c.gridy = 1; this.getContentPane().add(destination, c); // Adding the tool bar to this container. toolBar.setFloatable(false); toolBar.setLocation(0, 0); toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); toolBar.setBorder(BorderFactory.createEtchedBorder()); arrangeToolBar(); c.fill = GridBagConstraints.HORIZONTAL; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 0; c.gridwidth = 3; c.anchor = GridBagConstraints.CENTER; c.gridx = 0; c.gridy = 0; this.getContentPane().add(toolBar, c); toolBar.revalidate(); toolBar.repaint(); repaint(); // Creating the menu bar arrangeMenu(); setJMenuBar(menuBar); // initializing the window size and visibility setDefaultCloseOperation(3); setSize(new Dimension(TRANSLATOR_WIDTH, TRANSLATOR_HEIGHT)); setVisible(true); }
public static JToolBar getToolbar(String label, int size, boolean hasStrings) { JToolBar toolBar = new JToolBar(); JButton buttonCut = new JButton(hasStrings ? "cut" : null, getIcon(size + "/edit-cut")); buttonCut.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE); toolBar.add(buttonCut); JButton buttonCopy = new JButton(hasStrings ? "copy" : null, getIcon(size + "/edit-copy")); buttonCopy.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE); buttonCopy.setEnabled(false); toolBar.add(buttonCopy); JButton buttonPaste = new JButton(getIcon(size + "/edit-paste")); toolBar.add(buttonPaste); JButton buttonSelectAll = new JButton(getIcon(size + "/edit-select-all")); toolBar.add(buttonSelectAll); JButton buttonDelete = new JButton(getIcon(size + "/edit-delete")); toolBar.add(buttonDelete); toolBar.addSeparator(); // add an inner toolbar to check the painting of toolbar // gradient and drop shadows under different skins. JToolBar innerToolbar = new JToolBar(JToolBar.HORIZONTAL); innerToolbar.setFloatable(false); JToggleButton buttonFormatCenter = new JToggleButton(getIcon(size + "/format-justify-center")); buttonFormatCenter.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 5.0f); innerToolbar.add(buttonFormatCenter); JToggleButton buttonFormatLeft = new JToggleButton(getIcon(size + "/format-justify-left")); innerToolbar.add(buttonFormatLeft); JToggleButton buttonFormatRight = new JToggleButton(getIcon(size + "/format-justify-right")); innerToolbar.add(buttonFormatRight); JToggleButton buttonFormatFill = new JToggleButton(getIcon(size + "/format-justify-fill")); buttonFormatFill.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f); innerToolbar.add(buttonFormatFill); toolBar.add(innerToolbar); toolBar.addSeparator(); if (size > 20) { JToolBar innerToolbar2 = new JToolBar(JToolBar.HORIZONTAL); innerToolbar2.setFloatable(false); JPanel innerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); innerToolbar2.add(innerPanel, BorderLayout.CENTER); final JToggleButton buttonStyleBold = new JToggleButton(getIcon(size + "/format-text-bold")); Set<Side> rightSide = EnumSet.of(Side.RIGHT); buttonStyleBold.putClientProperty(SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide); buttonStyleBold.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f); final JToggleButton buttonStyleItalic = new JToggleButton(getIcon(size + "/format-text-italic")); buttonStyleItalic.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f); buttonStyleItalic.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide); final JToggleButton buttonStyleUnderline = new JToggleButton(getIcon(size + "/format-text-underline")); buttonStyleUnderline.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f); buttonStyleUnderline.putClientProperty( SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide); final JToggleButton buttonStyleStrikethrough = new JToggleButton(getIcon(size + "/format-text-strikethrough")); buttonStyleStrikethrough.putClientProperty( SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, EnumSet.of(Side.LEFT)); buttonStyleStrikethrough.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f); buttonStyleBold.setSelected(true); innerPanel.add(buttonStyleBold); innerPanel.add(buttonStyleItalic); innerPanel.add(buttonStyleUnderline); innerPanel.add(buttonStyleStrikethrough); toolBar.add(innerToolbar2); } toolBar.add(Box.createGlue()); JButton buttonExit = new JButton(getIcon(size + "/process-stop")); buttonExit.setToolTipText("Closes the test application"); buttonExit.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); toolBar.add(buttonExit); return toolBar; }
/** Construct the TV object - that is, the main GUI for the program */ public TV(JFrame f, TD mod) { super(); frm = f; theTD = mod; JButton b; // Build the GUI toolBar = new JToolBar(); toolBar.setFloatable(false); toolBar.getAccessibleContext().setAccessibleName("File Toolbar"); toolBar.addSeparator(); b = addTool(toolBar, "Cut"); b = addTool(toolBar, "Copy"); b = addTool(toolBar, "Paste"); toolBar.addSeparator(); toolBar.putClientProperty("JToolBar.isRollover", Boolean.FALSE); // The Slider numSlider = new JSlider(JSlider.HORIZONTAL, 1, 40, 1); numSlider.setPaintTicks(true); numSlider.setPaintLabels(false); numSlider.setMajorTickSpacing(10); numSlider.setMinorTickSpacing(2); numSlider.setExtent(1); numSlider.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent ce) { // System.out.println("CHANGE: " + ce); setQNumber(((JSlider) (ce.getSource())).getValue()); } }); numSlider.setToolTipText("Slide to select question by number"); toolBar.add(numSlider); // The Question# textfield toolBar.add(numTF = new JTextField("01")); numTF.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String num = ((JTextField) e.getSource()).getText(); int n = Integer.parseInt(num.trim()); setQNumber(n); } }); numTF.setToolTipText("Type number to select question by number"); // The First Button b = addTool(toolBar, "First"); b.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setQNumber(1); } }); // The Previous Button b = addTool(toolBar, "Previous"); b.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (getQNumber() <= 1) return; setQNumber(getQNumber() - 1); } }); // The Next Button b = addTool(toolBar, "Next"); b.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (getQNumber() >= getNumQuestions()) return; setQNumber(getQNumber() + 1); } }); // The "Last" Button b = addTool(toolBar, "Last"); b.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setQNumber(getNumQuestions()); } }); add(BorderLayout.NORTH, toolBar); // Rest is a panel to hold the questions, one at a time. questionsPanel = new JPanel(); questionsPanel.setLayout(myCardLayout = new CardLayout()); add(BorderLayout.SOUTH, questionsPanel); fc = new FileDialog(frm); fc.setFilenameFilter( new FilenameFilter() { public boolean accept(File ff, String fname) { // System.out.println("accept("+fname+")"); // XXX TODO list of extentions, from properties. return fname.endsWith(".xam"); } }); TV.centre(fc); }
/** * Customization of external program paths. * * @param prefs a <code>JabRefPreferences</code> value */ public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) { _prefs = prefs; this.frame = frame; setLayout(new BorderLayout()); TableModel tm = new AbstractTableModel() { public int getRowCount() { return rowCount; } public int getColumnCount() { return 2; } public Object getValueAt(int row, int column) { if (row == 0) return (column == 0 ? GUIGlobals.NUMBER_COL : "" + ncWidth); row--; if (row >= tableRows.size()) return ""; Object rowContent = tableRows.elementAt(row); if (rowContent == null) return ""; TableRow tr = (TableRow) rowContent; switch (column) { case 0: return tr.name; case 1: return ((tr.length > 0) ? Integer.toString(tr.length) : ""); } return null; // Unreachable. } public String getColumnName(int col) { return (col == 0 ? Globals.lang("Field name") : Globals.lang("Column width")); } public Class<?> getColumnClass(int column) { if (column == 0) return String.class; else return Integer.class; } public boolean isCellEditable(int row, int col) { return !((row == 0) && (col == 0)); } public void setValueAt(Object value, int row, int col) { tableChanged = true; // Make sure the vector is long enough. while (row >= tableRows.size()) tableRows.add(new TableRow("", -1)); if ((row == 0) && (col == 1)) { ncWidth = Integer.parseInt(value.toString()); return; } TableRow rowContent = tableRows.elementAt(row - 1); if (col == 0) { rowContent.name = value.toString(); if (((String) getValueAt(row, 1)).equals("")) setValueAt("" + GUIGlobals.DEFAULT_FIELD_LENGTH, row, 1); } else { if (value == null) rowContent.length = -1; else rowContent.length = Integer.parseInt(value.toString()); } } }; colSetup = new JTable(tm); TableColumnModel cm = colSetup.getColumnModel(); cm.getColumn(0).setPreferredWidth(140); cm.getColumn(1).setPreferredWidth(80); FormLayout layout = new FormLayout( "1dlu, 8dlu, left:pref, 4dlu, fill:pref", // , 4dlu, fill:60dlu, 4dlu, fill:pref", ""); DefaultFormBuilder builder = new DefaultFormBuilder(layout); JPanel pan = new JPanel(); JPanel tabPanel = new JPanel(); tabPanel.setLayout(new BorderLayout()); JScrollPane sp = new JScrollPane( colSetup, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); colSetup.setPreferredScrollableViewportSize(new Dimension(250, 200)); sp.setMinimumSize(new Dimension(250, 300)); tabPanel.add(sp, BorderLayout.CENTER); JToolBar tlb = new JToolBar(SwingConstants.VERTICAL); tlb.setFloatable(false); // tlb.setRollover(true); // tlb.setLayout(gbl); AddRowAction ara = new AddRowAction(); DeleteRowAction dra = new DeleteRowAction(); MoveRowUpAction moveUp = new MoveRowUpAction(); MoveRowDownAction moveDown = new MoveRowDownAction(); tlb.setBorder(null); tlb.add(ara); tlb.add(dra); tlb.addSeparator(); tlb.add(moveUp); tlb.add(moveDown); // tlb.addSeparator(); // tlb.add(new UpdateWidthsAction()); tabPanel.add(tlb, BorderLayout.EAST); showOneLetterHeadingForIconColumns = new JCheckBox(Globals.lang("Show one letter heading for icon columns")); fileColumn = new JCheckBox(Globals.lang("Show file column")); pdfColumn = new JCheckBox(Globals.lang("Show PDF/PS column")); urlColumn = new JCheckBox(Globals.lang("Show URL/DOI column")); preferUrl = new JRadioButton(Globals.lang("Show URL first")); preferDoi = new JRadioButton(Globals.lang("Show DOI first")); preferUrlDoiGroup = new ButtonGroup(); preferUrlDoiGroup.add(preferUrl); preferUrlDoiGroup.add(preferDoi); urlColumn.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { preferUrl.setEnabled(urlColumn.isSelected()); preferDoi.setEnabled(urlColumn.isSelected()); } }); arxivColumn = new JCheckBox(Globals.lang("Show ArXiv column")); /** * begin: special table columns and special fields ** */ HelpAction help = new HelpAction(frame.helpDiag, GUIGlobals.specialFieldsHelp); hlb = new JButton(GUIGlobals.getImage("helpSmall")); hlb.setToolTipText(Globals.lang("Help on special fields")); hlb.addActionListener(help); specialFieldsEnabled = new JCheckBox(Globals.lang("Enable special fields")); // .concat(". ").concat(Globals.lang("You must restart JabRef for this to come into // effect."))); specialFieldsEnabled.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent event) { boolean isEnabled = specialFieldsEnabled.isSelected(); rankingColumn.setEnabled(isEnabled); compactRankingColumn.setEnabled(isEnabled ? rankingColumn.isSelected() : false); qualityColumn.setEnabled(isEnabled); priorityColumn.setEnabled(isEnabled); relevanceColumn.setEnabled(isEnabled); syncKeywords.setEnabled(isEnabled); writeSpecialFields.setEnabled(isEnabled); } }); rankingColumn = new JCheckBox(Globals.lang("Show rank")); rankingColumn.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent event) { compactRankingColumn.setEnabled(rankingColumn.isSelected()); } }); compactRankingColumn = new JCheckBox(Globals.lang("Compact rank")); qualityColumn = new JCheckBox(Globals.lang("Show quality")); priorityColumn = new JCheckBox(Globals.lang("Show priority")); relevanceColumn = new JCheckBox(Globals.lang("Show relevance")); // "sync keywords" and "write special" fields may be configured mutually exclusive only // The implementation supports all combinations (TRUE+TRUE and FALSE+FALSE, even if the latter // does not make sense) // To avoid confusion, we opted to make the setting mutually exclusive syncKeywords = new JRadioButton(Globals.lang("Synchronize with keywords")); writeSpecialFields = new JRadioButton( Globals.lang("Write values of special fields as separate fields to BibTeX")); ButtonGroup group = new ButtonGroup(); group.add(syncKeywords); group.add(writeSpecialFields); builder.appendSeparator(Globals.lang("Special table columns")); builder.nextLine(); builder.append(pan); DefaultFormBuilder specialTableColumnsBuilder = new DefaultFormBuilder( new FormLayout( "8dlu, 8dlu, 8cm, 8dlu, 8dlu, left:pref:grow", "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref")); CellConstraints cc = new CellConstraints(); specialTableColumnsBuilder.add(specialFieldsEnabled, cc.xyw(1, 1, 3)); specialTableColumnsBuilder.add(rankingColumn, cc.xyw(2, 2, 2)); specialTableColumnsBuilder.add(compactRankingColumn, cc.xy(3, 3)); specialTableColumnsBuilder.add(relevanceColumn, cc.xyw(2, 4, 2)); specialTableColumnsBuilder.add(qualityColumn, cc.xyw(2, 5, 2)); specialTableColumnsBuilder.add(priorityColumn, cc.xyw(2, 6, 2)); specialTableColumnsBuilder.add(syncKeywords, cc.xyw(2, 7, 2)); specialTableColumnsBuilder.add(writeSpecialFields, cc.xyw(2, 8, 2)); specialTableColumnsBuilder.add(showOneLetterHeadingForIconColumns, cc.xyw(1, 9, 5)); specialTableColumnsBuilder.add(hlb, cc.xyw(1, 10, 2)); specialTableColumnsBuilder.add(fileColumn, cc.xyw(5, 1, 2)); specialTableColumnsBuilder.add(pdfColumn, cc.xyw(5, 2, 2)); specialTableColumnsBuilder.add(urlColumn, cc.xyw(5, 3, 2)); specialTableColumnsBuilder.add(preferUrl, cc.xy(6, 4)); specialTableColumnsBuilder.add(preferDoi, cc.xy(6, 5)); specialTableColumnsBuilder.add(arxivColumn, cc.xyw(5, 6, 2)); builder.append(specialTableColumnsBuilder.getPanel()); builder.nextLine(); /** * end: special table columns and special fields ** */ builder.appendSeparator(Globals.lang("Entry table columns")); builder.nextLine(); builder.append(pan); builder.append(tabPanel); builder.nextLine(); // lab = new JLabel("<HTML>("+Globals.lang("this button will update the column width // settings<BR>" // +"to match the current widths in your table")+")</HTML>"); // lab = new JLabel("<HTML>("+Globals.lang("this_button_will_update") +")</HTML>") ; builder.append(pan); JButton buttonWidth = new JButton(new UpdateWidthsAction()); JButton buttonOrder = new JButton(new UpdateOrderAction()); builder.append(buttonWidth); builder.nextLine(); builder.append(pan); builder.append(buttonOrder); builder.nextLine(); builder.append(pan); // builder.append(lab); builder.nextLine(); pan = builder.getPanel(); pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(pan, BorderLayout.CENTER); }