List of usage examples for javax.swing JButton setName
public void setName(String name)
From source file:Main.java
public static void main(String[] argv) throws Exception { JTabbedPane pane = new JTabbedPane(); JButton component = new JButton("button"); component.setName("Tab Label"); pane.add(component);/*from w w w . j av a 2 s. c om*/ }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); ComponentListener comp = new ComponentListener() { public void componentHidden(ComponentEvent e) { dump("Hidden", e); }//from w w w . j a v a 2s . c o m public void componentMoved(ComponentEvent e) { dump("Moved", e); } public void componentResized(ComponentEvent e) { dump("Resized", e); } public void componentShown(ComponentEvent e) { dump("Shown", e); } private void dump(String type, ComponentEvent e) { System.out.println(e.getComponent().getName() + " : " + type); } }; JButton left = new JButton("Left"); left.setName("Left"); left.addComponentListener(comp); final JButton right = new JButton("Right"); right.setName("Right"); right.addComponentListener(comp); ActionListener action = new ActionListener() { public void actionPerformed(ActionEvent e) { right.setVisible(!right.isVisible()); } }; left.addActionListener(action); JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, left, right); contentPane.add(pane, BorderLayout.CENTER); frame.setSize(300, 200); frame.show(); }
From source file:Main.java
public static JButton getButton(String displayText, ActionListener actionListener, String name) { JButton button = new JButton(displayText); button.setActionCommand(displayText); button.addActionListener(actionListener); if (name != null && !"".equals(name)) { button.setName(name); }/* ww w .j a va 2s . c om*/ return button; }
From source file:Main.java
/** * Returns a styled JButton./*from w w w. j a v a 2 s .c o m*/ * * @param style button type * @return a styled button */ public static JButton creaStyledButton(int style) { JButton jb = new JButton(); jb.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); jb.setMargin(new Insets(0, 5, 1, 5)); switch (style) { case STYLE_EDIT: { jb.setText("edit"); jb.setToolTipText("edit"); jb.setPreferredSize(new Dimension(60, 30)); return jb; } case STYLE_OK: { jb.setText("ok"); jb.setToolTipText("confirm changes"); jb.setPreferredSize(new Dimension(60, 30)); return jb; } case STYLE_CANCEL: { jb.setText("cancel"); jb.setToolTipText("discard changes"); jb.setPreferredSize(new Dimension(60, 30)); return jb; } case STYLE_INSBEFOREROW: { jb.setIcon(ICON_INSBEFOREROW); jb.setToolTipText("insert row before"); jb.setName("INSBEFOREROW"); return jb; } case STYLE_INSAFTERROW: { jb.setIcon(ICON_INSAFTERROW); jb.setToolTipText("insert row after"); jb.setName("INSAFTERROW"); return jb; } case STYLE_DELETEROW: { jb.setIcon(ICON_DELETEROW); jb.setToolTipText("delete row"); jb.setName("DELETEROW"); return jb; } case STYLE_CLONEBEFOREROW: { jb.setIcon(ICON_CLONEBEFOREROW); jb.setToolTipText("clone row before"); jb.setName("CLONEBEFOREROW"); return jb; } case STYLE_CLONEAFTERROW: { jb.setIcon(ICON_CLONEAFTERROW); jb.setToolTipText("clone row after"); jb.setName("CLONEAFTERROW"); return jb; } case STYLE_DEFAULTROWS: { jb.setIcon(ICON_DEFAULTROWS); jb.setToolTipText("set default values"); jb.setName("DEFAULTROWS"); return jb; } default: { return null; } } }
From source file:de.atomfrede.tools.evalutation.ui.ExceptionDialog.java
@SuppressWarnings("serial") @Override/*from w w w. j av a 2 s.c o m*/ public ButtonPanel createButtonPanel() { ButtonPanel buttonPanel = new ButtonPanel(); JButton closeButton = new JButton(); JButton detailButton = new JButton(); detailButton.setMnemonic('D'); closeButton.setName(OK); buttonPanel.addButton(closeButton, ButtonPanel.AFFIRMATIVE_BUTTON); buttonPanel.addButton(detailButton, ButtonPanel.OTHER_BUTTON); closeButton.setAction(new AbstractAction("Close") { @Override public void actionPerformed(ActionEvent e) { setDialogResult(RESULT_AFFIRMED); setVisible(false); dispose(); } }); detailButton.setAction(new AbstractAction("Details >>") { @Override public void actionPerformed(ActionEvent e) { if (_detailsPanel.isVisible()) { _detailsPanel.setVisible(false); putValue(Action.NAME, "Details <<"); pack(); } else { _detailsPanel.setVisible(true); putValue(Action.NAME, "<< Details"); pack(); } } }); setDefaultCancelAction(closeButton.getAction()); setDefaultAction(closeButton.getAction()); getRootPane().setDefaultButton(closeButton); buttonPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); buttonPanel.setSizeConstraint(ButtonPanel.NO_LESS_THAN); return buttonPanel; }
From source file:fr.duminy.components.swing.form.JFormPane.java
private void addButton(JPanel buttonsPanel, final I18nAction action, final String buttonName) { action.updateMessages();// w w w .j av a 2 s . c om JButton button = new JButton(action); button.setName(buttonName); buttonsPanel.add(button); }
From source file:com.smart.aqimonitor.client.AqiSettingDialog.java
/** * Create the dialog.//from www . j a v a 2 s .c om */ public AqiSettingDialog(Frame owner, final AbstractAqiParser aqiParser) { super(owner); this.aqiParser = aqiParser; setTitle("\u8BBE\u7F6E"); setResizable(false); setBounds(100, 100, 450, 135); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); GridBagLayout gbl_contentPanel = new GridBagLayout(); gbl_contentPanel.columnWidths = new int[] { 33, 48, 66, 41, 48, 66, 0, 0 }; gbl_contentPanel.rowHeights = new int[] { 21, 0, 0 }; gbl_contentPanel.columnWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; gbl_contentPanel.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; contentPanel.setLayout(gbl_contentPanel); { JLabel lblRetryTimes = new JLabel("\u91CD\u8BD5\u6B21\u6570\uFF1A"); GridBagConstraints gbc_lblRetryTimes = new GridBagConstraints(); gbc_lblRetryTimes.anchor = GridBagConstraints.WEST; gbc_lblRetryTimes.insets = new Insets(0, 0, 5, 5); gbc_lblRetryTimes.gridx = 1; gbc_lblRetryTimes.gridy = 0; contentPanel.add(lblRetryTimes, gbc_lblRetryTimes); } { tfRetryTimes = new JTextField(); tfRetryTimes.setPreferredSize(new Dimension(6, 29)); tfRetryTimes.setMinimumSize(new Dimension(60, 29)); GridBagConstraints gbc_tfRetryTimes = new GridBagConstraints(); gbc_tfRetryTimes.anchor = GridBagConstraints.NORTHWEST; gbc_tfRetryTimes.insets = new Insets(0, 0, 5, 5); gbc_tfRetryTimes.gridx = 2; gbc_tfRetryTimes.gridy = 0; contentPanel.add(tfRetryTimes, gbc_tfRetryTimes); tfRetryTimes.setColumns(10); } { JLabel lblRetryGap = new JLabel("\u91CD\u8BD5\u95F4\u9694\uFF1A"); GridBagConstraints gbc_lblRetryGap = new GridBagConstraints(); gbc_lblRetryGap.anchor = GridBagConstraints.WEST; gbc_lblRetryGap.insets = new Insets(0, 0, 5, 5); gbc_lblRetryGap.gridx = 4; gbc_lblRetryGap.gridy = 0; contentPanel.add(lblRetryGap, gbc_lblRetryGap); } { tfRetryGap = new JTextField(); tfRetryGap.setMinimumSize(new Dimension(60, 29)); tfRetryGap.setPreferredSize(new Dimension(60, 29)); GridBagConstraints gbc_tfRetryGap = new GridBagConstraints(); gbc_tfRetryGap.insets = new Insets(0, 0, 5, 5); gbc_tfRetryGap.anchor = GridBagConstraints.NORTHWEST; gbc_tfRetryGap.gridx = 5; gbc_tfRetryGap.gridy = 0; contentPanel.add(tfRetryGap, gbc_tfRetryGap); tfRetryGap.setColumns(10); } { JLabel label = new JLabel("\u5206\u949F"); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.insets = new Insets(0, 0, 5, 0); gbc_label.gridx = 6; gbc_label.gridy = 0; contentPanel.add(label, gbc_label); } { JLabel lblExportPath = new JLabel("\u8F93\u51FA\u8DEF\u5F84\uFF1A"); GridBagConstraints gbc_lblExportPath = new GridBagConstraints(); gbc_lblExportPath.anchor = GridBagConstraints.EAST; gbc_lblExportPath.insets = new Insets(0, 0, 0, 5); gbc_lblExportPath.gridx = 1; gbc_lblExportPath.gridy = 1; contentPanel.add(lblExportPath, gbc_lblExportPath); } { tfExportPath = new JTextField(); tfExportPath.setEditable(false); tfExportPath.setPreferredSize(new Dimension(180, 29)); tfExportPath.setMinimumSize(new Dimension(180, 29)); GridBagConstraints gbc_tfExportPath = new GridBagConstraints(); gbc_tfExportPath.gridwidth = 4; gbc_tfExportPath.insets = new Insets(0, 0, 0, 5); gbc_tfExportPath.fill = GridBagConstraints.HORIZONTAL; gbc_tfExportPath.gridx = 2; gbc_tfExportPath.gridy = 1; contentPanel.add(tfExportPath, gbc_tfExportPath); tfExportPath.setColumns(10); } { JButton button = new JButton("..."); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fDialog = new JFileChooser(); // fDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int result = fDialog.showOpenDialog(contentPanel); if (result == JFileChooser.APPROVE_OPTION) { tfExportPath.setText(fDialog.getSelectedFile().getAbsolutePath()); } } }); GridBagConstraints gbc_button = new GridBagConstraints(); gbc_button.gridx = 6; gbc_button.gridy = 1; contentPanel.add(button, gbc_button); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton("\u786E\u5B9A"); okButton.setName("settingOk"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String retryTimes = tfRetryTimes.getText(); if (StringUtils.isEmpty(retryTimes) || !isNumeric(retryTimes)) { JOptionPane.showMessageDialog(contentPanel, "", "", JOptionPane.ERROR_MESSAGE); return; } String retryGap = tfRetryGap.getText(); if (StringUtils.isEmpty(retryGap) || !isNumeric(retryGap)) { JOptionPane.showMessageDialog(contentPanel, "", "", JOptionPane.ERROR_MESSAGE); return; } String exportPath = tfExportPath.getText(); if (StringUtils.isEmpty(exportPath)) { JOptionPane.showMessageDialog(contentPanel, "", "", JOptionPane.ERROR_MESSAGE); return; } File testFile = new File(exportPath); if (!testFile.exists()) { JOptionPane.showMessageDialog(contentPanel, "", "", JOptionPane.ERROR_MESSAGE); return; } props.put("query.retryTimes", retryTimes); props.put("query.retryGap", retryGap); props.put("result.path", exportPath); try { props.store(new FileOutputStream(propertiesResource.getFile()), ""); aqiParser.setRetryTimes(Integer.parseInt(retryTimes)); aqiParser.setRetryGap(Integer.parseInt(retryGap)); aqiParser.setFilePath(exportPath); } catch (IOException e1) { e1.printStackTrace(); } finally { dispose(); } } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("\u53D6\u6D88"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } }
From source file:DateChooserPanel.java
/** * Returns a panel of buttons, each button representing a day in the month. * This is a sub-component of the DatePanel. * * @return the panel.//from ww w .j a v a 2s .c o m */ private JPanel getCalendarPanel() { final JPanel p = new JPanel(new GridLayout(7, 7)); final DateFormatSymbols dateFormatSymbols = new DateFormatSymbols(); final String[] weekDays = dateFormatSymbols.getShortWeekdays(); for (int i = 0; i < this.WEEK_DAYS.length; i++) { p.add(new JLabel(weekDays[this.WEEK_DAYS[i]], SwingConstants.CENTER)); } this.buttons = new JButton[42]; for (int i = 0; i < 42; i++) { final JButton b = new JButton(""); b.setMargin(new Insets(1, 1, 1, 1)); b.setName(Integer.toString(i)); b.setFont(this.dateFont); b.setFocusPainted(false); b.setActionCommand("dateButtonClicked"); b.addActionListener(this); this.buttons[i] = b; p.add(b); } return p; }
From source file:com.mgmtp.perfload.loadprofiles.ui.dialog.SettingsDialog.java
private void initComponents() { getContentPane().setLayout(new MigLayout("", "[grow]", "[][grow][grow][grow][]")); {/* w w w. j a va 2 s . co m*/ JPanel pnlConfigurations = new JPanel(); pnlConfigurations.setBorder(new TitledBorder(null, "Saved Configurations", TitledBorder.LEADING, TitledBorder.TOP, null, null)); pnlConfigurations.setName("pnlConfigurations"); getContentPane().add(pnlConfigurations, "cell 0 0, growx"); pnlConfigurations.setLayout(new MigLayout("", "[grow]", "[]")); { JLabel lblFileName = new JLabel("File Name"); lblFileName.setName("lblFileName"); pnlConfigurations.add(lblFileName, "flowx,cell 0 0"); } { cboConfigurationFile = new JComboBox() { @Override public void setSelectedItem(final Object anObject) { if (checkDirty()) { super.setSelectedItem(anObject); } } }; cboConfigurationFile.addItemListener(new CboConfigurationFileItemListener()); pnlConfigurations.add(cboConfigurationFile, "cell 0 0,growx"); cboConfigurationFile.setName("cboConfigurationFile"); } { JButton btnNewConfigurationFile = new JButtonExt("New..."); btnNewConfigurationFile.addActionListener(new BtnNewConfigurationFileActionListener()); pnlConfigurations.add(btnNewConfigurationFile, "cell 0 0, sg btns"); btnNewConfigurationFile.setName("btnNewButton"); } { JButton btnCopy = new JButtonExt("Copy..."); btnCopy.addActionListener(new BtnCopyActionListener()); btnCopy.setName("btnCopy"); pnlConfigurations.add(btnCopy, "cell 0 0, sg btns"); } { JButton btnDelete = new JButtonExt("Delete..."); btnDelete.addActionListener(new BtnDeleteActionListener()); btnDelete.setName("btnDelete"); pnlConfigurations.add(btnDelete, "cell 0 0, sg btns"); } } { JPanel pnlOperations = new JPanel(); getContentPane().add(pnlOperations, "cell 0 1, grow"); pnlOperations.setBorder( new TitledBorder(null, "Operations", TitledBorder.LEADING, TitledBorder.TOP, null, null)); pnlOperations.setName("pnlOperations"); pnlOperations.setLayout(new MigLayout("insets 4", "[grow][110!]", "[][]")); { JScrollPane spOperations = new JScrollPane(); spOperations.setName("spOperations"); pnlOperations.add(spOperations, "cell 0 0 1 2, height 180::, grow"); { tblOperations = new JTableExt(); tblOperations.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tblOperations.setFillsViewportHeight(true); tblOperations.setName("tblOperations"); spOperations.setViewportView(tblOperations); } } { JButton btnAddOperation = new JButtonExt("Add Operation"); btnAddOperation.addActionListener(new BtnAddOperationActionListener()); btnAddOperation.setMargin(new Insets(2, 2, 2, 2)); btnAddOperation.setName("btnAddOperation"); pnlOperations.add(btnAddOperation, "cell 1 0, grow"); } { JButton btnRemoveOperation = new JButtonExt("Delete Operation"); btnRemoveOperation.addActionListener(new BtnRemoveOperationActionListener()); btnRemoveOperation.setMargin(new Insets(2, 2, 2, 2)); btnRemoveOperation.setName("btnRemoveOperation"); pnlOperations.add(btnRemoveOperation, "cell 1 1, growx, top"); } } { JPanel pnlTargets = new JPanel(); getContentPane().add(pnlTargets, "cell 0 2, grow"); pnlTargets.setBorder( new TitledBorder(null, "Targets", TitledBorder.LEADING, TitledBorder.TOP, null, null)); pnlTargets.setName("pnlTargets"); pnlTargets.setLayout(new MigLayout("insets 4", "[grow][110!]", "[][]")); { JScrollPane spTargets = new JScrollPane(); spTargets.setName("spTargets"); pnlTargets.add(spTargets, "cell 0 0 1 2, height 50::, grow"); { tblTargets = new JTableExt(); tblTargets.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tblTargets.setFillsViewportHeight(true); tblTargets.setName("tblTargets"); spTargets.setViewportView(tblTargets); } } { JButton btnAddTarget = new JButtonExt("Add Target"); btnAddTarget.addActionListener(new BtnAddTargetActionListener()); btnAddTarget.setMargin(new Insets(2, 2, 2, 2)); btnAddTarget.setName("btnAddClientConfig"); pnlTargets.add(btnAddTarget, "cell 1 0, growx"); } { JButton btnRemoveTarget = new JButtonExt("Delete Target"); btnRemoveTarget.addActionListener(new BtnRemoveTargetActionListener()); btnRemoveTarget.setMargin(new Insets(2, 2, 2, 2)); btnRemoveTarget.setName("btnRemoveClientConfig"); pnlTargets.add(btnRemoveTarget, "cell 1 1, growx, top"); } } { JPanel pnlClients = new JPanel(); getContentPane().add(pnlClients, "cell 0 3, grow"); pnlClients.setBorder( new TitledBorder(null, "Clients", TitledBorder.LEADING, TitledBorder.TOP, null, null)); pnlClients.setName("pnlClientConfigs"); pnlClients.setLayout(new MigLayout("insets 4", "[grow][110!]", "[][]")); { JScrollPane spClients = new JScrollPane(); spClients.setName("spClients"); pnlClients.add(spClients, "cell 0 0 1 2, height 50::, grow"); { tblClients = new JTableExt(); tblClients.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tblClients.setFillsViewportHeight(true); tblClients.setName("tblClients"); spClients.setViewportView(tblClients); } } { JButton btnAddClient = new JButtonExt("Add Client"); btnAddClient.addActionListener(new BtnAddClientActionListener()); btnAddClient.setMargin(new Insets(2, 2, 2, 2)); btnAddClient.setName("btnAddClient"); pnlClients.add(btnAddClient, "cell 1 0, growx"); } { JButton btnRemoveClient = new JButtonExt("Delete Client"); btnRemoveClient.addActionListener(new BtnRemoveClientActionListener()); btnRemoveClient.setMargin(new Insets(2, 2, 2, 2)); btnRemoveClient.setName("btnRemoveClient"); pnlClients.add(btnRemoveClient, "cell 1 1, growx, top"); } } { JButton btnOk = new JButtonExt("OK"); getRootPane().setDefaultButton(btnOk); btnOk.addActionListener(new BtnOkActionListener()); btnOk.setName("btnOk"); getContentPane().add(btnOk, "cell 0 4,alignx right"); } { JButton btnCancel = new JButtonExt("Cancel"); btnCancel.addActionListener(new BtnCancelActionListener()); btnCancel.setName("btnCancel"); getContentPane().add(btnCancel, "cell 0 4,alignx right"); } }
From source file:eu.apenet.dpt.standalone.gui.eag2012.EagIdentityPanel.java
/** * Builds and answer the editor's tab for the given layout. * @return the editor's panel/*from w w w. ja v a 2s .c om*/ */ protected JComponent buildEditorPanel(List<String> errors) { if (errors == null) errors = new ArrayList<String>(0); else if (Utilities.isDev && errors.size() > 0) { LOG.info("Errors in form:"); for (String error : errors) { LOG.info(error); } } FormLayout layout = new FormLayout("right:max(50dlu;p), 4dlu, 100dlu, 7dlu, right:p, 4dlu, 100dlu", EDITOR_ROW_SPEC); layout.setColumnGroups(new int[][] { { 1, 3, 5, 7 } }); PanelBuilder builder = new PanelBuilder(layout); builder.setDefaultDialogBorder(); CellConstraints cc = new CellConstraints(); rowNb = 1; builder.addLabel(labels.getString("eag2012.commons.countryCode") + "*", cc.xy(1, rowNb)); builder.addLabel(eag.getArchguide().getIdentity().getRepositorid().getCountrycode(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.idUsedInApe"), cc.xy(5, rowNb)); builder.addLabel(eag.getControl().getRecordId().getValue(), cc.xy(7, rowNb)); setNextRow(); for (OtherRecordId otherRecordId : eag.getControl().getOtherRecordId()) { builder.addLabel(labels.getString("eag2012.control.identifierInstitution"), cc.xy(1, rowNb)); builder.addLabel(otherRecordId.getValue(), cc.xy(3, rowNb)); setNextRow(); } // name of the institution nameInstitutionTfs = new ArrayList<TextFieldWithLanguage>( eag.getArchguide().getIdentity().getAutform().size()); int loop = 0; for (Autform autform : eag.getArchguide().getIdentity().getAutform()) { TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(autform.getContent(), autform.getLang()); nameInstitutionTfs.add(textFieldWithLanguage); if (loop++ == 0) { builder.addLabel(labels.getString("eag2012.commons.nameOfInstitution") + "*", cc.xy(1, rowNb)); textFieldWithLanguage.getTextField().setEnabled(false); } else { builder.addLabel(labels.getString("eag2012.commons.nameOfInstitution"), cc.xy(1, rowNb)); } builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb)); setNextRow(); } JButton addNewNameInstitutionBtn = new ButtonTab(labels.getString("eag2012.identity.addAnotherForm")); addNewNameInstitutionBtn.addActionListener(new AddNameInstitutionAction(eag, tabbedPane, model)); builder.add(addNewNameInstitutionBtn, cc.xy(1, rowNb)); setNextRow(); parallelNameTfs = new ArrayList<TextFieldWithLanguage>( eag.getArchguide().getIdentity().getParform().size()); loop = 0; for (Parform parform : eag.getArchguide().getIdentity().getParform()) { TextFieldWithLanguage textFieldWithLanguage = new TextFieldWithLanguage(parform.getContent(), parform.getLang()); parallelNameTfs.add(textFieldWithLanguage); if (loop++ == 0 && StringUtils.isNotEmpty(textFieldWithLanguage.getTextValue())) textFieldWithLanguage.getTextField().setEnabled(false); builder.addLabel(labels.getString("eag2012.commons.parallelNameOfInstitution"), cc.xy(1, rowNb)); builder.add(textFieldWithLanguage.getTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(textFieldWithLanguage.getLanguageBox(), cc.xy(7, rowNb)); setNextRow(); } JButton addNewParallelNameInstitutionBtn = new ButtonTab( labels.getString("eag2012.identity.addAnotherParallelName")); addNewParallelNameInstitutionBtn .addActionListener(new AddParallelNameInstitutionAction(eag, tabbedPane, model)); builder.add(addNewParallelNameInstitutionBtn, cc.xy(1, rowNb)); setNextRow(); formerlyUsedNameTfs = new ArrayList<FormerlyUsedName>( eag.getArchguide().getIdentity().getNonpreform().size()); for (int formerNameCounter = 0; formerNameCounter < eag.getArchguide().getIdentity().getNonpreform() .size(); formerNameCounter++) { Nonpreform nonpreform = eag.getArchguide().getIdentity().getNonpreform().get(formerNameCounter); String nameStr = ""; for (int i = 0; i < nonpreform.getContent().size(); i++) { Object object = nonpreform.getContent().get(i); if (object instanceof String) { nameStr += (String) object; } if (object instanceof UseDates) { UseDates useDates = (UseDates) object; if (useDates.getDateSet() != null) { datesForFormerlyUsedName = new ArrayList<TextFieldWithDate>( useDates.getDateSet().getDateOrDateRange().size()); for (Object object1 : useDates.getDateSet().getDateOrDateRange()) { if (object1 instanceof eu.apenet.dpt.utils.eag2012.Date) { TextFieldWithDate textFieldWithDate = new TextFieldWithDate("", "", "", "", ((eu.apenet.dpt.utils.eag2012.Date) object1).getContent()); datesForFormerlyUsedName.add(textFieldWithDate); } if (object1 instanceof DateRange) { TextFieldWithDate textFieldWithDate = new TextFieldWithDate("", "", ((DateRange) object1).getFromDate().getContent(), ((DateRange) object1).getToDate().getContent(), ""); textFieldWithDate.setDateRange(true); datesForFormerlyUsedName.add(textFieldWithDate); } } } else { datesForFormerlyUsedName = new ArrayList<TextFieldWithDate>(); if (useDates.getDate() != null) { TextFieldWithDate textFieldWithDate = new TextFieldWithDate("", "", "", "", useDates.getDate().getContent()); datesForFormerlyUsedName.add(textFieldWithDate); } if (useDates.getDateRange() != null) { TextFieldWithDate textFieldWithDate = new TextFieldWithDate("", "", useDates.getDateRange().getFromDate().getContent(), useDates.getDateRange().getToDate().getContent(), ""); textFieldWithDate.setDateRange(true); datesForFormerlyUsedName.add(textFieldWithDate); } } } } if (datesForFormerlyUsedName.isEmpty()) datesForFormerlyUsedName.add(new TextFieldWithDate("", "", "", "", "")); FormerlyUsedName formerlyUsedName = new FormerlyUsedName(nameStr, nonpreform.getLang(), datesForFormerlyUsedName); formerlyUsedName.setOrderInXmlFile(formerNameCounter); formerlyUsedNameTfs.add(formerlyUsedName); builder.addLabel(labels.getString("eag2012.identity.previousNameOfArchive"), cc.xy(1, rowNb)); builder.add(formerlyUsedName.getNameTextField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.language"), cc.xy(5, rowNb)); builder.add(formerlyUsedName.getLanguageBox(), cc.xy(7, rowNb)); setNextRow(); builder.addLabel(labels.getString("eag2012.identity.yearsOfUsedName"), cc.xy(1, rowNb)); setNextRow(); for (TextFieldWithDate textFieldWithDate : datesForFormerlyUsedName) { if (!textFieldWithDate.isDateRange()) { builder.addLabel(labels.getString("eag2012.commons.year"), cc.xy(1, rowNb)); builder.add(textFieldWithDate.getDateField(), cc.xy(3, rowNb)); setNextRow(); } else { builder.addLabel(labels.getString("eag2012.commons.year") + " " + labels.getString("eag2012.commons.from"), cc.xy(1, rowNb)); builder.add(textFieldWithDate.getFromDateField(), cc.xy(3, rowNb)); builder.addLabel(labels.getString("eag2012.commons.to"), cc.xy(5, rowNb)); builder.add(textFieldWithDate.getToDateField(), cc.xy(7, rowNb)); setNextRow(); } } if (!formerlyUsedNameTfs.isEmpty()) { JButton addSingleYearBtn = new ButtonTab(labels.getString("eag2012.commons.addYearButton")); addSingleYearBtn.setName("formerName_addSingleBtn_" + formerNameCounter); addSingleYearBtn.addActionListener(new AddSingleYearAction(eag, tabbedPane, model)); builder.add(addSingleYearBtn, cc.xy(1, rowNb)); JButton addYearRangeBtn = new ButtonTab(labels.getString("eag2012.commons.addYearRangeButton")); addYearRangeBtn.setName("formerName_addYearRangeBtn_" + formerNameCounter); addYearRangeBtn.addActionListener(new AddYearRangeAction(eag, tabbedPane, model)); builder.add(addYearRangeBtn, cc.xy(3, rowNb)); setNextRow(); } } JButton addNewNonpreNameInstitutionBtn = new ButtonTab( labels.getString("eag2012.identity.addAnotherFormerlyUsedName")); addNewNonpreNameInstitutionBtn .addActionListener(new AddNonpreNameInstitutionAction(eag, tabbedPane, model)); builder.add(addNewNonpreNameInstitutionBtn, cc.xy(1, rowNb)); setNextRow(); //print repositoryType combo if (eag.getArchguide().getIdentity().getRepositoryType() != null && !eag.getArchguide().getIdentity().getRepositoryType().isEmpty()) { for (RepositoryType repoType : eag.getArchguide().getIdentity().getRepositoryType()) { builder.addLabel(labels.getString("eag2012.identity.selectType"), cc.xy(1, rowNb)); JComboBox comboBox = new JComboBox(typeInstitution); if (repoType.getValue() != null && !repoType.getValue().isEmpty()) { comboBox.setSelectedItem(repoType.getValue()); } else { comboBox.setSelectedItem("---"); } typeInstitutionComboList.add(comboBox); builder.add(comboBox, cc.xy(3, rowNb)); setNextRow(); } } else { builder.addLabel(labels.getString("eag2012.identity.selectType"), cc.xy(1, rowNb)); JComboBox comboBox = new JComboBox(typeInstitution); comboBox.setSelectedItem("---"); typeInstitutionComboList.add(comboBox); builder.add(comboBox, cc.xy(3, rowNb)); setNextRow(); } //add another repositoryType button JButton addNewTypeOfTheInstitution = new ButtonTab( labels.getString("eag2012.identity.addAnotherRepositoryType")); addNewTypeOfTheInstitution.addActionListener(new AddRepositoryTypeAction(eag, tabbedPane, model)); builder.add(addNewTypeOfTheInstitution, cc.xy(1, rowNb)); setNextRow(); builder.addSeparator("", cc.xyw(1, rowNb, 7)); setNextRow(); JButton exitBtn = new ButtonTab(labels.getString("eag2012.commons.exit")); builder.add(exitBtn, cc.xy(1, rowNb)); exitBtn.addActionListener(new ExitBtnAction(eag, tabbedPane, model)); JButton previousTabBtn = new ButtonTab(labels.getString("eag2012.commons.previousTab")); builder.add(previousTabBtn, cc.xy(3, rowNb)); previousTabBtn.addActionListener(new ChangeTabBtnAction(eag, tabbedPane, model, false)); JButton nextTabBtn = new ButtonTab(labels.getString("eag2012.commons.nextTab")); builder.add(nextTabBtn, cc.xy(5, rowNb)); nextTabBtn.addActionListener(new ChangeTabBtnAction(eag, tabbedPane, model, true)); setNextRow(); JButton saveBtn = new ButtonTab(labels.getString("eag2012.commons.save")); builder.add(saveBtn, cc.xy(5, rowNb)); saveBtn.addActionListener(new SaveBtnAction(eag, tabbedPane, model)); setNextRow(); builder.addSeparator("", cc.xyw(1, rowNb, 7)); setNextRow(); JButton nextInstitutionTabBtn = new ButtonTab(labels.getString("eag2012.controls.nextInstitution")); nextInstitutionTabBtn.addActionListener(new NextInstitutionTabBtnAction(eag, tabbedPane, model)); builder.add(nextInstitutionTabBtn, cc.xy(5, rowNb)); // Define the change tab listener. this.removeChangeListener(); this.tabbedPane.addChangeListener(new ChangeTabListener(this.eag, this.tabbedPane, this.model, 1)); JPanel panel = builder.getPanel(); KeyboardFocusManager.getCurrentKeyboardFocusManager() .addPropertyChangeListener(new FocusManagerListener(panel)); return panel; }