List of usage examples for javax.swing JMenuBar JMenuBar
public JMenuBar()
From source file:com.adobe.aem.demo.gui.AemDemo.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private void initialize() { // Initialize properties setDefaultProperties(AemDemoUtils/*from w w w.j a va 2s . c o m*/ .loadProperties(buildFile.getParentFile().getAbsolutePath() + File.separator + "build.properties")); setPersonalProperties(AemDemoUtils.loadProperties(buildFile.getParentFile().getAbsolutePath() + File.separator + "conf" + File.separator + "build-personal.properties")); // Constructing the main frame frameMain = new JFrame(); frameMain.setBounds(100, 100, 700, 530); frameMain.getContentPane().setLayout(null); // Main menu bar for the Frame JMenuBar menuBar = new JMenuBar(); JMenu mnAbout = new JMenu("AEM Demo Machine"); mnAbout.setMnemonic(KeyEvent.VK_A); menuBar.add(mnAbout); JMenuItem mntmDoc = new JMenuItem("Help and Documentation"); mntmDoc.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_H, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmDoc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties, AemDemoConstants.OPTIONS_DOCUMENTATION)); } }); mnAbout.add(mntmDoc); JMenuItem mntmQuit = new JMenuItem("Quit"); mntmQuit.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmQuit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(-1); } }); mnAbout.add(mntmQuit); JMenu mnNew = new JMenu("New"); mnNew.setMnemonic(KeyEvent.VK_N); menuBar.add(mnNew); // New Demo Machine JMenuItem mntmNewDemo = new JMenuItem("Demo Environment"); mntmNewDemo.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmNewDemo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (AemDemo.this.getBuildInProgress()) { JOptionPane.showMessageDialog(null, "A Demo Environment is currently being built. Please wait until it is finished."); } else { final AemDemoNew dialogNew = new AemDemoNew(AemDemo.this); dialogNew.setModal(true); dialogNew.setVisible(true); dialogNew.getDemoBuildName().requestFocus(); ; } } }); mnNew.add(mntmNewDemo); JMenuItem mntmNewOptions = new JMenuItem("Demo Properties"); mntmNewOptions.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_P, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmNewOptions.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final AemDemoOptions dialogOptions = new AemDemoOptions(AemDemo.this); dialogOptions.setModal(true); dialogOptions.setVisible(true); } }); mnNew.add(mntmNewOptions); JMenu mnUpdate = new JMenu("Add-ons"); menuBar.add(mnUpdate); // Sites Add-on JMenu mnSites = new JMenu("Sites"); mnUpdate.add(mnSites); JMenuItem mntmSitesDownloadAddOn = new JMenuItem("Download Add-On"); mntmSitesDownloadAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_sites"); } }); mnSites.add(mntmSitesDownloadAddOn); JMenuItem mntmSitesDownloadFP = new JMenuItem("Download Feature Pack (VPN)"); mntmSitesDownloadFP.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_sites_fp"); } }); mnSites.add(mntmSitesDownloadFP); mnSites.addSeparator(); JMenuItem mntmSitesInstallAddOn = new JMenuItem("Install Add-on"); mntmSitesInstallAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "sites"); } }); mnSites.add(mntmSitesInstallAddOn); // Assets Add-on JMenu mnAssets = new JMenu("Assets"); mnUpdate.add(mnAssets); JMenuItem mntmAssetsDownloadAddOn = new JMenuItem("Download Add-on"); mntmAssetsDownloadAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_assets"); } }); mnAssets.add(mntmAssetsDownloadAddOn); mnAssets.addSeparator(); JMenuItem mntmAssetsInstallAddOn = new JMenuItem("Install Add-on"); mntmAssetsInstallAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "assets"); } }); mnAssets.add(mntmAssetsInstallAddOn); // Communities Add-on JMenu mnCommunities = new JMenu("Communities"); mnUpdate.add(mnCommunities); JMenuItem mntmAemCommunitiesUber = new JMenuItem("Download Latest Bundles (VPN)"); mntmAemCommunitiesUber.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_U, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmAemCommunitiesUber.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_communities_bundles"); } }); mnCommunities.add(mntmAemCommunitiesUber); JMenuItem mntmAemCommunitiesFeaturePacks = new JMenuItem("Download Latest Feature Packs (PackageShare)"); mntmAemCommunitiesFeaturePacks.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_communities_fp"); } }); mnCommunities.add(mntmAemCommunitiesFeaturePacks); JMenuItem mntmAemCommunitiesEnablement = new JMenuItem("Download Enablement Demo Site Add-on (4.5GB)"); mntmAemCommunitiesEnablement.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_enablement"); } }); mnCommunities.add(mntmAemCommunitiesEnablement); mnCommunities.addSeparator(); JMenuItem mntmAemCommunitiesAddOn = new JMenuItem("Install Add-on"); mntmAemCommunitiesAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "communities"); } }); mnCommunities.add(mntmAemCommunitiesAddOn); // Forms Add-on JMenu mnForms = new JMenu("Forms"); mnUpdate.add(mnForms); JMenuItem mntmAemFormsFP = new JMenuItem("Download Demo Add-on (PackageShare)"); mntmAemFormsFP.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_forms_fp"); } }); mnForms.add(mntmAemFormsFP); mnForms.addSeparator(); JMenuItem mntmAemFormsAddOn = new JMenuItem("Install Add-on"); mntmAemFormsAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "forms"); } }); mnForms.add(mntmAemFormsAddOn); // Apps Add-on JMenu mnApps = new JMenu("Apps"); mnUpdate.add(mnApps); JMenuItem mntmAemApps = new JMenuItem("Download Add-on"); mntmAemApps.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_apps"); } }); mnApps.add(mntmAemApps); mnApps.addSeparator(); JMenuItem mntmAemAppsAddOn = new JMenuItem("Install Add-on"); mntmAemAppsAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "apps"); } }); mnApps.add(mntmAemAppsAddOn); // Commerce Add-on JMenu mnCommerce = new JMenu("Commerce"); mnUpdate.add(mnCommerce); JMenu mnCommerceDownload = new JMenu("Download Add-on"); mnCommerce.add(mnCommerceDownload); // Commerce EP JMenuItem mnCommerceDownloadEP = new JMenuItem("ElasticPath"); mnCommerceDownloadEP.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_commerce_ep"); } }); mnCommerceDownload.add(mnCommerceDownloadEP); // Commerce WebSphere JMenuItem mnCommerceDownloadWAS = new JMenuItem("WebSphere"); mnCommerceDownloadWAS.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_commerce_websphere"); } }); mnCommerceDownload.add(mnCommerceDownloadWAS); mnCommerce.addSeparator(); JMenuItem mntmAemCommerceAddOn = new JMenuItem("Install Add-on"); mntmAemCommerceAddOn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "commerce"); } }); mnCommerce.add(mntmAemCommerceAddOn); mnUpdate.addSeparator(); JMenuItem mntmAemDownloadAll = new JMenuItem("Download All Add-ons"); mntmAemDownloadAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_all"); } }); mnUpdate.add(mntmAemDownloadAll); JMenuItem mntmAemDownloadFromDrive = new JMenuItem("Download Web Page"); mntmAemDownloadFromDrive.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties, AemDemoConstants.OPTIONS_WEBDOWNLOAD)); } }); mnUpdate.add(mntmAemDownloadFromDrive); JMenu mnInfrastructure = new JMenu("Infrastructure"); menuBar.add(mnInfrastructure); JMenu mnMongo = new JMenu("MongoDB"); JMenuItem mntmInfraMongoDB = new JMenuItem("Download"); mntmInfraMongoDB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_mongo"); } }); mnMongo.add(mntmInfraMongoDB); JMenuItem mntmInfraMongoDBInstall = new JMenuItem("Install"); mntmInfraMongoDBInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "install_mongo"); } }); mnMongo.add(mntmInfraMongoDBInstall); mnMongo.addSeparator(); JMenuItem mntmInfraMongoDBStart = new JMenuItem("Start"); mntmInfraMongoDBStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "mongo_start"); } }); mnMongo.add(mntmInfraMongoDBStart); JMenuItem mntmInfraMongoDBStop = new JMenuItem("Stop"); mntmInfraMongoDBStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "mongo_stop"); } }); mnMongo.add(mntmInfraMongoDBStop); mnInfrastructure.add(mnMongo); // SOLR options JMenu mnSOLR = new JMenu("SOLR"); JMenuItem mntmInfraSOLR = new JMenuItem("Download"); mntmInfraSOLR.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_solr"); } }); mnSOLR.add(mntmInfraSOLR); JMenuItem mntmInfraSOLRInstall = new JMenuItem("Install"); mntmInfraSOLRInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "install_solr"); } }); mnSOLR.add(mntmInfraSOLRInstall); mnSOLR.addSeparator(); JMenuItem mntmInfraSOLRStart = new JMenuItem("Start"); mntmInfraSOLRStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "solr_start"); } }); mnSOLR.add(mntmInfraSOLRStart); JMenuItem mntmInfraSOLRStop = new JMenuItem("Stop"); mntmInfraSOLRStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "solr_stop"); } }); mnSOLR.add(mntmInfraSOLRStop); mnInfrastructure.add(mnSOLR); // MySQL options JMenu mnMySQL = new JMenu("MySQL"); JMenuItem mntmInfraMysql = new JMenuItem("Download"); mntmInfraMysql.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_mysql"); } }); mnMySQL.add(mntmInfraMysql); JMenuItem mntmInfraMysqlInstall = new JMenuItem("Install"); mntmInfraMysqlInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "install_mysql"); } }); mnMySQL.add(mntmInfraMysqlInstall); mnMySQL.addSeparator(); JMenuItem mntmInfraMysqlStart = new JMenuItem("Start"); mntmInfraMysqlStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "mysql_start"); } }); mnMySQL.add(mntmInfraMysqlStart); JMenuItem mntmInfraMysqlStop = new JMenuItem("Stop"); mntmInfraMysqlStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "mysql_stop"); } }); mnMySQL.add(mntmInfraMysqlStop); mnInfrastructure.add(mnMySQL); // FFMPEPG options JMenu mnFFMPEG = new JMenu("FFMPEG"); JMenuItem mntmInfraFFMPEG = new JMenuItem("Download"); mntmInfraFFMPEG.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_ffmpeg"); } }); mnFFMPEG.add(mntmInfraFFMPEG); JMenuItem mntmInfraFFMPEGInstall = new JMenuItem("Install"); mntmInfraFFMPEGInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "install_ffmpeg"); } }); mnFFMPEG.add(mntmInfraFFMPEGInstall); mnInfrastructure.add(mnFFMPEG); // Apache James options JMenu mnJames = new JMenu("James SMTP"); JMenuItem mnJamesStart = new JMenuItem("Start"); mnJamesStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "james_start"); } }); mnJames.add(mnJamesStart); JMenuItem mnJamesStop = new JMenuItem("Stop"); mnJamesStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "james_stop"); } }); mnJames.add(mnJamesStop); mnInfrastructure.add(mnJames); mnInfrastructure.addSeparator(); JMenuItem mntmInfraInstall = new JMenuItem("All in One Setup"); mntmInfraInstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "infrastructure"); } }); mnInfrastructure.add(mntmInfraInstall); JMenu mnOther = new JMenu("Other"); menuBar.add(mnOther); JMenu mntmAemDownload = new JMenu("AEM & License files (VPN)"); JMenuItem mntmAemDownloadAEM61 = new JMenuItem("Download AEM 6.1"); mntmAemDownloadAEM61.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_aem61"); } }); mntmAemDownload.add(mntmAemDownloadAEM61); JMenuItem mntmAemDownloadAEM60 = new JMenuItem("Download AEM 6.0"); mntmAemDownloadAEM60.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_aem60"); } }); mntmAemDownload.add(mntmAemDownloadAEM60); JMenuItem mntmAemDownloadCQ561 = new JMenuItem("Download CQ 5.6.1"); mntmAemDownloadCQ561.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_cq561"); } }); mntmAemDownload.add(mntmAemDownloadCQ561); JMenuItem mntmAemDownloadCQ56 = new JMenuItem("Download CQ 5.6"); mntmAemDownloadCQ56.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_cq56"); } }); mntmAemDownload.add(mntmAemDownloadCQ56); JMenuItem mntmAemDownloadOthers = new JMenuItem("Other Releases & License files"); mntmAemDownloadOthers.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties, AemDemoConstants.OPTIONS_DOWNLOAD)); } }); mntmAemDownload.add(mntmAemDownloadOthers); mnOther.add(mntmAemDownload); JMenuItem mntmAemSnapshot = new JMenuItem("Download Latest AEM Snapshot (VPN)"); mntmAemSnapshot.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_T, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmAemSnapshot.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "download_snapshot"); } }); mnOther.add(mntmAemSnapshot); JMenuItem mntmAemDemoMachine = new JMenuItem("Download Latest AEM Demo Machine"); mntmAemDemoMachine.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_D, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mntmAemDemoMachine.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.openWebpage(AemDemoUtils.getActualPropertyValue(defaultProperties, personalProperties, AemDemoConstants.OPTIONS_DEMODOWNLOAD)); } }); mnOther.add(mntmAemDemoMachine); // Adding the menu bar frameMain.setJMenuBar(menuBar); // Adding other form elements JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(24, 184, 650, 230); frameMain.getContentPane().add(scrollPane); final JTextArea textArea = new JTextArea(""); textArea.setEditable(false); scrollPane.setViewportView(textArea); // List of demo machines available JScrollPane scrollDemoList = new JScrollPane(); scrollDemoList.setBounds(24, 55, 208, 100); frameMain.getContentPane().add(scrollDemoList); listModelDemoMachines = AemDemoUtils.listDemoMachines(buildFile.getParentFile().getAbsolutePath()); listDemoMachines = new JList(listModelDemoMachines); scrollDemoList.setViewportView(listDemoMachines); // Capturing the output stream of ANT commands AemDemoOutputStream out = new AemDemoOutputStream(textArea); System.setOut(new PrintStream(out)); JButton btnStart = new JButton("Start"); btnStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "start"); } }); btnStart.setBounds(250, 50, 117, 29); frameMain.getContentPane().add(btnStart); // Set Start as the default button JRootPane rootPane = SwingUtilities.getRootPane(btnStart); rootPane.setDefaultButton(btnStart); JButton btnInfo = new JButton("Details"); btnInfo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "version"); AemDemoUtils.antTarget(AemDemo.this, "configuration"); } }); btnInfo.setBounds(250, 80, 117, 29); frameMain.getContentPane().add(btnInfo); JButton btnStop = new JButton("Stop"); btnStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "stop"); } }); btnStop.setBounds(500, 50, 117, 29); frameMain.getContentPane().add(btnStop); JButton btnExit = new JButton("Exit"); btnExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(-1); } }); btnExit.setBounds(550, 429, 117, 29); frameMain.getContentPane().add(btnExit); JButton btnClear = new JButton("Clear"); btnClear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textArea.setText(""); } }); btnClear.setBounds(40, 429, 117, 29); frameMain.getContentPane().add(btnClear); JButton btnBackup = new JButton("Backup"); btnBackup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "backup"); } }); btnBackup.setBounds(500, 80, 117, 29); frameMain.getContentPane().add(btnBackup); JButton btnRestore = new JButton("Restore"); btnRestore.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "restore"); } }); btnRestore.setBounds(500, 110, 117, 29); frameMain.getContentPane().add(btnRestore); JButton btnDelete = new JButton("Delete"); btnDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AemDemoUtils.antTarget(AemDemo.this, "uninstall"); } }); btnDelete.setBounds(500, 140, 117, 29); frameMain.getContentPane().add(btnDelete); JLabel lblSelectYourDemo = new JLabel("Select your Demo Environment"); lblSelectYourDemo.setBounds(24, 31, 219, 16); frameMain.getContentPane().add(lblSelectYourDemo); JLabel lblCommandOutput = new JLabel("Command Output"); lblCommandOutput.setBounds(24, 164, 160, 16); frameMain.getContentPane().add(lblCommandOutput); // Launching the download tracker task AemDemoDownload aemDownload = new AemDemoDownload(AemDemo.this); ScheduledExecutorService executor = Executors.newScheduledThreadPool(1); executor.scheduleAtFixedRate(aemDownload, 0, 5, TimeUnit.SECONDS); }
From source file:edu.purdue.cc.bionet.ui.ClusteringDisplayPanel.java
/** * A class for displaying information about a Clustering */// w w w .j ava 2s . c om public ClusteringDisplayPanel() { super(new BorderLayout()); Language language = Settings.getLanguage(); this.addComponentListener(new InitialSetup()); this.menuBar = new JMenuBar(); this.groupsMenu = new JMenu(language.get("Groups")); this.groupsMenu.setMnemonic(KeyEvent.VK_G); this.removeSampleGroupsMenuItem = new JMenuItem(language.get("Reset Sample Groups"), KeyEvent.VK_R); this.chooseSampleGroupsMenuItem = new JMenuItem(language.get("Choose Sample Groups"), KeyEvent.VK_C); this.recomputeMenuItem = new JMenuItem(Settings.getLanguage().get("Recompute/Set Parameters")); this.recomputeMenuItem.addActionListener(this); this.groupsMenu.add(this.removeSampleGroupsMenuItem); this.groupsMenu.add(this.chooseSampleGroupsMenuItem); this.chooseSampleGroupsMenuItem.addActionListener(this); this.removeSampleGroupsMenuItem.addActionListener(this); this.add(menuBar, BorderLayout.NORTH); this.menuBar.add(this.groupsMenu); this.menuBar.add(this.recomputeMenuItem); }
From source file:ImageProcessingTest.java
public ImageProcessingFrame() { setTitle("ImageProcessingTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); add(new JComponent() { public void paintComponent(Graphics g) { if (image != null) g.drawImage(image, 0, 0, null); }//from w w w . j av a 2 s . c o m }); JMenu fileMenu = new JMenu("File"); JMenuItem openItem = new JMenuItem("Open"); openItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { openFile(); } }); fileMenu.add(openItem); JMenuItem exitItem = new JMenuItem("Exit"); exitItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.exit(0); } }); fileMenu.add(exitItem); JMenu editMenu = new JMenu("Edit"); JMenuItem blurItem = new JMenuItem("Blur"); blurItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { float weight = 1.0f / 9.0f; float[] elements = new float[9]; for (int i = 0; i < 9; i++) elements[i] = weight; convolve(elements); } }); editMenu.add(blurItem); JMenuItem sharpenItem = new JMenuItem("Sharpen"); sharpenItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { float[] elements = { 0.0f, -1.0f, 0.0f, -1.0f, 5.f, -1.0f, 0.0f, -1.0f, 0.0f }; convolve(elements); } }); editMenu.add(sharpenItem); JMenuItem brightenItem = new JMenuItem("Brighten"); brightenItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { float a = 1.1f; // float b = 20.0f; float b = 0; RescaleOp op = new RescaleOp(a, b, null); filter(op); } }); editMenu.add(brightenItem); JMenuItem edgeDetectItem = new JMenuItem("Edge detect"); edgeDetectItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { float[] elements = { 0.0f, -1.0f, 0.0f, -1.0f, 4.f, -1.0f, 0.0f, -1.0f, 0.0f }; convolve(elements); } }); editMenu.add(edgeDetectItem); JMenuItem negativeItem = new JMenuItem("Negative"); negativeItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { short[] negative = new short[256 * 1]; for (int i = 0; i < 256; i++) negative[i] = (short) (255 - i); ShortLookupTable table = new ShortLookupTable(0, negative); LookupOp op = new LookupOp(table, null); filter(op); } }); editMenu.add(negativeItem); JMenuItem rotateItem = new JMenuItem("Rotate"); rotateItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { if (image == null) return; AffineTransform transform = AffineTransform.getRotateInstance(Math.toRadians(5), image.getWidth() / 2, image.getHeight() / 2); AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BICUBIC); filter(op); } }); editMenu.add(rotateItem); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); menuBar.add(editMenu); setJMenuBar(menuBar); }
From source file:com.moss.bdbadmin.client.ui.BdbAdminClient.java
public BdbAdminClient(HttpClient httpClient, JFrame window, File configPath, ProxyFactory proxyFactory) { this.httpClient = httpClient; this.ancestor = window; this.configPath = configPath; this.proxyFactory = proxyFactory; try {/* w w w . j a va2s. c o m*/ configJaxbContext = JAXBContext.newInstance(ServiceConfig.class); } catch (JAXBException ex) { throw new RuntimeException(ex); } JMenuItem newServiceItem = new JMenuItem("New Service"); newServiceItem.setAction(new NewServiceAction()); JMenu fileMenu = new JMenu("File"); fileMenu.add(newServiceItem); JMenuBar menuBar = new JMenuBar(); menuBar.add(fileMenu); window.setJMenuBar(menuBar); window.setIconImage(new ImageIcon(this.getClass().getClassLoader().getResource("service.gif")).getImage()); this.root = new DefaultMutableTreeNode(); this.model = new DefaultTreeModel(root); getTree().setModel(model); getTree().setShowsRootHandles(true); getTree().setRootVisible(false); getTree().setCellRenderer(new Renderer()); getTree().getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); getTree().getSelectionModel().addTreeSelectionListener(new SelectionListener()); getTree().addMouseListener(new ContextMenuHandler()); addAncestorListener(new AncestorListener() { public void ancestorAdded(AncestorEvent event) { loadConfig(); } public void ancestorMoved(AncestorEvent event) { } public void ancestorRemoved(AncestorEvent event) { } }); }
From source file:MainFrame.MainFrame.java
public MainFrame() { //Create menu this.menuBar = new JMenuBar(); this.menuProxy = new JMenu("Proxy"); this.menuBar.add(menuProxy); this.cbMenuItem = new JCheckBoxMenuItem("? proxy"); this.cbMenuItem.setMnemonic(KeyEvent.VK_C); ActionListener aListener = new ActionListener() { public void actionPerformed(ActionEvent event) { AbstractButton aButton = (AbstractButton) event.getSource(); boolean selected = aButton.getModel().isSelected(); if (selected) { SingleDataHolder.getInstance().isProxyActivated = true; SingleDataHolder.getInstance().proxyIpAdress = MainFrame.this.proxyIpAdress.getText(); SingleDataHolder.getInstance().proxyPort = Integer.parseInt(MainFrame.this.proxyPort.getText()); SingleDataHolder.getInstance().proxyLogin = MainFrame.this.proxyLogin.getText(); SingleDataHolder.getInstance().proxyPassword = String .valueOf(MainFrame.this.proxyPassword.getPassword()); } else { SingleDataHolder.getInstance().isProxyActivated = false; }//from www. ja v a 2 s . c om } }; this.cbMenuItem.addActionListener(aListener); this.proxyIpAdress = new JTextField(); this.proxyPort = new JTextField(); this.proxyLogin = new JTextField(); ; this.proxyPassword = new JPasswordField(); this.menuProxy.add(this.cbMenuItem); this.menuProxy.add(new JLabel("IP ?")); this.menuProxy.add(this.proxyIpAdress); this.menuProxy.add(new JLabel("? ")); this.menuProxy.add(this.proxyPort); this.menuProxy.add(new JLabel("")); this.menuProxy.add(this.proxyLogin); this.menuProxy.add(new JLabel("")); this.menuProxy.add(this.proxyPassword); this.setJMenuBar(this.menuBar); communicator = new HttpCommunicator(); myActionListener = new mainFrameActionListener(); mainPanel = new JPanel(new BorderLayout()); this.setContentPane(mainPanel); JPanel P = new JPanel(new FlowLayout(FlowLayout.LEFT, 15, 5)); mainPanel.add(P, BorderLayout.NORTH); //Create Group label labelGroup = new JLabel(""); P.add(labelGroup); //Create Group combo comboGroup = new JComboBox(); comboGroup.addItem("?"); comboGroup.addActionListener(myActionListener); P.add(comboGroup); //Create Date label labelDate = new JLabel(""); P.add(labelDate); //Create Date combo comboDate = new JComboBox(); comboDate.addItem("?"); comboDate.addActionListener(myActionListener); P.add(comboDate); //Create Delete button buttonDelete = new JButton(""); buttonDelete.setEnabled(false); buttonDelete.addActionListener(myActionListener); P.add(buttonDelete); //this.checkConnection = new CheckConnection(buttonDelete); buttonPasswordsManager = new JButton(" "); buttonPasswordsManager.addActionListener(myActionListener); P.add(buttonPasswordsManager); try { Image img = ImageIO.read(getClass().getResource("resources/table_refresh.png")); this.buttonRefresh = new JButton(new ImageIcon(img)); this.buttonRefresh.addActionListener(myActionListener); this.buttonRefresh.setToolTipText(" "); P.add(buttonRefresh); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } //CreateLessonTableModel lessonTableModel = new LessonTableModel(); try { communicator.setCombos(comboGroup, comboDate, lessonTableModel); } catch (IOException ex) { JOptionPane.showMessageDialog(null, " ? ? ."); Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } //CreateTable table = new JTable(lessonTableModel); table.setFillsViewportHeight(true); table.setAutoCreateRowSorter(true); JScrollPane scrollP = new JScrollPane(table); mainPanel.add(scrollP, BorderLayout.CENTER); //Create Table sorter sorter = new TableRowSorter<LessonTableModel>(lessonTableModel); table.setRowSorter(sorter); table.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { int row = e.getFirstRow(); int column = e.getColumn(); TableModel model = (TableModel) e.getSource(); for (int i = 0; i < model.getRowCount(); i++) { if ((boolean) model.getValueAt(i, 2) == true) { buttonDelete.setEnabled(true); return; } } buttonDelete.setEnabled(false); } }); //Standart block this.setSize(700, 400); this.setTitle(" "); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we) { System.exit(0); } }); try { Image img = ImageIO.read(getClass().getResource("resources/appIcon.png")); this.setIconImage(img); } catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } this.setVisible(true); }
From source file:direccion.Reportes.java
public Reportes() { String titulo = "Reportes"; jFrame = new JFrame(titulo); jFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); jFrame.setSize(800, 600);//from w w w. j av a2 s. com Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screenSize.width / 2) - (jFrame.getSize().width / 2); int y = (screenSize.height / 2) - (jFrame.getSize().height / 2); jFrame.setLocation(x, y); JLabel etiqueta = new JLabel("Reportes"); etiqueta.setBounds(300, 25, 200, 50); etiqueta.setFont(new Font("Verdana", Font.BOLD, 30)); etiqueta.setForeground(Color.BLACK); JMenuBar jMenuBar = new JMenuBar(); JMenu acceso = new JMenu("Acceso a"); JMenu ayuda = new JMenu("Ayuda"); JMenuItem rec_hum = new JMenuItem("Recursos Humanos"); JMenuItem conta = new JMenuItem("Contabilidad"); JMenuItem ventas = new JMenuItem("Ventas"); JMenuItem compras = new JMenuItem("Compras"); JMenuItem inventario = new JMenuItem("Inventario"); JMenuItem acerca_de = new JMenuItem("Acerca de"); acerca_de.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "Ayuda", "Ayuda", 3); } }); acceso.add(rec_hum); acceso.add(conta); acceso.add(ventas); acceso.add(compras); acceso.add(inventario); ayuda.add(acerca_de); jMenuBar.add(acceso); jMenuBar.add(ayuda); JCalendar cal1 = new JCalendar(); cal1.setBounds(250, 150, 400, 300); JCalendarCombo cal2 = new JCalendarCombo(); cal2.setBounds(250, 150, 400, 300); String reportes[] = { "Mantenimiento", "Compras", "Ventas", "Inventario", "Contabilidad", "Recursos Humanos" }; JComboBox combobox = new JComboBox(reportes); combobox.setBounds(300, 100, 150, 30); JLabel calendario = new JLabel("Fecha de Operacin:"); calendario.setBounds(60, 150, 150, 30); JButton aceptar = new JButton("Aceptar"); aceptar.setBounds(50, 200, 150, 30); aceptar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (combobox.getSelectedIndex() == 0) { datos_mantenimiento.setValue("Recursos Humanos", d_mant_rh); datos_mantenimiento.setValue("Contabilidad", d_mant_cont); datos_mantenimiento.setValue("Ventas", d_mant_vent); datos_mantenimiento.setValue("Compras", d_mant_comp); datos_mantenimiento.setValue("Inventario", d_mant_inv); datos_mantenimiento.setValue("Mantenimiento", d_mant_mant); Grafica = ChartFactory.createPieChart3D("Mantenimiento", datos_mantenimiento, true, true, true); ChartPanel panel_grafica = new ChartPanel(Grafica); JFrame frame_grafica = new JFrame("Grfico"); JMenuBar menu = new JMenuBar(); JMenu archivo = new JMenu("Archivo"); JMenuItem guardar = new JMenuItem("Guardar como reporte..."); guardar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Document document = new Document(); PdfWriter writer = null; try { writer = PdfWriter.getInstance(document, new FileOutputStream("Grfico Mantenimiento.pdf")); } catch (DocumentException ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(450, 450); Graphics2D g2 = tp.createGraphicsShapes(450, 450); menu.setVisible(false); frame_grafica.print(g2); menu.setVisible(true); g2.dispose(); cb.addTemplate(tp, 30, 400); document.close(); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Reporte de Mantenimiento"); Row fila = sheet.createRow(0); File archivo = new File("Reporte de Mantenimiento.xls"); Cell celda; String[] titulos = { "Recursos Humanos", "Contabilidad", "Ventas", "Compras", "Inventario", "Mantenimiento" }; Double[] datos = { d_mant_rh, d_mant_cont, d_mant_vent, d_mant_comp, d_mant_inv, d_mant_mant }; int i; for (i = 0; i < titulos.length; i++) { celda = fila.createCell(i); celda.setCellValue(titulos[i]); } fila = sheet.createRow(1); for (i = 0; i < datos.length; i++) { celda = fila.createCell(i); celda.setCellValue(datos[i]); } try { FileOutputStream out = new FileOutputStream(archivo); workbook.write(out); out.close(); System.out.println("Archivo creado exitosamente!"); } catch (IOException ex) { System.out.println("Error de escritura"); ex.printStackTrace(); } } }); archivo.add(guardar); menu.add(archivo); frame_grafica.getContentPane().add(panel_grafica); frame_grafica.setBounds(60, 60, 450, 400); frame_grafica.setJMenuBar(menu); frame_grafica.setVisible(true); frame_grafica.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } if (combobox.getSelectedIndex() == 1) { datos_compras.setValue("Nomina", d_comp_nom); datos_compras.setValue("Compras", d_comp_comp); datos_compras.setValue("Gastos Fijos", d_comp_gf); datos_compras.setValue("Gastos Variables", d_comp_gv); datos_compras.setValue("Gastos Otros", d_comp_go); Grafica = ChartFactory.createPieChart3D("Compras", datos_compras, true, true, true); ChartPanel panel_grafica = new ChartPanel(Grafica); JFrame frame_grafica = new JFrame("Grfico"); JMenuBar menu = new JMenuBar(); JMenu archivo = new JMenu("Archivo"); JMenuItem guardar = new JMenuItem("Guardar como reporte..."); guardar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Document document = new Document(); PdfWriter writer = null; try { writer = PdfWriter.getInstance(document, new FileOutputStream("Grfico Compras.pdf")); } catch (DocumentException ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } document.open(); menu.setVisible(false); PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(450, 450); Graphics2D g2 = tp.createGraphicsShapes(850, 850); menu.setVisible(false); frame_grafica.print(g2); menu.setVisible(true); g2.dispose(); cb.addTemplate(tp, 30, 400); document.close(); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Reporte de Compras"); Row fila = sheet.createRow(0); File archivo = new File("Reporte de Compras.xls"); Cell celda; String[] titulos = { "Nomina", "Compras", "Gastos Fijos", "Gastos Variables", "Gastos Otros" }; Double[] datos = { d_comp_nom, d_comp_comp, d_comp_gf, d_comp_gv, d_comp_go }; int i; for (i = 0; i < titulos.length; i++) { celda = fila.createCell(i); celda.setCellValue(titulos[i]); } fila = sheet.createRow(1); for (i = 0; i < datos.length; i++) { celda = fila.createCell(i); celda.setCellValue(datos[i]); } try { FileOutputStream out = new FileOutputStream(archivo); workbook.write(out); out.close(); System.out.println("Archivo creado exitosamente!"); } catch (IOException ex) { System.out.println("Error de escritura"); ex.printStackTrace(); } } }); archivo.add(guardar); menu.add(archivo); frame_grafica.getContentPane().add(panel_grafica); frame_grafica.setBounds(60, 60, 450, 400); frame_grafica.setJMenuBar(menu); frame_grafica.setVisible(true); frame_grafica.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } if (combobox.getSelectedIndex() == 2) { datos_ventas.addValue(d_vent_s1_lu, "Semana 1", "Lunes"); datos_ventas.addValue(d_vent_s1_ma, "Semana 1", "Martes"); datos_ventas.addValue(d_vent_s1_mi, "Semana 1", "Mircoles"); datos_ventas.addValue(d_vent_s1_ju, "Semana 1", "Jueves"); datos_ventas.addValue(d_vent_s1_vi, "Semana 1", "Viernes"); datos_ventas.addValue(d_vent_s1_sa, "Semana 1", "Sbado"); datos_ventas.addValue(d_vent_s1_do, "Semana 1", "Domingo"); datos_ventas.addValue(d_vent_s2_lu, "Semana 2", "Lunes"); datos_ventas.addValue(d_vent_s2_ma, "Semana 2", "Martes"); datos_ventas.addValue(d_vent_s2_mi, "Semana 2", "Mircoles"); datos_ventas.addValue(d_vent_s2_ju, "Semana 2", "Jueves"); datos_ventas.addValue(d_vent_s2_vi, "Semana 2", "Viernes"); datos_ventas.addValue(d_vent_s2_sa, "Semana 2", "Sbado"); datos_ventas.addValue(d_vent_s2_do, "Semana 2", "Domingo"); Grafica = ChartFactory.createLineChart3D("Ventas", "Das", "Ingresos", datos_ventas, PlotOrientation.VERTICAL, true, true, false); ChartPanel panel_grafica = new ChartPanel(Grafica); JFrame frame_grafica = new JFrame("Grfico"); JMenuBar menu = new JMenuBar(); JMenu archivo = new JMenu("Archivo"); JMenuItem guardar = new JMenuItem("Guardar como reporte..."); guardar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Document document = new Document(); PdfWriter writer = null; try { writer = PdfWriter.getInstance(document, new FileOutputStream("Grfico Ventas.pdf")); } catch (DocumentException ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(450, 450); Graphics2D g2 = tp.createGraphicsShapes(450, 450); menu.setVisible(false); frame_grafica.print(g2); menu.setVisible(true); g2.dispose(); cb.addTemplate(tp, 30, 400); document.close(); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Reporte de Ventas"); Row fila = sheet.createRow(0); File archivo = new File("Reporte de Ventas.xls"); Cell celda; String[] titulos1 = { "S1 lunes", "S1 martes", "S1 miercoles", "S1 jueves", "S1 viernes", "S1 sabado", "S1 domingo" }; String[] titulos2 = { "S2 lunes", "S2 martes", "S2 miercoles", "S2 jueves", "S2 viernes", "S2 sabado", "S2 domingo" }; Double[] datos1 = { d_vent_s1_lu, d_vent_s1_ma, d_vent_s1_mi, d_vent_s1_ju, d_vent_s1_vi, d_vent_s1_sa, d_vent_s1_do }; Double[] datos2 = { d_vent_s2_lu, d_vent_s2_ma, d_vent_s2_mi, d_vent_s2_ju, d_vent_s2_vi, d_vent_s2_sa, d_vent_s2_do }; int i, j; for (i = 0; i < titulos1.length; i++) { celda = fila.createCell(i); celda.setCellValue(titulos1[i]); } fila = sheet.createRow(1); for (i = 0; i < datos1.length; i++) { celda = fila.createCell(i); celda.setCellValue(datos1[i]); } fila = sheet.createRow(3); for (j = 0; j < titulos2.length; j++) { celda = fila.createCell(j); celda.setCellValue(titulos2[j]); } fila = sheet.createRow(4); for (j = 0; j < datos2.length; j++) { celda = fila.createCell(j); celda.setCellValue(datos2[j]); } try { FileOutputStream out = new FileOutputStream(archivo); workbook.write(out); out.close(); System.out.println("Archivo creado exitosamente!"); } catch (IOException ex) { System.out.println("Error de escritura"); ex.printStackTrace(); } } }); archivo.add(guardar); menu.add(archivo); frame_grafica.getContentPane().add(panel_grafica); frame_grafica.setBounds(60, 60, 450, 400); frame_grafica.setJMenuBar(menu); frame_grafica.setVisible(true); frame_grafica.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } if (combobox.getSelectedIndex() == 3) { datos_inventario.setValue("Producto 1", d_inv_p1); datos_inventario.setValue("Producto 2", d_inv_p2); datos_inventario.setValue("Producto 3", d_inv_p3); datos_inventario.setValue("Producto 4", d_inv_p4); datos_inventario.setValue("Producto 5", d_inv_p5); Grafica = ChartFactory.createPieChart3D("Inventario", datos_inventario, true, true, true); ChartPanel panel_grafica = new ChartPanel(Grafica); JFrame frame_grafica = new JFrame("Grfico"); JMenuBar menu = new JMenuBar(); JMenu archivo = new JMenu("Archivo"); JMenuItem guardar = new JMenuItem("Guardar como reporte..."); guardar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Document document = new Document(); PdfWriter writer = null; try { writer = PdfWriter.getInstance(document, new FileOutputStream("Grfico Inventario.pdf")); } catch (DocumentException ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(450, 450); Graphics2D g2 = tp.createGraphicsShapes(450, 450); menu.setVisible(false); frame_grafica.print(g2); menu.setVisible(true); g2.dispose(); cb.addTemplate(tp, 30, 400); document.close(); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Reporte de Inventario"); Row fila = sheet.createRow(0); File archivo = new File("Reporte de Inventario.xls"); Cell celda; String[] titulos = { "Producto 1", "Producto 2", "Prroducto 3", "Producto 4", "Producto 5" }; Double[] datos = { d_inv_p1, d_inv_p2, d_inv_p3, d_inv_p4, d_inv_p5 }; int i; for (i = 0; i < titulos.length; i++) { celda = fila.createCell(i); celda.setCellValue(titulos[i]); } fila = sheet.createRow(1); for (i = 0; i < datos.length; i++) { celda = fila.createCell(i); celda.setCellValue(datos[i]); } try { FileOutputStream out = new FileOutputStream(archivo); workbook.write(out); out.close(); System.out.println("Archivo creado exitosamente!"); } catch (IOException ex) { System.out.println("Error de escritura"); ex.printStackTrace(); } } }); archivo.add(guardar); menu.add(archivo); frame_grafica.getContentPane().add(panel_grafica); frame_grafica.setBounds(60, 60, 450, 400); frame_grafica.setJMenuBar(menu); frame_grafica.setVisible(true); frame_grafica.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } if (combobox.getSelectedIndex() == 4) { datos_contabilidad.addValue(d_cont_e_lu, "Entradas", "Lunes"); datos_contabilidad.addValue(d_cont_e_ma, "Entradas", "Martes"); datos_contabilidad.addValue(d_cont_e_mi, "Entradas", "Mircoles"); datos_contabilidad.addValue(d_cont_e_ju, "Entradas", "Jueves"); datos_contabilidad.addValue(d_cont_e_vi, "Entradas", "Viernes"); datos_contabilidad.addValue(d_cont_e_sa, "Entradas", "Sbado"); datos_contabilidad.addValue(d_cont_e_do, "Entradas", "Domingo"); datos_contabilidad.addValue(d_cont_s_lu, "Salidas", "Lunes"); datos_contabilidad.addValue(d_cont_s_ma, "Salidas", "Martes"); datos_contabilidad.addValue(d_cont_s_mi, "Salidas", "Mircoles"); datos_contabilidad.addValue(d_cont_s_ju, "Salidas", "Jueves"); datos_contabilidad.addValue(d_cont_s_vi, "Salidas", "Viernes"); datos_contabilidad.addValue(d_cont_s_sa, "Salidas", "Sbado"); datos_contabilidad.addValue(d_cont_s_do, "Salidas", "Domingo"); datos_contabilidad.addValue(d_cont_u_lu, "Utilidades", "Lunes"); datos_contabilidad.addValue(d_cont_u_ma, "Utilidades", "Martes"); datos_contabilidad.addValue(d_cont_u_mi, "Utilidades", "Mircoles"); datos_contabilidad.addValue(d_cont_u_ju, "Utilidades", "Jueves"); datos_contabilidad.addValue(d_cont_u_vi, "Utilidades", "Viernes"); datos_contabilidad.addValue(d_cont_u_sa, "Utilidades", "Sbado"); datos_contabilidad.addValue(d_cont_u_do, "Utilidades", "Domingo"); Grafica = ChartFactory.createLineChart3D("Contabilidad", "Das", "Ingresos", datos_contabilidad, PlotOrientation.VERTICAL, true, true, false); ChartPanel panel_grafica = new ChartPanel(Grafica); JFrame frame_grafica = new JFrame("Grfico"); JMenuBar menu = new JMenuBar(); JMenu archivo = new JMenu("Archivo"); JMenuItem guardar = new JMenuItem("Guardar como reporte..."); guardar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Document document = new Document(); PdfWriter writer = null; try { writer = PdfWriter.getInstance(document, new FileOutputStream("Grfico Contabilidad.pdf")); } catch (DocumentException ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(450, 450); Graphics2D g2 = tp.createGraphicsShapes(450, 450); menu.setVisible(false); frame_grafica.print(g2); menu.setVisible(true); g2.dispose(); cb.addTemplate(tp, 30, 400); document.close(); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Reporte de Contabilidad"); Row fila = sheet.createRow(0); File archivo = new File("Reporte de Contabilidad.xls"); Cell celda; String[] t_ent = { "E lunes", "E martes", "E miercoles", "E jueves", "E viernes", "E sabado", "E domingo" }; String[] t_sal = { "S lunes", "S martes", "S miercoles", "S jueves", "S viernes", "S sabado", "S domingo" }; String[] t_uti = { "U lunes", "U martes", "U miercoles", "U jueves", "U viernes", "U sabado", "U domingo" }; Double[] d_ent = { d_cont_e_lu, d_cont_e_ma, d_cont_e_mi, d_cont_e_ju, d_cont_e_vi, d_cont_e_sa, d_cont_e_do }; Double[] d_sal = { d_cont_s_lu, d_cont_s_ma, d_cont_s_mi, d_cont_s_ju, d_cont_s_vi, d_cont_s_sa, d_cont_s_do }; Double[] d_uti = { d_cont_u_lu, d_cont_u_ma, d_cont_u_mi, d_cont_u_ju, d_cont_u_vi, d_cont_u_sa, d_cont_u_do }; int i, j, k; for (i = 0; i < t_ent.length; i++) { celda = fila.createCell(i); celda.setCellValue(t_ent[i]); } fila = sheet.createRow(1); for (i = 0; i < d_ent.length; i++) { celda = fila.createCell(i); celda.setCellValue(d_ent[i]); } fila = sheet.createRow(3); for (j = 0; j < t_sal.length; j++) { celda = fila.createCell(j); celda.setCellValue(t_sal[j]); } fila = sheet.createRow(4); for (j = 0; j < d_sal.length; j++) { celda = fila.createCell(j); celda.setCellValue(d_sal[j]); } fila = sheet.createRow(6); for (k = 0; k < t_uti.length; k++) { celda = fila.createCell(k); celda.setCellValue(t_uti[k]); } fila = sheet.createRow(7); for (k = 0; k < d_uti.length; k++) { celda = fila.createCell(k); celda.setCellValue(d_uti[k]); } try { FileOutputStream out = new FileOutputStream(archivo); workbook.write(out); out.close(); System.out.println("Archivo creado exitosamente!"); } catch (IOException ex) { System.out.println("Error de escritura"); ex.printStackTrace(); } } }); archivo.add(guardar); menu.add(archivo); frame_grafica.getContentPane().add(panel_grafica); frame_grafica.setBounds(60, 60, 450, 400); frame_grafica.setJMenuBar(menu); frame_grafica.setVisible(true); frame_grafica.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } if (combobox.getSelectedIndex() == 5) { datos_rec_hum.addValue(d_rh_a_lu, "Asistencias", "Lunes"); datos_rec_hum.addValue(d_rh_a_ma, "Asistencias", "Martes"); datos_rec_hum.addValue(d_rh_a_mi, "Asistencias", "Mircoles"); datos_rec_hum.addValue(d_rh_a_ju, "Asistencias", "Jueves"); datos_rec_hum.addValue(d_rh_a_vi, "Asistencias", "Viernes"); datos_rec_hum.addValue(d_rh_a_sa, "Asistencias", "Sbado"); datos_rec_hum.addValue(d_rh_a_do, "Asistencias", "Domingo"); datos_rec_hum.addValue(d_rh_r_lu, "Retardos", "Lunes"); datos_rec_hum.addValue(d_rh_r_ma, "Retardos", "Martes"); datos_rec_hum.addValue(d_rh_r_mi, "Retardos", "Mircoles"); datos_rec_hum.addValue(d_rh_r_ju, "Retardos", "Jueves"); datos_rec_hum.addValue(d_rh_r_vi, "Retardos", "Viernes"); datos_rec_hum.addValue(d_rh_r_sa, "Retardos", "Sbado"); datos_rec_hum.addValue(d_rh_r_do, "Retardos", "Domingo"); datos_rec_hum.addValue(d_rh_f_lu, "Faltas", "Lunes"); datos_rec_hum.addValue(d_rh_f_ma, "Faltas", "Martes"); datos_rec_hum.addValue(d_rh_f_mi, "Faltas", "Mircoles"); datos_rec_hum.addValue(d_rh_f_ju, "Faltas", "Jueves"); datos_rec_hum.addValue(d_rh_f_vi, "Faltas", "Viernes"); datos_rec_hum.addValue(d_rh_f_sa, "Faltas", "Sbado"); datos_rec_hum.addValue(d_rh_f_do, "Faltas", "Domingo"); Grafica = ChartFactory.createBarChart3D("Recursos Humanos", "Das", "Nmero de Empleados", datos_rec_hum, PlotOrientation.VERTICAL, true, true, false); ChartPanel panel_grafica = new ChartPanel(Grafica); JFrame frame_grafica = new JFrame("Grfico"); JMenuBar menu = new JMenuBar(); JMenu archivo = new JMenu("Archivo"); JMenuItem guardar = new JMenuItem("Guardar como reporte..."); guardar.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Document document = new Document(); PdfWriter writer = null; try { writer = PdfWriter.getInstance(document, new FileOutputStream("Grfico Recursos Humanos.pdf")); } catch (DocumentException ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(JFrame.class.getName()).log(Level.SEVERE, null, ex); } document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(450, 450); Graphics2D g2 = tp.createGraphicsShapes(450, 450); menu.setVisible(false); frame_grafica.print(g2); menu.setVisible(true); g2.dispose(); cb.addTemplate(tp, 30, 400); document.close(); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("Reporte de Recursos Humanos"); Row fila = sheet.createRow(0); File archivo = new File("Reporte de Recursos Humanos.xls"); Cell celda; String[] t_asi = { "A lunes", "A martes", "A miercoles", "A jueves", "A viernes", "A sabado", "A domingo" }; String[] t_ret = { "R lunes", "R martes", "R miercoles", "R jueves", "R viernes", "R sabado", "R domingo" }; String[] t_fal = { "F lunes", "F martes", "F miercoles", "F jueves", "F viernes", "F sabado", "F domingo" }; int[] d_asi = { d_rh_a_lu, d_rh_a_ma, d_rh_a_mi, d_rh_a_ju, d_rh_a_vi, d_rh_a_sa, d_rh_a_do }; int[] d_ret = { d_rh_r_lu, d_rh_r_ma, d_rh_r_mi, d_rh_r_ju, d_rh_r_vi, d_rh_r_sa, d_rh_r_do }; int[] d_fal = { d_rh_f_lu, d_rh_r_ma, d_rh_r_mi, d_rh_r_ju, d_rh_r_vi, d_rh_r_sa, d_rh_r_do }; int i, j, k; for (i = 0; i < t_asi.length; i++) { celda = fila.createCell(i); celda.setCellValue(t_asi[i]); } fila = sheet.createRow(1); for (i = 0; i < d_asi.length; i++) { celda = fila.createCell(i); celda.setCellValue(d_asi[i]); } fila = sheet.createRow(3); for (j = 0; j < t_ret.length; j++) { celda = fila.createCell(j); celda.setCellValue(t_ret[j]); } fila = sheet.createRow(4); for (j = 0; j < d_ret.length; j++) { celda = fila.createCell(j); celda.setCellValue(d_ret[j]); } fila = sheet.createRow(6); for (k = 0; k < t_fal.length; k++) { celda = fila.createCell(k); celda.setCellValue(t_fal[k]); } fila = sheet.createRow(7); for (k = 0; k < d_fal.length; k++) { celda = fila.createCell(k); celda.setCellValue(d_fal[k]); } try { FileOutputStream out = new FileOutputStream(archivo); workbook.write(out); out.close(); System.out.println("Archivo creado exitosamente!"); } catch (IOException ex) { System.out.println("Error de escritura"); ex.printStackTrace(); } } }); archivo.add(guardar); menu.add(archivo); frame_grafica.getContentPane().add(panel_grafica); frame_grafica.setBounds(60, 60, 450, 400); frame_grafica.setJMenuBar(menu); frame_grafica.setVisible(true); frame_grafica.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } } }); jPanel = new JPanel(); jPanel.setLayout(null); jPanel.add(cal1); jPanel.add(cal2); jPanel.add(etiqueta); jPanel.add(combobox); jPanel.add(calendario); jPanel.add(aceptar); jFrame.setJMenuBar(jMenuBar); jFrame.add(jPanel); jFrame.setVisible(true); }
From source file:de.huberlin.cuneiform.compiler.debug.DebugDispatcher.java
private void addMenu() { JMenuBar menuBar;/*from w w w . ja va 2 s . c om*/ JMenu fileMenu; JMenu helpMenu; JMenuItem aboutItem; menuBar = new JMenuBar(); frame.setJMenuBar(menuBar); fileMenu = new JMenu("File"); menuBar.add(fileMenu); openItem = new JMenuItem("Open File ..."); fileMenu.add(openItem); exitItem = new JMenuItem("Exit"); exitItem.addActionListener(this); fileMenu.add(exitItem); helpMenu = new JMenu("Help"); menuBar.add(helpMenu); aboutItem = new JMenuItem("About Cuneiform"); helpMenu.add(aboutItem); }
From source file:org.simbrain.plot.scatterplot.ScatterPlotGui.java
/** * Creates the menu bar.//from www . j a va 2s . co m */ private void createAttachMenuBar() { JMenuBar bar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); for (Action action : actionManager.getOpenSavePlotActions()) { fileMenu.add(action); } fileMenu.addSeparator(); fileMenu.add(new CloseAction(this.getWorkspaceComponent())); JMenu editMenu = new JMenu("Edit"); JMenuItem preferences = new JMenuItem("Preferences..."); preferences.addActionListener(this); preferences.setActionCommand("dialog"); editMenu.add(preferences); JMenu helpMenu = new JMenu("Help"); ShowHelpAction helpAction = new ShowHelpAction("Pages/Plot/scatter_plot.html"); JMenuItem helpItem = new JMenuItem(helpAction); helpMenu.add(helpItem); bar.add(fileMenu); bar.add(editMenu); bar.add(helpMenu); getParentFrame().setJMenuBar(bar); }
From source file:ListCutPaste.java
/** * Create an Edit menu to support cut/copy/paste. *//* ww w .java 2s. com*/ public JMenuBar createMenuBar() { JMenuItem menuItem = null; JMenuBar menuBar = new JMenuBar(); JMenu mainMenu = new JMenu("Edit"); mainMenu.setMnemonic(KeyEvent.VK_E); TransferActionListener actionListener = new TransferActionListener(); menuItem = new JMenuItem("Cut"); menuItem.setActionCommand((String) TransferHandler.getCutAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_T); mainMenu.add(menuItem); menuItem = new JMenuItem("Copy"); menuItem.setActionCommand((String) TransferHandler.getCopyAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_C); mainMenu.add(menuItem); menuItem = new JMenuItem("Paste"); menuItem.setActionCommand((String) TransferHandler.getPasteAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_P); mainMenu.add(menuItem); menuBar.add(mainMenu); return menuBar; }
From source file:fedroot.dacs.swingdemo.DacsSingleFrameApplication.java
private JMenuBar createMenuBar() { String[] menuActionNames = { "openAction", "helpAction", "aboutAction", "quit" }; JMenuBar menuBar = new JMenuBar(); menuBar.add(createMenu("mainMenu", menuActionNames)); return menuBar; }