List of usage examples for javax.swing ButtonGroup add
public void add(AbstractButton b)
From source file:components.FrameDemo2.java
protected JComponent createOptionControls() { JLabel label1 = new JLabel("Decoration options for subsequently created frames:"); ButtonGroup bg1 = new ButtonGroup(); JLabel label2 = new JLabel("Icon options:"); ButtonGroup bg2 = new ButtonGroup(); //Create the buttons JRadioButton rb1 = new JRadioButton(); rb1.setText("Look and feel decorated"); rb1.setActionCommand(LF_DECORATIONS); rb1.addActionListener(this); rb1.setSelected(true);/*w ww . j ava2 s. c o m*/ bg1.add(rb1); // JRadioButton rb2 = new JRadioButton(); rb2.setText("Window system decorated"); rb2.setActionCommand(WS_DECORATIONS); rb2.addActionListener(this); bg1.add(rb2); // JRadioButton rb3 = new JRadioButton(); rb3.setText("No decorations"); rb3.setActionCommand(NO_DECORATIONS); rb3.addActionListener(this); bg1.add(rb3); // // JRadioButton rb4 = new JRadioButton(); rb4.setText("Default icon"); rb4.setActionCommand(DEFAULT_ICON); rb4.addActionListener(this); rb4.setSelected(true); bg2.add(rb4); // JRadioButton rb5 = new JRadioButton(); rb5.setText("Icon from a JPEG file"); rb5.setActionCommand(FILE_ICON); rb5.addActionListener(this); bg2.add(rb5); // JRadioButton rb6 = new JRadioButton(); rb6.setText("Painted icon"); rb6.setActionCommand(PAINT_ICON); rb6.addActionListener(this); bg2.add(rb6); //Add everything to a container. Box box = Box.createVerticalBox(); box.add(label1); box.add(Box.createVerticalStrut(5)); //spacer box.add(rb1); box.add(rb2); box.add(rb3); // box.add(Box.createVerticalStrut(15)); //spacer box.add(label2); box.add(Box.createVerticalStrut(5)); //spacer box.add(rb4); box.add(rb5); box.add(rb6); //Add some breathing room. box.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); return box; }
From source file:ToolbarDemo.java
protected JMenuBar createMenuBar() { final JMenuBar menuBar = new JMenuBar(); JMenu mFile = new JMenu("File"); mFile.setMnemonic('f'); ImageIcon iconNew = new ImageIcon("file_new.gif"); Action actionNew = new AbstractAction("New", iconNew) { public void actionPerformed(ActionEvent e) { System.out.println("new action"); }/* ww w .j a va 2 s .c o m*/ }; JMenuItem item = mFile.add(actionNew); mFile.add(item); ImageIcon iconOpen = new ImageIcon("file_open.gif"); Action actionOpen = new AbstractAction("Open...", iconOpen) { public void actionPerformed(ActionEvent e) { System.out.println("open action"); } }; item = mFile.add(actionOpen); mFile.add(item); ImageIcon iconSave = new ImageIcon("file_save.gif"); Action actionSave = new AbstractAction("Save...", iconSave) { public void actionPerformed(ActionEvent e) { System.out.println("save action"); } }; item = mFile.add(actionSave); mFile.add(item); mFile.addSeparator(); Action actionExit = new AbstractAction("Exit") { public void actionPerformed(ActionEvent e) { System.exit(0); } }; item = mFile.add(actionExit); item.setMnemonic('x'); menuBar.add(mFile); toolBar = new JToolBar(); JButton btn1 = toolBar.add(actionNew); btn1.setToolTipText("New text"); JButton btn2 = toolBar.add(actionOpen); btn2.setToolTipText("Open text file"); JButton btn3 = toolBar.add(actionSave); btn3.setToolTipText("Save text file"); ActionListener fontListener = new ActionListener() { public void actionPerformed(ActionEvent e) { updateMonitor(); } }; JMenu mFont = new JMenu("Font"); mFont.setMnemonic('o'); ButtonGroup group = new ButtonGroup(); fontMenus = new JMenuItem[FontNames.length]; for (int k = 0; k < FontNames.length; k++) { int m = k + 1; fontMenus[k] = new JRadioButtonMenuItem(m + " " + FontNames[k]); boolean selected = (k == 0); fontMenus[k].setSelected(selected); fontMenus[k].setMnemonic('1' + k); fontMenus[k].setFont(fonts[k]); fontMenus[k].addActionListener(fontListener); group.add(fontMenus[k]); mFont.add(fontMenus[k]); } mFont.addSeparator(); boldMenu.setMnemonic('b'); Font fn = fonts[1].deriveFont(Font.BOLD); boldMenu.setFont(fn); boldMenu.setSelected(false); boldMenu.addActionListener(fontListener); mFont.add(boldMenu); italicMenu.setMnemonic('i'); fn = fonts[1].deriveFont(Font.ITALIC); italicMenu.setFont(fn); italicMenu.setSelected(false); italicMenu.addActionListener(fontListener); mFont.add(italicMenu); menuBar.add(mFont); getContentPane().add(toolBar, BorderLayout.NORTH); return menuBar; }
From source file:Main.java
protected JMenuBar createMenuBar() { final JMenuBar menuBar = new JMenuBar(); JMenu mFont = new JMenu("Font"); mFont.setMnemonic('o'); ButtonGroup group = new ButtonGroup(); fontMenus = new JMenuItem[FontName.length]; for (int k = 0; k < FontName.length; k++) { int m = k + 1; fontMenus[k] = new JRadioButtonMenuItem(m + " " + FontName[k]); boolean selected = (k == 0); fontMenus[k].setSelected(selected); fontMenus[k].setMnemonic('1' + k); fontMenus[k].setFont(fonts[k]);//from ww w. ja v a 2s.c o m fontMenus[k].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.out.println(((JComponent) arg0.getSource()).getFont()); } }); group.add(fontMenus[k]); mFont.add(fontMenus[k]); } menuBar.add(mFont); return menuBar; }
From source file:FrameDemo2.java
protected JComponent createOptionControls() { JLabel label1 = new JLabel("Decoration options for subsequently created frames:"); ButtonGroup bg1 = new ButtonGroup(); JLabel label2 = new JLabel("Icon options:"); ButtonGroup bg2 = new ButtonGroup(); // Create the buttons JRadioButton rb1 = new JRadioButton(); rb1.setText("Look and feel decorated"); rb1.setActionCommand(LF_DECORATIONS); rb1.addActionListener(this); rb1.setSelected(true);//from ww w .j a v a 2 s. c o m bg1.add(rb1); // JRadioButton rb2 = new JRadioButton(); rb2.setText("Window system decorated"); rb2.setActionCommand(WS_DECORATIONS); rb2.addActionListener(this); bg1.add(rb2); // JRadioButton rb3 = new JRadioButton(); rb3.setText("No decorations"); rb3.setActionCommand(NO_DECORATIONS); rb3.addActionListener(this); bg1.add(rb3); // // JRadioButton rb4 = new JRadioButton(); rb4.setText("Default icon"); rb4.setActionCommand(DEFAULT_ICON); rb4.addActionListener(this); rb4.setSelected(true); bg2.add(rb4); // JRadioButton rb5 = new JRadioButton(); rb5.setText("Icon from a JPEG file"); rb5.setActionCommand(FILE_ICON); rb5.addActionListener(this); bg2.add(rb5); // JRadioButton rb6 = new JRadioButton(); rb6.setText("Painted icon"); rb6.setActionCommand(PAINT_ICON); rb6.addActionListener(this); bg2.add(rb6); // Add everything to a container. Box box = Box.createVerticalBox(); box.add(label1); box.add(Box.createVerticalStrut(5)); // spacer box.add(rb1); box.add(rb2); box.add(rb3); // box.add(Box.createVerticalStrut(15)); // spacer box.add(label2); box.add(Box.createVerticalStrut(5)); // spacer box.add(rb4); box.add(rb5); box.add(rb6); // Add some breathing room. box.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); return box; }
From source file:edu.ucla.stat.SOCR.chart.SuperXYChart_QQ.java
public void initMapPanel() { listIndex = new int[dataTable.getColumnCount()]; for (int j = 0; j < listIndex.length; j++) listIndex[j] = 1;/*from w w w.j ava 2 s .co m*/ bPanel = new JPanel(new BorderLayout()); mapPanel = new JPanel(new GridLayout(2, 3, 50, 50)); bPanel.add(mapPanel, BorderLayout.CENTER); addButton1.addActionListener(this); addButton2.addActionListener(this); removeButton1.addActionListener(this); removeButton2.addActionListener(this); lModelAdded = new DefaultListModel(); lModelDep = new DefaultListModel(); lModelIndep = new DefaultListModel(); int cellWidth = 10; listAdded = new JList(lModelAdded); listAdded.setSelectedIndex(0); listDepRemoved = new JList(lModelDep); listIndepRemoved = new JList(lModelIndep); paintMappingLists(listIndex); listAdded.setFixedCellWidth(cellWidth); listDepRemoved.setFixedCellWidth(cellWidth); listIndepRemoved.setFixedCellWidth(cellWidth); tools1 = new JToolBar(JToolBar.VERTICAL); tools2 = new JToolBar(JToolBar.VERTICAL); tools1.add(depLabel); // tools2.add(indLabel); tools1.setFloatable(false); tools2.setFloatable(false); tools1.add(addButton1); tools1.add(removeButton1); // tools2.add(addButton2); // tools2.add(removeButton2); JRadioButton disChoices_normal; JRadioButton disChoices_poisson; // JPanel choicesPanel = new JPanel(); disChoices_normal = new JRadioButton("Normal"); disChoices_normal.addActionListener(this); disChoices_normal.setActionCommand(NORMAL); disChoices_normal.setSelected(true); disChoice = NORMAL; disChoices_poisson = new JRadioButton("Poisson"); disChoices_poisson.addActionListener(this); disChoices_poisson.setActionCommand(POISSON); ButtonGroup group = new ButtonGroup(); group.add(disChoices_normal); group.add(disChoices_poisson); choicesPanel.add(new JLabel("Choices of distribution:")); choicesPanel.add(disChoices_normal); choicesPanel.add(disChoices_poisson); choicesPanel.setPreferredSize(new Dimension(200, 100)); mapPanel.add(new JScrollPane(listAdded)); mapPanel.add(tools1); mapPanel.add(new JScrollPane(listDepRemoved)); // JPanel emptyPanel = new JPanel(new GridLayout(0,1)); // mapPanel.add(emptyPanel); mapPanel.add(choicesPanel); mapPanel.add(tools2); mapPanel.add(new JScrollPane(listIndepRemoved)); }
From source file:net.sf.jabref.gui.openoffice.OpenOfficePanel.java
private void showSettingsPopup() { JPopupMenu menu = new JPopupMenu(); final JCheckBoxMenuItem autoSync = new JCheckBoxMenuItem( Localization.lang("Automatically sync bibliography when inserting citations"), preferences.syncWhenCiting()); final JRadioButtonMenuItem useActiveBase = new JRadioButtonMenuItem( Localization.lang("Look up BibTeX entries in the active tab only")); final JRadioButtonMenuItem useAllBases = new JRadioButtonMenuItem( Localization.lang("Look up BibTeX entries in all open databases")); final JMenuItem clearConnectionSettings = new JMenuItem(Localization.lang("Clear connection settings")); ButtonGroup bg = new ButtonGroup(); bg.add(useActiveBase); bg.add(useAllBases);//from w ww. j a v a 2s .c o m if (preferences.useAllDatabases()) { useAllBases.setSelected(true); } else { useActiveBase.setSelected(true); } autoSync.addActionListener(e -> preferences.setSyncWhenCiting(autoSync.isSelected())); useAllBases.addActionListener(e -> preferences.setUseAllDatabases(useAllBases.isSelected())); useActiveBase.addActionListener(e -> preferences.setUseAllDatabases(!useActiveBase.isSelected())); clearConnectionSettings.addActionListener(e -> frame.output(preferences.clearConnectionSettings())); menu.add(autoSync); menu.addSeparator(); menu.add(useActiveBase); menu.add(useAllBases); menu.addSeparator(); menu.add(clearConnectionSettings); menu.show(settingsB, 0, settingsB.getHeight()); }
From source file:com.milkdairy.collectionsmodule.CollectionsUpdateFormJPanel.java
public void init() { this.setLayout(null); System.setProperty("collectionsStoredFormColor", this.color); this.setBackground(Color.getColor("collectionsStoredFormColor")); this.formerIDL = this.addComponent(formerIDL, milkManagementSystemService.xPoint, milkManagementSystemService.yPoint, milkManagementSystemService.lblWidth, milkManagementSystemService.lblHeight); this.formerIDL.setText("Former ID"); formerIDTF = this.addComponent(formerIDTF, milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 20, milkManagementSystemService.yPoint, milkManagementSystemService.tfWidth, milkManagementSystemService.tflHeight); formerIDTF.setEditable(false);/* ww w . j a v a 2 s . c om*/ this.formerIDErrorL = this.addComponent(formerIDErrorL, milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + milkManagementSystemService.tfWidth + 40, milkManagementSystemService.yPoint, milkManagementSystemService.lblWidth, milkManagementSystemService.lblHeight); this.formerIDErrorL.setForeground(Color.RED); this.formerNameL = this.addComponent(formerNameL, milkManagementSystemService.xPoint, milkManagementSystemService.yPoint + 40, milkManagementSystemService.lblWidth, milkManagementSystemService.lblHeight); this.formerNameL.setText("Former Name"); formerNameTF = this.addComponent(formerNameTF, milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 20, milkManagementSystemService.yPoint + 40, milkManagementSystemService.tfWidth, milkManagementSystemService.tflHeight); formerNameTF.setEditable(false); this.formerNameErrorL = this.addComponent(formerNameErrorL, milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + milkManagementSystemService.tfWidth + 40, milkManagementSystemService.yPoint + 40, milkManagementSystemService.lblWidth, milkManagementSystemService.lblHeight); this.formerNameErrorL.setForeground(Color.RED); this.milkPadL = this.addComponent(milkPadL, milkManagementSystemService.xPoint, milkManagementSystemService.yPoint + 80, milkManagementSystemService.lblWidth, milkManagementSystemService.lblHeight); this.milkPadL.setText("Milk Pad Value"); milkPadTF = this.addComponent(milkPadTF, milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 20, milkManagementSystemService.yPoint + 80, milkManagementSystemService.tfWidth, milkManagementSystemService.tflHeight); this.milkPadErrorL = this.addComponent(milkPadErrorL, milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + milkManagementSystemService.tfWidth + 40, milkManagementSystemService.yPoint + 80, milkManagementSystemService.lblWidth, milkManagementSystemService.lblHeight); this.milkPadErrorL.setForeground(Color.RED); this.milkValueL = this.addComponent(milkValueL, milkManagementSystemService.xPoint, milkManagementSystemService.yPoint + 120, milkManagementSystemService.lblWidth, milkManagementSystemService.lblHeight); this.milkValueL.setText("Milk Quantity"); milkValueTF = this.addComponent(milkValueTF, milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 20, milkManagementSystemService.yPoint + 120, milkManagementSystemService.tfWidth, milkManagementSystemService.tflHeight); this.milkValueErrorL = this.addComponent(milkValueErrorL, milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + milkManagementSystemService.tfWidth + 40, milkManagementSystemService.yPoint + 120, milkManagementSystemService.lblWidth, milkManagementSystemService.lblHeight); this.milkValueErrorL.setForeground(Color.RED); this.milkPriceL = this.addComponent(milkPriceL, milkManagementSystemService.xPoint, milkManagementSystemService.yPoint + 160, milkManagementSystemService.lblWidth, milkManagementSystemService.lblHeight); this.milkPriceL.setText("Milk Price"); milkPriceTF = this.addComponent(milkPriceTF, milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 20, milkManagementSystemService.yPoint + 160, milkManagementSystemService.tfWidth, milkManagementSystemService.tflHeight); this.milkPriceErrorL = this.addComponent(milkPriceErrorL, milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + milkManagementSystemService.tfWidth + 40, milkManagementSystemService.yPoint + 160, milkManagementSystemService.lblWidth, milkManagementSystemService.lblHeight); this.milkPriceErrorL.setForeground(Color.RED); this.saveBtn = this.addComponent(this.saveBtn, milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 20, milkManagementSystemService.yPoint + 200, 80, 30); this.saveBtn.setText("Save"); this.saveBtn.setForeground(Color.BLUE); this.add(this.saveBtn); this.saveBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { milkPriceErrorL.setText(""); milkPadErrorL.setText(""); milkValueErrorL.setText(""); milkPriceErrorL.setText(""); formerNameErrorL.setText(""); formerIDErrorL.setText(""); if ("".equals(formerIDTF.getText())) { formerIDErrorL.setText(ERROR_FORM); } else if ("".equals(formerNameTF.getText())) { formerNameErrorL.setText(ERROR_FORM); } else if ("".equals(milkPadTF.getText())) { milkPadErrorL.setText(ERROR_FORM); } else if ("".equals(milkValueTF.getText())) { milkValueErrorL.setText(ERROR_FORM); } else if ("".equals(milkPriceTF.getText())) { milkPriceErrorL.setText(ERROR_FORM); } // else if (formerIDCombo.getSelectedItem() == null) { // System.out.println("Former id selection Error"); // } // else if (startdateTimePicker == null) { // System.out.println("date selection Error"); // } else { Milk milk = new Milk(); milk.setFormerID(formerIDCombo.getSelectedItem().toString()); milk.setName(formerNameTF.getText()); milk.setPadValue(milkPadTF.getText()); milk.setQuantity(milkValueTF.getText()); milk.setRate(milkPriceTF.getText()); milk.setDate("dsad"); System.out.println("Im in Former create and save submit action " + milk.toString()); //filePersistenceManager.save(milk); } System.out.println("Im in Former create and update submit action"); } }); this.resetBtn = this.addComponent(this.resetBtn, milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth + 140, milkManagementSystemService.yPoint + 200, 80, 30); this.resetBtn.setText("Reset"); this.resetBtn.setForeground(Color.BLUE); this.add(this.resetBtn); this.resetBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { milkPriceTF.setText(""); milkPadTF.setText(""); milkValueTF.setText(""); milkPriceTF.setText(""); System.out.println("Im in Former create and update submit action"); } }); collectionMonthDetailsJP = new CollectionMonthDetailsJPanel(); collectionMonthDetailsJP.setBounds( milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth * 2 + milkManagementSystemService.tfWidth * 2, milkManagementSystemService.yPoint, (milkManagementSystemService.SCREEN_WIDTH / 2) - milkManagementSystemService.tfWidth / 5, 400); this.add(collectionMonthDetailsJP); List<String> formerIds = persistenceManager.getFormerValues("id"); if (!CollectionUtils.isEmpty(formerIds)) { ids = new String[formerIds.size()]; formerIds.toArray(ids); } formerIDCombo = new JComboBox(ids); // has to be editable formerIDCombo.setEditable(true); // change the editor's document new CustomInitialSelectionComboBox(formerIDCombo); formerIDCombo.setBounds( milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth * 2 + milkManagementSystemService.tfWidth + 40, milkManagementSystemService.yPoint, milkManagementSystemService.lblWidth + 20, milkManagementSystemService.lblHeight + 10); formerIDCombo.setMaximumRowCount(5); this.add(formerIDCombo); List<String> formerNames = persistenceManager.getFormerValues("name"); if (!CollectionUtils.isEmpty(formerNames)) { names = new String[formerNames.size()]; formerNames.toArray(names); } System.out.println("Names1 " + formerNames); formerNameCombo = new JComboBox(names); // has to be editable formerNameCombo.setEditable(true); // change the editor's document new CustomInitialSelectionComboBox(formerNameCombo); //customerIDListScrollPane = new JScrollPane(customerIDCombo); formerNameCombo.setBounds( milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth * 2 + milkManagementSystemService.tfWidth + 40, milkManagementSystemService.yPoint + milkManagementSystemService.lblHeight + 20, milkManagementSystemService.lblWidth + 20, milkManagementSystemService.lblHeight + 10); formerNameCombo.setMaximumRowCount(5); this.add(formerNameCombo); UtilDateModel model = new UtilDateModel(); model.setDate(2016, 04, 16); model.setSelected(true); Properties p = new Properties(); p.put("text.today", "Today"); p.put("text.month", "Month"); p.put("text.year", "Year"); JDatePanelImpl datePanel = new JDatePanelImpl(model, p); datePicker = new JDatePickerImpl(datePanel, new DateLabelFormatter()); datePicker.setBounds( milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth * 2 + milkManagementSystemService.tfWidth + 40, milkManagementSystemService.yPoint + milkManagementSystemService.lblHeight + 60, milkManagementSystemService.lblWidth + 20, milkManagementSystemService.lblHeight + 5); this.add(datePicker); am = new JRadioButton("AM", true); pm = new JRadioButton("PM"); //Group the radio buttons. ButtonGroup amPmgroup = new ButtonGroup(); amPmgroup.add(am); amPmgroup.add(pm); am.setBounds( milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth * 2 + milkManagementSystemService.tfWidth + 40, milkManagementSystemService.yPoint + milkManagementSystemService.lblHeight + 100, milkManagementSystemService.lblWidth / 2, milkManagementSystemService.lblHeight + 5); this.add(am); pm.setBounds( milkManagementSystemService.xPoint + milkManagementSystemService.lblWidth * 2 + milkManagementSystemService.tfWidth + 40 + milkManagementSystemService.lblWidth / 2, milkManagementSystemService.yPoint + milkManagementSystemService.lblHeight + 100, milkManagementSystemService.lblWidth / 2, milkManagementSystemService.lblHeight + 5); this.add(pm); this.search = this.addComponent(this.search, milkManagementSystemService.xPoint + (milkManagementSystemService.lblWidth * 2) + milkManagementSystemService.tfWidth + 60, milkManagementSystemService.yPoint + 200, 80, 30); this.search.setText("Search"); this.search.setForeground(Color.BLUE); this.add(this.search); this.search.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { System.out.println("Im in Former create and update submit action"); System.out.println("Former id" + (String) formerIDCombo.getSelectedItem()); System.out.println("Former name" + (String) formerNameCombo.getSelectedItem()); System.out.println("Am " + am.isSelected()); System.out.println("pm " + pm.isSelected()); String forID = (String) formerIDCombo.getSelectedItem(); String forName = (String) formerNameCombo.getSelectedItem(); String amPMStr = am.isSelected() ? "AM" : "PM"; String dateTime = DateTimeUtil .convertdateToStringeWithTime((Date) datePicker.getModel().getValue()); System.out.println("Seleted date " + dateTime); List<Collection> collectionList = persistenceManager.getCollectionsBy(forID, forName, amPMStr, dateTime); if (!CollectionUtils.isEmpty(collectionList)) { Collection searchCollection = collectionList.get(0); formerNameTF.setText(searchCollection.getFormerName()); ; formerIDTF.setText(searchCollection.getFormerID()); ; milkPadTF.setText(searchCollection.getMilkPad()); ; milkValueTF.setText(searchCollection.getMilkQuantity()); ; milkPriceTF.setText(searchCollection.getMilkPrice()); ; } } }); // UtilDateModel model = new UtilDateModel(); // JDatePanelImpl datePanel = new JDatePanelImpl(model, null); // JDatePickerImpl datePicker = new JDatePickerImpl(datePanel, null); // // this.add(datePicker); // JSpinner timeSpinner = new JSpinner( new SpinnerDateModel() ); // JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(timeSpinner, "HH:mm:ss"); // timeSpinner.setEditor(timeEditor); // timeSpinner.setValue(new Date()); // timeSpinner.setBounds(); // this.add(timeSpinner); // DateTimePicker dateTimePicker = new DateTimePicker(); // dateTimePicker.setFormats( DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.MEDIUM ) ); // dateTimePicker.setTimeFormat( DateFormat.getTimeInstance( DateFormat.MEDIUM ) ); // dateTimePicker.setDate(new Date()); // dateTimePicker.setBounds(milkManagementSystemService.xPoint // + (milkManagementSystemService.lblWidth*2)+milkManagementSystemService.tfWidth+60, // milkManagementSystemService.yPoint + 200, 80, 30); // this.add(dateTimePicker); }
From source file:com.emental.mindraider.ui.dialogs.AttachmentJDialog.java
/** * Concetructor./* w w w .j a v a2 s. co m*/ * * @param noteResource * The concept resource. * @param dragAndDropReference * The drag'n'drop reference. */ public AttachmentJDialog(ConceptResource conceptResource, DragAndDropReference dragAndDropReference) { super(Messages.getString("AttachmentJDialog.title")); this.conceptResource = conceptResource; getContentPane().setLayout(new BorderLayout()); JPanel p, pp; p = new JPanel(); p.setLayout(new BorderLayout()); JLabel intro = new JLabel("<html> " + Messages.getString("AttachmentJDialog.introduction") + " <br><br></html>"); p.add(intro, BorderLayout.NORTH); p.add(new JLabel("<html> " + Messages.getString("AttachmentJDialog.description") + "</html>"), BorderLayout.CENTER); description = new JTextField(38); pp = new JPanel(new FlowLayout(FlowLayout.LEFT)); pp.add(description); p.add(pp, BorderLayout.SOUTH); getContentPane().add(p, BorderLayout.NORTH); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.setBorder(new TitledBorder(Messages.getString("AttachmentJDialog.resource"))); ButtonGroup attachType = new ButtonGroup(); JPanel webPanel = new JPanel(); webPanel.setLayout(new BorderLayout()); webType = new JRadioButton(Messages.getString("AttachmentJDialog.web")); webType.setActionCommand(WEB); webType.addActionListener(this); webType.setSelected(true); attachType.add(webType); webPanel.add(webType, BorderLayout.NORTH); urlTextField = new JTextField("http://", 35); urlTextField.selectAll(); urlTextField.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) { attach(); } } public void keyReleased(KeyEvent keyEvent) { } public void keyTyped(KeyEvent keyEvent) { } }); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT)); p.add(new JLabel(" ")); p.add(urlTextField); webPanel.add(p, BorderLayout.SOUTH); mainPanel.add(webPanel, BorderLayout.NORTH); JPanel localPanel = new JPanel(); localPanel.setLayout(new BorderLayout()); JRadioButton localType = new JRadioButton(Messages.getString("AttachmentJDialog.local")); localType.setActionCommand(LOCAL); localType.addActionListener(this); localPanel.add(localType, BorderLayout.NORTH); pathTextField = new JTextField(35); pathTextField.setEnabled(false); browseButton = new JButton(Messages.getString("AttachmentJDialog.browse")); browseButton.setToolTipText(Messages.getString("AttachmentJDialog.browseTip")); browseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setApproveButtonText(Messages.getString("AttachmentJDialog.attach")); fc.setControlButtonsAreShown(true); fc.setDialogTitle(Messages.getString("AttachmentJDialog.chooseAttachment")); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); int returnVal = fc.showOpenDialog(AttachmentJDialog.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); pathTextField.setText(file.toString()); } } }); browseButton.setEnabled(false); pp = new JPanel(); pp.setLayout(new BorderLayout()); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.LEFT)); p.add(new JLabel(" ")); pp.add(p, BorderLayout.NORTH); p.add(pathTextField); p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); p.add(browseButton); pp.add(p, BorderLayout.SOUTH); localPanel.add(pp, BorderLayout.SOUTH); attachType.add(localType); mainPanel.add(localPanel, BorderLayout.SOUTH); getContentPane().add(mainPanel, BorderLayout.CENTER); // buttons p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.CENTER)); JButton addButton = new JButton(Messages.getString("AttachmentJDialog.attach")); p.add(addButton); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { attach(); } }); JButton cancelButton = new JButton(Messages.getString("AttachmentJDialog.cancel")); p.add(cancelButton); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AttachmentJDialog.this.dispose(); } }); getContentPane().add(p, BorderLayout.SOUTH); /* * drag and drop initialization */ if (dragAndDropReference != null) { if (dragAndDropReference.getType() == DragAndDropReference.BROWSER_LINK) { urlTextField.setText(dragAndDropReference.getReference()); localType.setSelected(false); webType.setSelected(true); enableWebTypeButtons(); } else { pathTextField.setText(dragAndDropReference.getReference()); localType.setSelected(true); webType.setSelected(false); enableLocalTypeButtons(); } description.setText(dragAndDropReference.getTitle()); } pack(); Gfx.centerAndShowWindow(this); }
From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.area.AreaDoseResponseController.java
/** * Initialize main view//from w w w . j a va2s . c o m */ @Override protected void initMainView() { dRPanel = new DRPanel(); //create a ButtonGroup for the radioButtons used for analysis ButtonGroup mainDRRadioButtonGroup = new ButtonGroup(); //adding buttons to a ButtonGroup automatically deselect one when another one gets selected mainDRRadioButtonGroup.add(dRPanel.getInputDRButton()); mainDRRadioButtonGroup.add(dRPanel.getInitialPlotDRButton()); mainDRRadioButtonGroup.add(dRPanel.getNormalizedPlotDRButton()); mainDRRadioButtonGroup.add(dRPanel.getResultsDRButton()); //select as default first button dRPanel.getInputDRButton().setSelected(true); //init dataTable dataTable = new JTable(); JScrollPane scrollPane = new JScrollPane(dataTable); //the table will take all the viewport height available dataTable.setFillsViewportHeight(true); scrollPane.getViewport().setBackground(Color.white); dataTable.getTableHeader().setReorderingAllowed(false); //row and column selection must be false //dataTable.setColumnSelectionAllowed(false); //dataTable.setRowSelectionAllowed(false); dRPanel.getDatatableDRPanel().add(scrollPane, BorderLayout.CENTER); /** * When button is selected, switch view to corresponding subview */ dRPanel.getInputDRButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //switch shared table view updateModelInTable(dRInputController.getTableModel()); updateTableInfoMessage("This table contains all conditions and their respective slopes"); /** * for (int columnIndex = 0; columnIndex < * dataTable.getColumnCount(); columnIndex++) { * GuiUtils.packColumn(dataTable, columnIndex); } */ dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT)); //remove other panels dRInitialController.getInitialChartPanel().setChart(null); dRNormalizedController.getNormalizedChartPanel().setChart(null); dRResultsController.getDupeInitialChartPanel().setChart(null); dRResultsController.getDupeNormalizedChartPanel().setChart(null); dRPanel.getGraphicsDRParentPanel().removeAll(); dRPanel.getGraphicsDRParentPanel().revalidate(); dRPanel.getGraphicsDRParentPanel().repaint(); //add panel to view dRPanel.getGraphicsDRParentPanel().add(dRInputController.getdRInputPanel(), gridBagConstraints); } }); dRPanel.getInitialPlotDRButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dRAnalysisGroup != null) { if (isFirstFitting()) { initFirstFitting(); setFirstFitting(false); } //switch shared table view updateModelInTable(dRInitialController.getTableModel()); updateTableInfoMessage( "Concentrations of conditions selected previously have been log-transformed, slopes have not been changed"); /** * for (int columnIndex = 0; columnIndex < * dataTable.getColumnCount(); columnIndex++) { * GuiUtils.packColumn(dataTable, columnIndex); } */ dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT)); //remove other panels dRNormalizedController.getNormalizedChartPanel().setChart(null); dRResultsController.getDupeInitialChartPanel().setChart(null); dRResultsController.getDupeNormalizedChartPanel().setChart(null); dRPanel.getGraphicsDRParentPanel().removeAll(); dRPanel.getGraphicsDRParentPanel().revalidate(); dRPanel.getGraphicsDRParentPanel().repaint(); dRPanel.getGraphicsDRParentPanel().add(dRInitialController.getDRInitialPlotPanel(), gridBagConstraints); //Plot fitted data in dose-response curve, along with R annotation plotDoseResponse(dRInitialController.getInitialChartPanel(), dRInitialController.getDRInitialPlotPanel().getDoseResponseChartParentPanel(), getDataToFit(false), getdRAnalysisGroup(), false); } } }); dRPanel.getNormalizedPlotDRButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dRAnalysisGroup != null) { //in case user skips "initial" subview and goes straight to normalization if (isFirstFitting()) { initFirstFitting(); setFirstFitting(false); } //switch shared table view updateModelInTable(dRNormalizedController.getTableModel()); updateTableInfoMessage( "Log-transformed concentrations with their normalized responses per replicate"); /** * for (int columnIndex = 0; columnIndex < * dataTable.getColumnCount(); columnIndex++) { * GuiUtils.packColumn(dataTable, columnIndex); } */ dataTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer(SwingConstants.LEFT)); //remove other panels dRInitialController.getInitialChartPanel().setChart(null); dRResultsController.getDupeInitialChartPanel().setChart(null); dRResultsController.getDupeNormalizedChartPanel().setChart(null); dRPanel.getGraphicsDRParentPanel().removeAll(); dRPanel.getGraphicsDRParentPanel().revalidate(); dRPanel.getGraphicsDRParentPanel().repaint(); dRPanel.getGraphicsDRParentPanel().add(dRNormalizedController.getDRNormalizedPlotPanel(), gridBagConstraints); //Plot fitted data in dose-response curve, along with R annotation plotDoseResponse(dRNormalizedController.getNormalizedChartPanel(), dRNormalizedController.getDRNormalizedPlotPanel().getDoseResponseChartParentPanel(), getDataToFit(true), getdRAnalysisGroup(), true); } } }); dRPanel.getResultsDRButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (dRAnalysisGroup != null) { //switch shared table view: create and set new table model with most recent statistical values // (these values get recalculated after each new fitting) dRResultsController.setTableModel(dRResultsController.reCreateTableModel(dRAnalysisGroup)); updateModelInTable(dRResultsController.getTableModel()); updateTableInfoMessage( "Statistical values from the curve fit of the initial and normalized data."); //remove other panels dRInitialController.getInitialChartPanel().setChart(null); dRNormalizedController.getNormalizedChartPanel().setChart(null); dRPanel.getGraphicsDRParentPanel().removeAll(); dRPanel.getGraphicsDRParentPanel().revalidate(); dRPanel.getGraphicsDRParentPanel().repaint(); dRPanel.getGraphicsDRParentPanel().add(dRResultsController.getdRResultsPanel(), gridBagConstraints); //plot curves dRResultsController.plotCharts(); } } }); //add view to parent panel areaMainController.getAreaAnalysisPanel().getDoseResponseParentPanel().add(dRPanel, gridBagConstraints); }
From source file:net.sf.jabref.openoffice.OpenOfficePanel.java
private void showSettingsPopup() { JPopupMenu menu = new JPopupMenu(); final JCheckBoxMenuItem autoSync = new JCheckBoxMenuItem( Localization.lang("Automatically sync bibliography when inserting citations"), Globals.prefs.getBoolean(JabRefPreferences.SYNC_OO_WHEN_CITING)); final JRadioButtonMenuItem useActiveBase = new JRadioButtonMenuItem( Localization.lang("Look up BibTeX entries in the active tab only")); final JRadioButtonMenuItem useAllBases = new JRadioButtonMenuItem( Localization.lang("Look up BibTeX entries in all open databases")); final JMenuItem clearConnectionSettings = new JMenuItem(Localization.lang("Clear connection settings")); ButtonGroup bg = new ButtonGroup(); bg.add(useActiveBase); bg.add(useAllBases);/* w w w . j av a 2 s. c om*/ if (Globals.prefs.getBoolean(JabRefPreferences.USE_ALL_OPEN_BASES)) { useAllBases.setSelected(true); } else { useActiveBase.setSelected(true); } autoSync.addActionListener( e -> Globals.prefs.putBoolean(JabRefPreferences.SYNC_OO_WHEN_CITING, autoSync.isSelected())); useAllBases.addActionListener( e -> Globals.prefs.putBoolean(JabRefPreferences.USE_ALL_OPEN_BASES, useAllBases.isSelected())); useActiveBase.addActionListener( e -> Globals.prefs.putBoolean(JabRefPreferences.USE_ALL_OPEN_BASES, !useActiveBase.isSelected())); clearConnectionSettings.addActionListener(e -> { Globals.prefs.clear(JabRefPreferences.OO_PATH); Globals.prefs.clear(JabRefPreferences.OO_EXECUTABLE_PATH); Globals.prefs.clear(JabRefPreferences.OO_JARS_PATH); frame.output(Localization.lang("Cleared connection settings.")); }); menu.add(autoSync); menu.addSeparator(); menu.add(useActiveBase); menu.add(useAllBases); menu.addSeparator(); menu.add(clearConnectionSettings); menu.show(settingsB, 0, settingsB.getHeight()); }