3 Replies Latest reply: Mar 26, 2013 2:36 AM by tanvir ahmed RSS

    what is equivalent of JInternalFrame in JavaFX 2.0?

    tanvir ahmed
      what is equivalent of JInternalFrame in JavaFX 2.0?

      Actually I want to use pure javaFX 2.0 to view report created in iReport 5.0.0.

      I have used java.swing code, and now I want to use pure javaFX 2.0.

      My code in swing is as follows

      /*
      * To change this template, choose Tools | Templates
      * and open the template in the editor.
      */
      package reports;

      import java.awt.BorderLayout;
      import java.awt.Container;
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.SQLException;
      import java.util.HashMap;
      import net.sf.jasperreports.engine.JRException;
      import net.sf.jasperreports.engine.JasperFillManager;
      import net.sf.jasperreports.engine.JasperPrint;
      import net.sf.jasperreports.view.JRViewer;

      /**
      *
      * @author TANVIR AHMED
      */
      public class ReportsViewer extends javax.swing.JInternalFrame {

      /**
      * Creates new form MyiReportViewer
      */
      private ReportsViewer()
      {
      super("Report Viewer",true,true,true,true);

      initComponents();
      setBounds(10,10,600,500);
      setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      }

      public ReportsViewer(String fileName)
      {
      this(fileName,null);
      }
      public ReportsViewer(String fileName,HashMap parameter)
      {
      this();
      try
      {
      /* load the required JDBC driver and create the connection
      here JDBC Type Four Driver for MySQL is used*/
      //Class.forName("com.mysql.jdbc.Driver");
      Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "invoice", "item");
      //Connection con=DriverManager.getConnection("jdbc:mysql://localhost/inventory","root","karim");
      /*(Here the parameter file should be in .jasper extension
      i.e., the compiled report)*/
      JasperPrint print = JasperFillManager.fillReport(
      fileName, parameter, con);
      JRViewer viewer=new JRViewer(print);
      Container c=getContentPane();
      c.setLayout(new BorderLayout());
      c.add(viewer);
      }
      catch(SQLException sqle)
      {
      sqle.printStackTrace();
      }
      catch(JRException jre)
      {
      jre.printStackTrace();
      }
      }
      /**
      * This method is called from within the constructor to initialize the form.
      * WARNING: Do NOT modify this code. The content of this method is always
      * regenerated by the Form Editor.
      */
      @SuppressWarnings("unchecked")
      // <editor-fold defaultstate="collapsed" desc="Generated Code">
      private void initComponents() {

      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 394, Short.MAX_VALUE)
      );
      layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGap(0, 290, Short.MAX_VALUE)
      );

      pack();
      }// </editor-fold>
      // Variables declaration - do not modify
      // End of variables declaration
      }


      and


      /*
      * To change this template, choose Tools | Templates
      * and open the template in the editor.
      */
      package reports;

      import java.beans.PropertyVetoException;

      /**
      *
      * @author TANVIR AHMED
      */
      public class MainUI extends javax.swing.JFrame {

      /**
      * Creates new form MainUI
      */
      public MainUI() {
      super("REPORTS");
      initComponents();
      setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize());
      setDefaultCloseOperation(DISPOSE_ON_CLOSE);
      }


      @SuppressWarnings("unchecked")
      // <editor-fold defaultstate="collapsed" desc="Generated Code">
      private void initComponents() {

      jMenuItem1 = new javax.swing.JMenuItem();
      desktopPane = new javax.swing.JDesktopPane();
      salesTaxInv = new javax.swing.JButton();
      jLabel1 = new javax.swing.JLabel();
      supplyRegister = new javax.swing.JButton();
      PartyLedger = new javax.swing.JButton();
      menuBar = new javax.swing.JMenuBar();

      jMenuItem1.setText("jMenuItem1");

      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

      desktopPane.setBackground(new java.awt.Color(255, 204, 0));
      desktopPane.setBorder(new javax.swing.border.MatteBorder(null));
      desktopPane.setForeground(new java.awt.Color(255, 0, 102));
      desktopPane.setAutoscrolls(true);
      desktopPane.setFont(new java.awt.Font("Bookman Old Style", 0, 14)); // NOI18N
      desktopPane.setPreferredSize(new java.awt.Dimension(1024, 768));

      salesTaxInv.setBackground(new java.awt.Color(255, 255, 255));
      salesTaxInv.setFont(new java.awt.Font("Bookman Old Style", 1, 18)); // NOI18N
      salesTaxInv.setForeground(new java.awt.Color(204, 0, 0));
      salesTaxInv.setText("Sales Tax Invoice");
      salesTaxInv.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      salesTaxInvActionPerformed(evt);
      }
      });
      salesTaxInv.setBounds(20, 53, 200, 31);
      desktopPane.add(salesTaxInv, javax.swing.JLayeredPane.DEFAULT_LAYER);

      jLabel1.setFont(new java.awt.Font("Bookman Old Style", 0, 24)); // NOI18N
      jLabel1.setForeground(new java.awt.Color(50, 72, 255));
      jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
      jLabel1.setText("Invoice System Reports");
      jLabel1.setBounds(0, -1, 1024, 50);
      desktopPane.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

      supplyRegister.setFont(new java.awt.Font("Bookman Old Style", 1, 18)); // NOI18N
      supplyRegister.setForeground(new java.awt.Color(204, 0, 0));
      supplyRegister.setText("Supply Register");
      supplyRegister.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      supplyRegisterActionPerformed(evt);
      }
      });
      supplyRegister.setBounds(20, 100, 200, 30);
      desktopPane.add(supplyRegister, javax.swing.JLayeredPane.DEFAULT_LAYER);

      PartyLedger.setFont(new java.awt.Font("Bookman Old Style", 1, 18)); // NOI18N
      PartyLedger.setForeground(new java.awt.Color(204, 0, 0));
      PartyLedger.setText("Party Ledger");
      PartyLedger.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      PartyLedgerActionPerformed(evt);
      }
      });
      PartyLedger.setBounds(20, 140, 200, 30);
      desktopPane.add(PartyLedger, javax.swing.JLayeredPane.DEFAULT_LAYER);

      setJMenuBar(menuBar);

      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
      );
      layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addComponent(desktopPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
      );

      pack();
      }// </editor-fold>

      private void salesTaxInvActionPerformed(java.awt.event.ActionEvent evt) {                                           
      try
      {
      ReportsViewer myiReportViewer = new ReportsViewer("reports/INV.jasper");
      myiReportViewer.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
      myiReportViewer.setVisible(true);
      desktopPane.add(myiReportViewer);
      myiReportViewer.setSelected(true);
      }
      catch (PropertyVetoException pve)
      {
      pve.printStackTrace();
      }
      }

      private void supplyRegisterActionPerformed(java.awt.event.ActionEvent evt) {                                              
      try
      {
      ReportsViewer myiReportViewer = new ReportsViewer("reports/supplyRegister.jasper");
      myiReportViewer.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
      myiReportViewer.setVisible(true);
      desktopPane.add(myiReportViewer);
      myiReportViewer.setSelected(true);
      }
      catch (PropertyVetoException pve)
      {
      pve.printStackTrace();
      }

      }

      private void PartyLedgerActionPerformed(java.awt.event.ActionEvent evt) {                                           
      try
      {
      ReportsViewer myiReportViewer = new ReportsViewer("reports/CustomerLedger.jasper");
      myiReportViewer.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight());
      myiReportViewer.setVisible(true);
      desktopPane.add(myiReportViewer);
      myiReportViewer.setSelected(true);
      }
      catch (PropertyVetoException pve)
      {
      pve.printStackTrace();
      }
      }

      /**
      * @param args the command line arguments
      */
      public static void main(String args[]) {

      java.awt.EventQueue.invokeLater(new Runnable() {

      public void run() {
      new MainUI().setVisible(true);
      }
      });
      }
      // Variables declaration - do not modify
      private javax.swing.JButton PartyLedger;
      private javax.swing.JDesktopPane desktopPane;
      private javax.swing.JLabel jLabel1;
      private javax.swing.JMenuItem jMenuItem1;
      private javax.swing.JMenuBar menuBar;
      private javax.swing.JButton salesTaxInv;
      private javax.swing.JButton supplyRegister;
      // End of variables declaration
      }

      Best Regards