List of usage examples for java.awt BorderLayout WEST
String WEST
To view the source code for java.awt BorderLayout WEST.
Click Source Link
From source file:StandardDialog.java
/** * Standard constructor - creates a three button panel with the specified button labels. * * @param label1 the label for button 1. * @param label2 the label for button 2. * @param label3 the label for button 3. *///from w w w. j ava 2s . c o m public L1R2ButtonPanel(final String label1, final String label2, final String label3) { setLayout(new BorderLayout()); // create the pieces... this.left = new JButton(label1); final JPanel rightButtonPanel = new JPanel(new GridLayout(1, 2)); this.right1 = new JButton(label2); this.right2 = new JButton(label3); rightButtonPanel.add(this.right1); rightButtonPanel.add(this.right2); // ...and put them together add(this.left, BorderLayout.WEST); add(rightButtonPanel, BorderLayout.EAST); }
From source file:edu.harvard.mcz.imagecapture.VerbatimCaptureDialog.java
protected void init() { setDefaultCloseOperation(DISPOSE_ON_CLOSE); setTitle("Transcribe Verbatim Data"); setMinimumSize(new Dimension(1020, 640)); setBounds(100, 100, 1020, 640);/*www .j a v a2 s . co m*/ getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new BorderLayout(0, 0)); { JPanel panel = new JPanel(); contentPanel.add(panel, BorderLayout.NORTH); panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); JLabel lblVerbatimDataFor = new JLabel("Verbatim Data for:"); panel.add(lblVerbatimDataFor); lblBarcode = new JLabel("Barcode"); panel.add(lblBarcode); lblCurrentid = new JLabel("CurrentID"); panel.add(lblCurrentid); } { JPanel panel = new JPanel(); contentPanel.add(panel, BorderLayout.WEST); GridBagLayout gbl_panel = new GridBagLayout(); gbl_panel.columnWidths = new int[] { 0, 0, 0, 0 }; gbl_panel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; gbl_panel.columnWeights = new double[] { 0.0, 1.0, 1.0, Double.MIN_VALUE }; gbl_panel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; panel.setLayout(gbl_panel); JLabel lblNewLabel = new JLabel("Locality"); GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); gbc_lblNewLabel.anchor = GridBagConstraints.NORTHEAST; gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel.gridx = 0; gbc_lblNewLabel.gridy = 0; panel.add(lblNewLabel, gbc_lblNewLabel); textFieldVerbLocality = new JTextArea(); textFieldVerbLocality.setRows(3); GridBagConstraints gbc_textFieldVerbLocality = new GridBagConstraints(); gbc_textFieldVerbLocality.gridheight = 2; gbc_textFieldVerbLocality.gridwidth = 2; gbc_textFieldVerbLocality.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbLocality.fill = GridBagConstraints.BOTH; gbc_textFieldVerbLocality.gridx = 1; gbc_textFieldVerbLocality.gridy = 0; panel.add(textFieldVerbLocality, gbc_textFieldVerbLocality); textFieldVerbLocality.setColumns(10); JLabel lblVerbatimDate = new JLabel("Date"); GridBagConstraints gbc_lblVerbatimDate = new GridBagConstraints(); gbc_lblVerbatimDate.anchor = GridBagConstraints.EAST; gbc_lblVerbatimDate.insets = new Insets(0, 0, 5, 5); gbc_lblVerbatimDate.gridx = 0; gbc_lblVerbatimDate.gridy = 2; panel.add(lblVerbatimDate, gbc_lblVerbatimDate); textFieldVerbDate = new JTextField(); GridBagConstraints gbc_textFieldVerbDate = new GridBagConstraints(); gbc_textFieldVerbDate.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbDate.gridwidth = 2; gbc_textFieldVerbDate.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldVerbDate.gridx = 1; gbc_textFieldVerbDate.gridy = 2; panel.add(textFieldVerbDate, gbc_textFieldVerbDate); textFieldVerbDate.setColumns(10); JLabel lblCollector = new JLabel("Collector"); GridBagConstraints gbc_lblCollector = new GridBagConstraints(); gbc_lblCollector.anchor = GridBagConstraints.EAST; gbc_lblCollector.insets = new Insets(0, 0, 5, 5); gbc_lblCollector.gridx = 0; gbc_lblCollector.gridy = 3; panel.add(lblCollector, gbc_lblCollector); textFieldVerbCollector = new JTextField(); GridBagConstraints gbc_textFieldVerbCollector = new GridBagConstraints(); gbc_textFieldVerbCollector.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbCollector.gridwidth = 2; gbc_textFieldVerbCollector.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldVerbCollector.gridx = 1; gbc_textFieldVerbCollector.gridy = 3; panel.add(textFieldVerbCollector, gbc_textFieldVerbCollector); textFieldVerbCollector.setColumns(10); JLabel lblNewLabel_1 = new JLabel("Collection"); GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints(); gbc_lblNewLabel_1.anchor = GridBagConstraints.EAST; gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel_1.gridx = 0; gbc_lblNewLabel_1.gridy = 4; panel.add(lblNewLabel_1, gbc_lblNewLabel_1); textFieldVerbCollection = new JTextField(); GridBagConstraints gbc_textFieldVerbCollection = new GridBagConstraints(); gbc_textFieldVerbCollection.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbCollection.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldVerbCollection.gridx = 2; gbc_textFieldVerbCollection.gridy = 4; panel.add(textFieldVerbCollection, gbc_textFieldVerbCollection); textFieldVerbCollection.setColumns(10); JLabel lblNumbers = new JLabel("Numbers"); GridBagConstraints gbc_lblNumbers = new GridBagConstraints(); gbc_lblNumbers.anchor = GridBagConstraints.EAST; gbc_lblNumbers.insets = new Insets(0, 0, 5, 5); gbc_lblNumbers.gridx = 0; gbc_lblNumbers.gridy = 5; panel.add(lblNumbers, gbc_lblNumbers); textFieldVerbNumbers = new JTextField(); GridBagConstraints gbc_textFieldVerbNumbers = new GridBagConstraints(); gbc_textFieldVerbNumbers.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbNumbers.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldVerbNumbers.gridx = 2; gbc_textFieldVerbNumbers.gridy = 5; panel.add(textFieldVerbNumbers, gbc_textFieldVerbNumbers); textFieldVerbNumbers.setColumns(10); JLabel lblNewLabel_2 = new JLabel("Other Text"); GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints(); gbc_lblNewLabel_2.anchor = GridBagConstraints.EAST; gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5); gbc_lblNewLabel_2.gridx = 0; gbc_lblNewLabel_2.gridy = 6; panel.add(lblNewLabel_2, gbc_lblNewLabel_2); textFieldVerbUnclassifiedText = new JTextArea(); textFieldVerbUnclassifiedText.setRows(3); GridBagConstraints gbc_textFieldVerbUnclassifiedText = new GridBagConstraints(); gbc_textFieldVerbUnclassifiedText.gridheight = 2; gbc_textFieldVerbUnclassifiedText.insets = new Insets(0, 0, 5, 5); gbc_textFieldVerbUnclassifiedText.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldVerbUnclassifiedText.gridx = 2; gbc_textFieldVerbUnclassifiedText.gridy = 6; panel.add(textFieldVerbUnclassifiedText, gbc_textFieldVerbUnclassifiedText); textFieldVerbUnclassifiedText.setColumns(10); JLabel lblQuestions = new JLabel("Questions"); GridBagConstraints gbc_lblQuestions = new GridBagConstraints(); gbc_lblQuestions.anchor = GridBagConstraints.EAST; gbc_lblQuestions.insets = new Insets(0, 0, 5, 5); gbc_lblQuestions.gridx = 0; gbc_lblQuestions.gridy = 8; panel.add(lblQuestions, gbc_lblQuestions); textFieldQuestions = new JTextField(); GridBagConstraints gbc_textFieldQuestions = new GridBagConstraints(); gbc_textFieldQuestions.insets = new Insets(0, 0, 5, 5); gbc_textFieldQuestions.fill = GridBagConstraints.HORIZONTAL; gbc_textFieldQuestions.gridx = 2; gbc_textFieldQuestions.gridy = 8; panel.add(textFieldQuestions, gbc_textFieldQuestions); textFieldQuestions.setColumns(30); JLabel lblWorkflowStatus = new JLabel("Workflow Status"); GridBagConstraints gbc_lblWorkflowStatus = new GridBagConstraints(); gbc_lblWorkflowStatus.anchor = GridBagConstraints.EAST; gbc_lblWorkflowStatus.insets = new Insets(0, 0, 5, 5); gbc_lblWorkflowStatus.gridx = 0; gbc_lblWorkflowStatus.gridy = 9; panel.add(lblWorkflowStatus, gbc_lblWorkflowStatus); comboBoxWorkflowStatus = new JComboBox<String>(WorkFlowStatus.getVerbatimWorkFlowStatusValues()); GridBagConstraints gbc_comboBoxWorkflowStatus = new GridBagConstraints(); gbc_comboBoxWorkflowStatus.insets = new Insets(0, 0, 5, 0); gbc_comboBoxWorkflowStatus.gridwidth = 2; gbc_comboBoxWorkflowStatus.fill = GridBagConstraints.HORIZONTAL; gbc_comboBoxWorkflowStatus.gridx = 2; gbc_comboBoxWorkflowStatus.gridy = 9; panel.add(comboBoxWorkflowStatus, gbc_comboBoxWorkflowStatus); JPanel panel_1 = new JPanel(); GridBagConstraints gbc_panel_1 = new GridBagConstraints(); gbc_panel_1.gridwidth = 2; gbc_panel_1.insets = new Insets(0, 0, 0, 5); gbc_panel_1.fill = GridBagConstraints.BOTH; gbc_panel_1.gridx = 2; gbc_panel_1.gridy = 11; panel.add(panel_1, gbc_panel_1); GridBagLayout gbl_panel_1 = new GridBagLayout(); gbl_panel_1.columnWidths = new int[] { 150, 143, 0 }; gbl_panel_1.rowHeights = new int[] { 25, 0, 0, 0, 0 }; gbl_panel_1.columnWeights = new double[] { 0.0, 0.0, 0.0 }; gbl_panel_1.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; panel_1.setLayout(gbl_panel_1); JButton btnPartiallyIllegible = new JButton("Partially Illegible"); btnPartiallyIllegible.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { appendToQuestions(Verbatim.PARTLY_ILLEGIBLE); } }); GridBagConstraints gbc_btnPartiallyIllegible = new GridBagConstraints(); gbc_btnPartiallyIllegible.fill = GridBagConstraints.HORIZONTAL; gbc_btnPartiallyIllegible.anchor = GridBagConstraints.NORTH; gbc_btnPartiallyIllegible.insets = new Insets(0, 0, 5, 5); gbc_btnPartiallyIllegible.gridx = 0; gbc_btnPartiallyIllegible.gridy = 0; panel_1.add(btnPartiallyIllegible, gbc_btnPartiallyIllegible); JButton btnNewButton = new JButton("No Locality Data"); btnNewButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textFieldVerbLocality.setText(Verbatim.NO_LOCALITY_DATA); } }); GridBagConstraints gbc_btnNewButton = new GridBagConstraints(); gbc_btnNewButton.anchor = GridBagConstraints.NORTHWEST; gbc_btnNewButton.insets = new Insets(0, 0, 5, 5); gbc_btnNewButton.gridx = 1; gbc_btnNewButton.gridy = 0; panel_1.add(btnNewButton, gbc_btnNewButton); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); JButton btnNewButton_1 = new JButton("Entirely Illegible"); btnNewButton_1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { appendToQuestions(Verbatim.ENTIRELY_ILLEGIBLE); } }); GridBagConstraints gbc_btnNewButton_1 = new GridBagConstraints(); gbc_btnNewButton_1.fill = GridBagConstraints.HORIZONTAL; gbc_btnNewButton_1.anchor = GridBagConstraints.NORTH; gbc_btnNewButton_1.insets = new Insets(0, 0, 5, 5); gbc_btnNewButton_1.gridx = 0; gbc_btnNewButton_1.gridy = 1; panel_1.add(btnNewButton_1, gbc_btnNewButton_1); JButton btnNoDateData = new JButton("No Date Data"); btnNoDateData.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textFieldVerbDate.setText("[No date data]"); } }); GridBagConstraints gbc_btnNoDateData = new GridBagConstraints(); gbc_btnNoDateData.fill = GridBagConstraints.HORIZONTAL; gbc_btnNoDateData.insets = new Insets(0, 0, 5, 5); gbc_btnNoDateData.gridx = 1; gbc_btnNoDateData.gridy = 1; panel_1.add(btnNoDateData, gbc_btnNoDateData); JButton btnLabelTruncatedIn = new JButton("Label Truncated in Image"); btnLabelTruncatedIn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { appendToQuestions(Verbatim.TRUNCATED_BY_IMAGE); } }); GridBagConstraints gbc_btnLabelTruncatedIn = new GridBagConstraints(); gbc_btnLabelTruncatedIn.insets = new Insets(0, 0, 5, 5); gbc_btnLabelTruncatedIn.anchor = GridBagConstraints.NORTHWEST; gbc_btnLabelTruncatedIn.gridx = 0; gbc_btnLabelTruncatedIn.gridy = 2; panel_1.add(btnLabelTruncatedIn, gbc_btnLabelTruncatedIn); JButton btnNoCollectorData = new JButton("No Collector Data"); btnNoCollectorData.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { textFieldVerbCollector.setText("[No collector data]"); } }); GridBagConstraints gbc_btnNoCollectorData = new GridBagConstraints(); gbc_btnNoCollectorData.insets = new Insets(0, 0, 5, 5); gbc_btnNoCollectorData.gridx = 1; gbc_btnNoCollectorData.gridy = 2; panel_1.add(btnNoCollectorData, gbc_btnNoCollectorData); JButton btnNoPinLabels = new JButton("No Pin Labels"); btnNoPinLabels.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { appendToQuestions(Verbatim.NO_PIN_LABELS); } }); GridBagConstraints gbc_btnNoPinLabels = new GridBagConstraints(); gbc_btnNoPinLabels.insets = new Insets(0, 0, 0, 5); gbc_btnNoPinLabels.gridx = 0; gbc_btnNoPinLabels.gridy = 3; panel_1.add(btnNoPinLabels, gbc_btnNoPinLabels); } { JPanel panel = new JPanel(); contentPanel.add(panel, BorderLayout.CENTER); panel.setLayout(new BorderLayout(0, 0)); panel.add(getImagePanePinLabels()); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.LEFT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); btnPrevious = new JButton("Previous"); btnPrevious.setEnabled(false); if (specimenControler != null && specimenControler.isInTable()) { btnPrevious.setEnabled(true); } btnPrevious.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); if (specimenControler.previousSpecimenInTable()) { specimen = specimenControler.getSpecimen(); setValues(); } } }); buttonPane.add(btnPrevious); btnNext = new JButton("Next"); btnNext.setEnabled(false); if (specimenControler != null && specimenControler.isInTable()) { btnNext.setEnabled(true); } btnNext.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { save(); if (specimenControler.nextSpecimenInTable()) { specimen = specimenControler.getSpecimen(); setValues(); } } }); buttonPane.add(btnNext); { JButton okButton = new JButton("OK"); okButton.setActionCommand("OK"); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (save()) { setVisible(false); } } }); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); buttonPane.add(cancelButton); } } }
From source file:com.jamfsoftware.jss.healthcheck.ui.HealthReport.java
/** * Creates a new Health Report JPanel window from the Health Check JSON string. * Will throw errors if the JSON is not formatted correctly. *///from w w w . j a v a2s .c o m public HealthReport(final String JSON) throws Exception { LOGGER.debug("[DEBUG] - JSON String (Copy entire below line)"); LOGGER.debug(JSON.replace("\n", "")); LOGGER.debug("Attempting to parse Health Report JSON"); JsonElement report = new JsonParser().parse(JSON); JsonObject healthcheck = ((JsonObject) report).get("healthcheck").getAsJsonObject(); Boolean show_system_info = true; JsonObject system = null; //Check if the check JSON contains system information and show/hide panels accordingly later. system = ((JsonObject) report).get("system").getAsJsonObject(); final JsonObject data = ((JsonObject) report).get("checkdata").getAsJsonObject(); this.JSSURL = extractData(healthcheck, "jss_url"); if (extractData(system, "iscloudjss").contains("true")) { show_system_info = false; isCloudJSS = true; } PanelIconGenerator iconGen = new PanelIconGenerator(); PanelGenerator panelGen = new PanelGenerator(); //Top Level Frame final JFrame frame = new JFrame("JSS Health Check Report"); //Top Level Content JPanel outer = new JPanel(new BorderLayout()); //Two Blank Panels for the Sides JPanel blankLeft = new JPanel(); blankLeft.add(new JLabel(" ")); JPanel blankRight = new JPanel(); blankRight.add(new JLabel(" ")); blankLeft.setMinimumSize(new Dimension(100, 100)); blankRight.setMinimumSize(new Dimension(100, 100)); //Header JPanel header = new JPanel(); header.add(new JLabel("Total Computers: " + extractData(healthcheck, "totalcomputers"))); header.add(new JLabel("Total Mobile Devices: " + extractData(healthcheck, "totalmobile"))); header.add(new JLabel("Total Users: " + extractData(healthcheck, "totalusers"))); int total_devices = Integer.parseInt(extractData(healthcheck, "totalcomputers")) + Integer.parseInt(extractData(healthcheck, "totalmobile")); SimpleDateFormat df = new SimpleDateFormat("dd/MM/yy HH:mm:ss"); Date dateobj = new Date(); header.add(new JLabel("JSS Health Check Report Performed On " + df.format(dateobj))); //Foooter JPanel footer = new JPanel(); JButton view_report_json = new JButton("View Report JSON"); footer.add(view_report_json); JButton view_activation_code = new JButton("View Activation Code"); footer.add(view_activation_code); JButton test_again = new JButton("Run Test Again"); footer.add(test_again); JButton view_text_report = new JButton("View Text Report"); footer.add(view_text_report); JButton about_and_terms = new JButton("About and Terms"); footer.add(about_and_terms); //Middle Content, set the background white and give it a border JPanel content = new JPanel(new GridLayout(2, 3)); content.setBackground(Color.WHITE); content.setBorder(BorderFactory.createLineBorder(Color.BLACK)); //Setup Outer Placement outer.add(header, BorderLayout.NORTH); outer.add(footer, BorderLayout.SOUTH); outer.add(blankLeft, BorderLayout.WEST); outer.add(blankRight, BorderLayout.EAST); outer.add(content, BorderLayout.CENTER); //Don't show system info if it is hosted. JPanel system_info = null; JPanel database_health = null; if (show_system_info) { //Read all of the System information variables from the JSON and perform number conversions. String[][] sys_info = { { "Operating System", extractData(system, "os") }, { "Java Version", extractData(system, "javaversion") }, { "Java Vendor", extractData(system, "javavendor") }, { "Processor Cores", extractData(system, "proc_cores") }, { "Is Clustered?", extractData(system, "clustering") }, { "Web App Directory", extractData(system, "webapp_dir") }, { "Free Memory", Double.toString( round((Double.parseDouble(extractData(system, "free_memory")) / 1000000000), 2)) + " GB" }, { "Max Memory", Double.toString( round((Double.parseDouble(extractData(system, "max_memory")) / 1000000000), 2)) + " GB" }, { "Memory currently in use", Double.toString(round( (Double.parseDouble(extractData(system, "memory_currently_in_use")) / 1000000000), 2)) + " GB" }, { "Total space", Double.toString( round((Double.parseDouble(extractData(system, "total_space")) / 1000000000), 2)) + " GB" }, { "Free Space", Double.toString(round( (Double.parseDouble(extractData(system, "usable_space")) / 1000000000), 2)) + " GB" } }; //Generate the system info panel. String systemInfoIcon = iconGen.getSystemInfoIconType( Integer.parseInt(extractData(healthcheck, "totalcomputers")) + Integer.parseInt(extractData(healthcheck, "totalmobile")), extractData(system, "javaversion"), Double.parseDouble(extractData(system, "max_memory"))); system_info = panelGen.generateContentPanelSystem("System Info", sys_info, "JSS Minimum Requirements", "http://www.jamfsoftware.com/resources/casper-suite-system-requirements/", systemInfoIcon); //Get all of the DB information. String[][] db_health = { { "Database Size", extractData(system, "database_size") + " MB" } }; if (extractData(system, "database_size").equals("0")) { db_health[0][0] = "Unable to connect to database."; } String[][] large_sql_tables = extractArrayData(system, "largeSQLtables", "table_name", "table_size"); String[][] db_health_for_display = ArrayUtils.addAll(db_health, large_sql_tables); //Generate the DB Health panel. String databaseIconType = iconGen.getDatabaseInfoIconType(total_devices, Double.parseDouble(extractData(system, "database_size")), extractArrayData(system, "largeSQLtables", "table_name", "table_size").length); database_health = panelGen.generateContentPanelSystem("Database Health", db_health_for_display, "Too Large SQL Tables", "https://google.com", databaseIconType); if (!databaseIconType.equals("green")) { this.showLargeDatabase = true; } } int password_strenth = 0; if (extractData(data, "password_strength", "uppercase?").contains("true")) { password_strenth++; } if (extractData(data, "password_strength", "lowercase?").contains("true")) { password_strenth++; } if (extractData(data, "password_strength", "number?").contains("true")) { password_strenth++; } if (extractData(data, "password_strength", "spec_chars?").contains("true")) { password_strenth++; } String password_strength_desc = ""; if (password_strenth == 4) { password_strength_desc = "Excellent"; } else if (password_strenth == 3 || password_strenth == 2) { password_strength_desc = "Good"; } else if (password_strenth == 1) { this.strongerPassword = true; password_strength_desc = "Poor"; } else { this.strongerPassword = true; password_strength_desc = "Needs Updating"; } if (extractData(data, "loginlogouthooks", "is_configured").contains("false")) { this.loginInOutHooks = true; } try { if (Integer.parseInt(extractData(data, "device_row_counts", "computers").trim()) != Integer .parseInt(extractData(data, "device_row_counts", "computers_denormalized").trim())) { this.computerDeviceTableCountMismatch = true; } if (Integer.parseInt(extractData(data, "device_row_counts", "mobile_devices").trim()) != Integer .parseInt(extractData(data, "device_row_counts", "mobile_devices_denormalized").trim())) { this.mobileDeviceTableCountMismatch = true; } } catch (Exception e) { System.out.println("Unable to parse device row counts."); } if ((extractData(system, "mysql_version").contains("5.6.16") || extractData(system, "mysql_version").contains("5.6.20")) && (extractData(system, "os").contains("OS X") || extractData(system, "os").contains("Mac") || extractData(system, "os").contains("OSX"))) { this.mysql_osx_version_bug = true; } //Get all of the information for the JSS ENV and generate the panel. String[][] env_info = { { "Checkin Frequency", extractData(data, "computercheckin", "frequency") + " Minutes" }, { "Log Flushing", extractData(data, "logflushing", "log_flush_time") }, { "Log In/Out Hooks", extractData(data, "loginlogouthooks", "is_configured") }, { "Computer EA", extractData(data, "computerextensionattributes", "count") }, { "Mobile Deivce EA", extractData(data, "mobiledeviceextensionattributes", "count") }, { "Password Strength", password_strength_desc }, { "SMTP Server", extractData(data, "smtpserver", "server") }, { "Sender Email", extractData(data, "smtpserver", "sender_email") }, { "GSX Connection", extractData(data, "gsxconnection", "status") } }; String[][] vpp_accounts = extractArrayData(data, "vppaccounts", "name", "days_until_expire"); String[][] ldap_servers = extractArrayData(data, "ldapservers", "name", "type", "address", "id"); String envIconType = iconGen.getJSSEnvIconType(Integer.parseInt(extractData(healthcheck, "totalcomputers")), Integer.parseInt(extractData(data, "computercheckin", "frequency")), Integer.parseInt(extractData(data, "computerextensionattributes", "count")), Integer.parseInt(extractData(data, "mobiledeviceextensionattributes", "count"))); JPanel env = panelGen.generateContentPanelEnv("JSS Environment", env_info, vpp_accounts, ldap_servers, "", "", envIconType); //Get all of the group information from the JSON, merge the arrays, and then generate the groups JPanel. String[][] groups_1 = ArrayUtils.addAll( extractArrayData(data, "computergroups", "name", "nested_groups_count", "criteria_count", "id"), extractArrayData(data, "mobiledevicegroups", "name", "nested_groups_count", "criteria_count", "id")); String[][] groups_2 = ArrayUtils.addAll(groups_1, extractArrayData(data, "usergroups", "name", "nested_groups_count", "criteria_count", "id")); String groupIconType = iconGen.getGroupIconType("groups", countJSONObjectSize(data, "computergroups") + countJSONObjectSize(data, "mobiledevicegroups") + countJSONObjectSize(data, "usergroups")); JPanel groups = panelGen.generateContentPanelGroups("Groups", groups_2, "", "", groupIconType); if (groupIconType.equals("yellow") || groupIconType.equals("red")) { this.showGroupsHelp = true; } //Get all of the information for the printers, policies and scripts, then generate the panel. String[][] printers = extractArrayData(data, "printer_warnings", "model"); String[][] policies = extractArrayData(data, "policies_with_issues", "name", "ongoing", "checkin_trigger"); String[][] scripts = extractArrayData(data, "scripts_needing_update", "name"); String[][] certs = { { "SSL Cert Issuer", extractData(data, "tomcat", "ssl_cert_issuer") }, { "SLL Cert Expires", extractData(data, "tomcat", "cert_expires") }, { "MDM Push Cert Expires", extractData(data, "push_cert_expirations", "mdm_push_cert") }, { "Push Proxy Expires", extractData(data, "push_cert_expirations", "push_proxy") }, { "Change Management Enabled?", extractData(data, "changemanagment", "isusinglogfile") }, { "Log File Path:", extractData(data, "changemanagment", "logpath") } }; String policiesScriptsIconType = iconGen.getPoliciesAndScriptsIconType( extractArrayData(data, "policies_with_issues", "name", "ongoing", "checkin_trigger").length, extractArrayData(data, "scripts_needing_update", "name").length); JPanel policies_scripts = panelGen.generateContentPanelPoliciesScripts( "Policies, Scripts, Certs and Change", policies, scripts, printers, certs, "", "", policiesScriptsIconType); if (extractArrayData(data, "policies_with_issues", "name", "ongoing", "checkin_trigger").length > 0) { this.showPolicies = true; } if (extractArrayData(data, "scripts_needing_update", "name").length > 0) { this.showScripts = true; } if (extractData(data, "changemanagment", "isusinglogfile").contains("false")) { this.showChange = true; } this.showCheckinFreq = iconGen.showCheckinFreq; this.showExtensionAttributes = iconGen.showCheckinFreq; this.showSystemRequirements = iconGen.showSystemRequirements; this.showScalability = iconGen.showScalability; //Update Panel Gen Variables updatePanelGenVariables(panelGen); //Generate the Help Section. content.add(panelGen.generateContentPanelHelp("Modifications to Consider", "", "", "blank")); //If contains system information, add those panels, otherwise just continue adding the rest of the panels. if (show_system_info) { content.add(system_info); content.add(database_health); } content.add(env); content.add(groups); content.add(policies_scripts); //View report action listner. //Opens a window with the health report JSON listed view_report_json.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPanel middlePanel = new JPanel(); middlePanel.setBorder(new TitledBorder(new EtchedBorder(), "Health Report JSON")); // create the middle panel components JTextArea display = new JTextArea(16, 58); display.setEditable(false); //Make a new GSON object so the text can be Pretty Printed. Gson gson = new GsonBuilder().setPrettyPrinting().create(); String pp_json = gson.toJson(JSON.trim()); display.append(JSON); JScrollPane scroll = new JScrollPane(display); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); //Add Textarea in to middle panel middlePanel.add(scroll); JFrame frame = new JFrame(); frame.add(middlePanel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); //Action listener for the Terms, About and Licence button. //Opens a new window with the AS IS License, 3rd Party Libs used and a small about section about_and_terms.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPanel middlePanel = new JPanel(); middlePanel.setBorder(new TitledBorder(new EtchedBorder(), "About, Licence and Terms")); // create the middle panel components JTextArea display = new JTextArea(16, 58); display.setEditable(false); display.append(StringConstants.ABOUT); display.append("\n\nThird Party Libraries Used:"); display.append( " Apache Commons Codec, Google JSON (gson), Java X JSON, JDOM, JSON-Simple, MySQL-connector"); display.append(StringConstants.LICENSE); JScrollPane scroll = new JScrollPane(display); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); //Add Textarea in to middle panel middlePanel.add(scroll); JFrame frame = new JFrame(); frame.add(middlePanel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); //Listener for a button click to open a window containing the activation code. view_activation_code.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(frame, extractData(data, "activationcode", "code") + "\nExpires: " + extractData(data, "activationcode", "expires")); } }); view_text_report.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPanel middlePanel = new JPanel(); middlePanel.setBorder(new TitledBorder(new EtchedBorder(), "Text Health Report")); // create the middle panel components JTextArea display = new JTextArea(16, 58); display.setEditable(false); //Make a new GSON object so the text can be Pretty Printed. display.append(new HealthReportHeadless(JSON).getReportString()); JScrollPane scroll = new JScrollPane(display); scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); //Add Textarea in to middle panel middlePanel.add(scroll); JFrame frame = new JFrame(); frame.add(middlePanel); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); //Listener for the Test Again button. Opens a new UserPrompt object and keeps the Health Report open in the background. test_again.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { new UserPrompt(); } catch (Exception ex) { ex.printStackTrace(); } } }); frame.add(outer); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setVisible(true); DetectVM vm_checker = new DetectVM(); if (EnvironmentUtil.isMac()) { if (vm_checker.getIsVM()) { JOptionPane.showMessageDialog(new JFrame(), "The tool has detected that it is running in a OSX Virtual Machine.\nThe opening of links is not supported on OSX VMs.\nPlease open the tool on a non-VM computer and run it again OR\nyou can also copy the JSON from the report to a non-VM OR view the text report.\nIf you are not running a VM, ignore this message.", "VM Detected", JOptionPane.ERROR_MESSAGE); } } }
From source file:hr.fer.zemris.vhdllab.platform.gui.dialog.save.SaveDialog.java
public SaveDialog(LocalizationSource source, SaveContext context) { super(source); Validate.notNull(context, "Save variant can't be null"); // setup label JLabel label = new JLabel(getMainMessage(source, context)); int width = DIALOG_WIDTH - 2 * BORDER; int height = LABEL_HEIGHT - 2 * BORDER; label.setPreferredSize(new Dimension(width, height)); label.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER)); // setup check box list list = new CheckBoxList(); width = DIALOG_WIDTH - 2 * BORDER;/*from ww w . j a v a 2 s . c o m*/ height = 0; // because list is a center component and it doesnt need // height list.setPreferredSize(new Dimension(width, height)); list.setBorder(BorderFactory.createEmptyBorder(BORDER, BORDER, BORDER, BORDER)); // setup select all and deselect all buttons JButton selectAll = new JButton(source.getMessage(SELECT_ALL_MESSAGE)); selectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); selectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.setSelectionToAll(true); } }); JButton deselectAll = new JButton(source.getMessage(DESELECT_ALL_MESSAGE)); deselectAll.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); deselectAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { list.setSelectionToAll(false); } }); Box selectBox = Box.createHorizontalBox(); selectBox.add(selectAll); selectBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT))); selectBox.add(deselectAll); selectBox.setBorder(BorderFactory.createEmptyBorder(0, 0, BORDER, 0)); // setup ok and cancel buttons JButton ok = new JButton(source.getMessage(OK_MESSAGE)); ok.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(new ArrayList<File>()); } }); JButton cancel = new JButton(source.getMessage(CANCEL_MESSAGE)); cancel.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT)); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(null); } }); Box actionBox = Box.createHorizontalBox(); actionBox.add(ok); actionBox.add(Box.createRigidArea(new Dimension(BORDER, BUTTON_HEIGHT))); actionBox.add(cancel); actionBox.setBorder(BorderFactory.createEmptyBorder(BORDER, 0, BORDER, 0)); JPanel selectPanel = new JPanel(new BorderLayout()); selectPanel.add(selectBox, BorderLayout.EAST); JPanel actionPanel = new JPanel(new BorderLayout()); actionPanel.add(actionBox, BorderLayout.EAST); JCheckBox alwaysSave = new JCheckBox(source.getMessage(ALWAYS_SAVE_MESSAGE)); alwaysSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JCheckBox checkBox = (JCheckBox) e.getSource(); Preferences preferences = Preferences.userNodeForPackage(SaveDialog.class); preferences.putBoolean(SHOULD_AUTO_SAVE, checkBox.isSelected()); } }); alwaysSave.setSelected(false); JPanel alwaysSavePanel = new JPanel(new BorderLayout()); alwaysSavePanel.add(alwaysSave, BorderLayout.WEST); JPanel lowerPanel = new JPanel(new BorderLayout()); lowerPanel.add(selectPanel, BorderLayout.NORTH); lowerPanel.add(alwaysSavePanel, BorderLayout.CENTER); lowerPanel.add(actionPanel, BorderLayout.SOUTH); this.setLayout(new BorderLayout()); JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.add(label, BorderLayout.NORTH); messagePanel.add(list, BorderLayout.CENTER); messagePanel.add(lowerPanel, BorderLayout.SOUTH); this.getContentPane().add(messagePanel, BorderLayout.CENTER); this.getRootPane().setDefaultButton(ok); this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT)); this.setTitle(getTitle(source, context)); }
From source file:org.rdv.ui.ExportDialog.java
private void initComponents(List<String> channels, List<String> fileFormats) { channelModel = new DefaultListModel(); for (int i = 0; i < channels.size(); i++) { String channelName = (String) channels.get(i); Channel channel = RBNBController.getInstance().getChannel(channelName); String mime = channel.getMetadata("mime"); if (mime.equals("application/octet-stream")) { channelModel.addElement(new ExportChannel(channelName)); }// ww w .j av a 2 s . co m } JPanel container = new JPanel(); setContentPane(container); InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = container.getActionMap(); container.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weighty = 0; c.gridwidth = 1; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; JLabel headerLabel = new JLabel("Select the time range and data channels to export."); headerLabel.setBackground(Color.white); headerLabel.setOpaque(true); headerLabel.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray), BorderFactory.createEmptyBorder(10, 10, 10, 10))); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 0, 0, 0); container.add(headerLabel, c); JPanel timeButtonPanel = new JPanel(); timeButtonPanel.setLayout(new BorderLayout()); MouseListener hoverMouseListener = new MouseAdapter() { public void mouseEntered(MouseEvent e) { e.getComponent().setForeground(Color.red); } public void mouseExited(MouseEvent e) { e.getComponent().setForeground(Color.blue); } }; startTimeButton = new JButton(); startTimeButton.setBorder(null); startTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); startTimeButton.setForeground(Color.blue); startTimeButton.addMouseListener(hoverMouseListener); startTimeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { double startTime = DateTimeDialog.showDialog(ExportDialog.this, timeSlider.getStart(), timeSlider.getMinimum(), timeSlider.getEnd()); if (startTime >= 0) { timeSlider.setStart(startTime); } } }); timeButtonPanel.add(startTimeButton, BorderLayout.WEST); durationLabel = new JLabel(); durationLabel.setHorizontalAlignment(JLabel.CENTER); timeButtonPanel.add(durationLabel, BorderLayout.CENTER); endTimeButton = new JButton(); endTimeButton.setBorder(null); endTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); endTimeButton.setForeground(Color.blue); endTimeButton.addMouseListener(hoverMouseListener); endTimeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { double endTime = DateTimeDialog.showDialog(ExportDialog.this, timeSlider.getEnd(), timeSlider.getStart(), timeSlider.getMaximum()); if (endTime >= 0) { timeSlider.setEnd(endTime); } } }); timeButtonPanel.add(endTimeButton, BorderLayout.EAST); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(10, 10, 10, 10); container.add(timeButtonPanel, c); timeSlider = new TimeSlider(); timeSlider.setValueChangeable(false); timeSlider.setValueVisible(false); timeSlider.addTimeAdjustmentListener(new TimeAdjustmentListener() { public void timeChanged(TimeEvent event) { } public void rangeChanged(TimeEvent event) { updateTimeRangeLabel(); } public void boundsChanged(TimeEvent event) { } }); updateTimeRangeLabel(); updateTimeBounds(); List<EventMarker> markers = RBNBController.getInstance().getMarkerManager().getMarkers(); for (EventMarker marker : markers) { timeSlider.addMarker(marker); } c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(timeSlider, c); JLabel numericHeaderLabel = new JLabel("Data Channels:"); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 3; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(numericHeaderLabel, c); numericChannelList = new JList(channelModel); numericChannelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); numericChannelList.setCellRenderer(new CheckListRenderer()); numericChannelList.setVisibleRowCount(10); numericChannelList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { int index = numericChannelList.locationToIndex(e.getPoint()); ExportChannel item = (ExportChannel) numericChannelList.getModel().getElementAt(index); item.setSelected(!item.isSelected()); Rectangle rect = numericChannelList.getCellBounds(index, index); numericChannelList.repaint(rect); checkSelectedChannels(); updateTimeBounds(); } }); JScrollPane scrollPane = new JScrollPane(numericChannelList); c.fill = GridBagConstraints.BOTH; c.weightx = 0; c.weighty = 1; c.gridx = 0; c.gridy = 4; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(scrollPane, c); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.weighty = 0; c.gridx = 0; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 10, 10, 5); container.add(new JLabel("Data file: "), c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 1; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; dataFileTextField = new JTextField(20); c.insets = new java.awt.Insets(0, 0, 10, 5); container.add(dataFileTextField, c); dataFileTextField .setText(UIUtilities.getCurrentDirectory().getAbsolutePath() + File.separator + "data.dat"); dataFileButton = new JButton("Browse"); dataFileButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { File selectedFile = new File(dataFileTextField.getText()); selectedFile = UIUtilities.getFile("OK", "Select export file", selectedFile); if (selectedFile != null) { dataFileTextField.setText(selectedFile.getAbsolutePath()); } } }); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.gridx = 2; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 0, 10, 10); container.add(dataFileButton, c); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.gridx = 0; c.gridy = 6; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 10, 10, 5); container.add(new JLabel("File format: "), c); fileFormatComboBox = new JComboBox(fileFormats.toArray()); fileFormatComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { fileFormatUpdated(); } }); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 1; c.gridy = 6; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 0, 10, 10); container.add(fileFormatComboBox, c); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); Action exportAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = -5356258138620428023L; public void actionPerformed(ActionEvent e) { ok(); } }; exportAction.putValue(Action.NAME, "Export"); inputMap.put(KeyStroke.getKeyStroke("ENTER"), "export"); actionMap.put("export", exportAction); exportButton = new JButton(exportAction); panel.add(exportButton); Action cancelAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = -5868609501314154642L; public void actionPerformed(ActionEvent e) { cancel(); } }; cancelAction.putValue(Action.NAME, "Cancel"); inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel"); actionMap.put("cancel", cancelAction); cancelButton = new JButton(cancelAction); panel.add(cancelButton); c.fill = GridBagConstraints.NONE; c.weightx = 0.5; c.gridx = 0; c.gridy = 7; c.gridwidth = GridBagConstraints.REMAINDER; ; c.anchor = GridBagConstraints.LINE_END; c.insets = new java.awt.Insets(0, 0, 10, 5); container.add(panel, c); pack(); if (getWidth() < 600) { setSize(600, getHeight()); } dataFileTextField.requestFocusInWindow(); setLocationByPlatform(true); }
From source file:org.jfree.demo.DrawStringDemo.java
/** * Creates the content for tab 2./*from w w w . j ava 2 s .c o m*/ * * @return The content panel. */ private JPanel createTab2Content() { JPanel content = new JPanel(new BorderLayout()); JPanel controls = new JPanel(); controls.add(new JLabel("Text anchor: ")); this.combo2 = new JComboBox(); populateTextAnchorCombo(this.combo2); this.combo2.setActionCommand("combo2.changed"); this.combo2.addActionListener(this); controls.add(this.combo2); controls.add(new JLabel("Rotation anchor: ")); this.combo3 = new JComboBox(); populateTextAnchorCombo(this.combo3); this.combo3.setActionCommand("combo3.changed"); this.combo3.addActionListener(this); controls.add(this.combo3); this.slider = new JSlider(SwingConstants.VERTICAL, 0, 360, 0); this.slider.setMajorTickSpacing(45); this.slider.setMinorTickSpacing(5); this.slider.setPaintLabels(true); this.slider.setPaintTicks(true); this.slider.setPaintTrack(true); this.slider.addChangeListener(this); content.add(controls, BorderLayout.NORTH); content.add(this.slider, BorderLayout.WEST); this.drawStringPanel2 = new DrawStringPanel("Rotated Text", true); content.add(this.drawStringPanel2); return content; }
From source file:org.rdv.ui.ExportVideoDialog.java
private void initComponents() { JPanel container = new JPanel(); setContentPane(container);/*from w w w . j a va 2 s . co m*/ InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = container.getActionMap(); container.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weighty = 0; c.gridwidth = 1; c.gridheight = 1; c.ipadx = 0; c.ipady = 0; JLabel headerLabel = new JLabel("Select the time range and video channels to export."); headerLabel.setBackground(Color.white); headerLabel.setOpaque(true); headerLabel.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray), BorderFactory.createEmptyBorder(10, 10, 10, 10))); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 0, 0, 0); container.add(headerLabel, c); JPanel timeButtonPanel = new JPanel(); timeButtonPanel.setLayout(new BorderLayout()); MouseListener hoverMouseListener = new MouseAdapter() { public void mouseEntered(MouseEvent e) { e.getComponent().setForeground(Color.red); } public void mouseExited(MouseEvent e) { e.getComponent().setForeground(Color.blue); } }; startTimeButton = new JButton(); startTimeButton.setBorder(null); startTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); startTimeButton.setForeground(Color.blue); startTimeButton.addMouseListener(hoverMouseListener); startTimeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { double startTime = DateTimeDialog.showDialog(ExportVideoDialog.this, timeSlider.getStart(), timeSlider.getMinimum(), timeSlider.getEnd()); if (startTime >= 0) { timeSlider.setStart(startTime); } } }); timeButtonPanel.add(startTimeButton, BorderLayout.WEST); durationLabel = new JLabel(); durationLabel.setHorizontalAlignment(JLabel.CENTER); timeButtonPanel.add(durationLabel, BorderLayout.CENTER); endTimeButton = new JButton(); endTimeButton.setBorder(null); endTimeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); endTimeButton.setForeground(Color.blue); endTimeButton.addMouseListener(hoverMouseListener); endTimeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { double endTime = DateTimeDialog.showDialog(ExportVideoDialog.this, timeSlider.getEnd(), timeSlider.getStart(), timeSlider.getMaximum()); if (endTime >= 0) { timeSlider.setEnd(endTime); } } }); timeButtonPanel.add(endTimeButton, BorderLayout.EAST); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(10, 10, 10, 10); container.add(timeButtonPanel, c); timeSlider = new TimeSlider(); timeSlider.setValueChangeable(false); timeSlider.setValueVisible(false); timeSlider.addTimeAdjustmentListener(new TimeAdjustmentListener() { public void timeChanged(TimeEvent event) { } public void rangeChanged(TimeEvent event) { updateTimeRangeLabel(); } public void boundsChanged(TimeEvent event) { } }); updateTimeRangeLabel(); updateTimeBounds(); List<EventMarker> markers = rbnb.getMarkerManager().getMarkers(); for (EventMarker marker : markers) { timeSlider.addMarker(marker); } c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 2; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(timeSlider, c); JLabel numericHeaderLabel = new JLabel("Video Channels:"); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0; c.gridx = 0; c.gridy = 3; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(numericHeaderLabel, c); videoChannelList = new JList(videoChannelModel); videoChannelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); videoChannelList.setCellRenderer(new CheckListRenderer()); videoChannelList.setVisibleRowCount(10); videoChannelList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { int index = videoChannelList.locationToIndex(e.getPoint()); ExportChannel item = (ExportChannel) videoChannelList.getModel().getElementAt(index); item.setSelected(!item.isSelected()); Rectangle rect = videoChannelList.getCellBounds(index, index); videoChannelList.repaint(rect); updateTimeBounds(); } }); JScrollPane scrollPane = new JScrollPane(videoChannelList); c.fill = GridBagConstraints.BOTH; c.weightx = 0; c.weighty = 1; c.gridx = 0; c.gridy = 4; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.NORTHEAST; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(scrollPane, c); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.weighty = 0; c.gridx = 0; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 10, 10, 5); container.add(new JLabel("Choose Directory: "), c); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; c.gridx = 1; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; directoryTextField = new JTextField(20); c.insets = new java.awt.Insets(0, 0, 10, 5); container.add(directoryTextField, c); directoryTextField.setText(UIUtilities.getCurrentDirectory().getAbsolutePath()); directoryButton = new JButton("Browse"); directoryButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { File selectedDirectory = UIUtilities.getDirectory("Select export directory"); if (selectedDirectory != null) { directoryTextField.setText(selectedDirectory.getAbsolutePath()); } } }); c.fill = GridBagConstraints.NONE; c.weightx = 0; c.gridx = 2; c.gridy = 5; c.gridwidth = 1; c.anchor = GridBagConstraints.NORTHWEST; c.insets = new java.awt.Insets(0, 0, 10, 10); container.add(directoryButton, c); exportProgressBar = new JProgressBar(0, 100000); exportProgressBar.setStringPainted(true); exportProgressBar.setValue(0); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 0; c.gridy = 6; c.gridwidth = GridBagConstraints.REMAINDER; ; c.anchor = GridBagConstraints.CENTER; c.insets = new java.awt.Insets(0, 10, 10, 10); container.add(exportProgressBar, c); JPanel panel = new JPanel(); panel.setLayout(new FlowLayout()); Action exportAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = 1547500154252213911L; public void actionPerformed(ActionEvent e) { exportVideo(); } }; exportAction.putValue(Action.NAME, "Export"); inputMap.put(KeyStroke.getKeyStroke("ENTER"), "export"); actionMap.put("export", exportAction); exportButton = new JButton(exportAction); panel.add(exportButton); Action cancelAction = new AbstractAction() { /** serialization version identifier */ private static final long serialVersionUID = -7440298547807878651L; public void actionPerformed(ActionEvent e) { cancel(); } }; cancelAction.putValue(Action.NAME, "Cancel"); inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "cancel"); actionMap.put("cancel", cancelAction); cancelButton = new JButton(cancelAction); panel.add(cancelButton); c.fill = GridBagConstraints.NONE; c.weightx = 0.5; c.gridx = 0; c.gridy = 7; c.gridwidth = GridBagConstraints.REMAINDER; ; c.anchor = GridBagConstraints.LINE_END; c.insets = new java.awt.Insets(0, 0, 10, 5); container.add(panel, c); pack(); if (getWidth() < 600) { setSize(600, getHeight()); } directoryTextField.requestFocusInWindow(); setLocationByPlatform(true); setVisible(true); }
From source file:gtu._work.ui.JarFinderUI.java
private void initGUI() { try {/* w ww. j ava2 s. c o m*/ BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setTitle("Jar finder"); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("src dir", null, jPanel1, null); { openDir = new JButton(); jPanel1.add(openDir, BorderLayout.NORTH); openDir.setText("open dir"); openDir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton1ActionPerformed(evt); } }); } { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); jScrollPane1.setPreferredSize(new java.awt.Dimension(406, 255)); { DefaultListModel jList1Model = new DefaultListModel(); try { prop.load(new FileInputStream(CONFIG_FILE)); for (Enumeration<?> enu = prop.keys(); enu.hasMoreElements();) { File val = new File((String) enu.nextElement()); jList1Model.addElement(val); } } catch (Exception ex) { JCommonUtil.handleException("??:" + CONFIG_FILE, ex); } jarFileDirs = new JList(); jScrollPane1.setViewportView(jarFileDirs); jarFileDirs.setModel(jList1Model); jarFileDirs.setPreferredSize(new java.awt.Dimension(406, 221)); jarFileDirs.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (!JListUtil.newInstance(jarFileDirs).isCorrectMouseClick(evt)) { return; } File file = (File) JListUtil.getLeadSelectionObject(jarFileDirs); try { Desktop.getDesktop().open(file); } catch (IOException e) { JCommonUtil.handleException(e); } } }); jarFileDirs.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(jarFileDirs).defaultJListKeyPressed(evt); } }); } } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("result", null, jPanel2, null); { jPanel3 = new JPanel(); BorderLayout jPanel3Layout = new BorderLayout(); jPanel3.setLayout(jPanel3Layout); jPanel2.add(jPanel3, BorderLayout.NORTH); jPanel3.setPreferredSize(new java.awt.Dimension(406, 26)); { searchText = new JTextField(); jPanel3.add(searchText, BorderLayout.WEST); searchText.setPreferredSize(new java.awt.Dimension(326, 26)); } { search = new JButton(); jPanel3.add(search, BorderLayout.CENTER); search.setText("search"); search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButton2ActionPerformed(evt); } }); } } { jScrollPane2 = new JScrollPane(); jPanel2.add(jScrollPane2, BorderLayout.CENTER); jScrollPane2.setPreferredSize(new java.awt.Dimension(406, 231)); { ListModel searchResultModel = new DefaultListModel(); searchResult = new JList(); jScrollPane2.setViewportView(searchResult); searchResult.setModel(searchResultModel); searchResult.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { jList1MouseClicked(evt); } }); searchResult.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(searchResult).defaultJListKeyPressed(evt); } }); } } { resetFinder = new JButton(); jPanel2.add(resetFinder, BorderLayout.SOUTH); resetFinder.setText("reset finder"); resetFinder.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jarfinder.clear(); } }); } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("copy to", null, jPanel4, null); { copyToBtn = new JButton(); jPanel4.add(copyToBtn, BorderLayout.NORTH); copyToBtn.setText("copy to"); copyToBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("copy to dir undefined!", getTitle()); return; } else { copyToFile = file; } } }); } { jScrollPane3 = new JScrollPane(); jPanel4.add(jScrollPane3, BorderLayout.CENTER); { DefaultListModel copyToListModel = new DefaultListModel(); copyToList = new JList(); jScrollPane3.setViewportView(copyToList); copyToList.setModel(copyToListModel); { panel = new JPanel(); jTabbedPane1.addTab("config", null, panel, null); panel.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); { lblNewLabel = new JLabel("JD Gui"); panel.add(lblNewLabel, "2, 2, right, default"); } { jdGuiText = new JTextField(); JCommonUtil.jTextFieldSetFilePathMouseEvent(jdGuiText, false); panel.add(jdGuiText, "4, 2, fill, default"); jdGuiText.setColumns(10); } { saveConfigBtn = new JButton(""); saveConfigBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { configBean.reflectSetConfig(JarFinderUI.this); configBean.store(); JCommonUtil._jOptionPane_showMessageDialog_info("?!"); } catch (Exception ex) { JCommonUtil.handleException(ex); } } }); panel.add(saveConfigBtn, "2, 24"); } } copyToList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { // copyToFile if (evt.getClickCount() != 2) { return; } if (copyToList.getLeadSelectionIndex() == -1) { return; } if (copyToFile == null) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("copy to dir undefined!", getTitle()); return; } DefaultListModel model = (DefaultListModel) copyToList.getModel(); Object val = model.getElementAt(copyToList.getLeadSelectionIndex()); StringBuilder sb = new StringBuilder(); sb.append("?\n"); sb.append("file : " + val + "\n"); sb.append("copy to dir : " + copyToFile + "\n"); ComfirmDialogResult result = JOptionPaneUtil.newInstance().confirmButtonYesNo() .showConfirmDialog(sb, getTitle()); File srcFile = new File((String) val); if (!srcFile.exists()) { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog(srcFile + " not found!", getTitle()); return; } File copyDestFile = new File(copyToFile, srcFile.getName()); switch (result) { case YES_OK_OPTION: System.out.println("yes.."); try { FileUtil.copyFile(srcFile, copyDestFile); } catch (IOException e) { JCommonUtil.handleException(e.toString(), e); } if (srcFile != null && // copyDestFile != null && // srcFile.length() == copyDestFile.length()) { JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("success!\n" + copyDestFile, getTitle()); } else { JOptionPaneUtil.newInstance().iconErrorMessage() .showMessageDialog("failed!\n" + copyDestFile, getTitle()); } break; case NO_OPTION: System.out.println("no.."); break; } } }); } } } jTabbedPane1.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { copyToList.setModel(searchResult.getModel()); } }); } this.setSize(562, 407); JCommonUtil.frameCloseDo(this, new WindowAdapter() { public void windowClosing(WindowEvent paramWindowEvent) { if (CONFIG_FILE.exists()) { DefaultListModel model = (DefaultListModel) jarFileDirs.getModel(); for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) { Object obj = enu.nextElement(); prop.setProperty(((File) obj).getAbsolutePath(), ""); } try { prop.store(new FileOutputStream(CONFIG_FILE), "testtesttesttest"); } catch (Exception e) { JCommonUtil.handleException("", e); } } setVisible(false); dispose(); } }); { configBean.reflectInit(this); } } catch (Exception e) { e.printStackTrace(); } }
From source file:Visuals.RingChart.java
public JPanel addAVCharts() { JPanel thisPanel = new JPanel(); thisPanel.setLayout(new BorderLayout()); int tempCriticalCount = 0, tempUpdatedCount = 0; String[][] criticalList = new String[critical][4]; String[][] updatedList = new String[low][4]; for (int i = 0; i < riskCount; i++) { if (risks[i][2].equals("Critical")) { criticalList[tempCriticalCount][0] = risks[i][0]; criticalList[tempCriticalCount][1] = risks[i][1]; criticalList[tempCriticalCount][3] = risks[i][3]; tempCriticalCount++;//from w w w . j a v a2 s . c o m } if (risks[i][2].equals("Low")) { updatedList[tempUpdatedCount][0] = risks[i][0]; updatedList[tempUpdatedCount][1] = risks[i][1]; tempUpdatedCount++; } } JTable criticalTable = new JTable(criticalList, criticalColumns); JTable updatedTable = new JTable(updatedList, updatedColumns); TableColumn tcol = criticalTable.getColumnModel().getColumn(2); criticalTable.removeColumn(tcol); TableColumn tcol2 = updatedTable.getColumnModel().getColumn(2); updatedTable.removeColumn(tcol2); criticalTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); updatedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); criticalTable.setEnabled(false); updatedTable.setEnabled(false); int width = 0; for (int i = 0; i < 3; i++) { for (int row = 0; row < criticalTable.getRowCount(); row++) { TableCellRenderer renderer = criticalTable.getCellRenderer(row, i); Component comp = criticalTable.prepareRenderer(renderer, row, i); width = Math.max(comp.getPreferredSize().width, width); } criticalTable.getColumnModel().getColumn(i).setPreferredWidth(width); width = 0; } for (int i = 0; i < 2; i++) { for (int row = 0; row < updatedTable.getRowCount(); row++) { TableCellRenderer renderer = updatedTable.getCellRenderer(row, i); Component comp = updatedTable.prepareRenderer(renderer, row, i); width = Math.max(comp.getPreferredSize().width, width); } updatedTable.getColumnModel().getColumn(i).setPreferredWidth(width); width = 0; } criticalTable.setShowHorizontalLines(true); criticalTable.setRowHeight(40); updatedTable.setShowHorizontalLines(true); updatedTable.setRowHeight(40); JScrollPane criticalTableScrollPane = new JScrollPane(criticalTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); JScrollPane updatedTableScrollPane = new JScrollPane(updatedTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); Dimension d = criticalTable.getPreferredSize(); criticalTableScrollPane.setPreferredSize( new Dimension((d.width - 400), (criticalTable.getRowHeight() + 1) * (tempCriticalCount + 1))); Dimension d2 = updatedTable.getPreferredSize(); updatedTableScrollPane.setPreferredSize( new Dimension((d.width - 400), (updatedTable.getRowHeight() + 1) * (tempUpdatedCount + 1))); Font titleFonts = new Font("Calibri", Font.BOLD, 30); JLabel criticalLabel = new JLabel(" Critical "); criticalLabel.setFont(titleFonts); criticalLabel.setForeground(new Color(230, 27, 27)); JPanel leftPanel = new JPanel(); leftPanel.setLayout(new BorderLayout()); leftPanel.add(criticalLabel, BorderLayout.WEST); leftPanel.add(criticalTableScrollPane, BorderLayout.CENTER); JLabel updatedLabel = new JLabel(" Updated "); updatedLabel.setFont(titleFonts); updatedLabel.setForeground(new Color(47, 196, 6)); JPanel rightPanel = new JPanel(); rightPanel.setLayout(new BorderLayout()); rightPanel.add(updatedLabel, BorderLayout.WEST); rightPanel.add(updatedTableScrollPane, BorderLayout.CENTER); if (tempCriticalCount != 0) thisPanel.add(leftPanel, BorderLayout.NORTH); if (tempUpdatedCount != 0) thisPanel.add(rightPanel, BorderLayout.SOUTH); return thisPanel; }
From source file:com.eviware.soapui.support.SoapUIVersionUpdate.java
protected JPanel buildToolbar(JDialog dialog) { JPanel toolbarPanel = new JPanel(new BorderLayout()); JPanel leftBtns = new JPanel(); leftBtns.add(new JButton((new IgnoreUpdateAction(dialog)))); leftBtns.add(new JButton(new RemindLaterAction(dialog))); JButton createToolbarButton = new JButton( new OpenDownloadUrlAction("Download latest version", getDownloadLinkCore(), dialog)); JPanel rightBtn = new JPanel(); rightBtn.add(createToolbarButton);/*from w w w . j a v a 2s . c om*/ toolbarPanel.add(leftBtns, BorderLayout.WEST); toolbarPanel.add(rightBtn, BorderLayout.EAST); return toolbarPanel; }