List of usage examples for javax.swing JButton setBounds
public void setBounds(int x, int y, int width, int height)
From source file:org.zaproxy.zap.extension.cmss.CMSSFrame.java
/** Create the frame. */ public CMSSFrame() { setTitle("Fingerprinting tools"); setResizable(false);// w ww . jav a2 s. c om setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setBounds(100, 100, 756, 372); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JLayeredPane layeredPane = new JLayeredPane(); contentPane.add(layeredPane, BorderLayout.CENTER); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setBounds(0, 0, 725, 323); layeredPane.add(tabbedPane); JLayeredPane layeredPane_1 = new JLayeredPane(); tabbedPane.addTab("Fingerprint", null, layeredPane_1, null); JLabel label = new JLabel("App name:"); label.setBounds(35, 188, 76, 14); layeredPane_1.add(label); JLabel label_1 = new JLabel("Version:"); label_1.setBounds(35, 230, 76, 14); layeredPane_1.add(label_1); textField = new JTextField(); textField.setColumns(10); textField.setBounds(121, 188, 109, 29); layeredPane_1.add(textField); textField_1 = new JTextField(); textField_1.setColumns(10); textField_1.setBounds(121, 223, 109, 29); layeredPane_1.add(textField_1); JSeparator separator = new JSeparator(); separator.setBounds(35, 72, 665, 2); layeredPane_1.add(separator); JSeparator separator_1 = new JSeparator(); separator_1.setBounds(196, 11, 1, 201); layeredPane_1.add(separator_1); JSeparator separator_2 = new JSeparator(); separator_2.setOrientation(SwingConstants.VERTICAL); separator_2.setBounds(260, 81, 1, 201); layeredPane_1.add(separator_2); final JCheckBox chckbxGetVersion = new JCheckBox("Get version"); chckbxGetVersion.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (textField_1.isEnabled() && !chckbxGetVersion.isSelected()) textField_1.setEnabled(false); if (!textField_1.isEnabled() && chckbxGetVersion.isSelected()) textField_1.setEnabled(true); } }); chckbxGetVersion.setBounds(35, 81, 195, 23); layeredPane_1.add(chckbxGetVersion); final JCheckBox chckbxPassiveFingerprinting = new JCheckBox("Passive"); chckbxPassiveFingerprinting.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); chckbxPassiveFingerprinting.setBounds(35, 107, 195, 23); chckbxPassiveFingerprinting.setSelected(true); // layeredPane_1.add(chckbxPassiveFingerprinting); final JCheckBox chckbxAgressive = new JCheckBox("Agressive"); chckbxAgressive.setBounds(35, 133, 195, 23); layeredPane_1.add(chckbxAgressive); JLabel lblWhatToFingerprint = new JLabel("What to fingerprint ?"); lblWhatToFingerprint.setBounds(287, 81, 109, 14); layeredPane_1.add(lblWhatToFingerprint); JCheckBox chckbxCms = new JCheckBox("cms"); chckbxCms.setBounds(280, 102, 134, 23); layeredPane_1.add(chckbxCms); JCheckBox chckbxMessageboards = new JCheckBox("message-boards"); chckbxMessageboards.setBounds(280, 128, 134, 23); layeredPane_1.add(chckbxMessageboards); JCheckBox chckbxJavascriptframeworks = new JCheckBox("javascript-frameworks"); chckbxJavascriptframeworks.setBounds(281, 154, 133, 23); layeredPane_1.add(chckbxJavascriptframeworks); JCheckBox chckbxWebframeworks = new JCheckBox("web-frameworks"); chckbxWebframeworks.setBounds(281, 178, 133, 23); layeredPane_1.add(chckbxWebframeworks); JCheckBox chckbxWebservers = new JCheckBox("web-servers"); chckbxWebservers.setBounds(281, 204, 133, 23); layeredPane_1.add(chckbxWebservers); JSeparator separator_4 = new JSeparator(); separator_4.setOrientation(SwingConstants.VERTICAL); separator_4.setBounds(435, 81, 1, 201); layeredPane_1.add(separator_4); JCheckBox chckbxDatabases = new JCheckBox("databases"); chckbxDatabases.setBounds(281, 228, 133, 23); layeredPane_1.add(chckbxDatabases); JButton btnMore = new JButton("More"); btnMore.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { wtfpFrame = new WhatToFingerPrintFrame(); wtfpFrame.setLocationRelativeTo(null); wtfpFrame.setVisible(true); } }); btnMore.setBounds(291, 261, 123, 23); layeredPane_1.add(btnMore); JLabel lblFingerprintingTimeAnd = new JLabel("Fingerprinting time and occuracy settings:"); lblFingerprintingTimeAnd.setBounds(490, 81, 210, 14); layeredPane_1.add(lblFingerprintingTimeAnd); JButton btnFingerprint = new JButton("Fingerprint"); btnFingerprint.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!chckbxPassiveFingerprinting.isSelected() && !chckbxAgressive.isSelected()) chckbxPassiveFingerprinting.setSelected(true); if (chckbxPassiveFingerprinting.isSelected() && !chckbxAgressive.isSelected()) POrAOption = 1; else if (!chckbxPassiveFingerprinting.isSelected() && chckbxAgressive.isSelected()) POrAOption = 2; else if (chckbxPassiveFingerprinting.isSelected() && chckbxAgressive.isSelected()) POrAOption = 3; try { targetUrl = new URL(txtHttp.getText()); } catch (MalformedURLException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } System.out.println("POrAOption : " + POrAOption); // we concatenate the two ArrayLists ArrayList<String> wtfpList = getWhatToFingerprint(); for (String wtfp : wtfpFrame.getWhatToFingerprint()) { wtfpList.add(wtfp); } // we call FastFingerprinter.filterResults on the global whatToFingerPrint // List fpThread = new FingerPrintingThread(targetUrl, wtfpList, POrAOption); fpThread.start(); while (fpThread.isAlive()) { // waiting; } ArrayList<String> resultList = fpThread.getFingerPrintingResult(); for (String app : resultList) { textField.setText(textField.getText() + app + " , "); } if (chckbxGetVersion.isSelected()) { System.out.println("wiw"); ArrayList<String> versions = new ArrayList<String>(); if (resultList.contains("wordpress")) { textField_1.setText(textField_1.getText() + "wordpress :"); for (String version : FastFingerprinter.WordpressFastFingerprint(targetUrl)) { textField_1.setText(textField_1.getText() + version + " ; "); } } if (resultList.contains("joomla")) { textField_1.setText(textField_1.getText() + "joomla :"); for (String version : FastFingerprinter.JoomlaFastFingerprint(targetUrl)) { textField_1.setText(textField_1.getText() + version + " ; "); } } // blindelephant for (String app : resultList) { System.out.println("---->" + app); try { versions = WebAppGuesser.fingerPrintFile(app); textField_1.setText(textField_1.getText() + app + " : "); for (String version : versions) { textField_1.setText(textField_1.getText() + version + " ; "); } } catch (NoSuchAlgorithmException | IOException | DecoderException e1) { e1.printStackTrace(); } } } } }); btnFingerprint.setBounds(35, 154, 195, 23); layeredPane_1.add(btnFingerprint); JButton btnDetailedView = new JButton("Detailed view "); btnDetailedView.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); btnDetailedView.setBounds(35, 259, 195, 23); layeredPane_1.add(btnDetailedView); this.checkBoxesList.add(chckbxCms); this.checkBoxesList.add(chckbxJavascriptframeworks); this.checkBoxesList.add(chckbxWebframeworks); this.checkBoxesList.add(chckbxWebservers); this.checkBoxesList.add(chckbxDatabases); this.checkBoxesList.add(chckbxMessageboards); txtHttp = new JTextField(); txtHttp.setText("http://"); txtHttp.setBounds(128, 22, 568, 29); layeredPane_1.add(txtHttp); txtHttp.setColumns(10); JLabel lblTarget = new JLabel("Target : "); lblTarget.setBounds(51, 29, 46, 14); layeredPane_1.add(lblTarget); JLayeredPane layeredPane_2 = new JLayeredPane(); tabbedPane.addTab("Details", null, layeredPane_2, null); JTabbedPane tabbedPane_1 = new JTabbedPane(JTabbedPane.TOP); tabbedPane_1.setBounds(0, 0, 720, 223); layeredPane_2.add(tabbedPane_1); JLayeredPane layeredPane_4 = new JLayeredPane(); tabbedPane_1.addTab("Detailed result", null, layeredPane_4, null); JLayeredPane layeredPane_3 = new JLayeredPane(); tabbedPane_1.addTab("Passive fingerprint", null, layeredPane_3, null); JTabbedPane tabbedPane_2 = new JTabbedPane(JTabbedPane.TOP); tabbedPane_1.addTab("Agressive fingerprint", null, tabbedPane_2, null); }
From source file:snepsui.Interface.TestDraw.java
private void initGUI() { nodesList = new LinkedList<Node>(); molNodes = new Hashtable<String, CaseFrame>(); builtMolNodes = new Hashtable<String, Node>(); this.setPreferredSize(new Dimension(815, 600)); graph = new DirectedOrderedSparseMultigraph<String, String>(); this.layout = new StaticLayout<String, String>(graph, new Dimension(700, 450)); shape = new Transformer<String, Integer>() { public Integer transform(String vertex) { int stringLength = 0; if (molNodes.containsKey(vertex)) { stringLength = 3;//from www. j a v a2 s . c om } else { for (Node node : nodesList) { if (vertex.equals(node.getIdentifier())) { stringLength = node.getIdentifier().length(); } } } return stringLength; } }; vertexPaint = new Transformer<String, Paint>() { public Paint transform(String vertex) { // if(molNodes.containsKey(vertex)) { // if(builtMolNodes.containsKey(vertex)) { // Node node = builtMolNodes.get(vertex); // if (node.getClass().getSimpleName().equals("PatternNode")) { // return Color.blue; // } else if (node.getClass().getSimpleName().equals("ClosedNode")) { // return Color.yellow; // } // } else // return Color.white; // } else { // for(Node node : nodesList) { // if(node.getIdentifier().equals(vertex)) { // if(node.getClass().getSimpleName().equals("BaseNode")) { // return Color.green; // } else if (node.getClass().getSimpleName().equals("VariableNode")) { // return Color.gray; // } else if (node.getClass().getSimpleName().equals("PatternNode")) { // return Color.blue; // } else if (node.getClass().getSimpleName().equals("ClosedNode")) { // return Color.yellow; // } else { // return Color.magenta; // } // } // } // } return Color.white; } }; edgeLabel = new Transformer<String, String>() { public String transform(String edge) { String result = ""; if (edge.isEmpty()) graph.removeEdge(""); vv.repaint(); try { result = edge.substring(0, edge.indexOf(":")); } catch (StringIndexOutOfBoundsException e) { } return result; } }; VertexShapeSizeAspect<String> vssa = new VertexShapeSizeAspect<String>(graph, shape); vv = new VisualizationViewer<String, String>(layout, new Dimension(700, 470)); vv.setBackground(Color.white); vv.getRenderContext().setVertexLabelTransformer(MapTransformer.<String, String>getInstance( LazyMap.<String, String>decorate(new HashMap<String, String>(), new ToStringLabeller<String>()))); vv.getRenderContext().setEdgeLabelTransformer(MapTransformer.<String, String>getInstance( LazyMap.<String, String>decorate(new HashMap<String, String>(), new ToStringLabeller<String>()))); vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer()); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); vv.getRenderContext().setVertexShapeTransformer(vssa); vv.getRenderContext() .setEdgeLabelClosenessTransformer(new ConstantDirectionalEdgeValueTransformer(0.5, 0.5)); vv.getRenderContext().setEdgeLabelTransformer(edgeLabel); vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); vv.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { point = e.getPoint(); } public void mouseReleased(MouseEvent e) { vv.repaint(); } }); vssa.setScaling(true); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); this.add(panel); Factory<String> vertexFactory = new VertexFactory(); Factory<String> edgeFactory = new EdgeFactory(); final EditingModalGraphMouse<String, String> graphMouse = new EditingModalGraphMouse<String, String>( vv.getRenderContext(), vertexFactory, edgeFactory); graphMouse.add(new CustomEditingPopupGraphMousePlugin<String>(vertexFactory, edgeFactory)); graphMouse.remove(graphMouse.getPopupEditingPlugin()); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); graphMouse.setMode(ModalGraphMouse.Mode.EDITING); final ScalingControl scaler = new CrossoverScalingControl(); vv.scaleToLayout(scaler); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JPanel scaleGrid = new JPanel(new GridLayout(1, 0)); scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom")); String path = "src/snepsui/Interface/resources/icons/"; JButton infoButton = new JButton(new ImageIcon(path + "info.png")); infoButton.setBounds(710, 320, 16, 16); infoButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(vv, instructions); } }); JButton resetbutton = new JButton(new ImageIcon(path + "resetnet.png")); resetbutton.setBounds(710, 300, 16, 16); resetbutton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int result = JOptionPane.showConfirmDialog(vv, "Are you sure you want to reset the drawing area?", "Reset", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { builtMolNodes.clear(); molNodes.clear(); nodesList.clear(); LinkedList<String> vertexList = new LinkedList<String>(); Collection<String> vertices = graph.getVertices(); for (String vertex : vertices) { vertexList.add(vertex); } for (String item : vertexList) { graph.removeVertex(item); } vv.repaint(); } } }); JLabel caseframeLabel = new JLabel("Case Frames"); DefaultComboBoxModel caseframeComboBoxModel = new DefaultComboBoxModel( new String[] { "define-caseframe", "undefine-caseframe" }); caseframeComboBox = new JComboBox(); caseframeComboBox.setModel(caseframeComboBoxModel); JLabel relationsLabel = new JLabel("Relations"); DefaultComboBoxModel relationsComboBoxModel = new DefaultComboBoxModel( new String[] { "define", "undefine" }); relationsComboBox = new JComboBox(); relationsComboBox.setModel(relationsComboBoxModel); this.add(infoButton, BorderLayout.EAST); this.add(resetbutton); JPanel controls = new JPanel(); scaleGrid.add(plus); scaleGrid.add(minus); controls.add(scaleGrid); controls.add(relationsLabel); controls.add(relationsComboBox); controls.add(caseframeLabel); controls.add(caseframeComboBox); JComboBox modeBox = graphMouse.getModeComboBox(); controls.add(modeBox); this.add(controls, BorderLayout.SOUTH); }
From source file:updater.UpdaterGUI.java
@SuppressWarnings("resource") public UpdaterGUI() { try {/*from w ww . java 2 s . co m*/ URL url1 = new URL( "https://raw.githubusercontent.com/kvsjxd/Droid-PC-Suite/master/.release-version.txt"); ReadableByteChannel obj1 = Channels.newChannel(url1.openStream()); FileOutputStream outputstream1 = new FileOutputStream(".release-version.txt"); outputstream1.getChannel().transferFrom(obj1, 0, Long.MAX_VALUE); URL url2 = new URL( "https://raw.githubusercontent.com/kvsjxd/Droid-PC-Suite/master/.release-changelog.txt"); ReadableByteChannel obj2 = Channels.newChannel(url2.openStream()); FileOutputStream outputstream2 = new FileOutputStream(".release-changelog.txt"); outputstream2.getChannel().transferFrom(obj2, 0, Long.MAX_VALUE); FileReader file = new FileReader(".release-version.txt"); BufferedReader reader = new BufferedReader(file); String DownloadedString = reader.readLine(); File file2 = new File(".release-version.txt"); if (file2.exists() && !file2.isDirectory()) { file2.delete(); } AvailableUpdate = Double.parseDouble(DownloadedString); InputStreamReader reader2 = new InputStreamReader( getClass().getResourceAsStream("/others/app-version.txt")); String tmp = IOUtils.toString(reader2); ApplicationVersion = Double.parseDouble(tmp); } catch (Exception e) { e.printStackTrace(); } setIconImage(Toolkit.getDefaultToolkit().getImage(UpdaterGUI.class.getResource("/graphics/Icon.png"))); setResizable(false); setType(Type.UTILITY); setTitle("Updater"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 430, 415); contentPane = new JPanel(); contentPane.setBackground(Color.WHITE); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel lblApplicationVersion = new JLabel("App Version: v" + ApplicationVersion); lblApplicationVersion.setBounds(12, 12, 222, 15); contentPane.add(lblApplicationVersion); JLabel lblUpdateVersion = new JLabel("Update Version: v" + AvailableUpdate); lblUpdateVersion.setBounds(12, 30, 222, 15); contentPane.add(lblUpdateVersion); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(0, 51, 422, 281); contentPane.add(scrollPane); JTextArea UpdateChangelogViewer = new JTextArea(); scrollPane.setViewportView(UpdateChangelogViewer); JButton btnDownload = new JButton("Download"); btnDownload.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { JFrame parentFrame = new JFrame(); JFileChooser fileChooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("Zip Files", "zip"); fileChooser.setFileFilter(filter); fileChooser.setDialogTitle("Save as"); int userSelection = fileChooser.showSaveDialog(parentFrame); if (userSelection == JFileChooser.APPROVE_OPTION) { File fileToSave = fileChooser.getSelectedFile(); try { URL url = new URL("https://github.com/kvsjxd/Droid-PC-Suite/releases/download/" + AvailableUpdate + "/DPCS.v" + AvailableUpdate + ".Stable.zip"); ReadableByteChannel obj = Channels.newChannel(url.openStream()); FileOutputStream outputstream = new FileOutputStream(fileToSave.getAbsolutePath() + ".zip"); outputstream.getChannel().transferFrom(obj, 0, Long.MAX_VALUE); JOptionPane.showMessageDialog(null, "Download complete!\nPlease delete this version and extract the downloaded zip\nwhich is saved at " + fileToSave.getAbsolutePath() + ".zip"); } catch (Exception e) { e.printStackTrace(); } } } }); btnDownload.setBounds(140, 344, 117, 25); contentPane.add(btnDownload); try { FileReader reader3 = new FileReader(new File(".release-changelog.txt")); UpdateChangelogViewer.read(reader3, ""); File file3 = new File(".release-changelog.txt"); if (file3.exists() && !file3.isDirectory()) { file3.delete(); } } catch (Exception e) { e.printStackTrace(); } }