List of usage examples for javax.swing JRadioButton JRadioButton
public JRadioButton(String text)
From source file:org.tellervo.desktop.tridasv2.ui.ComponentViewerOld.java
private void initComponents() { JLabel label;/*from ww w . jav a 2s.com*/ setLayout(new BorderLayout()); // create button panel JPanel topPanel = new JPanel(); label = new JLabel("View as: "); btnTreeView = new JRadioButton("tree"); btnTreeView.putClientProperty("cv.cardName", TREEPANEL); btnTableView = new JRadioButton("table"); btnTableView.putClientProperty("cv.cardName", TABLEPANEL); ActionListener btnListener = new ActionListener() { public void actionPerformed(ActionEvent e) { // show the right layout panel String v = (String) ((AbstractButton) e.getSource()).getClientProperty("cv.cardName"); if (v != null) ((CardLayout) contentPanel.getLayout()).show(contentPanel, v); } }; btnTableView.addActionListener(btnListener); btnTreeView.addActionListener(btnListener); // connect buttons ButtonGroup group = new ButtonGroup(); group.add(btnTreeView); group.add(btnTableView); topPanel.setLayout(new MigLayout("", "[64px][55px][62px][63px][][]", "[23px]")); // add it all to a panel topPanel.add(label, "cell 0 0,alignx left,aligny center"); topPanel.add(btnTreeView, "cell 1 0,alignx left,aligny center"); topPanel.add(btnTableView, "cell 2 0,alignx left,aligny center"); topPanel.setBorder(BorderFactory.createEmptyBorder(2, 8, 8, 8)); add(topPanel, BorderLayout.NORTH); JButton btnOrder = new JButton("Order"); btnOrder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { } }); topPanel.add(btnOrder, "cell 5 0"); // create status bar JPanel status = new JPanel(); status.setLayout(new BoxLayout(status, BoxLayout.X_AXIS)); txtStatus = new JLabel(""); pbStatus = new JProgressBar(); pbStatus.setVisible(false); status.add(txtStatus); status.add(Box.createHorizontalStrut(8)); status.add(pbStatus); status.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); add(status, BorderLayout.SOUTH); contentPanel = new JPanel(new CardLayout()); add(contentPanel, BorderLayout.CENTER); tablePanel = new JPanel(new BorderLayout()); setupTable(); tablePanel.add(new JScrollPane(table), BorderLayout.CENTER); treePanel = new JPanel(new BorderLayout()); setupTree(); treePanel.add(new JScrollPane(tree), BorderLayout.CENTER); tree2Panel = new JPanel(new BorderLayout()); createTree(); //setupTreeGUI(); contentPanel.add(tablePanel, TABLEPANEL); contentPanel.add(treePanel, TREEPANEL); contentPanel.add(tree2Panel, TREE2PANEL); }
From source file:org.tinymediamanager.ui.tvshows.settings.TvShowScraperSettingsPanel.java
/** * Instantiates a new movie scraper settings panel. *///from w w w . ja v a 2s. co m public TvShowScraperSettingsPanel() { // data init MediaScraper defaultMediaScraper = TvShowList.getInstance().getDefaultMediaScraper(); int selectedIndex = 0; int counter = 0; for (MediaScraper scraper : TvShowList.getInstance().getAvailableMediaScrapers()) { TvShowScraper tvShowScraper = new TvShowScraper(scraper); if (scraper.equals(defaultMediaScraper)) { tvShowScraper.defaultScraper = true; selectedIndex = counter; } scrapers.add(tvShowScraper); counter++; } List<String> enabledArtworkProviders = settings.getTvShowArtworkScrapers(); int artworkSelectedIndex = -1; int counterAW = 0; for (MediaScraper scraper : TvShowList.getInstance().getAvailableArtworkScrapers()) { ArtworkScraper artworkScraper = new ArtworkScraper(scraper); if (enabledArtworkProviders.contains(artworkScraper.getScraperId())) { artworkScraper.active = true; if (artworkSelectedIndex < 0) { artworkSelectedIndex = counterAW; } } artworkScrapers.add(artworkScraper); counterAW++; } // UI init setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelTvShowScrapers = new JPanel(); panelTvShowScrapers.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.metadata.defaults"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); // $NON-NLS-1$ add(panelTvShowScrapers, "2, 2, fill, top"); panelTvShowScrapers.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("100dlu:grow"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, })); scrollPaneScraper = new JScrollPane(); panelTvShowScrapers.add(scrollPaneScraper, "1, 2, 3, 1, fill, fill"); tableScraper = new JTable(); tableScraper.setRowHeight(29); scrollPaneScraper.setViewportView(tableScraper); scrollPaneScraperDetails = new JScrollPane(); scrollPaneScraperDetails.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPaneScraperDetails.setBorder(null); panelTvShowScrapers.add(scrollPaneScraperDetails, "5, 2, fill, fill"); panelScraperDetails = new ScrollablePanel(); scrollPaneScraperDetails.setViewportView(panelScraperDetails); panelScraperDetails.setLayout(new FormLayout(new ColumnSpec[] { ColumnSpec.decode("200dlu:grow"), }, new RowSpec[] { RowSpec.decode("default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); // add a CSS rule to force body tags to use the default label font // instead of the value in javax.swing.text.html.default.csss Font font = UIManager.getFont("Label.font"); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }"; tpScraperDescription = new JTextPane(); tpScraperDescription.setOpaque(false); tpScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); panelScraperDetails.add(tpScraperDescription, "1, 1, fill, top"); panelScraperOptions = new JPanel(); panelScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelScraperDetails.add(panelScraperOptions, "1, 3, fill, top"); JSeparator separator = new JSeparator(); panelTvShowScrapers.add(separator, "1, 4, 5, 1"); JLabel lblScraperLanguage = new JLabel(BUNDLE.getString("Settings.preferredLanguage")); //$NON-NLS-1$ panelTvShowScrapers.add(lblScraperLanguage, "1, 6, right, default"); cbScraperTmdbLanguage = new JComboBox(MediaLanguages.values()); panelTvShowScrapers.add(cbScraperTmdbLanguage, "3, 6"); JLabel lblCountry = new JLabel(BUNDLE.getString("Settings.certificationCountry")); //$NON-NLS-1$ panelTvShowScrapers.add(lblCountry, "1, 8, right, default"); cbCountry = new JComboBox(CountryCode.values()); panelTvShowScrapers.add(cbCountry, "3, 8, fill, default"); btnGroupThumbFilenaming = new ButtonGroup(); panelArtworkScrapers = new JPanel(); panelArtworkScrapers.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.images"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelArtworkScrapers, "2, 4, fill, fill"); panelArtworkScrapers.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("80dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, })); scrollPaneArtworkScraper = new JScrollPane(); panelArtworkScrapers.add(scrollPaneArtworkScraper, "2, 2, fill, fill"); tableArtworkScraper = new JTable(); tableArtworkScraper.setRowHeight(29); scrollPaneArtworkScraper.setViewportView(tableArtworkScraper); scrollPaneArtworkScraperDetails = new JScrollPane(); scrollPaneArtworkScraperDetails.setBorder(null); panelArtworkScrapers.add(scrollPaneArtworkScraperDetails, "4, 2, fill, fill"); panelArtworkScraperDetails = new JPanel(); scrollPaneArtworkScraperDetails.setViewportView(panelArtworkScraperDetails); panelArtworkScraperDetails.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow"), }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), })); tpArtworkScraperDescription = new JTextPane(); tpArtworkScraperDescription.setEditorKit(new HTMLEditorKit()); ((HTMLDocument) tpArtworkScraperDescription.getDocument()).getStyleSheet().addRule(bodyRule); tpArtworkScraperDescription.setOpaque(false); panelArtworkScraperDetails.add(tpArtworkScraperDescription, "2, 2, fill, fill"); panelArtworkScraperOptions = new JPanel(); panelArtworkScraperOptions.setLayout(new FlowLayout(FlowLayout.LEFT)); panelArtworkScraperDetails.add(panelArtworkScraperOptions, "2, 4, fill, fill"); separator = new JSeparator(); panelArtworkScrapers.add(separator, "2, 4, 3, 1"); panelImages = new JPanel(); panelArtworkScrapers.add(panelImages, "2, 6, 3, 1, fill, fill"); panelImages.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { RowSpec.decode("23px"), })); lblNewLabel = new JLabel(BUNDLE.getString("image.thumb.naming")); panelImages.add(lblNewLabel, "1, 1, left, center"); rdbtnThumbWithPostfix = new JRadioButton("<dynamic>-thumb.ext"); panelImages.add(rdbtnThumbWithPostfix, "3, 1, fill, top"); btnGroupThumbFilenaming.add(rdbtnThumbWithPostfix); rdbtnThumbTbn = new JRadioButton("<dynamic>.tbn"); btnGroupThumbFilenaming.add(rdbtnThumbTbn); rdbtnThumbWoPostfix = new JRadioButton("<dynamic>.ext"); panelImages.add(rdbtnThumbWoPostfix, "5, 1, fill, top"); btnGroupThumbFilenaming.add(rdbtnThumbWoPostfix); panelImages.add(rdbtnThumbTbn, "7, 1"); panelScraperMetadataContainer = new JPanel(); panelScraperMetadataContainer.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), BUNDLE.getString("scraper.metadata.defaults"), TitledBorder.LEADING, TitledBorder.TOP, null, //$NON-NLS-1$ new Color(51, 51, 51))); add(panelScraperMetadataContainer, "2, 6, fill, top"); panelScraperMetadataContainer.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); panelScraperMetadata = new TvShowScraperMetadataPanel( Settings.getInstance().getTvShowScraperMetadataConfig()); panelScraperMetadataContainer.add(panelScraperMetadata, "1, 1, 2, 1, fill, default"); chckbxAutomaticallyScrapeImages = new JCheckBox(BUNDLE.getString("Settings.default.autoscrape")); //$NON-NLS-1$ panelScraperMetadataContainer.add(chckbxAutomaticallyScrapeImages, "2, 3"); initDataBindings(); { // adjust table columns // Checkbox and Logo shall have minimal width TableColumnResizer.setMaxWidthForColumn(tableScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableScraper, 5); TableColumnResizer.setMaxWidthForColumn(tableArtworkScraper, 0, 2); TableColumnResizer.setMaxWidthForColumn(tableArtworkScraper, 1, 2); TableColumnResizer.adjustColumnPreferredWidths(tableArtworkScraper, 5); // implement listener to simulate button group tableScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); TvShowScraper changedScraper = scrapers.get(row); // if flag inNFO was changed, change all other trailers flags if (changedScraper.getDefaultScraper()) { settings.setTvShowScraper(changedScraper.getScraperId()); for (TvShowScraper scraper : scrapers) { if (scraper != changedScraper) { scraper.setDefaultScraper(Boolean.FALSE); } } } } } }); // implement selection listener to load settings tableScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableScraper.convertRowIndexToModel(tableScraper.getSelectedRow()); if (index > -1) { panelScraperOptions.removeAll(); if (scrapers.get(index).getMediaProvider().getProviderInfo().getConfig().hasConfig()) { panelScraperOptions.add( new MediaScraperConfigurationPanel(scrapers.get(index).getMediaProvider())); } panelScraperOptions.revalidate(); } } }); tableArtworkScraper.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent arg0) { // click on the checkbox if (arg0.getColumn() == 0) { int row = arg0.getFirstRow(); ArtworkScraper changedScraper = artworkScrapers.get(row); if (changedScraper.active) { settings.addTvShowArtworkScraper(changedScraper.getScraperId()); } else { settings.removeTvShowArtworkScraper(changedScraper.getScraperId()); } } } }); // implement selection listener to load settings tableArtworkScraper.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int index = tableArtworkScraper.convertRowIndexToModel(tableArtworkScraper.getSelectedRow()); if (index > -1) { panelArtworkScraperOptions.removeAll(); if (artworkScrapers.get(index).getMediaProvider().getProviderInfo().getConfig() .hasConfig()) { panelArtworkScraperOptions.add(new MediaScraperConfigurationPanel( artworkScrapers.get(index).getMediaProvider())); } panelArtworkScraperOptions.revalidate(); } } }); // select default TV show scraper if (counter > 0) { tableScraper.getSelectionModel().setSelectionInterval(selectedIndex, selectedIndex); } // select default artwork scraper if (counterAW > 0) { tableArtworkScraper.getSelectionModel().setSelectionInterval(artworkSelectedIndex, artworkSelectedIndex); } ItemListener itemListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }; rdbtnThumbWoPostfix.addItemListener(itemListener); rdbtnThumbWithPostfix.addItemListener(itemListener); rdbtnThumbTbn.addItemListener(itemListener); switch (settings.getTvShowEpisodeThumbFilename()) { case FILENAME_THUMB_POSTFIX: rdbtnThumbWithPostfix.setSelected(true); break; case FILENAME_THUMB: rdbtnThumbWoPostfix.setSelected(true); break; case FILENAME_THUMB_TBN: rdbtnThumbTbn.setSelected(true); break; default: break; } } }
From source file:org.ut.biolab.medsavant.client.annotation.InstallAnnotationWizard.java
@Deprecated private AbstractWizardPage getAnnotationSourcePage() { return new DefaultWizardPage(PAGENAME_SRC) { private JRadioButton radioFromRepo = new JRadioButton("MedSavant public repository"); private JRadioButton radioFromFile = new JRadioButton("file (for custom annotations)"); {/*from w w w . jav a 2 s .c om*/ ButtonGroup g = new ButtonGroup(); g.add(radioFromRepo); //g.add(radioFromFile); final DefaultWizardPage instance = this; radioFromRepo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { setSourceFromRepo(radioFromRepo.isSelected(), instance); } }); radioFromFile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { setSourceFromRepo(radioFromRepo.isSelected(), instance); } }); addText("Install annotation from:"); addComponent(radioFromRepo); addComponent(radioFromFile); radioFromRepo.setSelected(true); } @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.NEXT); } }; }
From source file:org.ut.biolab.medsavant.client.filter.FilterHistoryPanel.java
public FilterHistoryPanel() { FilterController.getInstance().addListener(new Listener<FilterEvent>() { @Override/*from w w w . j a v a 2 s .c om*/ public void handleEvent(final FilterEvent event) { new MedSavantWorker<Void>("FilterHistoryPanel") { @Override protected void showProgress(double fraction) { } @Override protected void showSuccess(Void result) { } @Override protected Void doInBackground() throws Exception { int numLeft = ResultController.getInstance().getFilteredVariantCount(); addFilterSet(event.getFilter(), event.getType(), numLeft); return null; } }.execute(); } }); ReferenceController.getInstance().addListener(new Listener<ReferenceEvent>() { @Override public void handleEvent(ReferenceEvent event) { if (event.getType() == ReferenceEvent.Type.CHANGED) { reset(); } } }); //this.setBackground(new Color(100,100,100)); this.setBorder(ViewUtil.getMediumBorder()); this.setMinimumSize(new Dimension(200, 300)); this.setPreferredSize(new Dimension(200, 300)); this.setName("History"); this.setLayout(new BorderLayout()); table = new JTable() { @Override public TableCellRenderer getCellRenderer(int row, int column) { if (model.getColumnClass(column).equals(JPanel.class)) { return new JPanelRenderer(); } return super.getCellRenderer(row, column); } }; model = new ProgressTableModel(); table.setModel(model); JPanel modePanel = ViewUtil.getClearPanel(); ButtonGroup group = new ButtonGroup(); JRadioButton globalButton = new JRadioButton("Global"); ViewUtil.makeSmall(globalButton); globalButton.setSelected(true); globalButton.setOpaque(false); JRadioButton relativeButton = new JRadioButton("Relative to previous change"); ViewUtil.makeSmall(relativeButton); relativeButton.setOpaque(false); globalButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { changeMode(Mode.GLOBAL); } }); relativeButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { changeMode(Mode.RELATIVE); } }); group.add(globalButton); group.add(relativeButton); modePanel.add(globalButton); modePanel.add(relativeButton); this.add(modePanel, BorderLayout.NORTH); final JScrollPane scrollPane = new JScrollPane(); scrollPane.getViewport().add(table); this.add(scrollPane, BorderLayout.CENTER); reset(); //FilterController.addFilterListener(this); }
From source file:org.ut.biolab.medsavant.client.variant.ImportVariantsWizard.java
private AbstractWizardPage getVCFSourcePage() { return new DefaultWizardPage("Location of Files") { private JRadioButton onMyComputerButton = new JRadioButton("This computer"); private JRadioButton onMedSavantServerButton = new JRadioButton("The MedSavant server"); {// w w w . j ava 2 s . co m ButtonGroup g = new ButtonGroup(); g.add(onMyComputerButton); g.add(onMedSavantServerButton); onMyComputerButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { setUploadRequired(onMyComputerButton.isSelected()); } }); onMedSavantServerButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { setUploadRequired(onMyComputerButton.isSelected()); } }); addText("The VCFs I want to import are on:"); addComponent(onMyComputerButton); addComponent(onMedSavantServerButton); onMyComputerButton.setSelected(true); } @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } }; }
From source file:org.ut.biolab.medsavant.client.view.genetics.variantinfo.SearchSubInspector.java
private JRadioButton makeWhite(String string) { JRadioButton b = new JRadioButton(string); //b.setForeground(Color.white); bg.add(b);//w w w. ja va 2s .c o m return b; }
From source file:org.ut.biolab.medsavant.client.view.manage.ServerLogPage.java
@Override public JPanel getView() { if (view == null) { view = new JPanel(); view.setLayout(new BorderLayout()); menuPanel = new JPanel(); ViewUtil.applyHorizontalBoxLayout(menuPanel); ButtonGroup bg = new ButtonGroup(); JRadioButton b1 = new JRadioButton("Client"); //JRadioButton b2 = new JRadioButton("Server"); JRadioButton b3 = new JRadioButton("Annotations"); bg.add(b1);/* w w w.java 2s .c om*/ //bg.add(b2); bg.add(b3); listPanel = new JPanel(); listPanel.setLayout(new CardLayout()); listPanel.add(getWaitPanel(), CARDNAME_WAIT); listPanel.add(getClientCard(), CARDNAME_CLIENT); //listPanel.add(getServerCard(), CARDNAME_SERVER); listPanel.add(getAnnotationCard(), CARDNAME_ANNOTATION); view.add(menuPanel, BorderLayout.NORTH); view.add(listPanel, BorderLayout.CENTER); b1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { changeToCard(CARDNAME_CLIENT); } }); /*b2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { changeToCard(CARDNAME_SERVER); } });*/ b3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { changeToCard(CARDNAME_ANNOTATION); } }); b3.setSelected(true); this.changeToCard(CARDNAME_ANNOTATION); JButton refreshButton = new JButton("Refresh"); refreshButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { refreshCurrentCard(); } }); menuPanel.add(Box.createHorizontalGlue()); menuPanel.add(b3); menuPanel.add(b1); //menuPanel.add(b2); menuPanel.add(refreshButton); menuPanel.add(Box.createHorizontalGlue()); } return view; }
From source file:pcgen.gui2.dialog.OptionsPathDialog.java
private void addRadioButton(String text, String command, ButtonGroup group, ActionListener listener, GridBagConstraints gbc) { boolean selected = command.equals(selectedDir); if (selected) { text += " (default)"; //for i18n this will need to be handled differently }/* www . ja v a 2s. c o m*/ AbstractButton rButton = new JRadioButton(text); rButton.setActionCommand(command); rButton.setSelected(selected); rButton.addActionListener(listener); group.add(rButton); getContentPane().add(rButton, gbc); }
From source file:pcgen.gui2.prefs.LocationPanel.java
/** * Instantiates a new location panel.//from w w w .j a va 2s. c om */ public LocationPanel() { Border etched = null; TitledBorder title1 = BorderFactory.createTitledBorder(etched, IN_LOCATION); title1.setTitleJustification(TitledBorder.LEFT); this.setBorder(title1); GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(2, 2, 2, 2); Utility.buildConstraints(constraints, 0, 0, 1, 1, 0, 0); JLabel label = new JLabel(IN_BROWSER_PATH + ": "); gridbag.setConstraints(label, constraints); this.add(label); Utility.buildConstraints(constraints, 1, 0, 1, 1, 1, 0); browserPath = new JTextField(String.valueOf(PCGenSettings.getBrowserPath())); // sage_sam 9 April 2003 browserPath.addFocusListener(textFieldListener); gridbag.setConstraints(browserPath, constraints); this.add(browserPath); Utility.buildConstraints(constraints, 2, 0, 1, 1, 0, 0); browserPathButton = new JButton(IN_CHOOSE); gridbag.setConstraints(browserPathButton, constraints); this.add(browserPathButton); browserPathButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 1, 1, 1, 1, 0, 0); clearBrowserPathButton = new JButton(IN_CLEAR_BROWSER_PATH); gridbag.setConstraints(clearBrowserPathButton, constraints); this.add(clearBrowserPathButton); clearBrowserPathButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 2, 1, 1, 0, 0); JLabel in_prefs_pcgenCharacterDir = new JLabel( LanguageBundle.getString("in_Prefs_pcgenCharacterDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 2, 1, 1, 0, 0); pcgenCharacterDir = new JTextField(String.valueOf(PCGenSettings.getPcgDir())); // sage_sam 9 April 2003 pcgenCharacterDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenCharacterDir, constraints); this.add(pcgenCharacterDir); Utility.buildConstraints(constraints, 2, 2, 1, 1, 0, 0); pcgenCharacterDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenCharacterDirButton, constraints); this.add(pcgenCharacterDirButton); pcgenCharacterDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 3, 1, 1, 0, 0); //TODO i18n in_prefs_pcgenCharacterDir = new JLabel("PCGen Portraits Directory" + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 3, 1, 1, 0, 0); pcgenPortraitsDir = new JTextField(String.valueOf(PCGenSettings.getPortraitsDir())); // sage_sam 9 April 2003 pcgenPortraitsDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenPortraitsDir, constraints); this.add(pcgenPortraitsDir); Utility.buildConstraints(constraints, 2, 3, 1, 1, 0, 0); pcgenPortraitsDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenPortraitsDirButton, constraints); this.add(pcgenPortraitsDirButton); pcgenPortraitsDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 4, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenDataDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 4, 1, 1, 0, 0); pcgenDataDir = new JTextField(String.valueOf(ConfigurationSettings.getPccFilesDir())); // sage_sam 9 April 2003 pcgenDataDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenDataDir, constraints); this.add(pcgenDataDir); Utility.buildConstraints(constraints, 2, 4, 1, 1, 0, 0); pcgenDataDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenDataDirButton, constraints); this.add(pcgenDataDirButton); pcgenDataDirButton.addActionListener(prefsButtonHandler); ////////////////////// Utility.buildConstraints(constraints, 0, 5, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenCustomDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 5, 1, 1, 0, 0); pcgenCustomDir = new JTextField(String.valueOf(PCGenSettings.getCustomDir())); // sage_sam 9 April 2003 pcgenCustomDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenCustomDir, constraints); this.add(pcgenCustomDir); Utility.buildConstraints(constraints, 2, 5, 1, 1, 0, 0); pcgenCustomDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenCustomDirButton, constraints); this.add(pcgenCustomDirButton); pcgenCustomDirButton.addActionListener(prefsButtonHandler); //////////////////// Utility.buildConstraints(constraints, 0, 6, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenVendorDataDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 6, 1, 1, 0, 0); pcgenVendorDataDir = new JTextField(String.valueOf(PCGenSettings.getVendorDataDir())); // sage_sam 9 April 2003 pcgenVendorDataDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenVendorDataDir, constraints); this.add(pcgenVendorDataDir); Utility.buildConstraints(constraints, 2, 6, 1, 1, 0, 0); pcgenVendorDataDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenVendorDataDirButton, constraints); this.add(pcgenVendorDataDirButton); pcgenVendorDataDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 7, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenHomebrewDataDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 7, 1, 1, 0, 0); pcgenHomebrewDataDir = new JTextField(String.valueOf(PCGenSettings.getHomebrewDataDir())); pcgenHomebrewDataDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenHomebrewDataDir, constraints); this.add(pcgenHomebrewDataDir); Utility.buildConstraints(constraints, 2, 7, 1, 1, 0, 0); pcgenHomebrewDataDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenHomebrewDataDirButton, constraints); this.add(pcgenHomebrewDataDirButton); pcgenHomebrewDataDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 8, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenDocsDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 8, 1, 1, 0, 0); pcgenDocsDir = new JTextField(String.valueOf(ConfigurationSettings.getDocsDir())); // sage_sam 9 April 2003 pcgenDocsDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenDocsDir, constraints); this.add(pcgenDocsDir); Utility.buildConstraints(constraints, 2, 8, 1, 1, 0, 0); pcgenDocsDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenDocsDirButton, constraints); this.add(pcgenDocsDirButton); pcgenDocsDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 9, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenSystemDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 9, 1, 1, 0, 0); pcgenSystemDir = new JTextField(String.valueOf(ConfigurationSettings.getSystemsDir())); // sage_sam 9 April 2003 pcgenSystemDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenSystemDir, constraints); this.add(pcgenSystemDir); Utility.buildConstraints(constraints, 2, 9, 1, 1, 0, 0); pcgenSystemDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenSystemDirButton, constraints); this.add(pcgenSystemDirButton); pcgenSystemDirButton.addActionListener(prefsButtonHandler); // Output Sheet directory Utility.buildConstraints(constraints, 0, 10, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenOutputSheetDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 10, 1, 1, 0, 0); pcgenOutputSheetDir = new JTextField(String.valueOf(ConfigurationSettings.getOutputSheetsDir())); pcgenOutputSheetDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenOutputSheetDir, constraints); this.add(pcgenOutputSheetDir); Utility.buildConstraints(constraints, 2, 10, 1, 1, 0, 0); pcgenOutputSheetDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenOutputSheetDirButton, constraints); this.add(pcgenOutputSheetDirButton); pcgenOutputSheetDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 11, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenPreviewDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 11, 1, 1, 0, 0); pcgenPreviewDir = new JTextField(String.valueOf(ConfigurationSettings.getPreviewDir())); pcgenPreviewDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenPreviewDir, constraints); this.add(pcgenPreviewDir); Utility.buildConstraints(constraints, 2, 11, 1, 1, 0, 0); pcgenPreviewDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenPreviewDirButton, constraints); this.add(pcgenPreviewDirButton); pcgenPreviewDirButton.addActionListener(prefsButtonHandler); // Character File Backup directory Utility.buildConstraints(constraints, 0, 12, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel( LanguageBundle.getString("in_Prefs_pcgenCreateBackupCharacter") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 12, 1, 1, 0, 0); gridbag.setConstraints(pcgenCreateBackupCharacter, constraints); this.add(pcgenCreateBackupCharacter); Utility.buildConstraints(constraints, 0, 13, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel( LanguageBundle.getString("in_Prefs_pcgenBackupCharacterDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); Utility.buildConstraints(constraints, 1, 13, 1, 1, 0, 0); pcgenBackupCharacterDir = new JTextField(String.valueOf(PCGenSettings.getBackupPcgDir())); pcgenBackupCharacterDir.addFocusListener(textFieldListener); gridbag.setConstraints(pcgenBackupCharacterDir, constraints); this.add(pcgenBackupCharacterDir); Utility.buildConstraints(constraints, 2, 13, 1, 1, 0, 0); pcgenBackupCharacterDirButton = new JButton(IN_CHOOSE); gridbag.setConstraints(pcgenBackupCharacterDirButton, constraints); this.add(pcgenBackupCharacterDirButton); pcgenBackupCharacterDirButton.addActionListener(prefsButtonHandler); // Where to store options.ini file Utility.buildConstraints(constraints, 0, 14, 1, 1, 0, 0); in_prefs_pcgenCharacterDir = new JLabel(LanguageBundle.getString("in_Prefs_pcgenFilesDir") + ": "); gridbag.setConstraints(in_prefs_pcgenCharacterDir, constraints); this.add(in_prefs_pcgenCharacterDir); pcgenFilesDirRadio = new JRadioButton("PCGen Dir"); usersFilesDirRadio = new JRadioButton("Home Dir"); selectFilesDirRadio = new JRadioButton("Select a directory"); pcgenFilesDir = new JTextField(String.valueOf(ConfigurationSettings.getSettingsDir())); pcgenFilesDir.addFocusListener(textFieldListener); String fType = ConfigurationSettings.getSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH); if ((fType == null) || (fType.length() < 1)) { // make sure we have a default fType = ConfigurationSettings.getDefaultSettingsFilesPath(); ConfigurationSettings.setSystemProperty(ConfigurationSettings.SETTINGS_FILES_PATH, fType); } pcgenFilesDir.setText(ConfigurationSettings.getSettingsDir()); if (fType.equals(SettingsFilesPath.pcgen.name())) { pcgenFilesDirRadio.setSelected(true); } else if (fType.equals(SettingsFilesPath.user.name()) || fType.equals(SettingsFilesPath.mac_user.name()) || fType.equals(SettingsFilesPath.FD_USER.name())) { usersFilesDirRadio.setSelected(true); } else { selectFilesDirRadio.setSelected(true); } Utility.buildConstraints(constraints, 0, 15, 1, 1, 0, 0); gridbag.setConstraints(pcgenFilesDirRadio, constraints); this.add(pcgenFilesDirRadio); Utility.buildConstraints(constraints, 1, 15, 1, 1, 0, 0); gridbag.setConstraints(usersFilesDirRadio, constraints); this.add(usersFilesDirRadio); groupFilesDir = new ButtonGroup(); groupFilesDir.add(pcgenFilesDirRadio); groupFilesDir.add(usersFilesDirRadio); groupFilesDir.add(selectFilesDirRadio); pcgenFilesDirRadio.addActionListener(evt -> { pcgenFilesDir.setText(SettingsFilesPath.pcgen.getSettingsDir()); pcgenFilesDirButton.setEnabled(false); }); usersFilesDirRadio.addActionListener(evt -> { pcgenFilesDir.setText(ConfigurationSettings.getUserSettingsDirFromFilePath()); pcgenFilesDirButton.setEnabled(false); }); selectFilesDirRadio.addActionListener(evt -> { pcgenFilesDir.setText(""); pcgenFilesDirButton.setEnabled(true); }); Utility.buildConstraints(constraints, 0, 16, 1, 1, 0, 0); gridbag.setConstraints(selectFilesDirRadio, constraints); this.add(selectFilesDirRadio); Utility.buildConstraints(constraints, 1, 16, 1, 1, 0, 0); gridbag.setConstraints(pcgenFilesDir, constraints); this.add(pcgenFilesDir); Utility.buildConstraints(constraints, 2, 16, 1, 1, 0, 0); pcgenFilesDirButton = new JButton(IN_CHOOSE); pcgenFilesDirButton.setEnabled(selectFilesDirRadio.isSelected()); gridbag.setConstraints(pcgenFilesDirButton, constraints); this.add(pcgenFilesDirButton); pcgenFilesDirButton.addActionListener(prefsButtonHandler); Utility.buildConstraints(constraints, 0, 20, 3, 1, 1, 1); constraints.fill = GridBagConstraints.BOTH; JLabel emptyLabel = new JLabel(" "); gridbag.setConstraints(emptyLabel, constraints); this.add(emptyLabel); }
From source file:pcgen.gui2.prefs.LookAndFeelPanel.java
/** * Instantiates a new look and feel panel. *///from w w w . ja v a2 s.c o m public LookAndFeelPanel(Dialog parent) { JLabel label; ButtonGroup exclusiveGroup; Border etched = null; TitledBorder title1 = BorderFactory.createTitledBorder(etched, IN_LOOK_AND_FEEL); title1.setTitleJustification(TitledBorder.LEFT); this.setBorder(title1); GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(2, 2, 2, 2); exclusiveGroup = new ButtonGroup(); Action[] actions = LookAndFeelManager.getActions(); laf = new JRadioButton[actions.length - 1]; for (int i = 0; i < laf.length; ++i) { laf[i] = new JRadioButton(actions[i]); int whichChar = (laf[i].getText().charAt(0) == 'C') ? 1 : 0; laf[i].setMnemonic(laf[i].getText().charAt(whichChar)); Utility.buildConstraints(c, 0, i, 3, 1, 0, 0); gridbag.setConstraints(laf[i], c); this.add(laf[i]); exclusiveGroup.add(laf[i]); } skinnedLookFeel.addActionListener(actions[actions.length - 1]); skinnedLookFeel.setText(IN_SKINNED_LAF + ": "); skinnedLookFeel.setToolTipText(LanguageBundle.getString("in_Prefs_skinnedLAFTooltip")); skinnedLookFeel.setMnemonic(LanguageBundle.getMnemonic("in_mn_Prefs_skinnedLAF")); Utility.buildConstraints(c, 0, laf.length, 3, 1, 0, 0); gridbag.setConstraints(skinnedLookFeel, c); this.add(skinnedLookFeel); exclusiveGroup.add(skinnedLookFeel); Utility.buildConstraints(c, 3, laf.length, 1, 1, 1, 0); themepackLabel = new JTextField(LookAndFeelManager.getCurrentThemePack()); themepackLabel.setEditable(false); gridbag.setConstraints(themepackLabel, c); this.add(themepackLabel); Utility.buildConstraints(c, 4, laf.length, 1, 1, 0, 0); themepack = new JButton(IN_CHOOSE); themepack.setToolTipText(LanguageBundle.getString("in_Prefs_chooseSkinTooltip")); gridbag.setConstraints(themepack, c); this.add(themepack); themepack.addActionListener(prefsButtonHandler); Utility.buildConstraints(c, 0, laf.length + 1, 5, 1, 0, 0); label = new JLabel(""); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 0, laf.length + 2, 5, 1, 0, 0); label = new JLabel(LanguageBundle.getString("in_Prefs_restartInfo")); gridbag.setConstraints(label, c); this.add(label); Utility.buildConstraints(c, 0, 20, 5, 1, 1, 1); c.fill = GridBagConstraints.BOTH; label = new JLabel(" "); gridbag.setConstraints(label, c); this.add(label); }