List of usage examples for javax.swing ButtonGroup add
public void add(AbstractButton b)
From source file:edu.ku.brc.specify.plugins.ipadexporter.InstitutionConfigDlg.java
private JPanel createURLPanel() { //setTitle(getResourceString("IMAGE_SRC_TITLE")); useAttachTitle = getResourceString("ATTCH_MGR"); useDirectTitle = getResourceString("DIR_URL"); CellConstraints cc = new CellConstraints(); PanelBuilder pb = new PanelBuilder(new FormLayout("p,2px,p,f:p:g", "p,4px,p,4px,p,4px,p,4px,p,4px")); label = createLabel(useAttachTitle + ":"); urlTextField = new ValTextField(40); statusLbl = createLabel(""); useAttchmentMgrRB = createI18NRadioButton("USE_ATT_MGR"); useDirectUrlRB = createI18NRadioButton("USE_DIR_URL"); int y = 1;/* ww w . jav a 2s .co m*/ pb.add(createI18NLabel("HOW_IMG_ACCESS"), cc.xy(1, y)); y += 2; pb.add(useAttchmentMgrRB, cc.xyw(1, y, 4)); y += 2; pb.add(useDirectUrlRB, cc.xyw(1, y, 4)); y += 2; PanelBuilder pbInner = new PanelBuilder(new FormLayout("p,2px,f:p:g", "p")); pbInner.add(label, cc.xy(1, 1)); pbInner.add(urlTextField, cc.xy(3, 1)); pb.add(pbInner.getPanel(), cc.xyw(1, y, 4)); y += 2; pb.add(statusLbl, cc.xyw(1, y, 4)); y += 2; pb.setDefaultDialogBorder(); KeyAdapter ka = new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { updateOKBtn(); } }; urlTextField.addKeyListener(ka); super.createUI(); ButtonGroup group = new ButtonGroup(); group.add(useAttchmentMgrRB); group.add(useDirectUrlRB); ActionListener al = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { radBtnSelected(); } }; useAttchmentMgrRB.addActionListener(al); useDirectUrlRB.addActionListener(al); // Set Data into form or initialize it String typeStr = AppPreferences.getRemote().get(getRemoteImageURLTypePrefName(), null); String imgURLPath = AppPreferences.getRemote().get(getRemoteImageURLPrefName(), null); //System.out.println(String.format("%s=%s", getRemoteImageURLTypePrefName(), typeStr)); //System.out.println(String.format("%s=%s", getRemoteImageURLPrefName(), imgURLPath)); if (isNotEmpty(typeStr) && isNotEmpty(imgURLPath)) { urlTextField.setText(imgURLPath); boolean isAttachMgr = isNotEmpty(typeStr) && typeStr.equals(ATTMGR); useAttchmentMgrRB.setSelected(isAttachMgr); useDirectUrlRB.setSelected(!isAttachMgr); } else { fillWithDefaultAttMgr(); } return pb.getPanel(); }
From source file:net.erdfelt.android.sdkfido.ui.SdkFidoFrame.java
private JMenu createViewMenu() { JMenu viewMenu = new JMenu("View"); viewMenu.setMnemonic('v'); JMenu lnfMenu = new JMenu("Look and Feel"); lnfMenu.setMnemonic('f'); ButtonGroup lnfGroup = new ButtonGroup(); LookAndFeelInfo lnfs[] = UIManager.getInstalledLookAndFeels(); String lnfCurrentName = null; LookAndFeel lnfCurrent = UIManager.getLookAndFeel(); if (lnfCurrent != null) { lnfCurrentName = lnfCurrent.getClass().getName(); }//from w ww .j av a 2 s. c o m UISwitcher switcher = new UISwitcher(); for (int i = 0; i < lnfs.length; i++) { JRadioButtonMenuItem lnfItem = new JRadioButtonMenuItem(lnfs[i].getName()); lnfItem.addActionListener(switcher); lnfItem.setActionCommand(lnfs[i].getClassName()); lnfGroup.add(lnfItem); lnfMenu.add(lnfItem); if (lnfs[i].getClassName().equals(lnfCurrentName)) { lnfGroup.setSelected(lnfItem.getModel(), true); } } viewMenu.add(lnfMenu); return viewMenu; }
From source file:com.googlecode.commons.swing.component.datetime.MiniDateCalendar.java
private void init() { final DateFormatSymbols dfs = new DateFormatSymbols(locale); CollectionUtils.addAll(this.weekdays, dfs.getShortWeekdays()); for (int i = 0; i < 7; i++) { orderedWeekdays.add(((i + weekDayStart - 1) % 7) + 1); }//from w ww . j av a2 s .c o m setLayout(new BorderLayout()); SizeUtils.setAllWidths(this, 150); SizeUtils.setAllHeights(this, 180); panNorth = new JPanel(new BorderLayout()); add(panNorth, BorderLayout.NORTH); btnPrev = new JButton(); SizeUtils.setAllWidths(btnPrev, 18); SizeUtils.setAllHeights(btnPrev, 18); btnPrev.setIcon(DefaultIcons.resultset_previous()); btnPrev.setMargin(new Insets(0, 0, 0, 0)); btnPrev.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onClickPrev(); } }); panNorth.add(btnPrev, BorderLayout.WEST); lblMonth = new JLabel(); SizeUtils.setMinHeight(lblMonth, 0); SizeUtils.setPreferredHeight(lblMonth, 0); lblMonth.setHorizontalAlignment(SwingConstants.CENTER); panNorth.add(lblMonth, BorderLayout.CENTER); btnNext = new JButton(); btnNext.setIcon(DefaultIcons.resultset_next()); SizeUtils.setAllWidths(btnNext, 18); SizeUtils.setAllHeights(btnNext, 18); btnNext.setMargin(new Insets(0, 0, 0, 0)); btnNext.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onClickNext(); } }); panNorth.add(btnNext, BorderLayout.EAST); panCenter = new JPanel(); panCenter.setLayout(new GridLayout(7, 7)); add(panCenter, BorderLayout.CENTER); for (int col = 0; col < 7; col++) { JLabel lblDay = new JLabel(weekdays.get(orderedWeekdays.get(col))); lblDay.setHorizontalAlignment(SwingConstants.CENTER); panCenter.add(lblDay); } ButtonGroup grp = new ButtonGroup(); for (int row = 0; row < 6; row++) { for (int col = 0; col < 7; col++) { final int day = orderedWeekdays.get(col); final DayButton btn = createDayButton(day, weekdays.get(day)); btn.setMargin(new Insets(0, 0, 0, 0)); btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onClickDay(btn.value); } }); days.add(btn); grp.add(btn); panCenter.add(btn); } } refresh(); }
From source file:GraficasForm.java
/** * Creates new form GraficasForm/*w ww .j a v a 2 s.c o m*/ */ public GraficasForm() { XYLineChartExample chart; initComponents(); Record r = new Record(); fileCandidatos = r.readFile("Candidates.txt"); filePartidos = r.readFile("Parties.txt"); ButtonGroup group = new ButtonGroup(); group.add(candidatosRadio); group.add(partidosRadio); candidatosCB.add(lincolnChaffeeCB); candidatosCB.add(hillaryClintonCB); candidatosCB.add(martinOMalleyCB); candidatosCB.add(bernieSandersCB); candidatosCB.add(jimWebbCB); candidatosCB.add(randPaulCB); candidatosCB.add(jebBushCB); candidatosCB.add(benCarsonCB); candidatosCB.add(chrisChristieCB); candidatosCB.add(tedCruzCB); candidatosCB.add(carlyFiorinaCB); candidatosCB.add(lindseyGrahamCB); candidatosCB.add(bobbyJindalCB); candidatosCB.add(johnKasichCB); candidatosCB.add(georgePatakiCB); candidatosCB.add(marcoRubioCB); candidatosCB.add(rickSantorumCB); candidatosCB.add(donaldTrumpCB); partidosCB.add(democrataCB); partidosCB.add(republicanoCB); partidosRadio.setSelected(true); partidosCB.elementAt(0).setSelected(true); partidosCB.elementAt(1).setSelected(true); for (int i = 0; i < candidatosCB.size(); ++i) { candidatosCB.elementAt(i).setEnabled(false); candidatosCB.elementAt(i).setSelected(false); } Vector<String> keys = new Vector<String>(); keys.add("Democrat"); keys.add("Republican"); chart = new XYLineChartExample(); panelGrafica.add(chart.createChartPanel(keys), BorderLayout.CENTER); panelGrafica.revalidate(); panelGrafica.repaint(); //panelGrafica = chart.createChartPanel(); //add(panelGrafica); }
From source file:it.iit.genomics.cru.igb.bundles.mi.view.StructuresPanel.java
public StructuresPanel(IgbService service, String label) { super("MI Structures", "MI Structures", "Display structure", true); igbLogger = IGBLogger.getInstance(label); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // Create hidden JmolFrame jmolFrame = new JFrame(); jmolPanel = new JmolPanel(); jmolPanel.setPreferredSize(new Dimension(500, 500)); Box jmolBox = new Box(BoxLayout.Y_AXIS); Box jmolButtonBox = new Box(BoxLayout.X_AXIS); jmolFrame.add(jmolBox);/* ww w .j ava 2s . c o m*/ jmolBox.add(jmolPanel); jmolBox.add(jmolButtonBox); jmolButtonBox.add(new JLabel("Display type:")); ButtonGroup displayGroup = new ButtonGroup(); JRadioButton cartoonButton = new JRadioButton(JMOL_DISPLAY_CARTOON); JRadioButton ballAndSticksButton = new JRadioButton(JMOL_DISPLAY_BALL_AND_STICK); JmolDisplayListener listener = new JmolDisplayListener(); cartoonButton.addActionListener(listener); ballAndSticksButton.addActionListener(listener); displayGroup.add(cartoonButton); displayGroup.add(ballAndSticksButton); jmolButtonBox.add(cartoonButton); jmolButtonBox.add(ballAndSticksButton); ballAndSticksButton.setSelected(true); jmolFrame.pack(); jmolFrame.setVisible(false); jmolButton.addActionListener(new JmolActionListener()); jmolButton.setIcon(new ImageIcon(getClass().getResource("/jmol.jpg"))); linkButton.addActionListener(new ExternalLinkActionListener()); linkButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/searchweb.png")); StructureTableModel model = new StructureTableModel(new ArrayList<StructureItem>(0)); structureList = new StructureTable(model, service); structureList.setTableHeader(null); structureList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane structureListPane = new JScrollPane(structureList); add(structureListPane); }
From source file:lab4.YouQuiz.java
private void updateAnswerForm() { contentPanel.answerPanel.removeAll(); final Question question = questionsArray.get(questionIndex); switch (question.type) { case Question.QUESTION_TYPE_MULTIPLE_CHOICE: case Question.QUESTION_TYPE_TRUE_FALSE: JRadioButton radioButton; final ButtonGroup radioGroup = new ButtonGroup(); for (int i = 0; i < ((MultipleChoiceQuestion) question).getChoices().size(); ++i) { radioButton = new JRadioButton(((MultipleChoiceQuestion) question).getChoices().get(i)); radioButton.setFont(new Font("Consolas", Font.PLAIN, 20)); radioGroup.add(radioButton); radioButton.setFocusable(false); contentPanel.answerPanel.add(radioButton); }/*from w w w . j a v a2 s .c o m*/ for (ActionListener al : contentPanel.checkButton.getActionListeners()) { contentPanel.checkButton.removeActionListener(al); } contentPanel.checkButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (question.checkAnswer(getSelectedButtonText(radioGroup))) { JOptionPane.showMessageDialog(null, "Thats Great, Correct Answer", "Excellent", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Oops! Wrong Answer. Its '" + question.getAnswer().get(0) + "'", "Sorry", JOptionPane.ERROR_MESSAGE); } } }); break; case Question.QUESTION_TYPE_SHORT_ANSWER: final JTextField answerText = new JTextField(25); answerText.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 20)); contentPanel.answerPanel.add(answerText); for (ActionListener al : contentPanel.checkButton.getActionListeners()) { contentPanel.checkButton.removeActionListener(al); } contentPanel.checkButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { if (question.checkAnswer(answerText.getText())) { JOptionPane.showMessageDialog(null, "Thats Great, Correct Answer", "Excellent", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "Oops! Wrong Answer. Its '" + question.getAnswer().get(0) + "'", "Sorry", JOptionPane.ERROR_MESSAGE); } } }); break; } contentPanel.answerPanel.invalidate(); }
From source file:cool.pandora.modeller.ui.jpanel.base.SaveBagFrame.java
private JPanel createComponents() { final Border border = new EmptyBorder(5, 5, 5, 5); final TitlePane titlePane = new TitlePane(); initStandardCommands();//from w w w . ja v a2s.c om final JPanel pageControl = new JPanel(new BorderLayout()); final JPanel titlePaneContainer = new JPanel(new BorderLayout()); titlePane.setTitle(bagView.getPropertyMessage("SaveBagFrame.title")); titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("Define the Bag " + "settings"))); titlePaneContainer.add(titlePane.getControl()); titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH); pageControl.add(titlePaneContainer, BorderLayout.NORTH); final JPanel contentPane = new JPanel(); // TODO: Add bag name field // TODO: Add save name file selection button final JLabel location = new JLabel("Save in:"); final JButton browseButton = new JButton(getMessage("bag.button.browse")); browseButton.addActionListener(new SaveBagAsHandler()); browseButton.setEnabled(true); browseButton.setToolTipText(getMessage("bag.button.browse.help")); final DefaultBag bag = bagView.getBag(); if (bag != null) { bagNameField = new JTextField(bag.getName()); bagNameField.setCaretPosition(bag.getName().length()); bagNameField.setEditable(false); bagNameField.setEnabled(false); } // Holey bag control final JLabel holeyLabel = new JLabel(bagView.getPropertyMessage("bag.label.isholey")); holeyLabel.setToolTipText(bagView.getPropertyMessage("bag.isholey.help")); final JCheckBox holeyCheckbox = new JCheckBox(bagView.getPropertyMessage("bag.checkbox" + ".isholey")); holeyCheckbox.setBorder(border); holeyCheckbox.addActionListener(new HoleyBagHandler()); holeyCheckbox.setToolTipText(bagView.getPropertyMessage("bag.isholey.help")); urlLabel = new JLabel(bagView.getPropertyMessage("baseURL.label")); urlLabel.setToolTipText(bagView.getPropertyMessage("baseURL.description")); urlField = new JTextField(""); try { assert bag != null; urlField.setText(bag.getFetch().getBaseURL()); } catch (Exception e) { log.error("Failed to set url label", e); } urlField.setEnabled(false); // TODO: Add format label final JLabel serializeLabel; serializeLabel = new JLabel(getMessage("bag.label.ispackage")); serializeLabel.setToolTipText(getMessage("bag.serializetype.help")); // TODO: Add format selection panel noneButton = new JRadioButton(getMessage("bag.serializetype.none")); noneButton.setEnabled(true); final AbstractAction serializeListener = new SerializeBagHandler(); noneButton.addActionListener(serializeListener); noneButton.setToolTipText(getMessage("bag.serializetype.none.help")); zipButton = new JRadioButton(getMessage("bag.serializetype.zip")); zipButton.setEnabled(true); zipButton.addActionListener(serializeListener); zipButton.setToolTipText(getMessage("bag.serializetype.zip.help")); /* * tarButton = new JRadioButton(getMessage("bag.serializetype.tar")); * tarButton.setEnabled(true); * tarButton.addActionListener(serializeListener); * tarButton.setToolTipText(getMessage("bag.serializetype.tar.help")); * * tarGzButton = new JRadioButton(getMessage("bag.serializetype.targz")); * tarGzButton.setEnabled(true); * tarGzButton.addActionListener(serializeListener); * tarGzButton.setToolTipText(getMessage("bag.serializetype.targz.help")); * * tarBz2Button = new JRadioButton(getMessage("bag.serializetype.tarbz2")); * tarBz2Button.setEnabled(true); * tarBz2Button.addActionListener(serializeListener); * tarBz2Button.setToolTipText(getMessage("bag.serializetype.tarbz2.help")); */ short mode = 2; if (bag != null) { mode = bag.getSerialMode(); } if (mode == DefaultBag.NO_MODE) { this.noneButton.setEnabled(true); } else if (mode == DefaultBag.ZIP_MODE) { this.zipButton.setEnabled(true); } else { this.noneButton.setEnabled(true); } final ButtonGroup serializeGroup = new ButtonGroup(); serializeGroup.add(noneButton); serializeGroup.add(zipButton); // serializeGroup.add(tarButton); // serializeGroup.add(tarGzButton); // serializeGroup.add(tarBz2Button); final JPanel serializeGroupPanel = new JPanel(new FlowLayout()); serializeGroupPanel.add(serializeLabel); serializeGroupPanel.add(noneButton); serializeGroupPanel.add(zipButton); // serializeGroupPanel.add(tarButton); // serializeGroupPanel.add(tarGzButton); // serializeGroupPanel.add(tarBz2Button); serializeGroupPanel.setBorder(border); serializeGroupPanel.setEnabled(true); serializeGroupPanel.setToolTipText(bagView.getPropertyMessage("bag.serializetype.help")); final JLabel tagLabel = new JLabel(getMessage("bag.label.istag")); tagLabel.setToolTipText(getMessage("bag.label.istag.help")); final JCheckBox isTagCheckbox = new JCheckBox(); isTagCheckbox.setBorder(border); isTagCheckbox.addActionListener(new TagManifestHandler()); isTagCheckbox.setToolTipText(getMessage("bag.checkbox.istag.help")); final JLabel tagAlgorithmLabel = new JLabel(getMessage("bag.label.tagalgorithm")); tagAlgorithmLabel.setToolTipText(getMessage("bag.label.tagalgorithm.help")); final ArrayList<String> listModel = new ArrayList<>(); for (final Algorithm algorithm : Algorithm.values()) { listModel.add(algorithm.bagItAlgorithm); } final JComboBox<String> tagAlgorithmList = new JComboBox<>(listModel.toArray(new String[listModel.size()])); tagAlgorithmList.setName(getMessage("bag.tagalgorithmlist")); tagAlgorithmList.addActionListener(new TagAlgorithmListHandler()); tagAlgorithmList.setToolTipText(getMessage("bag.tagalgorithmlist.help")); final JLabel payloadLabel = new JLabel(getMessage("bag.label.ispayload")); payloadLabel.setToolTipText(getMessage("bag.ispayload.help")); final JCheckBox isPayloadCheckbox = new JCheckBox(); isPayloadCheckbox.setBorder(border); isPayloadCheckbox.addActionListener(new PayloadManifestHandler()); isPayloadCheckbox.setToolTipText(getMessage("bag.ispayload.help")); final JLabel payAlgorithmLabel = new JLabel(bagView.getPropertyMessage("bag.label" + ".payalgorithm")); payAlgorithmLabel.setToolTipText(getMessage("bag.payalgorithm.help")); final JComboBox<String> payAlgorithmList = new JComboBox<String>( listModel.toArray(new String[listModel.size()])); payAlgorithmList.setName(getMessage("bag.payalgorithmlist")); payAlgorithmList.addActionListener(new PayAlgorithmListHandler()); payAlgorithmList.setToolTipText(getMessage("bag.payalgorithmlist.help")); //only if bag is not null if (bag != null) { final String fileName = bag.getName(); bagNameField = new JTextField(fileName); bagNameField.setCaretPosition(fileName.length()); holeyCheckbox.setSelected(bag.isHoley()); urlLabel.setEnabled(bag.isHoley()); isTagCheckbox.setSelected(bag.isBuildTagManifest()); tagAlgorithmList.setSelectedItem(bag.getTagManifestAlgorithm()); isPayloadCheckbox.setSelected(bag.isBuildPayloadManifest()); payAlgorithmList.setSelectedItem(bag.getPayloadManifestAlgorithm()); } final GridBagLayout layout = new GridBagLayout(); final GridBagConstraints glbc = new GridBagConstraints(); final JPanel panel = new JPanel(layout); panel.setBorder(new EmptyBorder(10, 10, 10, 10)); int row = 0; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(location, glbc); panel.add(location); buildConstraints(glbc, 2, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.EAST); glbc.ipadx = 5; layout.setConstraints(browseButton, glbc); glbc.ipadx = 0; panel.add(browseButton); buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); glbc.ipadx = 5; layout.setConstraints(bagNameField, glbc); glbc.ipadx = 0; panel.add(bagNameField); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(holeyLabel, glbc); panel.add(holeyLabel); buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.WEST, GridBagConstraints.WEST); layout.setConstraints(holeyCheckbox, glbc); panel.add(holeyCheckbox); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(urlLabel, glbc); panel.add(urlLabel); buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(urlField, glbc); panel.add(urlField); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(serializeLabel, glbc); panel.add(serializeLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); layout.setConstraints(serializeGroupPanel, glbc); panel.add(serializeGroupPanel); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(tagLabel, glbc); panel.add(tagLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(isTagCheckbox, glbc); panel.add(isTagCheckbox); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(tagAlgorithmLabel, glbc); panel.add(tagAlgorithmLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(tagAlgorithmList, glbc); panel.add(tagAlgorithmList); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(payloadLabel, glbc); panel.add(payloadLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(isPayloadCheckbox, glbc); panel.add(isPayloadCheckbox); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(payAlgorithmLabel, glbc); panel.add(payAlgorithmLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(payAlgorithmList, glbc); panel.add(payAlgorithmList); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); GuiStandardUtils.attachDialogBorder(contentPane); pageControl.add(panel); final JComponent buttonBar = createButtonBar(); pageControl.add(buttonBar, BorderLayout.SOUTH); this.pack(); return pageControl; }
From source file:TexBug.java
JPanel texture2DPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridLayout(1, 0)); // horizontal JPanel leftPanel = new JPanel(); leftPanel.setLayout(new GridLayout(0, 1)); // vertical panel.add(leftPanel);/*from www. j ava 2 s .com*/ JPanel rightPanel = new JPanel(); rightPanel.setLayout(new GridLayout(0, 1)); // vertical panel.add(rightPanel); texEnableCheckBox = new JCheckBox(texEnableString); // set up the action commands texEnableCheckBox.setActionCommand(texEnableString); // register the applet as the listener for the buttons texEnableCheckBox.addActionListener(this); // set the initial value texEnableCheckBox.setSelected(texEnable); // add the checkbox to the panel leftPanel.add(texEnableCheckBox); // texture boundary S leftPanel.add(new JLabel("Boundary S Mode:")); // create the buttons JRadioButton texBoundarySWrapButton = new JRadioButton(wrapString); JRadioButton texBoundarySClampButton = new JRadioButton(clampString); // set up the action commands texBoundarySWrapButton.setActionCommand(texBoundarySWrapString); texBoundarySClampButton.setActionCommand(texBoundarySClampString); // add the buttons to a group so that only one can be selected ButtonGroup boundSButtonGroup = new ButtonGroup(); boundSButtonGroup.add(texBoundarySWrapButton); boundSButtonGroup.add(texBoundarySClampButton); // register the applet as the listener for the buttons texBoundarySWrapButton.addActionListener(this); texBoundarySClampButton.addActionListener(this); // add the buttons to the panel leftPanel.add(texBoundarySWrapButton); leftPanel.add(texBoundarySClampButton); // set the default texBoundarySWrapButton.setSelected(true); // texture boundary T leftPanel.add(new JLabel("Boundary T Mode:")); // create the buttons JRadioButton texBoundaryTWrapButton = new JRadioButton(wrapString); JRadioButton texBoundaryTClampButton = new JRadioButton(clampString); // set up the action commands texBoundaryTWrapButton.setActionCommand(texBoundaryTWrapString); texBoundaryTClampButton.setActionCommand(texBoundaryTClampString); // add the buttons to a group so that only one can be selected ButtonGroup boundTButtonGroup = new ButtonGroup(); boundTButtonGroup.add(texBoundaryTWrapButton); boundTButtonGroup.add(texBoundaryTClampButton); // register the applet as the listener for the buttons texBoundaryTWrapButton.addActionListener(this); texBoundaryTClampButton.addActionListener(this); // add the buttons to the panel leftPanel.add(texBoundaryTWrapButton); leftPanel.add(texBoundaryTClampButton); // set the default texBoundaryTWrapButton.setSelected(true); // texture min filter rightPanel.add(new JLabel("Min Filter:")); // create the buttons JRadioButton texMinFilterBasePointButton = new JRadioButton(texFilterBasePointString); JRadioButton texMinFilterBaseLinearButton = new JRadioButton(texFilterBaseLinearString); JRadioButton texMinFilterMultiPointButton = new JRadioButton(texFilterMultiPointString); JRadioButton texMinFilterMultiLinearButton = new JRadioButton(texFilterMultiLinearString); JRadioButton texMinFilterNicestButton = new JRadioButton(nicestString); JRadioButton texMinFilterFastestButton = new JRadioButton(fastestString); // set up the action commands texMinFilterBasePointButton.setActionCommand(texMinFilterBasePointString); texMinFilterBaseLinearButton.setActionCommand(texMinFilterBaseLinearString); texMinFilterMultiPointButton.setActionCommand(texMinFilterMultiPointString); texMinFilterMultiLinearButton.setActionCommand(texMinFilterMultiLinearString); texMinFilterNicestButton.setActionCommand(texMinFilterNicestString); texMinFilterFastestButton.setActionCommand(texMinFilterFastestString); // add the buttons to a group so that only one can be selected ButtonGroup minFilterButtonGroup = new ButtonGroup(); minFilterButtonGroup.add(texMinFilterBasePointButton); minFilterButtonGroup.add(texMinFilterBaseLinearButton); minFilterButtonGroup.add(texMinFilterMultiPointButton); minFilterButtonGroup.add(texMinFilterMultiLinearButton); minFilterButtonGroup.add(texMinFilterNicestButton); minFilterButtonGroup.add(texMinFilterFastestButton); // register the applet as the listener for the buttons texMinFilterBasePointButton.addActionListener(this); texMinFilterBaseLinearButton.addActionListener(this); texMinFilterMultiPointButton.addActionListener(this); texMinFilterMultiLinearButton.addActionListener(this); texMinFilterNicestButton.addActionListener(this); texMinFilterFastestButton.addActionListener(this); // add the buttons to the panel rightPanel.add(texMinFilterBasePointButton); rightPanel.add(texMinFilterBaseLinearButton); rightPanel.add(texMinFilterMultiPointButton); rightPanel.add(texMinFilterMultiLinearButton); rightPanel.add(texMinFilterNicestButton); rightPanel.add(texMinFilterFastestButton); // set the default texMinFilterBasePointButton.setSelected(true); // texture max filter rightPanel.add(new JLabel("Mag Filter:")); // create the buttons JRadioButton texMagFilterBasePointButton = new JRadioButton(texFilterBasePointString); JRadioButton texMagFilterBaseLinearButton = new JRadioButton(texFilterBaseLinearString); JRadioButton texMagFilterNicestButton = new JRadioButton(nicestString); JRadioButton texMagFilterFastestButton = new JRadioButton(fastestString); // set up the action commands texMagFilterBasePointButton.setActionCommand(texMagFilterBasePointString); texMagFilterBaseLinearButton.setActionCommand(texMagFilterBaseLinearString); texMagFilterNicestButton.setActionCommand(texMagFilterNicestString); texMagFilterFastestButton.setActionCommand(texMagFilterFastestString); // add the buttons to a group so that only one can be selected ButtonGroup magFilterButtonGroup = new ButtonGroup(); magFilterButtonGroup.add(texMagFilterBasePointButton); magFilterButtonGroup.add(texMagFilterBaseLinearButton); magFilterButtonGroup.add(texMagFilterNicestButton); magFilterButtonGroup.add(texMagFilterFastestButton); // register the applet as the listener for the buttons texMagFilterBasePointButton.addActionListener(this); texMagFilterBaseLinearButton.addActionListener(this); texMagFilterNicestButton.addActionListener(this); texMagFilterFastestButton.addActionListener(this); // add the buttons to the panel rightPanel.add(texMagFilterBasePointButton); rightPanel.add(texMagFilterBaseLinearButton); rightPanel.add(texMagFilterNicestButton); rightPanel.add(texMagFilterFastestButton); // set the default texMagFilterBasePointButton.setSelected(true); // MipMap Mode leftPanel.add(new JLabel("MipMap Mode:")); // create the buttons JRadioButton texMipMapBaseButton = new JRadioButton(texMipMapBaseString); JRadioButton texMipMapMultiButton = new JRadioButton(texMipMapMultiString); // set up the action commands texMipMapBaseButton.setActionCommand(texMipMapBaseString); texMipMapMultiButton.setActionCommand(texMipMapMultiString); // add the buttons to a group so that only one can be selected ButtonGroup texMipMapButtonGroup = new ButtonGroup(); texMipMapButtonGroup.add(texMipMapBaseButton); texMipMapButtonGroup.add(texMipMapMultiButton); // register the applet as the listener for the buttons texMipMapBaseButton.addActionListener(this); texMipMapMultiButton.addActionListener(this); // add the buttons to the panel leftPanel.add(texMipMapBaseButton); leftPanel.add(texMipMapMultiButton); // set the default texMipMapBaseButton.setSelected(true); return panel; }
From source file:gov.loc.repository.bagger.ui.SaveBagFrame.java
private JPanel createComponents() { Border border = new EmptyBorder(5, 5, 5, 5); TitlePane titlePane = new TitlePane(); initStandardCommands();// www .j a va2s. com JPanel pageControl = new JPanel(new BorderLayout()); JPanel titlePaneContainer = new JPanel(new BorderLayout()); titlePane.setTitle(bagView.getPropertyMessage("SaveBagFrame.title")); titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("Define the Bag settings"))); titlePaneContainer.add(titlePane.getControl()); titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH); pageControl.add(titlePaneContainer, BorderLayout.NORTH); JPanel contentPane = new JPanel(); // TODO: Add bag name field // TODO: Add save name file selection button JLabel location = new JLabel("Save in:"); browseButton = new JButton(getMessage("bag.button.browse")); browseButton.addActionListener(new SaveBagAsHandler()); browseButton.setEnabled(true); browseButton.setToolTipText(getMessage("bag.button.browse.help")); String fileName = ""; DefaultBag bag = bagView.getBag(); if (bag != null) { fileName = bag.getName(); } bagNameField = new JTextField(fileName); bagNameField.setCaretPosition(fileName.length()); bagNameField.setEditable(false); bagNameField.setEnabled(false); // Holey bag control JLabel holeyLabel = new JLabel(bagView.getPropertyMessage("bag.label.isholey")); holeyLabel.setToolTipText(bagView.getPropertyMessage("bag.isholey.help")); holeyCheckbox = new JCheckBox(bagView.getPropertyMessage("bag.checkbox.isholey")); holeyCheckbox.setBorder(border); holeyCheckbox.setSelected(bag.isHoley()); holeyCheckbox.addActionListener(new HoleyBagHandler()); holeyCheckbox.setToolTipText(bagView.getPropertyMessage("bag.isholey.help")); urlLabel = new JLabel(bagView.getPropertyMessage("baseURL.label")); urlLabel.setToolTipText(bagView.getPropertyMessage("baseURL.description")); urlLabel.setEnabled(bag.isHoley()); urlField = new JTextField(""); try { urlField.setText(bag.getFetch().getBaseURL()); } catch (Exception e) { log.error("fetch baseURL: " + e.getMessage()); } urlField.setEnabled(false); // TODO: Add format label JLabel serializeLabel; serializeLabel = new JLabel(getMessage("bag.label.ispackage")); serializeLabel.setToolTipText(getMessage("bag.serializetype.help")); // TODO: Add format selection panel noneButton = new JRadioButton(getMessage("bag.serializetype.none")); noneButton.setEnabled(true); AbstractAction serializeListener = new SerializeBagHandler(); noneButton.addActionListener(serializeListener); noneButton.setToolTipText(getMessage("bag.serializetype.none.help")); zipButton = new JRadioButton(getMessage("bag.serializetype.zip")); zipButton.setEnabled(true); zipButton.addActionListener(serializeListener); zipButton.setToolTipText(getMessage("bag.serializetype.zip.help")); /* tarButton = new JRadioButton(getMessage("bag.serializetype.tar")); tarButton.setEnabled(true); tarButton.addActionListener(serializeListener); tarButton.setToolTipText(getMessage("bag.serializetype.tar.help")); tarGzButton = new JRadioButton(getMessage("bag.serializetype.targz")); tarGzButton.setEnabled(true); tarGzButton.addActionListener(serializeListener); tarGzButton.setToolTipText(getMessage("bag.serializetype.targz.help")); tarBz2Button = new JRadioButton(getMessage("bag.serializetype.tarbz2")); tarBz2Button.setEnabled(true); tarBz2Button.addActionListener(serializeListener); tarBz2Button.setToolTipText(getMessage("bag.serializetype.tarbz2.help")); */ short mode = bag.getSerialMode(); if (mode == DefaultBag.NO_MODE) { this.noneButton.setEnabled(true); } else if (mode == DefaultBag.ZIP_MODE) { this.zipButton.setEnabled(true); } /*else if (mode == DefaultBag.TAR_MODE) { this.tarButton.setEnabled(true); } else if (mode == DefaultBag.TAR_GZ_MODE) { this.tarGzButton.setEnabled(true); } else if (mode == DefaultBag.TAR_BZ2_MODE) { this.tarBz2Button.setEnabled(true); } */else { this.noneButton.setEnabled(true); } ButtonGroup serializeGroup = new ButtonGroup(); serializeGroup.add(noneButton); serializeGroup.add(zipButton); //serializeGroup.add(tarButton); //serializeGroup.add(tarGzButton); //serializeGroup.add(tarBz2Button); serializeGroupPanel = new JPanel(new FlowLayout()); serializeGroupPanel.add(serializeLabel); serializeGroupPanel.add(noneButton); serializeGroupPanel.add(zipButton); //serializeGroupPanel.add(tarButton); //serializeGroupPanel.add(tarGzButton); //serializeGroupPanel.add(tarBz2Button); serializeGroupPanel.setBorder(border); serializeGroupPanel.setEnabled(true); serializeGroupPanel.setToolTipText(bagView.getPropertyMessage("bag.serializetype.help")); JLabel tagLabel = new JLabel(getMessage("bag.label.istag")); tagLabel.setToolTipText(getMessage("bag.label.istag.help")); isTagCheckbox = new JCheckBox(); isTagCheckbox.setBorder(border); isTagCheckbox.setSelected(bag.isBuildTagManifest()); isTagCheckbox.addActionListener(new TagManifestHandler()); isTagCheckbox.setToolTipText(getMessage("bag.checkbox.istag.help")); JLabel tagAlgorithmLabel = new JLabel(getMessage("bag.label.tagalgorithm")); tagAlgorithmLabel.setToolTipText(getMessage("bag.label.tagalgorithm.help")); ArrayList<String> listModel = new ArrayList<String>(); for (Algorithm algorithm : Algorithm.values()) { listModel.add(algorithm.bagItAlgorithm); } tagAlgorithmList = new JComboBox(listModel.toArray()); tagAlgorithmList.setName(getMessage("bag.tagalgorithmlist")); tagAlgorithmList.setSelectedItem(bag.getTagManifestAlgorithm()); tagAlgorithmList.addActionListener(new TagAlgorithmListHandler()); tagAlgorithmList.setToolTipText(getMessage("bag.tagalgorithmlist.help")); JLabel payloadLabel = new JLabel(getMessage("bag.label.ispayload")); payloadLabel.setToolTipText(getMessage("bag.ispayload.help")); isPayloadCheckbox = new JCheckBox(); isPayloadCheckbox.setBorder(border); isPayloadCheckbox.setSelected(bag.isBuildPayloadManifest()); isPayloadCheckbox.addActionListener(new PayloadManifestHandler()); isPayloadCheckbox.setToolTipText(getMessage("bag.ispayload.help")); JLabel payAlgorithmLabel = new JLabel(bagView.getPropertyMessage("bag.label.payalgorithm")); payAlgorithmLabel.setToolTipText(getMessage("bag.payalgorithm.help")); payAlgorithmList = new JComboBox(listModel.toArray()); payAlgorithmList.setName(getMessage("bag.payalgorithmlist")); payAlgorithmList.setSelectedItem(bag.getPayloadManifestAlgorithm()); payAlgorithmList.addActionListener(new PayAlgorithmListHandler()); payAlgorithmList.setToolTipText(getMessage("bag.payalgorithmlist.help")); GridBagLayout layout = new GridBagLayout(); GridBagConstraints glbc = new GridBagConstraints(); JPanel panel = new JPanel(layout); panel.setBorder(new EmptyBorder(10, 10, 10, 10)); int row = 0; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(location, glbc); panel.add(location); buildConstraints(glbc, 2, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.EAST); glbc.ipadx = 5; layout.setConstraints(browseButton, glbc); glbc.ipadx = 0; panel.add(browseButton); buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); glbc.ipadx = 5; layout.setConstraints(bagNameField, glbc); glbc.ipadx = 0; panel.add(bagNameField); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(holeyLabel, glbc); panel.add(holeyLabel); buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.WEST, GridBagConstraints.WEST); layout.setConstraints(holeyCheckbox, glbc); panel.add(holeyCheckbox); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(urlLabel, glbc); panel.add(urlLabel); buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(urlField, glbc); panel.add(urlField); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(serializeLabel, glbc); panel.add(serializeLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); layout.setConstraints(serializeGroupPanel, glbc); panel.add(serializeGroupPanel); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(tagLabel, glbc); panel.add(tagLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(isTagCheckbox, glbc); panel.add(isTagCheckbox); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(tagAlgorithmLabel, glbc); panel.add(tagAlgorithmLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(tagAlgorithmList, glbc); panel.add(tagAlgorithmList); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(payloadLabel, glbc); panel.add(payloadLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(isPayloadCheckbox, glbc); panel.add(isPayloadCheckbox); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); layout.setConstraints(payAlgorithmLabel, glbc); panel.add(payAlgorithmLabel); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); layout.setConstraints(payAlgorithmList, glbc); panel.add(payAlgorithmList); row++; buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER); GuiStandardUtils.attachDialogBorder(contentPane); pageControl.add(panel); JComponent buttonBar = createButtonBar(); pageControl.add(buttonBar, BorderLayout.SOUTH); this.pack(); return pageControl; }
From source file:net.sf.jabref.openoffice.StyleSelectDialog.java
private void init(String inSelection) { this.initSelection = inSelection; ButtonGroup bg = new ButtonGroup(); bg.add(useDefaultAuthoryear); bg.add(useDefaultNumerical);/*from w w w . j av a 2s .c o m*/ bg.add(chooseDirectly); bg.add(setDirectory); if (Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_AUTHORYEAR_STYLE)) { useDefaultAuthoryear.setSelected(true); } else if (Globals.prefs.getBoolean(JabRefPreferences.OO_USE_DEFAULT_NUMERICAL_STYLE)) { useDefaultNumerical.setSelected(true); } else { if (Globals.prefs.getBoolean(JabRefPreferences.OO_CHOOSE_STYLE_DIRECTLY)) { chooseDirectly.setSelected(true); } else { setDirectory.setSelected(true); } } directFile.setText(Globals.prefs.get(JabRefPreferences.OO_DIRECT_FILE)); styleDir.setText(Globals.prefs.get(JabRefPreferences.OO_STYLE_DIRECTORY)); directFile.setEditable(false); styleDir.setEditable(false); popup.add(edit); BrowseAction dfBrowse = BrowseAction.buildForFile(directFile, directFile); browseDirectFile.addActionListener(dfBrowse); BrowseAction sdBrowse = BrowseAction.buildForDir(styleDir, setDirectory); browseStyleDir.addActionListener(sdBrowse); showDefaultAuthoryearStyle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { displayDefaultStyle(true); } }); showDefaultNumericalStyle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { displayDefaultStyle(false); } }); // Add action listener to "Edit" menu item, which is supposed to open the style file in an external editor: edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { int i = table.getSelectedRow(); if (i == -1) { return; } ExternalFileType type = ExternalFileTypes.getInstance().getExternalFileTypeByExt("jstyle"); String link = tableModel.getElementAt(i).getFile().getPath(); try { if (type == null) { JabRefDesktop.openExternalFileUnknown(frame, new BibEntry(), new MetaData(), link, new UnknownExternalFileType("jstyle")); } else { JabRefDesktop.openExternalFileAnyFormat(new MetaData(), link, type); } } catch (IOException e) { LOGGER.warn("Problem open style file editor", e); } } }); diag = new JDialog(frame, Localization.lang("Styles"), true); styles = new BasicEventList<>(); EventList<OOBibStyle> sortedStyles = new SortedList<>(styles); // Create a preview panel for previewing styles: preview = new PreviewPanel(null, new MetaData(), ""); // Use the test entry from the Preview settings tab in Preferences: preview.setEntry(prevEntry); tableModel = (DefaultEventTableModel<OOBibStyle>) GlazedListsSwing .eventTableModelWithThreadProxyList(sortedStyles, new StyleTableFormat()); table = new JTable(tableModel); TableColumnModel cm = table.getColumnModel(); cm.getColumn(0).setPreferredWidth(100); cm.getColumn(1).setPreferredWidth(200); cm.getColumn(2).setPreferredWidth(80); selectionModel = (DefaultEventSelectionModel<OOBibStyle>) GlazedListsSwing .eventSelectionModelWithThreadProxyList(sortedStyles); table.setSelectionModel(selectionModel); table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { if (mouseEvent.isPopupTrigger()) { tablePopup(mouseEvent); } } @Override public void mouseReleased(MouseEvent mouseEvent) { if (mouseEvent.isPopupTrigger()) { tablePopup(mouseEvent); } } }); selectionModel.getSelected().addListEventListener(new EntrySelectionListener()); styleDir.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { readStyles(); setDirectory.setSelected(true); } @Override public void removeUpdate(DocumentEvent documentEvent) { readStyles(); setDirectory.setSelected(true); } @Override public void changedUpdate(DocumentEvent documentEvent) { readStyles(); setDirectory.setSelected(true); } }); directFile.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent documentEvent) { chooseDirectly.setSelected(true); } @Override public void removeUpdate(DocumentEvent documentEvent) { chooseDirectly.setSelected(true); } @Override public void changedUpdate(DocumentEvent documentEvent) { chooseDirectly.setSelected(true); } }); contentPane.setTopComponent(new JScrollPane(table)); contentPane.setBottomComponent(preview); readStyles(); DefaultFormBuilder b = new DefaultFormBuilder( new FormLayout("fill:pref,4dlu,fill:150dlu,4dlu,fill:pref", "")); b.append(useDefaultAuthoryear, 3); b.append(showDefaultAuthoryearStyle); b.nextLine(); b.append(useDefaultNumerical, 3); b.append(showDefaultNumericalStyle); b.nextLine(); b.append(chooseDirectly); b.append(directFile); b.append(browseDirectFile); b.nextLine(); b.append(setDirectory); b.append(styleDir); b.append(browseStyleDir); b.nextLine(); DefaultFormBuilder b2 = new DefaultFormBuilder( new FormLayout("fill:1dlu:grow", "fill:pref, fill:pref, fill:270dlu:grow")); b2.nextLine(); b2.append(new JLabel("<html>" + Localization.lang("This is the list of available styles. Select the one you want to use.") + "</html>")); b2.nextLine(); b2.append(contentPane); b.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); b2.getPanel().setBorder(BorderFactory.createEmptyBorder(15, 5, 5, 5)); diag.add(b.getPanel(), BorderLayout.NORTH); diag.add(b2.getPanel(), BorderLayout.CENTER); AbstractAction okListener = new AbstractAction() { @Override public void actionPerformed(ActionEvent event) { if (!useDefaultAuthoryear.isSelected() && !useDefaultNumerical.isSelected()) { if (chooseDirectly.isSelected()) { File f = new File(directFile.getText()); if (!f.exists()) { JOptionPane.showMessageDialog(diag, Localization.lang( "You must select either a valid style file, or use a default style."), Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE); return; } } else { if ((table.getRowCount() == 0) || (table.getSelectedRowCount() == 0)) { JOptionPane.showMessageDialog(diag, Localization.lang( "You must select either a valid style file, or use a default style."), Localization.lang("Style selection"), JOptionPane.ERROR_MESSAGE); return; } } } okPressed = true; storeSettings(); diag.dispose(); } }; ok.addActionListener(okListener); Action cancelListener = new AbstractAction() { @Override public void actionPerformed(ActionEvent event) { diag.dispose(); } }; cancel.addActionListener(cancelListener); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); bb.addButton(ok); bb.addButton(cancel); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); diag.add(bb.getPanel(), BorderLayout.SOUTH); ActionMap am = bb.getPanel().getActionMap(); InputMap im = bb.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", cancelListener); im.put(KeyStroke.getKeyStroke("ENTER"), "enterOk"); am.put("enterOk", okListener); diag.pack(); diag.setLocationRelativeTo(frame); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { contentPane.setDividerLocation(contentPane.getSize().height - 150); } }); }