List of usage examples for javax.swing JInternalFrame add
public Component add(Component comp)
From source file:Main.java
public static void main(String[] args) { JDesktopPane dp = new JDesktopPane(); JInternalFrame inf = new JInternalFrame("Help", true, true, true, true); inf.setSize(200, 200);/*from ww w . java2 s . c om*/ inf.setVisible(true); dp.add(inf); JButton btn = new JButton("Click"); btn.addActionListener(e -> JOptionPane.showInternalInputDialog(inf, "Hit me")); inf.add(btn); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLayout(new BorderLayout()); f.add(dp); f.setSize(400, 400); f.setVisible(true); }
From source file:flow.visibility.FlowMain.java
public static void main(String[] args) throws Exception { /************************************************************** * Creating the Main GUI // w w w.jav a2 s .c o m **************************************************************/ final JDesktopPane desktop = new JDesktopPane(); final JMenuBar mb = new JMenuBar(); JMenu menu; /** Add File Menu to Open File and Save Result */ menu = new JMenu("File"); JMenuItem Open = new JMenuItem("Open"); JMenuItem Save = new JMenuItem("Save"); menu.add(Open); menu.add(Save); menu.addSeparator(); JMenuItem Exit = new JMenuItem("Exit"); menu.add(Exit); Exit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.exit(0); } }); mb.add(menu); /** Add Control Menu to Start and Stop Capture */ menu = new JMenu("Control"); JMenuItem Start = new JMenuItem("Start Capture"); JMenuItem Stop = new JMenuItem("Stop Capture"); menu.add(Start); Start.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FlowDumper.main(false); } }); menu.add(Stop); Stop.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FlowDumper.main(true); } }); mb.add(menu); /** Add Configuration Menu for Tapping and Display */ menu = new JMenu("Configuration"); JMenuItem Tapping = new JMenuItem("Tapping Configuration"); JMenuItem Display = new JMenuItem("Display Configuration"); menu.add(Tapping); Tapping.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { FlowTapping.main(null); } }); menu.add(Display); mb.add(menu); /** Add Detail Menu for NetGrok Visualization and JEthereal Inspection */ menu = new JMenu("Flow Detail"); JMenuItem FlowVisual = new JMenuItem("Flow Visualization"); JMenuItem FlowInspect = new JMenuItem("Flow Inspections"); menu.add(FlowVisual); FlowVisual.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { NetworkView.main(null); } }); menu.add(FlowInspect); FlowInspect.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Ethereal.main(null); } }); mb.add(menu); /** Add Help Menu for Software Information */ menu = new JMenu("Help"); JMenuItem About = new JMenuItem("About"); menu.add(About); About.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "OF@TEIN Flow Visibility Tools @ 2015 by GIST", "About the Software", JOptionPane.PLAIN_MESSAGE); } }); mb.add(menu); /** Creating the main frame */ JFrame frame = new JFrame("OF@TEIN Flow Visibility Tools"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(desktop); frame.setJMenuBar(mb); frame.setSize(1215, 720); frame.setLocationRelativeTo(null); frame.setVisible(true); /**Add Blank three (3) Internal Jframe*/ /**Internal Frame from Flow Summary Chart*/ JInternalFrame FlowStatistic = new JInternalFrame("Flow Statistic", true, true, true, true); FlowStatistic.setBounds(0, 0, 600, 330); ChartPanel chartPanel = new ChartPanel(createChart(null)); chartPanel.setMouseZoomable(true, false); FlowStatistic.add(chartPanel); FlowStatistic.setVisible(true); desktop.add(FlowStatistic); /**Internal Frame from Flow Summary Text*/ JInternalFrame FlowSummary = new JInternalFrame("Flow Summary", true, true, true, true); FlowSummary.setBounds(0, 331, 600, 329); JTextArea textArea = new JTextArea(50, 10); JScrollPane scrollPane = new JScrollPane(textArea); FlowSummary.add(scrollPane); FlowSummary.setVisible(true); desktop.add(FlowSummary); //JInternalFrame FlowInspection = new JInternalFrame("Flow Inspection", true, true, true, true); //FlowInspection.setBounds(601, 0, 600, 660); //JTextArea textArea2 = new JTextArea(50, 10); //JScrollPane scrollPane2 = new JScrollPane(textArea2); //FlowInspection.add(scrollPane2); //FlowInspection.setVisible(true); //desktop.add(FlowInspection); /**Internal Frame from Printing the Packet Sequence*/ JInternalFrame FlowSequence = new JInternalFrame("Flow Sequence", true, true, true, true); FlowSequence.setBounds(601, 0, 600, 660); JTextArea textArea3 = new JTextArea(50, 10); JScrollPane scrollPane3 = new JScrollPane(textArea3); FlowSequence.add(scrollPane3); FlowSequence.setVisible(true); desktop.add(FlowSequence); /************************************************************** * Update the Frame Regularly **************************************************************/ /** Regularly update the Frame Content every 3 seconds */ for (;;) { desktop.removeAll(); desktop.add(FlowProcess.FlowStatistic()); desktop.add(FlowProcess.FlowSummary()); //desktop.add(FlowProcess.FlowInspection()); desktop.add(FlowProcess.FlowSequence()); desktop.revalidate(); Thread.sleep(10000); } }
From source file:flow.visibility.pcap.FlowProcess.java
/** function to create internal frame contain flow summary chart */ public static JInternalFrame FlowStatistic() { final StringBuilder errbuf = new StringBuilder(); // For any error msgs final String file = "tmp-capture-file.pcap"; //System.out.printf("Opening file for reading: %s%n", file); /*************************************************************************** * Second we open up the selected file using openOffline call **************************************************************************/ Pcap pcap = Pcap.openOffline(file, errbuf); if (pcap == null) { System.err.printf("Error while opening device for capture: " + errbuf.toString()); }/*from w w w. j a v a 2 s . c o m*/ Pcap pcap1 = Pcap.openOffline(file, errbuf); FlowMap map = new FlowMap(); pcap1.loop(Pcap.LOOP_INFINITE, map, null); //System.out.printf(map.toString()); //System.out.printf(map.toString2()); /** Splitting the packets statistics strings from FlowMap function */ String packet = map.toString2(); String[] NumberPacket = packet.split(","); final XYSeries Flow = new XYSeries("Flow"); for (int i = 0; i < NumberPacket.length - 1; i = i + 1) { //System.out.printf(NumberPacket[i+1] + "\n"); double NoPacket = Double.valueOf(NumberPacket[i + 1]); Flow.add(i, NoPacket); } /** Create dataset for chart */ final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(Flow); /** Create the internal frame contain flow summary chart */ JInternalFrame FlowStatistic = new JInternalFrame("Flow Statistic", true, true, true, true); FlowStatistic.setBounds(0, 0, 600, 330); ChartPanel chartPanel = new ChartPanel(createChart(dataset)); chartPanel.setMouseZoomable(true, false); FlowStatistic.add(chartPanel); FlowStatistic.setVisible(true); FlowStatistic.revalidate(); pcap1.close(); return FlowStatistic; }
From source file:flow.visibility.pcap.FlowProcess.java
/** function to create internal frame contain flow summary in text */ public static JInternalFrame FlowSummary() { final StringBuilder errbuf = new StringBuilder(); // For any error msgs final String file = "tmp-capture-file.pcap"; //System.out.printf("Opening file for reading: %s%n", file); /*************************************************************************** * Second we open up the selected file using openOffline call **************************************************************************/ Pcap pcap = Pcap.openOffline(file, errbuf); if (pcap == null) { System.err.printf("Error while opening device for capture: " + errbuf.toString()); }//from w ww .j av a 2s. c o m /** create blank internal frame */ JInternalFrame FlowSummary = new JInternalFrame("Flow Summary", true, true, true, true); FlowSummary.setBounds(0, 331, 600, 329); JTextArea textArea = new JTextArea(50, 10); PrintStream printStream = new PrintStream(new CustomOutputStream(textArea)); System.setOut(printStream); System.setErr(printStream); JScrollPane scrollPane = new JScrollPane(textArea); FlowSummary.add(scrollPane); /** Process the FlowMap */ Pcap pcap2 = Pcap.openOffline(file, errbuf); JFlowMap superFlowMap = new JFlowMap(); pcap2.loop(Pcap.LOOP_INFINITE, superFlowMap, null); /** Redirect the FlowMap Output into the Frame Text Area */ FlowSummary.setVisible(true); System.out.printf("%s%n", superFlowMap); FlowSummary.revalidate(); pcap2.close(); return FlowSummary; }
From source file:flow.visibility.pcap.FlowProcess.java
/** function to create internal frame contain flow details */ public static JInternalFrame FlowInspection() { final StringBuilder errbuf = new StringBuilder(); // For any error msgs final String file = "tmp-capture-file.pcap"; //System.out.printf("Opening file for reading: %s%n", file); /*************************************************************************** * Second we open up the selected file using openOffline call **************************************************************************/ Pcap pcap = Pcap.openOffline(file, errbuf); if (pcap == null) { System.err.printf("Error while opening device for capture: " + errbuf.toString()); }/*w ww.j av a2 s .c om*/ /** create blank internal frame */ JInternalFrame FlowInspection = new JInternalFrame("Flow Inspection", true, true, true, true); FlowInspection.setBounds(601, 0, 600, 660); JTextArea textArea2 = new JTextArea(50, 10); PrintStream printStream2 = new PrintStream(new CustomOutputStream(textArea2)); System.setOut(printStream2); System.setErr(printStream2); JScrollPane scrollPane2 = new JScrollPane(textArea2); FlowInspection.add(scrollPane2); JPacketHandler<String> jpacketHandler = new JPacketHandler<String>() { public void nextPacket(JPacket packet, String user) { final JCaptureHeader header = packet.getCaptureHeader(); System.out.printf("========================= Next Packet ===============================\n"); System.out.printf("Packet caplen=%d wirelen=%d\n", header.caplen(), header.wirelen()); System.out.println(packet.toString()); } }; Pcap pcap3 = Pcap.openOffline(file, errbuf); /** Redirect Output into the Frame Text Area */ FlowInspection.setVisible(true); pcap3.loop(Pcap.LOOP_INFINITE, jpacketHandler, null); FlowInspection.revalidate(); pcap3.close(); return FlowInspection; }
From source file:flow.visibility.pcap.FlowProcess.java
/** function to create internal frame contain flow sequence */ public static JInternalFrame FlowSequence() { final StringBuilder errbuf = new StringBuilder(); // For any error msgs final String file = "tmp-capture-file.pcap"; //System.out.printf("Opening file for reading: %s%n", file); /*************************************************************************** * Second we open up the selected file using openOffline call **************************************************************************/ Pcap pcap = Pcap.openOffline(file, errbuf); if (pcap == null) { System.err.printf("Error while opening device for capture: " + errbuf.toString()); }/* ww w .j a va 2s . co m*/ /** create blank internal frame */ JInternalFrame FlowSequence = new JInternalFrame("Flow Sequence", true, true, true, true); FlowSequence.setBounds(601, 0, 600, 660); JTextArea textArea3 = new JTextArea(50, 10); PrintStream printStream3 = new PrintStream(new CustomOutputStream(textArea3)); System.setOut(printStream3); System.setErr(printStream3); JScrollPane scrollPane3 = new JScrollPane(textArea3); FlowSequence.add(scrollPane3); /** Process to print the packet one by one */ JPacketHandler<String> jpacketHandler = new JPacketHandler<String>() { public void nextPacket(JPacket packet, String user) { final JCaptureHeader header = packet.getCaptureHeader(); Timestamp timestamp = new Timestamp(header.timestampInMillis()); Tcp tcp = new Tcp(); Udp udp = new Udp(); Icmp icmp = new Icmp(); Ip4 ip4 = new Ip4(); Ethernet ethernet = new Ethernet(); /** For IP Packet */ if (packet.hasHeader(ip4)) { if (packet.hasHeader(tcp)) { System.out.println(timestamp.toString() + " : [TCP] : " + FormatUtils.ip(ip4.source()) + ":" + tcp.source() + "->" + FormatUtils.ip(ip4.destination()) + ":" + tcp.destination()); } if (packet.hasHeader(udp)) { System.out.println(timestamp.toString() + " : [UDP] : " + FormatUtils.ip(ip4.source()) + ":" + udp.source() + "->" + FormatUtils.ip(ip4.destination()) + ":" + udp.destination()); } if (packet.hasHeader(icmp)) { System.out.println(timestamp.toString() + " : [ICMP] : " + FormatUtils.ip(ip4.source()) + "->" + FormatUtils.ip(ip4.destination()) + ":" + icmp.type()); } } /** For Ethernet Packet */ else if (packet.hasHeader(ethernet)) { System.out.println(timestamp.toString() + " : [ETH] : " + FormatUtils.mac(ethernet.source()) + "->" + FormatUtils.mac(ethernet.destination()) + ":" + ethernet.type()); } } }; Pcap pcap4 = Pcap.openOffline(file, errbuf); /** Redirect the Output into Frame Text Area */ FlowSequence.setVisible(true); pcap4.loop(Pcap.LOOP_INFINITE, jpacketHandler, null); FlowSequence.revalidate(); pcap4.close(); return FlowSequence; }
From source file:fr.crnan.videso3d.ihm.PLNSPanel.java
private void addChart(JFreeChart chart) { ChartPanel panel = new ChartPanel(chart); chartPanels.add(panel);/*w ww.ja v a2 s . c om*/ JInternalFrame frame = new JInternalFrame(chart.getTitle().getText(), true, false, true, true); frame.add(panel); frame.pack(); frame.setVisible(true); desktop.add(frame); desktop.tile(true); if (chartMouseListener != null) { panel.addChartMouseListener(chartMouseListener); } }