List of usage examples for javax.swing JMenu JMenu
public JMenu(Action a)
Action
supplied. From source file:com.adobe.aem.demo.gui.AemDemo.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private void initialize() { // Initialize properties setDefaultProperties(AemDemoUtils//from w ww.ja va2 s. c om .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:com.fratello.longevity.smooth.AppGUI.java
private void initialize() { LabelMaxSize = 0;//from w w w . ja va 2 s. c o m ActiveGUI = true; GUI_Start = false; GUI_Pause = true; GUI_Stop = false; ran_at_least_once = false; execute(); initializeFields(); frmFileSystemSearch = new JFrame(); frmFileSystemSearch.setTitle("Smooth Longevity Fratello"); frmFileSystemSearch.setBounds(100, 100, 450, 300); frmFileSystemSearch.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frmFileSystemSearch.setResizable(false); UIManager.put("PopupMenu.border", BorderFactory.createLineBorder(Color.black, 1)); JMenuBar menuBar = new JMenuBar(); frmFileSystemSearch.setJMenuBar(menuBar); JMenu mnNewMenu = new JMenu("File"); menuBar.add(mnNewMenu); JMenuItem mntmFirst = new JMenuItem("Open Directory"); mntmFirst.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openFileChooserDir(mntmFirst); } }); mnNewMenu.add(mntmFirst); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { frmFileSystemSearch.dispose(); } }); mnNewMenu.add(mntmExit); JMenu mnHelp = new JMenu("Help"); menuBar.add(mnHelp); JMenuItem mntmAbout = new JMenuItem("About"); mnHelp.add(mntmAbout); JMenuItem mntmTutorials = new JMenuItem("Tutorials"); mnHelp.add(mntmTutorials); JMenuItem mntmCheckForUpdates = new JMenuItem("Check for Updates"); mnHelp.add(mntmCheckForUpdates); String ppallink = "https://www.paypal.com/cgi-bin/webscr" + "?cmd=" + "_donations" + "&business=" + "8YUJNSN6KFV54" + "&lc=" + "US" + "&item_name=" + "Personal%20funds%20for%20programming%20at%20university" + "¤cy_code=" + "USD" + "&bn=" + "PP%2dDonationsBF" + "%3abtn_donateCC_LG%2egif%3aNonHosted"; JButton btnDonate = new JButton("Donate"); btnDonate.setToolTipText("<html>Open default Internet browser <br>(Chrome, FireFox, etc.)</html>"); btnDonate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openWebPage(ppallink); } }); btnDonate.setBounds(159, 176, 90, 25); menuBar.add(btnDonate); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); frmFileSystemSearch.getContentPane().add(tabbedPane, BorderLayout.CENTER); // ---------------------------- JPanels ------------------------------ JPanel panel = new JPanel(); tabbedPane.addTab("Start Directory", null, panel, null); JPanel panel_1 = new JPanel(); tabbedPane.addTab("Search Setup", null, panel_1, null); panel_1.setLayout(null); JPanel panel_2 = new JPanel(); tabbedPane.addTab("Run Program", null, panel_2, null); panel_2.setLayout(null); JPanel panel_3 = new JPanel(); tabbedPane.addTab("Information", null, panel_3, null); panel_3.setBounds(10, 11, 409, 154); GridBagLayout gbl_panel_3 = new GridBagLayout(); gbl_panel_3.columnWidths = new int[] { 0, 0, 0 }; gbl_panel_3.rowHeights = new int[] { 0, 0, 0 }; gbl_panel_3.columnWeights = new double[] { 1.0, 1.0, 1.0 }; gbl_panel_3.rowWeights = new double[] { 0.0, 0.0, Double.MIN_VALUE }; panel_3.setLayout(gbl_panel_3); // ------------- Dynamic Update - Swingworker Components ------------- SentinelProgressBar = new JProgressBar(); SentinelProgressBar.setMaximumSize(new Dimension(146, 14)); SentinelProgressBar.setMaximum(1000); SentinelProgressBar.setBounds(74, 187, 146, 14); panel_2.add(SentinelProgressBar); SentinelProgressLabel = new JLabel(); SentinelProgressLabel.setToolTipText("Time needed to finish the program in progress"); SentinelProgressLabel.setBounds(333, 181, 86, 20); panel_2.add(SentinelProgressLabel); // ------------------------------------------------------------------- // ------------------------ JPanel Components ------------------------ JLabel lblCurrentDirectory = new JLabel("Current Directory"); panel.add(lblCurrentDirectory); userSelectedDirectories = new JTextField(); panel.add(userSelectedDirectories); userSelectedDirectories.setColumns(35); JButton btnBrowse = new JButton("Browse"); btnBrowse.setToolTipText("Locate directory in system"); btnBrowse.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openFileChooserDir(btnBrowse); } }); panel.add(btnBrowse); JButton btnClear = new JButton("Clear"); btnClear.setToolTipText("Deletes the current directory shown"); btnClear.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { userSelectedDirectories.setText(""); clearSourceDirectory(); } }); panel.add(btnClear); // ------------------------------------------------------------------- // ----------------------- JPanel_1 Components ----------------------- // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Extension :: [Check Box] chckbxExt = new JCheckBox("Extension"); chckbxExt.setToolTipText("Check to ignore file extensions"); chckbxExt.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Ext", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Ext", false); } }); chckbxExt.setBounds(8, 15, 97, 23); panel_1.add(chckbxExt); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Hash :: [Check Box] chckbxHash = new JCheckBox("Hash"); chckbxHash.setToolTipText("Check to compare by hashing files (FAST)"); chckbxHash.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Hash", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Hash", false); } }); chckbxHash.setBounds(8, 45, 97, 23); panel_1.add(chckbxHash); // Hash :: [Combo Box] comboBoxHash = new JComboBox<String>(); comboBoxHash.setToolTipText( "<html>Hash algorithm to use in file hashing <br>(note - SHA-512 may not be <br>supported by your computer)</html>"); comboBoxHash.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @SuppressWarnings("unchecked") JComboBox<String> cb = (JComboBox<String>) e.getSource(); String UIselect = (String) cb.getSelectedItem(); cf.setHashString(UIselect); } }); comboBoxHash .setModel(new DefaultComboBoxModel<String>(new String[] { "MD5", "SHA-1", "SHA-256", "SHA-512" })); comboBoxHash.setBounds(150, 44, 75, 25); panel_1.add(comboBoxHash); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Name :: [Check Box] chckbxName = new JCheckBox("Name"); chckbxName.setToolTipText("Name tool-tip goes here"); chckbxName.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Name", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Name", false); } }); chckbxName.setBounds(8, 75, 97, 23); panel_1.add(chckbxName); // Name :: [Text Field] namePercentMatchTextField = new JFormattedTextField(new Double(0.0d)); namePercentMatchTextField.setFormatterFactory(new DoubleDocListener(namePercentMatchTextField)); namePercentMatchTextField.getDocument() .addDocumentListener(new DoubleDocListener(namePercentMatchTextField)); namePercentMatchTextField.setToolTipText("Match file names by percentage [00.00-100.00]"); namePercentMatchTextField.setBounds(150, 74, 110, 25); panel_1.add(namePercentMatchTextField); namePercentMatchTextField.setColumns(10); // Name :: [Combo Box] comboBoxNames = new JComboBox<String>(); comboBoxNames.setToolTipText("Algorithm to compare names"); comboBoxNames.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @SuppressWarnings("unchecked") JComboBox<String> cb = (JComboBox<String>) e.getSource(); String UIselect = (String) cb.getSelectedItem(); cf.setMatchingAlgorithm(UIselect); } }); comboBoxNames.setModel(new DefaultComboBoxModel<String>(new String[] { "Bitap", "Cosine", "DamerauLevenshtein", "DynamicTimeWarpingStandard1", "DynamicTimeWarpingStandard2", "Hamming", "Hirschberg", "JaccardIndex", "JaroWinkler", "Levenshtein", "NeedlemanWunsch", "SmithWaterman", "SorensenSimilarityIndex", "WagnerFischer" })); comboBoxNames.setBounds(265, 74, 150, 25); panel_1.add(comboBoxNames); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Size :: [Check Box] chckbxSize = new JCheckBox("Size"); chckbxSize.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Size", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Size", false); } }); chckbxSize.setBounds(8, 105, 97, 23); panel_1.add(chckbxSize); // Size :: [Text Field] sizePercentMatchTextField = new JFormattedTextField(new Double(0.0d)); sizePercentMatchTextField.setFormatterFactory(new DoubleDocListener(sizePercentMatchTextField)); sizePercentMatchTextField.getDocument() .addDocumentListener(new DoubleDocListener(sizePercentMatchTextField)); sizePercentMatchTextField.setToolTipText("Match file sizes by percentage [00.00-100.00]"); sizePercentMatchTextField.setBounds(150, 104, 110, 25); panel_1.add(sizePercentMatchTextField); sizePercentMatchTextField.setColumns(10); // Size :: [Combo Box] comboBoxSize = new JComboBox<String>(); comboBoxSize.setToolTipText("Specify byte grouping"); comboBoxSize.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @SuppressWarnings("unchecked") JComboBox<String> cb = (JComboBox<String>) e.getSource(); String UIselect = (String) cb.getSelectedItem(); cf.setMetricSize(UIselect); } }); comboBoxSize.setModel( new DefaultComboBoxModel<String>(new String[] { "BYTE", "KILOBYTE", "MEGABYTE", "GIGABYTE" })); comboBoxSize.setBounds(265, 104, 150, 25); panel_1.add(comboBoxSize); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Thorough :: [Check Box] chckbxThorough = new JCheckBox("Thorough"); chckbxThorough.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setUse("Thorough", true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setUse("Thorough", false); } }); chckbxThorough.setToolTipText("Check byte by byte"); chckbxThorough.setBounds(8, 135, 97, 23); panel_1.add(chckbxThorough); // Thorough :: [Text Field] thoroughPercentMatchTextField = new JFormattedTextField(new Double(0.0d)); thoroughPercentMatchTextField.setFormatterFactory(new DoubleDocListener(thoroughPercentMatchTextField)); thoroughPercentMatchTextField.getDocument() .addDocumentListener(new DoubleDocListener(thoroughPercentMatchTextField)); thoroughPercentMatchTextField.setToolTipText("Match file sizes by percentage [00.00-100.00]"); thoroughPercentMatchTextField.setBounds(150, 134, 110, 25); panel_1.add(thoroughPercentMatchTextField); thoroughPercentMatchTextField.setColumns(10); // Thorough :: [Check Box] chckbxExitFast = new JCheckBox("Exit Fast"); chckbxExitFast.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) cf.setThoroughExitFirstByteMisMatch(true); else if (e.getStateChange() == ItemEvent.DESELECTED) cf.setThoroughExitFirstByteMisMatch(false); } }); chckbxExitFast.setToolTipText("<html>When the first byte comparison <br>is a mis-match then stop</html>"); chckbxExitFast.setBounds(265, 138, 105, 16); panel_1.add(chckbxExitFast); // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ JButton btnSaveSearchSettings = new JButton("Save Search Settings"); btnSaveSearchSettings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { pollSearchSettings(); cf.saveObject(); // System.out.println(cf.toString()); // debug } }); btnSaveSearchSettings.setBounds(292, 181, 140, 25); panel_1.add(btnSaveSearchSettings); JButton btnLoadSettings = new JButton("Load Settings"); btnLoadSettings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (!cf.loadObject()) cf.setDefaultSettings(); cacheUpdateGUISettings(); } }); btnLoadSettings.setBounds(148, 181, 140, 25); panel_1.add(btnLoadSettings); JButton btnDefaultSettings = new JButton("Use Default Settings"); btnDefaultSettings.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { cf.setDefaultSettings(); cacheUpdateGUISettings(); } }); btnDefaultSettings.setBounds(4, 181, 140, 25); panel_1.add(btnDefaultSettings); // ------------------------------------------------------------------- // ----------------------- JPanel_2 Components ----------------------- JLabel labelStatus = new JLabel("Progress"); labelStatus.setBounds(10, 187, 54, 14); panel_2.add(labelStatus); JButton btnStart = new JButton("Start"); btnStart.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pollSearchSettings(); if (!ran_at_least_once) ran_at_least_once = true; else { SentinelProgressBar.setValue(0); SentinelProgressLabel.setText("Waiting..."); } try { if (multiSelection == null) { JOptionPane.showMessageDialog(btnStart, "Please enter at least one directory.", "Press OK to continue", JOptionPane.PLAIN_MESSAGE); return; } setSourceDirectory(multiSelection); GUI_Start = true; } catch (Exception err) { err.printStackTrace(); } } }); btnStart.setBounds(40, 153, 89, 23); panel_2.add(btnStart); JButton btnStop = new JButton("Stop"); btnStop.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { GUI_Stop = true; } }); btnStop.setBounds(169, 153, 89, 23); panel_2.add(btnStop); JButton btnNewButton = new JButton("Pause"); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { GUI_Pause = true; } }); btnNewButton.setBounds(298, 153, 89, 23); panel_2.add(btnNewButton); JCheckBox chckbxDeleteDuplicateFiles = new JCheckBox("Delete duplicate files"); chckbxDeleteDuplicateFiles.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { deleteCopyResults = true; } }); chckbxDeleteDuplicateFiles.setBounds(230, 10, 150, 16); panel_2.add(chckbxDeleteDuplicateFiles); JCheckBox chckbxLogDuplicateFiles = new JCheckBox("Save duplicates to file"); chckbxLogDuplicateFiles.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { saveCopyResults = true; } }); chckbxLogDuplicateFiles.setBounds(230, 36, 150, 16); panel_2.add(chckbxLogDuplicateFiles); // ------------------------------------------------------------------- // ----------------------- JPanel_3 Components ----------------------- JLabel lblAbout = new JLabel("About"); GridBagConstraints gbc_lblAbout = new GridBagConstraints(); gbc_lblAbout.insets = new Insets(0, 0, 5, 5); gbc_lblAbout.gridx = 0; gbc_lblAbout.gridy = 0; panel_3.add(lblAbout, gbc_lblAbout); JLabel lblTutorials = new JLabel("Tutorials"); GridBagConstraints gbc_lblTutorials = new GridBagConstraints(); gbc_lblTutorials.insets = new Insets(0, 0, 5, 5); gbc_lblTutorials.gridx = 1; gbc_lblTutorials.gridy = 0; panel_3.add(lblTutorials, gbc_lblTutorials); JLabel lblUpdates = new JLabel("Updates"); GridBagConstraints gbc_lblUpdates = new GridBagConstraints(); gbc_lblUpdates.insets = new Insets(0, 0, 5, 0); gbc_lblUpdates.gridx = 2; gbc_lblUpdates.gridy = 0; panel_3.add(lblUpdates, gbc_lblUpdates); JButton btnInformation = new JButton("Information"); btnInformation.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openWebPage(ppallink); } }); GridBagConstraints gbc_btnInformation = new GridBagConstraints(); gbc_btnInformation.insets = new Insets(0, 0, 0, 5); gbc_btnInformation.gridx = 0; gbc_btnInformation.gridy = 1; panel_3.add(btnInformation, gbc_btnInformation); JButton btnExamples = new JButton("Examples"); btnExamples.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openWebPage(ppallink); } }); GridBagConstraints gbc_btnExamples = new GridBagConstraints(); gbc_btnExamples.insets = new Insets(0, 0, 0, 5); gbc_btnExamples.gridx = 1; gbc_btnExamples.gridy = 1; panel_3.add(btnExamples, gbc_btnExamples); JButton btnCheckNow = new JButton("Check Now"); btnCheckNow.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { openWebPage(ppallink); } }); GridBagConstraints gbc_btnCheckNow = new GridBagConstraints(); gbc_btnCheckNow.gridx = 2; gbc_btnCheckNow.gridy = 1; panel_3.add(btnCheckNow, gbc_btnCheckNow); }
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 ww . ja v a 2s . co 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:edu.purdue.cc.bionet.ui.ClusteringDisplayPanel.java
/** * A class for displaying information about a Clustering *///from w ww.ja va2 s .co m 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:uk.co.petertribble.jkstat.gui.KstatBaseChartFrame.java
/** * Create the Statistics Menu, showing all available statistics for the * chosen ChartableKstat./* ww w . j a va2 s . c om*/ * * @param cks the ChartableKstat to show the statistics of in the menu * @param statistics the initial statistics, which will be checked * * @return the Statistics Menu */ protected JMenu statisticsMenu(ChartableKstat cks, List<String> statistics) { JMenu jmstat = new JMenu(KstatResources.getString("CHART.SHOW")); jmstat.setMnemonic(KeyEvent.VK_S); for (String stat : cks.getStatistics()) { JCheckBoxMenuItem jmi = new JCheckBoxMenuItem(stat, statistics.contains(stat)); jmi.addActionListener(this); jmstat.add(jmi); } return jmstat; }
From source file:gdt.jgui.entity.contact.JContactEditor.java
@Override public JMenu getContextMenu() { final JMenu menu = new JMenu("Context"); menu.addMenuListener(new MenuListener() { @Override//from w ww .java 2s . c o m public void menuSelected(MenuEvent e) { // System.out.println("EntityEditor:getConextMenu:menu selected"); menu.removeAll(); JMenuItem facetsItem = new JMenuItem("Facets"); facetsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); JEntityFacetPanel erm = new JEntityFacetPanel(); String locator$ = erm.getLocator(); locator$ = Locator.append(locator$, Entigrator.ENTIHOME, entihome$); locator$ = Locator.append(locator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, locator$); } }); menu.add(facetsItem); JMenuItem digestItem = new JMenuItem("Digest"); digestItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); String locator$ = getLocator(); JEntityDigestDisplay edd = new JEntityDigestDisplay(); edd.instantiate(console, locator$); String eddLocator$ = edd.getLocator(); eddLocator$ = Locator.append(eddLocator$, Entigrator.ENTIHOME, entihome$); eddLocator$ = Locator.append(eddLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, eddLocator$); } }); menu.add(digestItem); JMenuItem structureItem = new JMenuItem("Structure"); structureItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); String locator$ = getLocator(); JEntityStructurePanel esp = new JEntityStructurePanel(); esp.instantiate(console, locator$); String espLocator$ = esp.getLocator(); espLocator$ = Locator.append(espLocator$, Entigrator.ENTIHOME, entihome$); espLocator$ = Locator.append(espLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, espLocator$); } }); menu.add(structureItem); menu.addSeparator(); JMenuItem doneItem = new JMenuItem("Done"); doneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Entigrator entigrator = console.getEntigrator(entihome$); Sack contact = entigrator.getEntityAtKey(entityKey$); String entityLabel$ = contact.getProperty("label"); String title$ = title.getText(); if (!entityLabel$.equals(title$)) { contact = entigrator.ent_assignLabel(contact, title$); contact = entigrator.ent_assignProperty(contact, "contact", contact.getProperty("label")); } contact = entigrator.ent_assignProperty(contact, "phone", phone.getText()); contact = entigrator.ent_assignProperty(contact, "email", email.getText()); if (requesterResponseLocator$ != null) { byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); // System.out.println("TextEditor:done:response locator="+responseLocator$); JConsoleHandler.execute(console, responseLocator$); } else console.back(); } catch (Exception ee) { Logger.getLogger(JContactEditor.class.getName()).severe(ee.toString()); } } }); menu.add(doneItem); JMenuItem cancelItem = new JMenuItem("Cancel"); cancelItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { console.back(); } }); menu.add(cancelItem); } @Override public void menuDeselected(MenuEvent e) { // TODO Auto-generated method stub } @Override public void menuCanceled(MenuEvent e) { // TODO Auto-generated method stub } }); return menu; }
From source file:com.projity.pm.graphic.gantt.GanttPopupMenu.java
/** * Because the styles may change, rebuild the menu each time * *///from w ww .j a va2s . c o m protected void init() { removeAll(); add(new SplitModeMenuAction()); add(new AssignmentsMenuAction()); final JMenu bars = new JMenu(Messages.getString("Gantt.Popup.barStylesMenu")); final JMenu annotations = new JMenu(Messages.getString("Gantt.Popup.annotationStylesMenu")); CollectionUtils.forAllDo(interactor.getGraph().getBarStyles().getRows(), new Closure() { public void execute(Object arg0) { BarStyle barStyle = (BarStyle) arg0; BarMenuAction menuAction = new BarMenuAction(barStyle); if (barStyle.isLink()) // move the show links item to the main menu add(menuAction); else if (barStyle.isCalendar()) // move the show links item to the main menu add(menuAction); else if (barStyle.isHorizontalGrid()) // move the show links item to the main menu add(menuAction); else if (barStyle.isAnnotation()) annotations.add(menuAction); else bars.add(menuAction); } }); add(bars); add(annotations); }
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; }/* w ww . j a v a 2s .c o m*/ } }; 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:jgraph.JShow.java
/** * a driver for this demo//from www . j av a2 s . c om */ @SuppressWarnings("serial") public static void showtest(DirectedOrderedSparseMultigraph<Object, Object> graph) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final JShow demo = new JShow(graph); JMenu menu = new JMenu("Snapshot"); menu.add(new AbstractAction("To JPEG") { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); int option = chooser.showSaveDialog(demo); if (option == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); demo.writeJPEGImage(file); } } }); menu.add(new AbstractAction("Print") { public void actionPerformed(ActionEvent e) { PrinterJob printJob = PrinterJob.getPrinterJob(); printJob.setPrintable(demo); if (printJob.printDialog()) { try { printJob.print(); } catch (Exception ex) { ex.printStackTrace(); } } } }); JPopupMenu.setDefaultLightWeightPopupEnabled(false); JMenuBar menuBar = new JMenuBar(); menuBar.add(menu); frame.setJMenuBar(menuBar); frame.getContentPane().add(demo); frame.pack(); frame.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);// ww w .j av a 2s . c om 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); }