List of usage examples for javax.swing JRadioButton JRadioButton
public JRadioButton(String text)
From source file:edu.uci.ics.jung.samples.LensVertexImageShaperDemo.java
/** * create an instance of a simple graph with controls to * demo the zoom features.// ww w . j av a 2 s .c o m * */ @SuppressWarnings("rawtypes") public LensVertexImageShaperDemo() { // create a simple graph for the demo graph = new DirectedSparseGraph<Number, Number>(); Number[] vertices = createVertices(11); // a Map for the labels Map<Number, String> map = new HashMap<Number, String>(); for (int i = 0; i < vertices.length; i++) { map.put(vertices[i], iconNames[i % iconNames.length]); } // a Map for the Icons Map<Number, Icon> iconMap = new HashMap<Number, Icon>(); for (int i = 0; i < vertices.length; i++) { String name = "/images/topic" + iconNames[i] + ".gif"; try { Icon icon = new LayeredIcon( new ImageIcon(LensVertexImageShaperDemo.class.getResource(name)).getImage()); iconMap.put(vertices[i], icon); } catch (Exception ex) { System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); } } createEdges(vertices); FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(600, 600)); Transformer<Number, Paint> vpf = new PickableVertexPaintTransformer<Number>(vv.getPickedVertexState(), Color.white, Color.yellow); vv.getRenderContext().setVertexFillPaintTransformer(vpf); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan)); vv.setBackground(Color.white); final Transformer<Number, String> vertexStringerImpl = new VertexStringerImpl<Number>(map); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); // features on and off. For a real application, use VertexIconAndShapeFunction instead. final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>( new EllipseVertexShapeTransformer<Number>()); final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>(); vertexImageShapeFunction.setIconMap(iconMap); vertexIconFunction.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction); vv.getRenderContext().setVertexIconTransformer(vertexIconFunction); // Get the pickedState and add a listener that will decorate the // Vertex images with a checkmark icon when they are picked PickedState<Number> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener(vertexIconFunction)); vv.addPostRenderPaintable(new VisualizationViewer.Paintable() { int x; int y; Font font; FontMetrics metrics; int swidth; int sheight; String str = "Thank You, slashdot.org, for the images!"; public void paint(Graphics g) { Dimension d = vv.getSize(); if (font == null) { font = new Font(g.getFont().getName(), Font.BOLD, 20); metrics = g.getFontMetrics(font); swidth = metrics.stringWidth(str); sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); x = (d.width - swidth) / 2; y = (int) (d.height - sheight * 1.5); } g.setFont(font); Color oldColor = g.getColor(); g.setColor(Color.lightGray); g.drawString(str, x, y); g.setColor(oldColor); } public boolean useTransform() { return false; } }); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse(); vv.setGraphMouse(graphMouse); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JComboBox modeBox = graphMouse.getModeComboBox(); JPanel modePanel = new JPanel(); modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode")); modePanel.add(modeBox); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); controls.add(modePanel); content.add(controls, BorderLayout.SOUTH); this.viewSupport = new MagnifyImageLensSupport<Number, Number>(vv); // new ViewLensSupport<Number,Number>(vv, new HyperbolicShapeTransformer(vv, // vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW)), // new ModalLensGraphMouse()); this.modelSupport = new LayoutLensSupport<Number, Number>(vv); graphMouse.addItemListener(modelSupport.getGraphMouse().getModeListener()); graphMouse.addItemListener(viewSupport.getGraphMouse().getModeListener()); ButtonGroup radio = new ButtonGroup(); JRadioButton none = new JRadioButton("None"); none.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (viewSupport != null) { viewSupport.deactivate(); } if (modelSupport != null) { modelSupport.deactivate(); } } }); none.setSelected(true); JRadioButton hyperView = new JRadioButton("View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JRadioButton hyperModel = new JRadioButton("Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { modelSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); radio.add(none); radio.add(hyperView); radio.add(hyperModel); JMenuBar menubar = new JMenuBar(); JMenu modeMenu = graphMouse.getModeMenu(); menubar.add(modeMenu); JPanel lensPanel = new JPanel(new GridLayout(2, 0)); lensPanel.setBorder(BorderFactory.createTitledBorder("Lens")); lensPanel.add(none); lensPanel.add(hyperView); lensPanel.add(hyperModel); controls.add(lensPanel); }
From source file:com.att.aro.ui.view.menu.datacollector.DeviceDialogOptions.java
private void loadRadioGroupCollector() { rooted = ResourceBundleHelper.getMessageString("dlog.collector.option.rooted"); vpn = ResourceBundleHelper.getMessageString("dlog.collector.option.vpn"); btnRooted = new JRadioButton(rooted); btnVpn = new JRadioButton(vpn); btnRooted.setActionCommand(rooted);//from w ww . j av a 2 s .c o m btnVpn.setActionCommand(vpn); btnRooted.setMnemonic(KeyEvent.VK_R); btnVpn.setMnemonic(KeyEvent.VK_V); btnRooted.addActionListener(this); btnVpn.addActionListener(this); btnRooted.setEnabled(false); btnVpn.setSelected(true); // only group the rooted & vpn radioBtnVpnRoot = new ButtonGroup(); radioBtnVpnRoot.add(btnRooted); radioBtnVpnRoot.add(btnVpn); btnRooted.setEnabled(true); }
From source file:emailplugin.MailCreator.java
/** * Gives the User the opportunity to specify which Desktop he uses (KDE or * Gnome)//from www . ja v a2 s .c o m * * @param parent * Parent Dialog * @return true if KDE or Gnome has been selected, false if the User wanted to * specify the App */ private boolean showKdeGnomeDialog(Frame parent) { final JDialog dialog = new JDialog(parent, true); dialog.setTitle(mLocalizer.msg("chooseTitle", "Choose")); JPanel panel = (JPanel) dialog.getContentPane(); panel.setLayout(new FormLayout("10dlu, fill:pref:grow", "default, 3dlu, default, 3dlu, default, 3dlu, default, 3dlu:grow, default")); panel.setBorder(Borders.DIALOG_BORDER); CellConstraints cc = new CellConstraints(); panel.add(UiUtilities.createHelpTextArea(mLocalizer.msg("cantConfigure", "Can't configure on your system")), cc.xyw(1, 1, 2)); JRadioButton kdeButton = new JRadioButton(mLocalizer.msg("kde", "I am using KDE")); panel.add(kdeButton, cc.xy(2, 3)); JRadioButton gnomeButton = new JRadioButton(mLocalizer.msg("gnome", "I am using Gnome")); panel.add(gnomeButton, cc.xy(2, 5)); JRadioButton selfButton = new JRadioButton(mLocalizer.msg("self", "I want to configure by myself")); panel.add(selfButton, cc.xy(2, 7)); ButtonGroup group = new ButtonGroup(); group.add(kdeButton); group.add(gnomeButton); group.add(selfButton); selfButton.setSelected(true); JButton ok = new JButton(Localizer.getLocalization(Localizer.I18N_OK)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); } }); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); buttonPanel.add(ok); panel.add(buttonPanel, cc.xy(2, 9)); UiUtilities.registerForClosing(new WindowClosingIf() { public void close() { dialog.setVisible(false); } public JRootPane getRootPane() { return dialog.getRootPane(); } }); dialog.getRootPane().setDefaultButton(ok); dialog.pack(); UiUtilities.centerAndShow(dialog); if (kdeButton.isSelected()) { mSettings.setApplication("kfmclient"); mSettings.setParameter("exec {content}"); } else if (gnomeButton.isSelected()) { mSettings.setApplication("gnome-open"); mSettings.setParameter("{content}"); } else { Plugin.getPluginManager().showSettings(mPlugin); return false; } return true; }
From source file:components.DialogDemo.java
private JPanel createIconDialogBox() { JButton showItButton = null;// w w w . j a v a2s . c om final int numButtons = 6; JRadioButton[] radioButtons = new JRadioButton[numButtons]; final ButtonGroup group = new ButtonGroup(); final String plainCommand = "plain"; final String infoCommand = "info"; final String questionCommand = "question"; final String errorCommand = "error"; final String warningCommand = "warning"; final String customCommand = "custom"; radioButtons[0] = new JRadioButton("Plain (no icon)"); radioButtons[0].setActionCommand(plainCommand); radioButtons[1] = new JRadioButton("Information icon"); radioButtons[1].setActionCommand(infoCommand); radioButtons[2] = new JRadioButton("Question icon"); radioButtons[2].setActionCommand(questionCommand); radioButtons[3] = new JRadioButton("Error icon"); radioButtons[3].setActionCommand(errorCommand); radioButtons[4] = new JRadioButton("Warning icon"); radioButtons[4].setActionCommand(warningCommand); radioButtons[5] = new JRadioButton("Custom icon"); radioButtons[5].setActionCommand(customCommand); for (int i = 0; i < numButtons; i++) { group.add(radioButtons[i]); } radioButtons[0].setSelected(true); showItButton = new JButton("Show it!"); showItButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String command = group.getSelection().getActionCommand(); //no icon if (command == plainCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "A plain message", JOptionPane.PLAIN_MESSAGE); //information icon } else if (command == infoCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane informational dialog", JOptionPane.INFORMATION_MESSAGE); //XXX: It doesn't make sense to make a question with //XXX: only one button. //XXX: See "Yes/No (but not in those words)" for a better solution. //question icon } else if (command == questionCommand) { JOptionPane.showMessageDialog(frame, "You shouldn't use a message dialog " + "(like this)\n" + "for a question, OK?", "Inane question", JOptionPane.QUESTION_MESSAGE); //error icon } else if (command == errorCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane error", JOptionPane.ERROR_MESSAGE); //warning icon } else if (command == warningCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane warning", JOptionPane.WARNING_MESSAGE); //custom icon } else if (command == customCommand) { JOptionPane.showMessageDialog(frame, "Eggs aren't supposed to be green.", "Inane custom dialog", JOptionPane.INFORMATION_MESSAGE, icon); } } }); return create2ColPane(iconDesc + ":", radioButtons, showItButton); }
From source file:ca.uhn.hl7v2.testpanel.ui.editor.Hl7V2MessageEditorPanel.java
/** * Create the panel.// w w w .j a va2 s.c o m */ public Hl7V2MessageEditorPanel(final Controller theController) { setBorder(null); myController = theController; ButtonGroup encGrp = new ButtonGroup(); setLayout(new BorderLayout(0, 0)); mysplitPane = new JSplitPane(); mysplitPane.setResizeWeight(0.5); mysplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); add(mysplitPane); mysplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent theEvt) { double ratio = (double) mysplitPane.getDividerLocation() / mysplitPane.getHeight(); ourLog.debug("Resizing split to ratio: {}", ratio); Prefs.getInstance().setHl7EditorSplit(ratio); } }); EventQueue.invokeLater(new Runnable() { public void run() { mysplitPane.setDividerLocation(Prefs.getInstance().getHl7EditorSplit()); } }); messageEditorContainerPanel = new JPanel(); messageEditorContainerPanel.setBorder(null); mysplitPane.setRightComponent(messageEditorContainerPanel); messageEditorContainerPanel.setLayout(new BorderLayout(0, 0)); myMessageEditor = new JEditorPane(); Highlighter h = new UnderlineHighlighter(); myMessageEditor.setHighlighter(h); // myMessageEditor.setFont(Prefs.getHl7EditorFont()); myMessageEditor.setSelectedTextColor(Color.black); myMessageEditor.setCaret(new EditorCaret()); myMessageScrollPane = new JScrollPane(myMessageEditor); messageEditorContainerPanel.add(myMessageScrollPane); JToolBar toolBar = new JToolBar(); messageEditorContainerPanel.add(toolBar, BorderLayout.NORTH); toolBar.setFloatable(false); toolBar.setRollover(true); myFollowToggle = new JToggleButton("Follow"); myFollowToggle.setToolTipText("Keep the message tree (above) and the message editor (below) in sync"); myFollowToggle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { theController.setMessageEditorInFollowMode(myFollowToggle.isSelected()); } }); myFollowToggle.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/updown.png"))); myFollowToggle.setSelected(theController.isMessageEditorInFollowMode()); toolBar.add(myFollowToggle); myhorizontalStrut = Box.createHorizontalStrut(20); toolBar.add(myhorizontalStrut); mylabel_4 = new JLabel("Encoding"); toolBar.add(mylabel_4); myRdbtnEr7 = new JRadioButton("ER7"); myRdbtnEr7.setMargin(new Insets(1, 2, 0, 1)); toolBar.add(myRdbtnEr7); myRdbtnXml = new JRadioButton("XML"); myRdbtnXml.setMargin(new Insets(1, 5, 0, 1)); toolBar.add(myRdbtnXml); encGrp.add(myRdbtnEr7); encGrp.add(myRdbtnXml); treeContainerPanel = new JPanel(); mysplitPane.setLeftComponent(treeContainerPanel); treeContainerPanel.setLayout(new BorderLayout(0, 0)); mySpinnerIconOn = new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/spinner.gif")); mySpinnerIconOff = new ImageIcon(); myTreePanel = new Hl7V2MessageTree(theController); myTreePanel.setWorkingListener(new IWorkingListener() { public void startedWorking() { mySpinner.setText(""); mySpinner.setIcon(mySpinnerIconOn); mySpinnerIconOn.setImageObserver(mySpinner); } public void finishedWorking(String theStatus) { mySpinner.setText(theStatus); mySpinner.setIcon(mySpinnerIconOff); mySpinnerIconOn.setImageObserver(null); } }); myTreeScrollPane = new JScrollPane(myTreePanel); myTopTabBar = new JTabbedPane(); treeContainerPanel.add(myTopTabBar); myTopTabBar.setBorder(null); JPanel treeContainer = new JPanel(); treeContainer.setLayout(new BorderLayout(0, 0)); treeContainer.add(myTreeScrollPane); myTopTabBar.add("Message Tree", treeContainer); mytoolBar_1 = new JToolBar(); mytoolBar_1.setFloatable(false); treeContainer.add(mytoolBar_1, BorderLayout.NORTH); mylabel_3 = new JLabel("Show"); mytoolBar_1.add(mylabel_3); myShowCombo = new JComboBox(); mytoolBar_1.add(myShowCombo); myShowCombo.setPreferredSize(new Dimension(130, 27)); myShowCombo.setMinimumSize(new Dimension(130, 27)); myShowCombo.setMaximumSize(new Dimension(130, 32767)); collapseAllButton = new JButton(); collapseAllButton.setBorderPainted(false); collapseAllButton.addMouseListener(new HoverButtonMouseAdapter(collapseAllButton)); collapseAllButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myTreePanel.collapseAll(); } }); collapseAllButton.setToolTipText("Collapse All"); collapseAllButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/collapse_all.png"))); mytoolBar_1.add(collapseAllButton); expandAllButton = new JButton(); expandAllButton.setBorderPainted(false); expandAllButton.addMouseListener(new HoverButtonMouseAdapter(expandAllButton)); expandAllButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myTreePanel.expandAll(); } }); expandAllButton.setToolTipText("Expand All"); expandAllButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/expand_all.png"))); mytoolBar_1.add(expandAllButton); myhorizontalGlue = Box.createHorizontalGlue(); mytoolBar_1.add(myhorizontalGlue); mySpinner = new JButton(""); mySpinner.setForeground(Color.DARK_GRAY); mySpinner.setHorizontalAlignment(SwingConstants.RIGHT); mySpinner.setMaximumSize(new Dimension(200, 15)); mySpinner.setPreferredSize(new Dimension(200, 15)); mySpinner.setMinimumSize(new Dimension(200, 15)); mySpinner.setBorderPainted(false); mySpinner.setSize(new Dimension(16, 16)); mytoolBar_1.add(mySpinner); myProfileComboboxModel = new ProfileComboModel(); myTablesComboModel = new TablesComboModel(myController); mytoolBar = new JToolBar(); mytoolBar.setFloatable(false); mytoolBar.setRollover(true); treeContainerPanel.add(mytoolBar, BorderLayout.NORTH); myOutboundInterfaceCombo = new JComboBox(); myOutboundInterfaceComboModel = new DefaultComboBoxModel(); mylabel_1 = new JLabel("Send"); mytoolBar.add(mylabel_1); myOutboundInterfaceCombo.setModel(myOutboundInterfaceComboModel); myOutboundInterfaceCombo.setMaximumSize(new Dimension(200, 32767)); mytoolBar.add(myOutboundInterfaceCombo); mySendButton = new JButton("Send"); mySendButton.addMouseListener(new HoverButtonMouseAdapter(mySendButton)); mySendButton.setBorderPainted(false); mySendButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // int selectedIndex = // myOutboundInterfaceComboModel.getIndexOf(myOutboundInterfaceComboModel.getSelectedItem()); int selectedIndex = myOutboundInterfaceCombo.getSelectedIndex(); OutboundConnection connection = myController.getOutboundConnectionList().getConnections() .get(selectedIndex); activateSendingActivityTabForConnection(connection); myController.sendMessages(connection, myMessage, mySendingActivityTable.provideTransmissionCallback()); } }); myhorizontalStrut_2 = Box.createHorizontalStrut(20); myhorizontalStrut_2.setPreferredSize(new Dimension(2, 0)); myhorizontalStrut_2.setMinimumSize(new Dimension(2, 0)); myhorizontalStrut_2.setMaximumSize(new Dimension(2, 32767)); mytoolBar.add(myhorizontalStrut_2); mySendOptionsButton = new JButton("Options"); mySendOptionsButton.setBorderPainted(false); final HoverButtonMouseAdapter sendOptionsHoverAdaptor = new HoverButtonMouseAdapter(mySendOptionsButton); mySendOptionsButton.addMouseListener(sendOptionsHoverAdaptor); mySendOptionsButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/sendoptions.png"))); mytoolBar.add(mySendOptionsButton); mySendOptionsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent theE) { if (mySendOptionsPopupDialog != null) { mySendOptionsPopupDialog.doHide(); mySendOptionsPopupDialog = null; return; } mySendOptionsPopupDialog = new SendOptionsPopupDialog(Hl7V2MessageEditorPanel.this, myMessage, mySendOptionsButton, sendOptionsHoverAdaptor); Point los = mySendOptionsButton.getLocationOnScreen(); mySendOptionsPopupDialog.setLocation(los.x, los.y + mySendOptionsButton.getHeight()); mySendOptionsPopupDialog.setVisible(true); } }); mySendButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/button_execute.png"))); mytoolBar.add(mySendButton); myhorizontalStrut_1 = Box.createHorizontalStrut(20); mytoolBar.add(myhorizontalStrut_1); mylabel_2 = new JLabel("Validate"); mytoolBar.add(mylabel_2); myProfileCombobox = new JComboBox(); mytoolBar.add(myProfileCombobox); myProfileCombobox.setPreferredSize(new Dimension(200, 27)); myProfileCombobox.setMinimumSize(new Dimension(200, 27)); myProfileCombobox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myHandlingProfileComboboxChange) { return; } myHandlingProfileComboboxChange = true; try { if (myProfileCombobox.getSelectedIndex() == 0) { myMessage.setValidationContext(null); } else if (myProfileCombobox.getSelectedIndex() == 1) { myMessage.setValidationContext(new DefaultValidation()); } else if (myProfileCombobox.getSelectedIndex() > 0) { ProfileGroup profile = myProfileComboboxModel.myProfileGroups .get(myProfileCombobox.getSelectedIndex()); myMessage.setRuntimeProfile(profile); // } else if (myProfileCombobox.getSelectedItem() == // ProfileComboModel.APPLY_CONFORMANCE_PROFILE) { // IOkCancelCallback<Void> callback = new // IOkCancelCallback<Void>() { // public void ok(Void theArg) { // myProfileComboboxModel.update(); // } // // public void cancel(Void theArg) { // myProfileCombobox.setSelectedIndex(0); // } // }; // myController.chooseAndLoadConformanceProfileForMessage(myMessage, // callback); } } catch (ProfileException e2) { ourLog.error("Failed to load profile", e2); } finally { myHandlingProfileComboboxChange = false; } } }); myProfileCombobox.setMaximumSize(new Dimension(300, 32767)); myProfileCombobox.setModel(myProfileComboboxModel); myhorizontalStrut_4 = Box.createHorizontalStrut(20); myhorizontalStrut_4.setPreferredSize(new Dimension(2, 0)); myhorizontalStrut_4.setMinimumSize(new Dimension(2, 0)); myhorizontalStrut_4.setMaximumSize(new Dimension(2, 32767)); mytoolBar.add(myhorizontalStrut_4); // mySendingPanel = new JPanel(); // mySendingPanel.setBorder(null); // myTopTabBar.addTab("Sending", null, mySendingPanel, null); // mySendingPanel.setLayout(new BorderLayout(0, 0)); mySendingActivityTable = new ActivityTable(); mySendingActivityTable.setController(myController); myTopTabBar.addTab("Sending", null, mySendingActivityTable, null); // mySendingPanelScrollPanel = new JScrollPane(); // mySendingPanelScrollPanel.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); // mySendingPanelScrollPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); // mySendingPanelScrollPanel.setColumnHeaderView(mySendingActivityTable); // // mySendingPanel.add(mySendingPanelScrollPanel, BorderLayout.CENTER); bottomPanel = new JPanel(); bottomPanel.setPreferredSize(new Dimension(10, 20)); bottomPanel.setMinimumSize(new Dimension(10, 20)); add(bottomPanel, BorderLayout.SOUTH); GridBagLayout gbl_bottomPanel = new GridBagLayout(); gbl_bottomPanel.columnWidths = new int[] { 98, 74, 0 }; gbl_bottomPanel.rowHeights = new int[] { 16, 0 }; gbl_bottomPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_bottomPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; bottomPanel.setLayout(gbl_bottomPanel); mylabel = new JLabel("Terser Path:"); mylabel.setHorizontalTextPosition(SwingConstants.LEFT); mylabel.setHorizontalAlignment(SwingConstants.LEFT); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.fill = GridBagConstraints.VERTICAL; gbc_label.weighty = 1.0; gbc_label.anchor = GridBagConstraints.NORTHWEST; gbc_label.gridx = 0; gbc_label.gridy = 0; bottomPanel.add(mylabel, gbc_label); myTerserPathTextField = new JLabel(); myTerserPathTextField.setForeground(Color.BLUE); myTerserPathTextField.setFont(new Font("Lucida Console", Font.PLAIN, 13)); myTerserPathTextField.setBorder(null); myTerserPathTextField.setBackground(SystemColor.control); myTerserPathTextField.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (StringUtils.isNotEmpty(myTerserPathTextField.getText())) { myTerserPathPopupMenu.show(myTerserPathTextField, 0, 0); } } }); GridBagConstraints gbc_TerserPathTextField = new GridBagConstraints(); gbc_TerserPathTextField.weightx = 1.0; gbc_TerserPathTextField.fill = GridBagConstraints.HORIZONTAL; gbc_TerserPathTextField.gridx = 1; gbc_TerserPathTextField.gridy = 0; bottomPanel.add(myTerserPathTextField, gbc_TerserPathTextField); initLocal(); }
From source file:eu.apenet.dpt.standalone.gui.ead2edm.EdmOptionsPanel.java
private void createOptionPanel() { labels = dataPreparationToolGUI.getLabels(); JPanel creativeCommonsPanel = new CreativeCommonsPanel(); JPanel europeanaRightsPanel = new EuropeanaRightsPanel(); JPanel emptyPanel = new JPanel(); JPanel formPanel = new JPanel(new GridLayout(14, 1)); JPanel extraLicenseCardLayoutPanel = new JPanel(new CardLayout()); extraLicenseCardLayoutPanel.add(creativeCommonsPanel, CREATIVE_COMMONS); extraLicenseCardLayoutPanel.add(europeanaRightsPanel, EUROPEANA_RIGHTS_STATEMENTS); extraLicenseCardLayoutPanel.add(emptyPanel, EMPTY_PANEL); CardLayout cardLayout = (CardLayout) extraLicenseCardLayoutPanel.getLayout(); cardLayout.show(extraLicenseCardLayoutPanel, EMPTY_PANEL); JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); conversionModeGroup = new ButtonGroup(); JRadioButton radioButton;//ww w . ja v a2 s . c om panel.add(new Label(this.labels.getString("edm.panel.label.choose.mode"))); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.mode.minimal")); radioButton.setActionCommand(MINIMAL); radioButton.setSelected(true); radioButton.addActionListener(new ConversionModeListener()); conversionModeGroup.add(radioButton); panel.add(radioButton); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.mode.full")); radioButton.setActionCommand(FULL); radioButton.addActionListener(new ConversionModeListener()); conversionModeGroup.add(radioButton); panel.add(radioButton); formPanel.add(panel); panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); cLevelIdSourceButtonGroup = new ButtonGroup(); panel.add(new Label(this.labels.getString("edm.generalOptionsForm.identifierSource.header"))); radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.identifierSource.unitid")); radioButton.setActionCommand(UNITID); if (retrieveFromDb.retrieveCIdentifierSource().equals(radioButton.getActionCommand())) { radioButton.setSelected(true); } cLevelIdSourceButtonGroup.add(radioButton); panel.add(radioButton); radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.identifierSource.cid")); radioButton.setActionCommand(CID); if (retrieveFromDb.retrieveCIdentifierSource().equals(radioButton.getActionCommand())) { radioButton.setSelected(true); } cLevelIdSourceButtonGroup.add(radioButton); panel.add(radioButton); formPanel.add(panel); panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); sourceOfFondsTitleGroup = new ButtonGroup(); determineDaoInformation(); panel.add(new Label(this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle"))); if (!this.batch && StringUtils.isBlank(ead2EdmInformation.getArchdescUnittitle()) && StringUtils.isBlank(ead2EdmInformation.getTitlestmtTitleproper())) { panel.add(new Label( this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.noSourceAvailable"))); } else { radioButton = new JRadioButton( this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.archdescUnittitle")); radioButton.setActionCommand(ARCHDESC_UNITTITLE); radioButton.setSelected(true); radioButton.addActionListener(new ConversionModeListener()); sourceOfFondsTitleGroup.add(radioButton); panel.add(radioButton); radioButton = new JRadioButton( this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.titlestmtTitleproper")); radioButton.setActionCommand(TITLESTMT_TITLEPROPER); radioButton.addActionListener(new ConversionModeListener()); sourceOfFondsTitleGroup.add(radioButton); panel.add(radioButton); } formPanel.add(panel); panel = new JPanel(new GridLayout(2, 2)); landingPageButtonGroup = new ButtonGroup(); panel.add(new Label(this.labels.getString("edm.generalOptionsForm.landingPages.header"))); radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.landingPages.ape")); radioButton.setActionCommand(APE); if (retrieveFromDb.retrieveLandingPageBase().equals(APE_BASE)) { radioButton.setSelected(true); } landingPageButtonGroup.add(radioButton); panel.add(radioButton); panel.add(new Label()); JPanel otherPanel = new JPanel(new GridLayout(1, 2)); radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.landingPages.other")); radioButton.setActionCommand(OTHER); landingPageButtonGroup.add(radioButton); otherPanel.add(radioButton); landingPageTextArea = new JTextArea(); landingPageTextArea.setLineWrap(true); landingPageTextArea.setWrapStyleWord(true); if (!retrieveFromDb.retrieveLandingPageBase().equals(APE_BASE)) { radioButton.setSelected(true); landingPageTextArea.setText(retrieveFromDb.retrieveLandingPageBase()); } JScrollPane lptaScrollPane = new JScrollPane(landingPageTextArea); lptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); otherPanel.add(lptaScrollPane); panel.add(otherPanel); formPanel.add(panel); panel = new JPanel(new GridLayout(1, 1)); panel.add(new Label(labels.getString("ese.mandatoryFieldsInfo"))); panel.add(new Label("")); panel.setBorder(BLACK_LINE); formPanel.add(panel); panel = new JPanel(new GridLayout(1, 3)); panel.add(new Label(labels.getString("ese.dataProvider") + ":" + "*")); dataProviderTextArea = new JTextArea(); dataProviderTextArea.setLineWrap(true); dataProviderTextArea.setWrapStyleWord(true); JScrollPane dptaScrollPane = new JScrollPane(dataProviderTextArea); dptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); panel.add(dptaScrollPane); useExistingRepoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileRepository")); useExistingRepoCheckbox.setSelected(true); useExistingRepoCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { //empty method on purpose } }); JPanel panel2 = new JPanel(new GridLayout(1, 1)); panel2.add(useExistingRepoCheckbox); if (!batch) { String repository = ead2EdmInformation.getRepository(); if (repository != null && !repository.equals("")) { dataProviderTextArea.setText(repository); } else { if (archdescRepository != null) { dataProviderTextArea.setText(archdescRepository); } else { useExistingRepoCheckbox.setSelected(false); } } } panel.add(panel2); panel.setBorder(BLACK_LINE); formPanel.add(panel); /* panel = new JPanel(new GridLayout(1, 3)); panel.add(new Label(labels.getString("ese.provider") + ":" + "*")); providerTextArea = new JTextArea(); providerTextArea.setLineWrap(true); providerTextArea.setWrapStyleWord(true); JScrollPane ptaScrollPane = new JScrollPane(providerTextArea); ptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); panel.add(ptaScrollPane); panel.add(new Label("")); panel.setBorder(BLACK_LINE); formPanel.add(panel); */ panel = new JPanel(new GridLayout(5, 3)); typeGroup = new ButtonGroup(); panel.add(new Label(labels.getString("ese.type") + ":" + "*")); String currentRoleType; if (batch) { currentRoleType = ""; } else { currentRoleType = ead2EdmInformation.getRoleType(); } radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.text")); if (currentRoleType.equals(EdmOptionsPanel.TEXT)) { radioButton.setSelected(true); } radioButton.setActionCommand(TEXT); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.image")); if (currentRoleType.equals(EdmOptionsPanel.IMAGE)) { radioButton.setSelected(true); } radioButton.setActionCommand(IMAGE); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.video")); if (currentRoleType.equals(EdmOptionsPanel.VIDEO)) { radioButton.setSelected(true); } radioButton.setActionCommand(VIDEO); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); useExistingDaoRoleCheckbox = new JCheckBox(labels.getString("ese.takeFromFileDaoRole")); useExistingDaoRoleCheckbox.setSelected(true); useExistingDaoRoleCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { } }); panel.add(useExistingDaoRoleCheckbox); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.sound")); if (currentRoleType.equals(EdmOptionsPanel.SOUND)) { radioButton.setSelected(true); } radioButton.setActionCommand(SOUND); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.threed")); if (currentRoleType.equals(EdmOptionsPanel.THREE_D)) { radioButton.setSelected(true); } radioButton.setActionCommand(THREE_D); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); panel.setBorder(GREY_LINE); formPanel.add(panel); if (this.batch) { panel = new JPanel(new GridLayout(1, 3)); panel.add(new Label(labels.getString("ese.selectLanguage") + ":" + "*")); panel.add(languageBoxPanel); useExistingLanguageCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLanguage")); useExistingLanguageCheckbox.setSelected(true); useExistingLanguageCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { //empty method on purpose } }); panel.add(useExistingLanguageCheckbox); panel.setBorder(BLACK_LINE); formPanel.add(panel); } else { inheritLanguagePanel = new JPanel(new GridLayout(1, 3)); inheritLanguagePanel.add(new Label(labels.getString("ese.inheritLanguage") + ":" + "*")); JPanel rbPanel = new JPanel(new GridLayout(4, 1)); inheritLanguageGroup = new ButtonGroup(); inhLanYesRadioButton = new JRadioButton(labels.getString("ese.yes")); inhLanYesRadioButton.setActionCommand(YES); inhLanYesRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); inheritLanguageGroup.add(inhLanYesRadioButton); rbPanel.add(inhLanYesRadioButton); inhLanNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); inhLanNoRadioButton.setActionCommand(NO); inhLanNoRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); inheritLanguageGroup.add(inhLanNoRadioButton); rbPanel.add(inhLanNoRadioButton); inhLanProvideRadioButton = new JRadioButton(labels.getString("ese.provide")); inhLanProvideRadioButton.setActionCommand(PROVIDE); inhLanProvideRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); inheritLanguageGroup.add(inhLanProvideRadioButton); rbPanel.add(inhLanProvideRadioButton); useExistingLanguageCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLanguage")); useExistingLanguageCheckbox.setSelected(true); useExistingLanguageCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { //empty method on purpose } }); rbPanel.add(useExistingLanguageCheckbox); inheritLanguagePanel.add(rbPanel, BorderLayout.WEST); languageBoxPanel.setVisible(true); inheritLanguagePanel.add(languageBoxPanel, BorderLayout.EAST); inheritLanguagePanel.setBorder(BLACK_LINE); inheritLanguagePanel.setVisible(true); formPanel.add(inheritLanguagePanel); } // if (this.batch) { panel = new JPanel(new GridLayout(1, 3)); panel.add(new JLabel(labels.getString("edm.panel.license.inheritLicense") + ":" + "*")); useExistingRightsInfoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLicense")); useExistingRightsInfoCheckbox.setSelected(true); useExistingRightsInfoCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { //empty method on purpose } }); panel.add(useExistingRightsInfoCheckbox); panel.add(new JLabel()); panel.setBorder(BLACK_LINE); panel.setVisible(true); formPanel.add(panel); // } else { // panel = new JPanel(new GridLayout(3, 3)); // inheritLicenseGroup = new ButtonGroup(); // // panel.add(new Label(labels.getString("edm.panel.license.inheritLicense") + ":" + "*")); // inhLicYesRadioButton = new JRadioButton(labels.getString("ese.yes")); // inhLicYesRadioButton.setActionCommand(YES); //// inhLicYesRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); // inheritLicenseGroup.add(inhLicYesRadioButton); // panel.add(inhLicYesRadioButton); // panel.add(new JLabel()); // // panel.add(new JLabel()); // inhLicNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); // inhLicNoRadioButton.setActionCommand(NO); //// inhLicNoRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); // inheritLicenseGroup.add(inhLicNoRadioButton); // panel.add(inhLicNoRadioButton); // useExistingRightsInfoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLicense")); // useExistingRightsInfoCheckbox.setSelected(true); // useExistingRightsInfoCheckbox.addItemListener(new ItemListener() { // @Override // public void itemStateChanged(ItemEvent e) { // //empty method on purpose // } // }); // // panel.add(useExistingRightsInfoCheckbox); // // panel.add(new JLabel()); // inhLicProvideRadioButton = new JRadioButton(labels.getString("ese.provide")); // inhLicProvideRadioButton.setActionCommand(PROVIDE); //// inhLicProvideRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); // inheritLicenseGroup.add(inhLicProvideRadioButton); // panel.add(inhLicProvideRadioButton); // panel.add(new JLabel()); // // panel.setBorder(BLACK_LINE); // panel.setVisible(true); // formPanel.add(panel); // } JPanel mainLicensePanel = new JPanel(new BorderLayout()); panel = new JPanel(new GridLayout(5, 2)); licenseGroup = new ButtonGroup(); // String currentRightsInformation; // if (batch) { // currentRightsInformation = ""; // } else { // currentRightsInformation = ead2EdmInformation.getArchdescLicenceType(); // } panel.add(new Label(labels.getString("ese.specifyLicense") + ":" + "*")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc")); // if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(CREATIVE_COMMONS); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc.zero")); // if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS_CC0)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(CREATIVE_COMMONS_CC0); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc.public")); // if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS_PUBLIC_DOMAIN_MARK)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(CREATIVE_COMMONS_PUBLIC_DOMAIN_MARK); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.europeana.rights")); // if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(EUROPEANA_RIGHTS_STATEMENTS); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.out.copyright")); // if (currentRightsInformation.equals(EdmOptionsPanel.OUT_OF_COPYRIGHT)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(EdmOptionsPanel.OUT_OF_COPYRIGHT); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); mainLicensePanel.add(panel, BorderLayout.WEST); mainLicensePanel.add(extraLicenseCardLayoutPanel, BorderLayout.EAST); // if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS) || currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) { // cardLayout.show(extraLicenseCardLayoutPanel, currentRightsInformation); // if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS)) { // if (ead2EdmInformation.getArchdescLicenceLink().endsWith("rr-f/")) { // europeanaRightsComboBox.setSelectedIndex(0); // } else if (ead2EdmInformation.getArchdescLicenceLink().endsWith("orphan-work-eu/")) { // europeanaRightsComboBox.setSelectedIndex(1); // } else if (ead2EdmInformation.getArchdescLicenceLink().endsWith("rr-p/")) { // europeanaRightsComboBox.setSelectedIndex(2); // } else { // europeanaRightsComboBox.setSelectedIndex(3); // } // } else if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) { // // get respective items from EAD2EDMInfo and set panel items appropriately // } // } mainLicensePanel.setBorder(BLACK_LINE); formPanel.add(mainLicensePanel); panel = new JPanel(new GridLayout(1, 1)); panel.add(new Label(labels.getString("ese.specifyAdditionalRightsInfo") + ":")); additionalRightsTextArea = new JTextArea(); additionalRightsTextArea.setLineWrap(true); additionalRightsTextArea.setWrapStyleWord(true); JScrollPane artaScrollPane = new JScrollPane(additionalRightsTextArea); artaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); panel.add(artaScrollPane); panel.setBorder(GREY_LINE); formPanel.add(panel); inheritParentPanel = new JPanel(new GridLayout(2, 3)); inheritParentCheckbox = new JCheckBox(labels.getString("ese.inheritParent") + ":" + "*"); inheritParentCheckbox.setSelected(true); inheritParentCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { inhParYesRadioButton.setEnabled(true); inhParNoRadioButton.setEnabled(true); } if (e.getStateChange() == ItemEvent.DESELECTED) { inhParYesRadioButton.setEnabled(false); inhParNoRadioButton.setEnabled(false); } } }); inheritParentPanel.add(inheritParentCheckbox); inheritParentGroup = new ButtonGroup(); inhParYesRadioButton = new JRadioButton(labels.getString("ese.yes")); inhParYesRadioButton.setActionCommand(YES); inheritParentGroup.add(inhParYesRadioButton); inheritParentPanel.add(inhParYesRadioButton); inheritParentPanel.add(new JLabel("")); inhParNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); inhParNoRadioButton.setActionCommand(NO); inheritParentGroup.add(inhParNoRadioButton); inheritParentPanel.add(inhParNoRadioButton); inheritParentPanel.setBorder(GREY_LINE); inheritParentPanel.setVisible(false); formPanel.add(inheritParentPanel); inheritOriginationPanel = new JPanel(new GridLayout(2, 3)); inheritOriginationCheckbox = new JCheckBox(labels.getString("ese.inheritOrigination") + ":" + "*"); inheritOriginationCheckbox.setSelected(true); inheritOriginationCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { inhOriYesRadioButton.setEnabled(true); inhOriNoRadioButton.setEnabled(true); } if (e.getStateChange() == ItemEvent.DESELECTED) { inhOriYesRadioButton.setEnabled(false); inhOriNoRadioButton.setEnabled(false); } } }); inheritOriginationPanel.add(inheritOriginationCheckbox); inheritOriginationGroup = new ButtonGroup(); inhOriYesRadioButton = new JRadioButton(labels.getString("ese.yes")); inhOriYesRadioButton.setActionCommand(YES); inheritOriginationGroup.add(inhOriYesRadioButton); inheritOriginationPanel.add(inhOriYesRadioButton); inheritOriginationPanel.add(new JLabel("")); inhOriNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); inhOriNoRadioButton.setActionCommand(NO); inheritOriginationGroup.add(inhOriNoRadioButton); inheritOriginationPanel.add(inhOriNoRadioButton); inheritOriginationPanel.setBorder(BLACK_LINE); inheritOriginationPanel.setVisible(false); formPanel.add(inheritOriginationPanel); inheritUnittitlePanel = new JPanel(new GridLayout(2, 3)); inheritUnittitleCheckbox = new JCheckBox(labels.getString("ese.inheritUnittitle") + ":" + "*"); inheritUnittitleCheckbox.setSelected(true); inheritUnittitleCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { inhTitleYesRadioButton.setEnabled(true); inhTitleNoRadioButton.setEnabled(true); } if (e.getStateChange() == ItemEvent.DESELECTED) { inhTitleYesRadioButton.setEnabled(false); inhTitleNoRadioButton.setEnabled(false); } } }); inheritUnittitlePanel.add(inheritUnittitleCheckbox); inheritUnittitleGroup = new ButtonGroup(); inhTitleYesRadioButton = new JRadioButton(labels.getString("ese.yes")); inhTitleYesRadioButton.setActionCommand(YES); inheritUnittitleGroup.add(inhTitleYesRadioButton); inheritUnittitlePanel.add(inhTitleYesRadioButton); inheritUnittitlePanel.add(new JLabel("")); inhTitleNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); inhTitleNoRadioButton.setActionCommand(NO); inheritUnittitleGroup.add(inhTitleNoRadioButton); inheritUnittitlePanel.add(inhTitleNoRadioButton); inheritUnittitlePanel.setBorder(BLACK_LINE); inheritUnittitlePanel.setVisible(false); formPanel.add(inheritUnittitlePanel); JButton createEdmBtn = new JButton(labels.getString("ese.createEseBtn")); JButton cancelBtn = new JButton(labels.getString("ese.cancelBtn")); createEdmBtn.addActionListener(new CreateEdmActionListener()); cancelBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (Map.Entry<String, FileInstance> entry : fileInstances.entrySet()) { FileInstance fileInstance = entry.getValue(); fileInstance.setEdm(false); } dataPreparationToolGUI.enableEdmConversionBtn(); if (batch) { dataPreparationToolGUI.enableAllBatchBtns(); } dataPreparationToolGUI.enableRadioButtons(); close(); } }); JPanel buttonPanel = new JPanel(new GridLayout(1, 5)); buttonPanel.add(new JLabel("")); buttonPanel.add(cancelBtn); buttonPanel.add(new JLabel("")); buttonPanel.add(createEdmBtn); buttonPanel.add(new JLabel("")); add(formPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); }
From source file:org.gumtree.vis.awt.time.TimePlotChartEditor.java
private JPanel createCordinatePanel() { JPanel wrap = new JPanel(new BorderLayout()); JPanel coordinate = new JPanel(new GridLayout(2, 1)); coordinate.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); //Horizontal group JPanel horizontal = new JPanel(new BorderLayout()); horizontal.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Time Axis")); JPanel inner = new JPanel(new LCBLayout(6)); inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); ButtonGroup axisControlGroup = new ButtonGroup(); showAllHistory = new JRadioButton("Show all history"); showAllHistory.setActionCommand(SHOW_ALL_HISTORY_COMMAND); showAllHistory.addActionListener(this); inner.add(showAllHistory);/*from w ww. jav a 2 s .co m*/ inner.add(new JLabel()); inner.add(new JLabel()); // showPartHistory = new JRadioButton("Fix time range"); showPartHistory.setActionCommand(FIXED_LENGTH_HISTORY_COMMAND); showPartHistory.addActionListener(this); inner.add(showPartHistory); timeField = new JTextField(5); inner.add(timeField); inner.add(new JLabel("seconds")); axisControlGroup.add(showAllHistory); axisControlGroup.add(showPartHistory); horizontal.add(inner, BorderLayout.NORTH); //Vertical group // JPanel vertical = new JPanel(new BorderLayout()); // vertical.setBorder(BorderFactory.createTitledBorder( // BorderFactory.createEtchedBorder(), "Vertical Axis")); // // inner = new JPanel(new LCBLayout(6)); // inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); // inner.add(new JLabel("Logarithm Y Axis")); // logarithmY = new JCheckBox(); // logarithmY.setActionCommand(LOGARITHM_Y_AXIS_COMMAND); // logarithmY.addActionListener(this); // inner.add(logarithmY); // inner.add(new JLabel()); // // inner.add(new JLabel("Flip Y Axis")); // flipY = new JCheckBox(); // flipY.setActionCommand(FLIP_Y_AXIS_COMMAND); // flipY.addActionListener(this); // inner.add(flipY); // inner.add(new JLabel()); // vertical.add(inner, BorderLayout.NORTH); coordinate.add(horizontal, BorderLayout.NORTH); // coordinate.add(vertical); wrap.setName("Coordinate"); wrap.add(coordinate, BorderLayout.NORTH); return wrap; }
From source file:edu.uci.ics.jung.samples.PerspectiveVertexImageShaperDemo.java
/** * create an instance of a simple graph with controls to * demo the zoom features.//from w ww . ja v a 2s.co m * */ @SuppressWarnings("serial") public PerspectiveVertexImageShaperDemo() { // create a simple graph for the demo graph = new DirectedSparseMultigraph<Number, Number>(); Number[] vertices = createVertices(11); // a Map for the labels Map<Number, String> map = new HashMap<Number, String>(); for (int i = 0; i < vertices.length; i++) { map.put(vertices[i], iconNames[i % iconNames.length]); } // a Map for the Icons Map<Number, Icon> iconMap = new HashMap<Number, Icon>(); for (int i = 0; i < vertices.length; i++) { String name = "/images/topic" + iconNames[i] + ".gif"; try { Icon icon = new LayeredIcon( new ImageIcon(PerspectiveVertexImageShaperDemo.class.getResource(name)).getImage()); iconMap.put(vertices[i], icon); } catch (Exception ex) { System.err.println("You need slashdoticons.jar in your classpath to see the image " + name); } } createEdges(vertices); final VertexStringerImpl<Number> vertexStringerImpl = new VertexStringerImpl<Number>(map); final VertexIconShapeTransformer<Number> vertexImageShapeFunction = new VertexIconShapeTransformer<Number>( new EllipseVertexShapeTransformer<Number>()); FRLayout<Number, Number> layout = new FRLayout<Number, Number>(graph); layout.setMaxIterations(100); vv = new VisualizationViewer<Number, Number>(layout, new Dimension(400, 400)); vv.setBackground(Color.decode("0xffffdd")); final DefaultVertexIconTransformer<Number> vertexIconFunction = new DefaultVertexIconTransformer<Number>(); vertexImageShapeFunction.setIconMap(iconMap); vertexIconFunction.setIconMap(iconMap); vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction); vv.getRenderContext().setVertexIconTransformer(vertexIconFunction); vv.getRenderContext().setVertexLabelTransformer(vertexStringerImpl); PickedState<Number> ps = vv.getPickedVertexState(); ps.addItemListener(new PickWithIconListener(vertexIconFunction)); vv.addPostRenderPaintable(new VisualizationServer.Paintable() { int x; int y; Font font; FontMetrics metrics; int swidth; int sheight; String str = "Thank You, slashdot.org, for the images!"; public void paint(Graphics g) { Dimension d = vv.getSize(); if (font == null) { font = new Font(g.getFont().getName(), Font.BOLD, 20); metrics = g.getFontMetrics(font); swidth = metrics.stringWidth(str); sheight = metrics.getMaxAscent() + metrics.getMaxDescent(); x = (d.width - swidth) / 2; y = (int) (d.height - sheight * 1.5); } g.setFont(font); Color oldColor = g.getColor(); g.setColor(Color.lightGray); g.drawString(str, x, y); g.setColor(oldColor); } public boolean useTransform() { return false; } }); // add a listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Number>()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final DefaultModalGraphMouse<Number, Number> graphMouse = new DefaultModalGraphMouse<Number, Number>(); vv.setGraphMouse(graphMouse); this.viewSupport = new PerspectiveImageLensSupport<Number, Number>(vv); this.layoutSupport = new PerspectiveLayoutTransformSupport<Number, Number>(vv); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 0.9f, vv.getCenter()); } }); final JSlider horizontalSlider = new JSlider(-120, 120, 0) { /* (non-Javadoc) * @see javax.swing.JComponent#getPreferredSize() */ @Override public Dimension getPreferredSize() { return new Dimension(80, super.getPreferredSize().height); } }; final JSlider verticalSlider = new JSlider(-120, 120, 0) { /* (non-Javadoc) * @see javax.swing.JComponent#getPreferredSize() */ @Override public Dimension getPreferredSize() { return new Dimension(super.getPreferredSize().width, 80); } }; verticalSlider.setOrientation(JSlider.VERTICAL); final ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { int vval = -verticalSlider.getValue(); int hval = horizontalSlider.getValue(); Dimension d = vv.getSize(); PerspectiveTransform pt = null; pt = PerspectiveTransform.getQuadToQuad(vval, hval, d.width - vval, -hval, d.width + vval, d.height + hval, -vval, d.height - hval, 0, 0, d.width, 0, d.width, d.height, 0, d.height); viewSupport.getPerspectiveTransformer().setPerspectiveTransform(pt); layoutSupport.getPerspectiveTransformer().setPerspectiveTransform(pt); vv.repaint(); } }; horizontalSlider.addChangeListener(changeListener); verticalSlider.addChangeListener(changeListener); JPanel perspectivePanel = new JPanel(new BorderLayout()); JPanel perspectiveCenterPanel = new JPanel(new BorderLayout()); perspectivePanel.setBorder(BorderFactory.createTitledBorder("Perspective Controls")); final JButton center = new JButton("Center"); center.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { horizontalSlider.setValue(0); verticalSlider.setValue(0); } }); final JCheckBox noText = new JCheckBox("No Text"); noText.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { JCheckBox cb = (JCheckBox) e.getSource(); vertexStringerImpl.setEnabled(!cb.isSelected()); vv.repaint(); } }); JPanel centerPanel = new JPanel(); centerPanel.add(noText); ButtonGroup radio = new ButtonGroup(); JRadioButton none = new JRadioButton("None"); none.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { boolean selected = e.getStateChange() == ItemEvent.SELECTED; if (selected) { if (viewSupport != null) { viewSupport.deactivate(); } if (layoutSupport != null) { layoutSupport.deactivate(); } } center.setEnabled(!selected); horizontalSlider.setEnabled(!selected); verticalSlider.setEnabled(!selected); } }); none.setSelected(true); JRadioButton hyperView = new JRadioButton("View"); hyperView.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { viewSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); JRadioButton hyperModel = new JRadioButton("Layout"); hyperModel.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { layoutSupport.activate(e.getStateChange() == ItemEvent.SELECTED); } }); radio.add(none); radio.add(hyperView); radio.add(hyperModel); JMenuBar menubar = new JMenuBar(); JMenu modeMenu = graphMouse.getModeMenu(); menubar.add(modeMenu); panel.setCorner(menubar); JPanel scaleGrid = new JPanel(new GridLayout(2, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); JPanel controls = new JPanel(new BorderLayout()); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid, BorderLayout.WEST); JPanel lensPanel = new JPanel(new GridLayout(2, 0)); lensPanel.add(none); lensPanel.add(hyperView); lensPanel.add(hyperModel); perspectivePanel.add(lensPanel, BorderLayout.WEST); perspectiveCenterPanel.add(horizontalSlider, BorderLayout.SOUTH); perspectivePanel.add(verticalSlider, BorderLayout.EAST); perspectiveCenterPanel.add(center); perspectivePanel.add(perspectiveCenterPanel); controls.add(perspectivePanel, BorderLayout.EAST); controls.add(centerPanel); content.add(controls, BorderLayout.SOUTH); }
From source file:eu.europa.ec.markt.dss.applet.util.ComponentFactory.java
/** * /*from w ww.ja va2 s. c o m*/ * @param text * @param valueModel * @param value * @return */ public static JRadioButton createRadioButton(final String text, final ValueModel valueModel, final Object value) { final JRadioButton button = new JRadioButton(text); final ButtonModel model = new RadioButtonAdapter(valueModel, value); button.setModel(model); return button; }
From source file:org.gumtree.vis.hist2d.Hist2DChartEditor.java
private JPanel createMaskingPanel(JFreeChart chart) { JPanel wrap = new JPanel(new BorderLayout()); JPanel maskingPanel = new JPanel(new GridLayout(1, 1)); maskingPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); //Horizontal group JPanel managePanel = new JPanel(new BorderLayout()); managePanel.setBorder(//from w ww. j a v a2 s.com BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Region of Interests")); JPanel inner = new JPanel(new LCBLayout(6)); inner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); inner.add(new JLabel("Select Region")); roiCombo = new JComboBox(panel.getMasks().toArray()); // colourScaleCombo.setMaximumRowCount(7); roiCombo.setActionCommand(CHANGE_ROI_COMMAND); roiCombo.addActionListener(this); roiCombo.setSelectedIndex(-1); inner.add(roiCombo); inner.add(new JLabel()); inner.add(new JLabel("or create")); JPanel createNewPanel = new JPanel(new GridLayout(1, 2)); newRectangleButton = new JButton("New Rectangle"); newRectangleButton.setActionCommand(CREATE_NEW_RECT_REGION_COMMAND); newRectangleButton.addActionListener(this); newEllipseButton = new JButton("New Ellipse"); newEllipseButton.setActionCommand(CREATE_NEW_ELLIPSE_REGION_COMMAND); newEllipseButton.addActionListener(this); createNewPanel.add(newRectangleButton); createNewPanel.add(newEllipseButton); inner.add(createNewPanel); inner.add(new JLabel()); JPanel editPanel = new JPanel(new BorderLayout()); editPanel .setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Edit the Region")); JPanel editInner = new JPanel(new LCBLayout(6)); editInner.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); editInner.add(new JLabel("Name")); roiName = new JTextField(10); // colourScaleCombo.setMaximumRowCount(7); roiName.setActionCommand(CHANGE_ROI_NAME_COMMAND); roiName.addActionListener(this); editInner.add(roiName); editInner.add(new JLabel()); editInner.add(new JLabel("Usage")); ButtonGroup buttonGroup = new ButtonGroup(); JPanel radioPanel = new JPanel(new GridLayout(1, 2)); inclusiveRadio = new JRadioButton("inclusive"); inclusiveRadio.setActionCommand(USE_INCLUSIVE_COMMAND); inclusiveRadio.addActionListener(this); buttonGroup.add(inclusiveRadio); radioPanel.add(inclusiveRadio); exclusiveRadio = new JRadioButton("exclusive"); exclusiveRadio.setActionCommand(USE_EXCLUSIVE_COMMAND); exclusiveRadio.addActionListener(this); buttonGroup.add(exclusiveRadio); radioPanel.add(exclusiveRadio); editInner.add(radioPanel); editInner.add(new JLabel()); editInner.add(new JLabel("Shape")); // ButtonGroup shapeGroup = new ButtonGroup(); // JPanel shapePanel = new JPanel(new GridLayout(1, 2)); // rectangleRadio = new JRadioButton("rectangle"); // rectangleRadio.setActionCommand(CHOOSE_RECTANGLE_SHAPE_COMMAND); // rectangleRadio.addActionListener(this); // shapeGroup.add(rectangleRadio); // shapePanel.add(rectangleRadio); // ellipseRadio = new JRadioButton("ellipse"); // ellipseRadio.setActionCommand(CHOOSE_ELLIPSE_SHAPE_COMMAND); // ellipseRadio.addActionListener(this); // shapeGroup.add(ellipseRadio); // shapePanel.add(ellipseRadio); // editInner.add(shapePanel); shapeLabel = new JLabel(); editInner.add(shapeLabel); editInner.add(new JLabel()); editInner.add(new JLabel("X Range")); JPanel xRangePanel = new JPanel(new GridLayout(1, 2)); JPanel xMinPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); xMinPanel.add(new JLabel("min: ")); xMin = new JTextField(10); // xMin.setActionCommand(CHANGE_XMIN_COMMAND); // xMin.addActionListener(this); xMin.addKeyListener(this); xMinPanel.add(xMin); xRangePanel.add(xMinPanel); JPanel xMaxPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); xMaxPanel.add(new JLabel("max: ")); xMax = new JTextField(10); // xMax.setActionCommand(CHANGE_XMAX_COMMAND); xMax.addKeyListener(this); xMaxPanel.add(xMax); xRangePanel.add(xMaxPanel); editInner.add(xRangePanel); editInner.add(new JLabel()); editInner.add(new JLabel("Y Range")); JPanel yRangePanel = new JPanel(new GridLayout(1, 2)); JPanel yMinPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); yMinPanel.add(new JLabel("min: ")); yMin = new JTextField(10); // yMin.setActionCommand(CHANGE_YMIN_COMMAND); // yMin.addActionListener(this); yMin.addKeyListener(this); yMinPanel.add(yMin); yRangePanel.add(yMinPanel); JPanel yMaxPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); yMaxPanel.add(new JLabel("max: ")); yMax = new JTextField(10); // yMax.setActionCommand(CHANGE_YMAX_COMMAND); // yMax.addActionListener(this); yMax.addKeyListener(this); yMaxPanel.add(yMax); yRangePanel.add(yMaxPanel); editInner.add(yRangePanel); editInner.add(new JLabel()); editInner.add(new JLabel()); JPanel applyPanel = new JPanel(new GridLayout(1, 2)); deleteButton = new JButton("Remove"); deleteButton.setEnabled(false); deleteButton.setActionCommand(REMOVE_CHANGE_ACTION); deleteButton.addActionListener(this); applyPanel.add(deleteButton); applyPanel.add(new JLabel()); applyButton = new JButton("Apply"); applyButton.setEnabled(false); applyButton.setActionCommand(APPLY_CHANGE_ACTION); applyButton.addActionListener(this); applyPanel.add(applyButton); editInner.add(applyPanel); editInner.add(new JLabel()); // inner.add(new JLabel("X Range")); // inner.add(inclusiveRadio); // exclusiveRadio = new JRadioButton("exclusive"); // exclusiveRadio.setActionCommand(USE_EXCLUSIVE_COMMAND); // exclusiveRadio.addActionListener(this); // inner.add(exclusiveRadio); editPanel.add(editInner, BorderLayout.NORTH); managePanel.add(editPanel, BorderLayout.SOUTH); managePanel.add(inner, BorderLayout.NORTH); maskingPanel.add(managePanel); wrap.setName("ROI"); wrap.add(maskingPanel, BorderLayout.NORTH); return wrap; }