SwingTableDemo() { // Create a new JFrame container. JFrame jfrm = new JFrame("JTable Demo"); // Specify FlowLayout for the layout manager. jfrm.setLayout(new FlowLayout()); // Give the frame an initial size. jfrm.setSize(460, 180); // Terminate the program when the user closes the application. jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create a table that displays order data. jtabOrders = new JTable(data, headings); // Wrap the table in a scroll pane. JScrollPane jscrlp = new JScrollPane(jtabOrders); // Set the scrollable viewport size. jtabOrders.setPreferredScrollableViewportSize(new Dimension(420, 62)); // Create the radio buttons that determine // what type of selections are allowed. jrbRows = new JRadioButton("Select Rows", true); jrbColumns = new JRadioButton("Select Columns"); jrbCells = new JRadioButton("Select Cells"); // Add the radio buttons to a group. ButtonGroup bg = new ButtonGroup(); bg.add(jrbRows); bg.add(jrbColumns); bg.add(jrbCells); // Radio button events are handled in common by the // actionPerformed() method implemented by TableDemo. jrbRows.addActionListener(this); jrbColumns.addActionListener(this); jrbCells.addActionListener(this); // Create the Single Selection Mode check box. // When checked, only single selections are allowed. jcbSingle = new JCheckBox("Single Selection Mode"); // Add item listener for jcbSingle. jcbSingle.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent ie) { if (jcbSingle.isSelected()) // Allow single selections. jtabOrders.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); else // Allow multiple selections. jtabOrders.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } }); // Add the components to the content pane. jfrm.add(jscrlp); jfrm.add(jrbRows); jfrm.add(jrbColumns); jfrm.add(jrbCells); jfrm.add(jcbSingle); // Display the frame. jfrm.setVisible(true); }
/** Creates an instance of <tt>ZrtpConfigurePanel</tt>. */ public ZrtpConfigurePanel() { super(new BorderLayout()); ResourceManagementService resources = NeomediaActivator.getResources(); JPanel mainPanel = new TransparentPanel(new BorderLayout(0, 10)); final JButton stdButton = new JButton(resources.getI18NString("impl.media.security.zrtp.STANDARD")); stdButton.setOpaque(false); final JButton mandButton = new JButton(resources.getI18NString("impl.media.security.zrtp.MANDATORY")); mandButton.setOpaque(false); final JButton saveButton = new JButton(resources.getI18NString("service.gui.SAVE")); saveButton.setOpaque(false); JPanel buttonBar = new TransparentPanel(new GridLayout(1, 7)); buttonBar.add(stdButton); buttonBar.add(mandButton); buttonBar.add(Box.createHorizontalStrut(10)); buttonBar.add(saveButton); ConfigurationService cfg = NeomediaActivator.getConfigurationService(); boolean trusted = cfg.getBoolean(TRUSTED_PROP, false); boolean sasSign = cfg.getBoolean(SASSIGN_PROP, false); JPanel checkBar = new TransparentPanel(new GridLayout(1, 2)); final JCheckBox trustedMitM = new SIPCommCheckBox(resources.getI18NString("impl.media.security.zrtp.TRUSTED"), trusted); final JCheckBox sasSignature = new SIPCommCheckBox( resources.getI18NString("impl.media.security.zrtp.SASSIGNATURE"), sasSign); checkBar.add(trustedMitM); checkBar.add(sasSignature); mainPanel.add(checkBar, BorderLayout.NORTH); ActionListener buttonListener = new ActionListener() { public void actionPerformed(ActionEvent event) { Object source = event.getSource(); if (source == stdButton) { inActive.clear(); active.setStandardConfig(); pkc.setStandard(); hc.setStandard(); sc.setStandard(); cc.setStandard(); lc.setStandard(); } else if (source == mandButton) { inActive.clear(); active.setMandatoryOnly(); pkc.setStandard(); hc.setStandard(); sc.setStandard(); cc.setStandard(); lc.setStandard(); } else if (source == saveButton) { ConfigurationService cfg = NeomediaActivator.getConfigurationService(); cfg.setProperty(TRUSTED_PROP, String.valueOf(active.isTrustedMitM())); cfg.setProperty(SASSIGN_PROP, String.valueOf(active.isSasSignature())); pkc.saveConfig(); hc.saveConfig(); sc.saveConfig(); cc.saveConfig(); lc.saveConfig(); } else return; } }; stdButton.addActionListener(buttonListener); mandButton.addActionListener(buttonListener); saveButton.addActionListener(buttonListener); ItemListener itemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { Object source = e.getItemSelectable(); if (source == trustedMitM) { active.setTrustedMitM(trustedMitM.isSelected()); } else if (source == sasSignature) { active.setSasSignature(sasSignature.isSelected()); } } }; trustedMitM.addItemListener(itemListener); sasSignature.addItemListener(itemListener); JTabbedPane algorithmsPane = new SIPCommTabbedPane(); algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.PUB_KEYS"), pkc); algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.HASHES"), hc); algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.SYM_CIPHERS"), cc); algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.SAS_TYPES"), sc); algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.SRTP_LENGTHS"), lc); algorithmsPane.setMinimumSize(new Dimension(400, 100)); algorithmsPane.setPreferredSize(new Dimension(400, 200)); mainPanel.add(algorithmsPane, BorderLayout.CENTER); mainPanel.add(buttonBar, BorderLayout.SOUTH); add(mainPanel); }