List of usage examples for javax.swing JInternalFrame JInternalFrame
public JInternalFrame(String title, boolean resizable, boolean closable, boolean maximizable, boolean iconifiable)
JInternalFrame
with the specified title, resizability, closability, maximizability, and iconifiability. 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()); }/*w ww .j a v a 2 s .com*/ 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: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);/* w w w . j a v a2 s .c o 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:InternalFrameEventDemo.java
protected void createDisplayWindow() { JButton b1 = new JButton("Show internal frame"); b1.setActionCommand(SHOW);//from w w w . java 2 s . c om b1.addActionListener(this); JButton b2 = new JButton("Clear event info"); b2.setActionCommand(CLEAR); b2.addActionListener(this); display = new JTextArea(3, 30); display.setEditable(false); JScrollPane textScroller = new JScrollPane(display); // Have to supply a preferred size, or else the scroll // area will try to stay as large as the text area. textScroller.setPreferredSize(new Dimension(200, 75)); textScroller.setMinimumSize(new Dimension(10, 10)); displayWindow = new JInternalFrame("Event Watcher", true, // resizable false, // not closable false, // not maximizable true); // iconifiable JPanel contentPane = new JPanel(); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); b1.setAlignmentX(CENTER_ALIGNMENT); contentPane.add(b1); contentPane.add(Box.createRigidArea(new Dimension(0, 5))); contentPane.add(textScroller); contentPane.add(Box.createRigidArea(new Dimension(0, 5))); b2.setAlignmentX(CENTER_ALIGNMENT); contentPane.add(b2); displayWindow.setContentPane(contentPane); displayWindow.pack(); displayWindow.setVisible(true); }
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 ww w .jav a 2 s . c om*/ 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:InternalFrameEventDemo.java
protected void createDisplayWindow() { JButton b1 = new JButton("Show internal frame"); b1.setActionCommand(SHOW);/*from w w w .j a va2 s .c o m*/ b1.addActionListener(this); JButton b2 = new JButton("Clear event info"); b2.setActionCommand(CLEAR); b2.addActionListener(this); display = new JTextArea(3, 30); display.setEditable(false); JScrollPane textScroller = new JScrollPane(display); //Have to supply a preferred size, or else the scroll //area will try to stay as large as the text area. textScroller.setPreferredSize(new Dimension(200, 75)); textScroller.setMinimumSize(new Dimension(10, 10)); displayWindow = new JInternalFrame("Event Watcher", true, //resizable false, //not closable false, //not maximizable true); //iconifiable JPanel contentPane = new JPanel(); contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); b1.setAlignmentX(CENTER_ALIGNMENT); contentPane.add(b1); contentPane.add(Box.createRigidArea(new Dimension(0, 5))); contentPane.add(textScroller); contentPane.add(Box.createRigidArea(new Dimension(0, 5))); b2.setAlignmentX(CENTER_ALIGNMENT); contentPane.add(b2); displayWindow.setContentPane(contentPane); displayWindow.pack(); displayWindow.setVisible(true); }
From source file:Controlador.ControladorLecturas.java
public JInternalFrame graficoTemperatura() { DefaultCategoryDataset defaultCategoryDataset = new DefaultCategoryDataset(); for (Object row : vectorTemperatura()) { int grados = Integer.parseInt(((Vector) row).elementAt(0).toString()); String rowKey = "Sensor 1"; String columnKey = ((Vector) row).elementAt(1).toString(); defaultCategoryDataset.addValue(grados, rowKey, columnKey); }// w ww. j a v a 2 s . com JFreeChart jFreeChart = ChartFactory.createLineChart(null, "Hora", "Grados", defaultCategoryDataset, PlotOrientation.VERTICAL, true, true, true); ChartPanel chartPanel = new ChartPanel(jFreeChart); JInternalFrame jInternalFrame = new JInternalFrame("Grafico de Temperatura Ambiental", true, true, true, true); jInternalFrame.add(chartPanel, BorderLayout.CENTER); jInternalFrame.pack(); return jInternalFrame; }
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 ww w . ja v 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:InternalFrameTest.java
/** * Creates an internal frame on the desktop. * @param c the component to display in the internal frame * @param t the title of the internal frame. *///ww w. j a va 2 s. com public void createInternalFrame(Component c, String t) { final JInternalFrame iframe = new JInternalFrame(t, true, // resizable true, // closable true, // maximizable true); // iconifiable iframe.add(c, BorderLayout.CENTER); desktop.add(iframe); iframe.setFrameIcon(new ImageIcon("document.gif")); // add listener to confirm frame closing iframe.addVetoableChangeListener(new VetoableChangeListener() { public void vetoableChange(PropertyChangeEvent event) throws PropertyVetoException { String name = event.getPropertyName(); Object value = event.getNewValue(); // we only want to check attempts to close a frame if (name.equals("closed") && value.equals(true)) { // ask user if it is ok to close int result = JOptionPane.showInternalConfirmDialog(iframe, "OK to close?", "Select an Option", JOptionPane.YES_NO_OPTION); // if the user doesn't agree, veto the close if (result != JOptionPane.YES_OPTION) throw new PropertyVetoException("User canceled close", event); } } }); // position frame int width = desktop.getWidth() / 2; int height = desktop.getHeight() / 2; iframe.reshape(nextFrameX, nextFrameY, width, height); iframe.show(); // select the frame--might be vetoed try { iframe.setSelected(true); } catch (PropertyVetoException e) { } frameDistance = iframe.getHeight() - iframe.getContentPane().getHeight(); // compute placement for next frame nextFrameX += frameDistance; nextFrameY += frameDistance; if (nextFrameX + width > desktop.getWidth()) nextFrameX = 0; if (nextFrameY + height > desktop.getHeight()) nextFrameY = 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);//from w w w. ja va2 s .c o 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:Controlador.ControladorLecturas.java
public JInternalFrame graficoHumedadAmbiental() { DefaultCategoryDataset defaultCategoryDataset = new DefaultCategoryDataset(); for (Object row : vectorHumedadAmbiental()) { int porcentaje = Integer.parseInt(((Vector) row).elementAt(0).toString()); String rowKey = "Sensor 1"; String columnKey = ((Vector) row).elementAt(1).toString(); defaultCategoryDataset.addValue(porcentaje, rowKey, columnKey); }/*from w w w .j a va2 s .co m*/ JFreeChart jFreeChart = ChartFactory.createLineChart(null, "Hora", "Porcentaje Humedad", defaultCategoryDataset, PlotOrientation.VERTICAL, true, true, true); ChartPanel chartPanel = new ChartPanel(jFreeChart); JInternalFrame jInternalFrame = new JInternalFrame("Grafico de Humedad Ambiental", true, true, true, true); jInternalFrame.add(chartPanel, BorderLayout.CENTER); jInternalFrame.pack(); return jInternalFrame; }