List of usage examples for javax.swing JInternalFrame setBounds
public void setBounds(int x, int y, int width, int height)
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 ava 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 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()); }//from ww w . j a v a 2s .c o 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:Figure3.java
private void addFrame(int number) { JInternalFrame f = new JInternalFrame("Frame " + number, true, true, true, true); f.setBounds(number * 10 - 5, number * 10 - 5, 250, 150); desk.add(f, 1);// w ww . j ava 2s. co m f.setVisible(true); }
From source file:CascadeDemo.java
public void newFrame() { JInternalFrame jif = new JInternalFrame("Frame " + m_count, true, true, true, true); jif.setBounds(20 * (m_count % 10) + m_tencount * 80, 20 * (m_count % 10), 200, 200); JLabel label = new JLabel(EARTH); jif.getContentPane().add(new JScrollPane(label)); m_desktop.add(jif);// w w w . ja v a 2 s . c om try { jif.setSelected(true); } catch (PropertyVetoException pve) { System.out.println("Could not select " + jif.getTitle()); } m_count++; if (m_count % 10 == 0) { if (m_tencount < 3) m_tencount++; else m_tencount = 0; } }
From source file:InternalFrameListenerDemo.java
public void newFrame() { JInternalFrame jif = new JInternalFrame("Frame " + m_count, true, true, true, true); jif.addInternalFrameListener(this); jif.setBounds(20 * (m_count % 10) + m_tencount * 80, 20 * (m_count % 10), 200, 200); JLabel label = new JLabel(); label.setBackground(Color.white); label.setOpaque(true);//from w w w .ja v a 2 s.co m jif.getContentPane().add(label); m_desktop.add(jif); try { jif.setSelected(true); } catch (PropertyVetoException pve) { System.out.println("Could not select " + jif.getTitle()); } m_count++; if (m_count % 10 == 0) { if (m_tencount < 3) m_tencount++; else m_tencount = 0; } }
From source file:DesktopManagerDemo.java
public void newFrame() { JInternalFrame jif = new JInternalFrame("Frame " + m_count, true, true, true, true); jif.setBounds(20 * (m_count % 10) + m_tencount * 80, 20 * (m_count % 10), 200, 200); JLabel label = new JLabel(); label.setBackground(Color.white); label.setOpaque(true);// w w w . j ava2 s .c om jif.getContentPane().add(label); m_desktop.add(jif); try { jif.setSelected(true); } catch (PropertyVetoException pve) { System.out.println("Could not select " + jif.getTitle()); } m_count++; if (m_count % 10 == 0) { if (m_tencount < 3) m_tencount++; else m_tencount = 0; } }
From source file:JavaXWin.java
public void newFrame() { JInternalFrame jif = new JInternalFrame("Frame " + m_count, true, true, true, true); jif.setBounds(20 * (m_count % 10) + m_tencount * 80, 20 * (m_count % 10), 200, 200); JTextArea text = new JTextArea(); JScrollPane scroller = new JScrollPane(); scroller.getViewport().add(text);/*from w w w .j a v a 2 s. co m*/ try { FileReader fileStream = new FileReader(""); text.read(fileStream, "JavaLinux.txt"); } catch (Exception e) { text.setText("* Could not read JavaLinux.txt *"); } jif.getContentPane().add(scroller); m_desktop.add(jif); try { jif.setSelected(true); } catch (PropertyVetoException pve) { System.out.println("Could not select " + jif.getTitle()); } m_count++; if (m_count % 10 == 0) { if (m_tencount < 3) m_tencount++; else m_tencount = 0; } }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
protected JInternalFrame createFrame() { JInternalFrame frame = new JInternalFrame("Some frame"); frame.setBounds(30, 30, 300, 300); frame.setTitle("Some frame"); frame.setVisible(true);//from w w w. java2 s . com return frame; }
From source file:mondrian.gui.Workbench.java
private void newQueryMenuItemActionPerformed(ActionEvent evt) { JMenuItem schemaMenuItem = schemaWindowMap.get(desktopPane.getSelectedFrame()); final JInternalFrame jf = new JInternalFrame(); jf.setTitle(getResourceConverter().getString("workbench.new.MDXQuery.title", "MDX Query")); QueryPanel qp = new QueryPanel(this); jf.getContentPane().add(qp);//from w ww. ja v a 2 s .c o m jf.setBounds(0, 0, 500, 480); jf.setClosable(true); jf.setIconifiable(true); jf.setMaximizable(true); jf.setResizable(true); jf.setVisible(true); desktopPane.add(jf); jf.show(); try { jf.setSelected(true); } catch (Exception ex) { // do nothing LOGGER.error("newQueryMenuItemActionPerformed.setSelected", ex); } // add the mdx frame to this set of mdx frames for cascading method mdxWindows.add(jf); // create mdx menu item final javax.swing.JMenuItem queryMenuItem = new javax.swing.JMenuItem(); queryMenuItem.setText(getResourceConverter().getFormattedString("workbench.new.MDXQuery.menuitem", "{0} MDX", Integer.toString(windowMenuMapIndex))); queryMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { if (jf.isIcon()) { jf.setIcon(false); } else { jf.setSelected(true); } } catch (Exception ex) { LOGGER.error("queryMenuItem", ex); } } }); // disable mdx frame close operation to provide our handler // to remove frame object from mdxframeset before closing jf.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); jf.addInternalFrameListener(new InternalFrameAdapter() { public void internalFrameClosing(InternalFrameEvent e) { mdxWindows.remove(jf); jf.dispose(); // follow this by removing file from schemaWindowMap windowMenu.remove(queryMenuItem); return; } }); windowMenu.add(queryMenuItem, -1); windowMenu.add(jSeparator3, -1); windowMenu.add(cascadeMenuItem, -1); windowMenu.add(tileMenuItem, -1); windowMenu.add(minimizeMenuItem, -1); windowMenu.add(maximizeMenuItem, -1); windowMenu.add(closeAllMenuItem, -1); qp.setMenuItem(queryMenuItem); qp.setSchemaWindowMap(schemaWindowMap); qp.setWindowMenuIndex(windowMenuMapIndex++); if (schemaMenuItem != null) { qp.initConnection(schemaMenuItem.getText()); } else { JOptionPane.showMessageDialog(this, getResourceConverter().getString("workbench.new.MDXQuery.no.selection", "No Mondrian connection. Select a Schema to connect."), getResourceConverter().getString("workbench.new.MDXQuery.no.selection.title", "Alert"), JOptionPane.WARNING_MESSAGE); } }
From source file:mondrian.gui.Workbench.java
private void aboutMenuItemActionPerformed(ActionEvent evt) { try {/*from w ww . ja v a 2 s . co m*/ JEditorPane jEditorPane = new JEditorPane( myClassLoader.getResource(getResourceConverter().getGUIReference("version")).toString()); jEditorPane.setEditable(false); JScrollPane jScrollPane = new JScrollPane(jEditorPane); JPanel jPanel = new JPanel(); jPanel.setLayout(new java.awt.BorderLayout()); jPanel.add(jScrollPane, java.awt.BorderLayout.CENTER); JInternalFrame jf = new JInternalFrame(); jf.setTitle("About"); jf.getContentPane().add(jPanel); Dimension screenSize = this.getSize(); int aboutW = 400; int aboutH = 300; int width = (screenSize.width / 2) - (aboutW / 2); int height = (screenSize.height / 2) - (aboutH / 2) - 100; jf.setBounds(width, height, aboutW, aboutH); jf.setClosable(true); desktopPane.add(jf); jf.setVisible(true); jf.show(); } catch (Exception ex) { LOGGER.error("aboutMenuItemActionPerformed", ex); } }