HELP!!!  Adding JPanel to JPanel (long code sample)

I need some help here. I have been stuck on this for more time than I care to admit. Now this project is due by Monday(tomorrow)! Why does the graph not appear in the tabbed pane "trend report"?? the TrendReport class on line 2131 creates the graph. Line 56 creates an instance. and line 831 adds it to the tabbed pane. everything shows up except the graph.
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import java.text.*;
import java.util.*;
import java.lang.*;
import javax.swing.JPopupMenu;
import javax.swing.JPanel;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.JTable;
import javax.swing.filechooser.*;
/*<br>
*A332IWon Class<br>
*CIS 32 / Cuesta College<br>
*Assignment     3<br>
*Due Date 10-08-03<br>
*<br>
*<br>
*<br> >>>>>>>>> Start filling in your class discription here <<<<<<<<<<<<
        >>>>>>>>> And Start filling in your method discriptions <<<<<<<<<<<
*<br>
*<br>@author<br>
*Chris Hoffman, Michael Krempely, Rudy Kalnin, Scott Thayer and Frank Randise<br>
*@version 10.16<br>
*<br>
*<br>
public class A332IWon extends JFrame
     * Class to handle all data input, output, sorting and display handling.
    private A332IWonEngine engine = new A332IWonEngine();
      * Instance of the inner class "QuickTable" called "quickTabke"
     private QuickTable quickTable = new QuickTable();
      * Instance of the inner class "BasicPayTable" called "basicPayTable"
    private BasicPayTable basicPayTable = new BasicPayTable();
     * Instance of the inner class "TrendReport" called "trendReport"
    private TrendReport trendReport = new TrendReport();       
      * Container that holds all panels, labels, and text fields
     private Container c = getContentPane();
      * The menu bar at the top of the application
     private JMenuBar bar = new JMenuBar();
      * Menu bar header called "File"
     private JMenu menuFile = new JMenu("File");
      * Menu bar header called "Edit"
     private JMenu menuEdit = new JMenu("Edit");
      * Menu bar header called "Reports"
    private JMenu menuReports = new JMenu("Reports");
      * Menu bar header called "Help"
    private JMenu menuHelp = new JMenu("Help");
      * Menu item called "Import" a sub menu item of "menuFile"
     private JMenuItem fileImport = new JMenu("Import");
      * Menu item called "Employee Text File" a sub menu item of "fileImport"
      * which in turn is a sub item of "menuFile"
     private JMenuItem fileEmpTxtFile = new JMenuItem("Employee Text File");
      * Menu item called "Pay Info File" a sub menu item of "fileImport"
      * which in turn is a sub item of "menuFile"
     private JMenuItem filePayInfoFile = new JMenuItem("Pay Info File");
      * Menu item called "Open" a sub menu item of "menuFile"
       private JMenuItem fileOpen = new JMenuItem("Open");
      * Menu item called "Save" a sub menu item of "menuFile"
       private JMenuItem fileSave = new JMenuItem("Save");
      * Menu item called "Exit" a sub menu item of "menuFile"
       private JMenuItem fileExit = new JMenuItem("Exit");
      * Menu item called "Search" a sub menu item of "menuEdit"
      private JMenuItem editSearch = new JMenu("Search");
      * Menu item called "Add/Remove" a sub menu item of "menuEdit"
       private JMenuItem editAddRemove = new JMenuItem("Add/Remove");
      * Menu item called "By ID #" a sub menu item of "editSearch"
      * which in turn is a sub item of "menuEdit"
       private JMenuItem editID = new JMenuItem("By ID #");
      * Menu item called "By name" a sub menu item of "editSearch"
      * which in turn is a sub item of "menuEdit"
       private JMenuItem editName = new JMenuItem("By name");
      * Menu item called "Basic Pay" a sub menu item of "menuReports"
       private JMenuItem repBasicPay = new JMenuItem("Basic Pay");
      * Menu item called "Trend" a sub menu item of "menuReports"
       private JMenuItem repTrend = new JMenuItem("Trend");
      * Menu item called "About" a sub menu item of "menuHelp"
       private JMenuItem helpAbout = new JMenuItem("About");
      * The tabbed pane that holds our table, reports and table editing capabilities
     private JTabbedPane empInfoTabPane = new JTabbedPane();
      * Main panel located in center that holds the tabbed pane "empInfoTabPane"
     private JPanel pCenterMain = new JPanel(new FlowLayout(FlowLayout.LEFT,25,30));
      * Panel that holds the table "table"
     private JPanel pTable = new JPanel(new GridLayout(2,1));
      * Main panel that holds the Basic Pay Report(s)
     private JPanel pBasicPayRep = new JPanel(new FlowLayout(FlowLayout.CENTER,10,20));
      * Main panel that holds the Trend Report(s)
     private JPanel pTrendRep = new JPanel(new FlowLayout(FlowLayout.CENTER,10,10));
      * Panel that holds all the add/remove fields, combo boxes and buttons
     private JPanel pAddRemove = new JPanel(new GridLayout(2,1));
        * Panel and Labels for Basic Pay Report
       private JPanel pBasicPayRepMain = new JPanel(new GridLayout(2,1));
      * Holds the pBasicPayGridLeft and pBasicPayGridRight
     private JPanel pBasicPayRepBot = new JPanel(new FlowLayout(FlowLayout.CENTER));
      * Holds the labels for each report
      * Recent Pay Period Worked, Cumulative Pay, Average Pay
     private JPanel pBasicPayGridLeft = new JPanel(new FlowLayout(FlowLayout.LEFT));
      * Holds all the basic pay report information for
      * Recent Pay Period Worked, Cumulative Pay, Average Pay
     private JPanel pBasicPayGridRight = new JPanel(new FlowLayout(FlowLayout.LEFT,20,0));
      * Displays the total number of employees that worked in the current pay period
     private JLabel txtTotalAllEmployees = new JLabel("0");
      * Displays the total number of Salaried employees that worked in the current pay period
     private JLabel txtTotalSalaried = new JLabel("0");
      * Displays the total number of Hourly employees that worked in the current pay period
     private JLabel txtTotalHourly = new JLabel("0");
      * Displays the total number of Temporary employees that worked in the current pay period
     private JLabel txtTotalTemporary = new JLabel("0");
      * Displays the total number of Contract employees that worked in the current pay period
     private JLabel txtTotalContract = new JLabel("0");
      * Displays the cumulative hourly rate in the current pay period
     private JLabel txtCumHourlyRate = new JLabel("0.00");
      * Displays the cumulative hours workded in the current pay period
       private JLabel txtCumHoursWorked = new JLabel("0");
      * Displays the cumulative gross pay in the current pay period
       private JLabel txtCumGrossPay = new JLabel("0.00");
      * Displays the cumulative tax paid in the current pay period
       private JLabel txtCumTax = new JLabel("0.00");
      * Displays the cumulative net pay in the current pay period
       private JLabel txtCumNetPay = new JLabel("0.00");
      * Displays the average hourly rate in the current pay period
       private JLabel txtAvgHourlyRate = new JLabel("0.00");
      * Displays the average hours workded in the current pay period
       private JLabel txtAvgHoursWorked = new JLabel("0.0");
      * Displays the average gross pay in the current pay period
       private JLabel txtAvgGrossPay = new JLabel("0.00");
      * Displays the average tax paid in the current pay period
       private JLabel txtAvgTax = new JLabel("0.00");
      * Displays the average net pay in the current pay period
       private JLabel txtAvgNetPay = new JLabel("0.00");
      * The table "table" created in the instance "quickTable"
     private JTable table = new JTable(quickTable);
      * The table "table2" created in the instance "BasicPayTable"
     private JTable table2 = new JTable(basicPayTable);
      * Turns the table "table" into a scroll pane
    private JScrollPane scrollpane = new JScrollPane(table);
      * Turns the table "table2" into a scroll pane2
    private JScrollPane scrollpane2 = new JScrollPane(table2);
      * **** Future Button to update the employee information in "table"
    private JButton updateEmplInfo = new JButton("Update");
     * Add button to add an employee
    private JButton bAdd = new JButton("Add");
     * Remove button to remove an employee
     private JButton bRemove = new JButton("Remove");
     * Search by employee ID button
     private JButton bSearchId = new JButton("Search");
     * Search by employee name button
     private     JButton bSearchName = new JButton("Search");
     * Texfield collects an employees ID number
    private JTextField fieldID = new JTextField(6);
     * Texfield collects an employees Last name
     private JTextField fieldLastName = new JTextField(22);
     * Texfield collects an employees First name
     private JTextField fieldFirstName = new JTextField(15);
     * Texfield collects an employees Middle initial
     private JTextField fieldMiddleInitial = new JTextField(1);
     * Texfield collects an employees street address
     private JTextField fieldStreetAddress = new JTextField(22);
     * Texfield collects an employees city lived in
     private JTextField fieldCity = new JTextField(18);
     * Texfield collects an employees state lived in
     private JTextField fieldState = new JTextField(2);
     * Texfield collects an employees zip code
     private JTextField fieldZip = new JTextField(6);
     * Texfield collects an employees hourly rate
     private JTextField fieldHourlyRate = new JTextField("0.00",6);
     * Texfield collects an employees year they started working
     private JTextField fieldYYYY = new JTextField("YYYY",4);
     * Texfield collects an employees ID number to perform a search with
     private JTextField fieldSearchById = new JTextField(6);
     * Texfield collects an employees last name to perform a search with
     private JTextField fieldSearchByLast = new JTextField(22);
     * Texfield collects an employees first name to perform a search with
     private     JTextField fieldSearchByFirst = new JTextField(15);
     * Texfield collects an employees middle initial to perform a search with
     private     JTextField fieldSearchByMiddle = new JTextField(1);
      * Background color designed to mimic Microsofts's default desktop color
     private Color MS = new Color(64,128,128);
     * Color used to simulate a manilla folder
     * <br>Used on the folders
     private Color manilla = new Color(252,220,140);
     * Color a complimenting color to "manilla" and "MS"
     * <br>Used as an accent in the search frames and tabs
     private Color seaFoam = new Color(156,198,172);
     * Color a complimenting color to "manilla" and "MS"
     * <br>Used as an accent in the tabs
     private Color babyBlue = new Color(170,220,238);
     * Color a complimenting color to "manilla" and "MS"
     * <br>Used as an accent in the tabs
     private Color lightPink = new Color(255,204,207);
     * Array of Strings: the 12 months of the year
     private String [] monthMM = {"MM","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug",
                                         "Sep","Oct","Nov","Dec"};
     * Array of Strings: the days of the month
     private String [] dayDD = {"DD","01","02","03","04","05","06","07","08","09","10","11",
                                      "12","13","14","15","16","17","18","19","20","21","22",
                                      "23","24","25","26","27","28","29","30","31"};
     * Array of Strings: employee types
     * <br>"Salaried","Hourly","Temporary","Contract"
     private String [] emplType = {"Emp Type","Salaried","Hourly","Temporary","Contract"};
     * String holds the month by using getSelectedItem()
     private String sMonth = "";
     * String holds the day by using getSelectedItem()
     private String sDay = "";
     * String holds the entire hire date
     private String sHireDate = "";
     * String holds the entire employee address
     private String sEmpAddress = "";
     * Double the horly rate paid to an employee
     private double hourlyRate = 0.0;
     * Drop down combo box displays the months of the year
    private JComboBox listMM = new JComboBox(monthMM);
     * Drop down combo box displays the days of the month
     private JComboBox listDD = new JComboBox(dayDD);
     * Drop down combo box displays the employee types
     private JComboBox listEmplType = new JComboBox(emplType);
     private JPanel pTrendReportMain = new JPanel();
     private JPanel pTrendReport = new JPanel();
     private JPanel pTrendRepMain = new JPanel(new GridLayout(2,1));
     private JPanel pTrendBot = new JPanel(new FlowLayout(FlowLayout.CENTER));
     private JPanel pTrendGridLeft = new JPanel(new FlowLayout(FlowLayout.LEFT));
     private JPanel pTrendGridRight = new JPanel(new FlowLayout(FlowLayout.LEFT,20,0));
     private JButton button, button2;
     private JLabel []JLab = new JLabel[4];
     private JTextField titletxt;
     private JTextField []Text = new JTextField[5];
     private JTextField []labeltxt = new JTextField[5];
     private JLabel txtTrendTotalEmployees = new JLabel("0");
     private JLabel txtTrendCumHourlyRate = new JLabel("0.00");
     private JLabel txtTrendAvgHourlyRate = new JLabel("0.00");
     private JLabel txtTrendTotalSalaried = new JLabel("0");
     private JLabel txtTrendCumHoursWorked = new JLabel("0");
     private JLabel txtTrendAvgHoursWorked = new JLabel("0.0");
     private JLabel txtTrendTotalHourly = new JLabel("0");
     private JLabel txtTrendCumGrossPay = new JLabel("0.00");
     private JLabel txtTrendAvgGrossPay = new JLabel("0.00");
     private JLabel txtTrendTotalTemporary = new JLabel("0");
     private JLabel txtTrendCumTax = new JLabel("0.00");
     private JLabel txtTrendAvgTax = new JLabel("0.00");
     private JLabel txtTrendTotalContract = new JLabel("0");
     private JLabel txtTrendCumNetPay = new JLabel("0.00");
     private JLabel txtTrendAvgNetPay = new JLabel("0.00");
     //Don't know if we can use these yet
     //private JLabel lPayPeriodStart = new JLabel("YYYY MM PP");
     //private JLabel lPayPeriodEnd = new JLabel("YYYY MM PP");
      * Standard constructor
      * <br>Call the main methods required to get the application to start
     public A332IWon(String title)
          super(title);
          menuDialogBar();
          setUpPanels();
          setContainerLayout();
          listenToMenuBar();
          listenToButtons();
          addWindowListener(new CloseWindow());
      * Contains all the ActionListener events associated with the menu bar
     public void listenToMenuBar()
          fileEmpTxtFile.addActionListener(quickTable);
          filePayInfoFile.addActionListener(quickTable);
          fileOpen.addActionListener(quickTable);
          fileSave.addActionListener(quickTable);
          fileExit.addActionListener(quickTable);
          editAddRemove.addActionListener(quickTable);
          editID.addActionListener(quickTable);
          editName.addActionListener(quickTable);
          repBasicPay.addActionListener(quickTable);
          repTrend.addActionListener(quickTable);
          helpAbout.addActionListener(quickTable);
      * Contains all ActionListener events associated with buttons and combo boxes
     public void listenToButtons()
          bAdd.addActionListener(quickTable);
          bRemove.addActionListener(quickTable);
          listMM.addActionListener(quickTable);
          listDD.addActionListener(quickTable);
          listEmplType.addActionListener(quickTable);
          bSearchId.addActionListener(quickTable);
          bSearchName.addActionListener(quickTable);
      * Contains the menu bar, the menus, and all the sub menu items
     public void menuDialogBar()
           JLabel menuShim = new JLabel("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
                                             + "XXXXXXXXXXXXXXXXXXXXXXx12345");
           setJMenuBar(bar);
           bar.add(menuFile);
           bar.add(menuEdit);
           bar.add(menuReports);
           bar.add(menuHelp);
           bar.add(menuShim);
           menuShim.setVisible(false);
           menuFile.add(fileImport);
           fileImport.add(fileEmpTxtFile);
           fileImport.add(filePayInfoFile);
           menuFile.add(fileOpen);
           menuFile.add(fileSave);
           menuFile.add(fileExit);
           menuEdit.add(editAddRemove);
           menuEdit.add(editSearch);
           editSearch.add(editID);
           editSearch.add(editName);
           menuReports.add(repBasicPay);
           menuReports.add(repTrend);
           menuHelp.add(helpAbout);
      * Sets the layout for the container "c" and sets pCenterMain centered in "c"
     public void setContainerLayout()
          c.setLayout(new BorderLayout());
          c.add(pCenterMain, "Center");
      * Sets up the main panels needed at run time
     public void setUpPanels()
          centerMainPanel();
          tabbedPane();
          tabPanels();
          addRemovePanel();
          basicPayReportMain();
          trendReportMain();
      * Sets up the main panel with the tabbed pane "empInfoTabPane"
     public void centerMainPanel()
          pCenterMain.add(empInfoTabPane);
          pCenterMain.setBackground(MS);
      * Sets up the tabbed pane with the table, and eddit block,
      * basic pay report, and trend report
     public void tabbedPane()
         empInfoTabPane.addTab("Employee Information",pTable);
         empInfoTabPane.addTab("Basic Pay Report",pBasicPayRep);
         empInfoTabPane.addTab("Trend Report",pTrendRep);
         //empInfoTabPane.setBackground(manilla);
         //empInfoTabPane.setBackgroundAt(0,manilla);
         empInfoTabPane.setBackgroundAt(0,seaFoam);
         empInfoTabPane.setBackgroundAt(1,lightPink);
         empInfoTabPane.setBackgroundAt(2,babyBlue);
         //AUTO_RESIZE_OFF
         //empInfoTabPane.setEnabledAt(0,false);
      * Sets up the panels in the tabbed pane
     public void tabPanels()
          //JLabel tabTrendRep = new JLabel("This area will show a Trend report");
         JPanel pTableTop = new JPanel(new FlowLayout(FlowLayout.CENTER,20,20));
         JPanel pTableBottom = new JPanel(new FlowLayout(FlowLayout.LEFT));
          scrollpane.setPreferredSize(new Dimension(695,185));
          scrollpane2.setPreferredSize(new Dimension(695,185));
          pTableTop.add(scrollpane);
          pTableBottom.add(pAddRemove);
          pTableTop.setBackground(manilla);
          pTableBottom.setBackground(manilla);
          pTable.add(pTableTop);
          pTable.add(pTableBottom);
          pBasicPayRep.add(pBasicPayRepMain);
         pBasicPayRep.setBackground(manilla);
         pTrendRep.add(pTrendRepMain);
         pTrendRep.setBackground(manilla);
      * Sets up the basic pay report main panel that holds the table and the bottom pay report
     public void basicPayReportMain()
          pBasicPayRepMain.add(scrollpane2);
          pBasicPayRepMain.add(pBasicPayRepBot);
          basicPayRepTotalsPanel();
      * Sets up the basic pay report grid panel under the basic pay report table.
     public void basicPayRepTotalsPanel()
          JPanel pBasicPayLeftRight = new JPanel(new FlowLayout(FlowLayout.CENTER,10,5));
            pBasicPayRepBot.add(pBasicPayLeftRight);
            pBasicPayRepBot.setBackground(manilla);
            pBasicPayLeftRight.add(pBasicPayGridLeft);
            pBasicPayLeftRight.add(pBasicPayGridRight);
            pBasicPayLeftRight.setBackground(manilla);
            basicPayGridLeft();
            basicPayGridRight();
      * Sets up the left grid of the basic pay report grid panel.
     public void basicPayGridLeft()
          JPanel pColumn1 = new JPanel(new GridLayout(10,1));
          JLabel lblTotalEmployees = new JLabel("Recent Pay Period Worked");
          JLabel lblCumulativePay = new JLabel("Cumulative Pay");
          JLabel lblAveragePay = new JLabel("Average Pay");
          JLabel lblShim1 = new JLabel("X");
          JLabel lblShim2 = new JLabel("X");
          JLabel lblShim3 = new JLabel("X");
          lblShim1.setForeground(manilla);
          lblShim2.setForeground(manilla);
          lblShim3.setForeground(manilla);
          pColumn1.add(lblTotalEmployees);
          pColumn1.add(lblShim1);
          pColumn1.add(new JLabel(" "));
          pColumn1.add(new JLabel(" "));
          pColumn1.add(lblCumulativePay);
          pColumn1.add(lblShim2);
          pColumn1.add(new JLabel(" "));
          pColumn1.add(new JLabel(" "));
          pColumn1.add(lblAveragePay);
          pColumn1.add(lblShim3);
          pColumn1.setBackground(manilla);
          lblTotalEmployees.setForeground(Color.black);
          lblCumulativePay.setForeground(Color.black);
          lblAveragePay.setForeground(Color.black);
          pBasicPayGridLeft.add(pColumn1);
          pBasicPayGridLeft.setBackground(manilla);
      * Sets up the right grid of the basic pay report grid panel.
      * <br>This is one narly method
     public void basicPayGridRight()
          JPanel pColumn1 = new JPanel(new GridLayout(10,1));
          JPanel pColumn2 = new JPanel(new GridLayout(10,1));
          JPanel pColumn3 = new JPanel(new GridLayout(10,1));
          JPanel pColumn4 = new JPanel(new GridLayout(10,1));
          JPanel pColumn5 = new JPanel(new GridLayout(10,1));
            JLabel lblTotalEmployees = new JLabel("Employees");
            JLabel lblTotalSalaried = new JLabel("Salaried");
            JLabel lblTotalHourly = new JLabel("Hourly");
            JLabel lblTotalTemporary = new JLabel("Temporary");
            JLabel lblTotalContract = new JLabel("Contract");
            JLabel lblCumHourlyRate = new JLabel("Pay Rate");
            JLabel lblCumHoursWorked = new JLabel("Hours Worked");
            JLabel lblCumGrossPay = new JLabel("Gross Pay");
            JLabel lblCumTax = new JLabel("Flat Tax 15%");
            JLabel lblCumNetPay = new JLabel("Net Pay");
            JLabel lblAvgHourlyRate = new JLabel("Pay Rate");
            JLabel lblAvgHoursWorked = new JLabel("Hours Worked");
            JLabel lblAvgGrossPay = new JLabel("Gross Pay");
            JLabel lblAvgTax = new JLabel("Flat Tax 15%");
            JLabel lblAvgNetPay = new JLabel("Net Pay");
          pColumn1.add(lblTotalEmployees);
          pColumn1.add(txtTotalAllEmployees);
          pColumn1.add(new JLabel(" "));
          pColumn1.add(new JLabel(" "));
          pColumn1.add(lblCumHourlyRate);
          pColumn1.add(txtCumHourlyRate);
          pColumn1.add(new JLabel(" "));
          pColumn1.add(new JLabel(" "));
          pColumn1.add(lblAvgHourlyRate);
          pColumn1.add(txtAvgHourlyRate);
          pColumn1.setBackground(manilla);
          lblTotalEmployees.setForeground(Color.black);
          txtTotalAllEmployees.setForeground(Color.black);
          lblCumHourlyRate.setForeground(Color.black);
          txtCumHourlyRate.setForeground(Color.black);
          lblAvgHourlyRate.setForeground(Color.black);
          txtAvgHourlyRate.setForeground(Color.black);
          pColumn2.add(lblTotalSalaried);
          pColumn2.add(txtTotalSalaried);
          pColumn2.add(new JLabel(" "));
          pColumn2.add(new JLabel(" "));
          pColumn2.add(lblCumHoursWorked);
          pColumn2.add(txtCumHoursWorked);
          pColumn2.add(new JLabel(" "));
          pColumn2.add(new JLabel(" "));
          pColumn2.add(lblAvgHoursWorked);
          pColumn2.add(txtAvgHoursWorked);
          pColumn2.setBackground(manilla);
          lblTotalSalaried.setForeground(Color.black);
          txtTotalSalaried.setForeground(Color.black);
          lblCumHoursWorked.setForeground(Color.black);
          txtCumHoursWorked.setForeground(Color.black);
          lblAvgHoursWorked.setForeground(Color.black);
          txtAvgHoursWorked.setForeground(Color.black);
          pColumn3.add(lblTotalHourly);
          pColumn3.add(txtTotalHourly);
          pColumn3.add(new JLabel(" "));
          pColumn3.add(new JLabel(" "));
          pColumn3.add(lblCumGrossPay);
          pColumn3.add(txtCumGrossPay);
          pColumn3.add(new JLabel(" "));
          pColumn3.add(new JLabel(" "));
          pColumn3.add(lblAvgGrossPay);
          pColumn3.add(txtAvgGrossPay);
          pColumn3.setBackground(manilla);
          lblTotalHourly.setForeground(Color.black);
          txtTotalHourly.setForeground(Color.black);
          lblCumGrossPay.setForeground(Color.black);
          txtCumGrossPay.setForeground(Color.black);
          lblAvgGrossPay.setForeground(Color.black);
          txtAvgGrossPay.setForeground(Color.black);
          pColumn4.add(lblTotalTemporary);
          pColumn4.add(txtTotalTemporary);
          pColumn4.add(new JLabel(" "));
          pColumn4.add(new JLabel(" "));
          pColumn4.add(lblCumTax);
          pColumn4.add(txtCumTax);
          pColumn4.add(new JLabel(" "));
          pColumn4.add(new JLabel(" "));
          pColumn4.add(lblAvgTax);
          pColumn4.add(txtAvgTax);
          pColumn4.setBackground(manilla);
          lblTotalTemporary.setForeground(Color.black);
          txtTotalTemporary.setForeground(Color.black);
          lblCumTax.setForeground(Color.black);
          txtCumTax.setForeground(Color.black);
          lblAvgTax.setForeground(Color.black);
          txtAvgTax.setForeground(Color.black);
          pColumn5.add(lblTotalContract);
          pColumn5.add(txtTotalContract);
          pColumn5.add(new JLabel(" "));
          pColumn5.add(new JLabel(" "));
          pColumn5.add(lblCumNetPay);
          pColumn5.add(txtCumNetPay);
          pColumn5.add(new JLabel(" "));
          pColumn5.add(new JLabel(" "));
          pColumn5.add(lblAvgNetPay);
          pColumn5.add(txtAvgNetPay);
          pColumn5.setBackground(manilla);
          lblTotalContract.setForeground(Color.black);
          txtTotalContract.setForeground(Color.black);
          lblCumNetPay.setForeground(Color.black);
          txtCumNetPay.setForeground(Color.black);
          lblAvgNetPay.setForeground(Color.black);
          txtAvgNetPay.setForeground(Color.black);
          pBasicPayGridRight.add(pColumn1);
          pBasicPayGridRight.add(pColumn2);
          pBasicPayGridRight.add(pColumn3);
          pBasicPayGridRight.add(pColumn4);
          pBasicPayGridRight.add(pColumn5);
          pBasicPayGridRight.setBackground(manilla);
      * Sets up the trend report main panel that holds the graph and the bottom trend report
     public void trendReportMain()//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
          //pTrendReportMain.add(trendReport);// changed pTrendReport to trendReport
          pTrendRepMain.add(trendReport);//changed pTrendRepMain to trendReport
          pTrendRepMain.add(pTrendBot);
          trendReportTotalsPanel();
     public void trendReportTotalsPanel()
          JPanel pTrendLeftRight = new JPanel(new FlowLayout(FlowLayout.CENTER,10,5));
            pTrendBot.add(pTrendLeftRight);
            pTrendBot.setBackground(manilla);
            pTrendLeftRight.add(pTrendGridLeft);
            pTrendLeftRight.add(pTrendGridRight);
            pTrendLeftRight.setBackground(manilla);
            trendReportLeft();
            trendReportRight();
     public void trendReportLeft()
          JPanel pColumn1 = new JPanel(new GridLayout(10,1));
          JLabel lblTotalEmployees = new JLabel("Recent Pay Period Worked");
          JLabel lblCumulativePay = new JLabel("Cumulative Pay Info");
          JLabel lblAveragePay = new JLabel("Average Pay Info");
          JLabel lblShim1 = new JLabel("X");
          JLabel lblShim2 = new JLabel("X");
          JLabel lblShim3 = new JLabel("X");
          lblShim1.setForeground(manilla);
          lblShim2.setForeground(manilla);
          lblShim3.setForeground(manilla);
          pColumn1.add(lblTotalEmployees);
          pColumn1.add(lblShim1);
          pColumn1.add(new JLabel(" "));
          pColumn1.add(new JLabel(" "));
          pColumn1.add(lblCumulativePay);
          pColumn1.add(lblShim2);
          pColumn1.add(new JLabel(" "));
          pColumn1.add(new JLabel(" "));
          pColumn1.add(lblAveragePay);
          pColumn1.add(lblShim3);
          pColumn1.setBackground(manilla);
          lblTotalEmployees.setForeground(Color.black);
          lblCumulativePay.setForeground(Color.black);
          lblAveragePay.setForeground(Color.black);
          pTrendGridLeft.add(pColumn1);
          pTrendGridLeft.setBackground(manilla);
     public void trendReportRight()
          JPanel pColumn1 = new JPanel(new GridLayout(10,1));
          JPanel pColumn2 = new JPanel(new GridLayout(10,1));
          JPanel pColumn3 = new JPanel(new GridLayout(10,1));
          JPanel pColumn4 = new JPanel(new GridLayout(10,1));
          JPanel pColumn5 = new JPanel(new GridLayout(10,1));
            JLabel lblTotalEmployees = new JLabel("Employees");
            JLabel lblTotalSalaried = new JLabel("Salaried");
            JLabel lblTotalHourly = new JLabel("Hourly");
            JLabel lblTotalTemporary = new JLabel("Temporary");
            JLabel lblTotalContract = new JLabel("Contract");
            JLabel lblCumHourlyRate = new JLabel("Pay Rate");
            JLabel lblCumHoursWorked = new JLabel("Hours Worked");
            JLabel lblCumGrossPay = new JLabel("Gross Pay");
            JLabel lblCumTax = new JLabel("Flat Tax 15%");
            JLabel lblCumNetPay = new JLabel("Net Pay");
            JLabel lblAvgHourlyRate = new JLabel("Pay Rate");
            JLabel lblAvgHoursWorked = new JLabel("Hours Worked");
            JLabel lblAvgGrossPay = new JLabel("Gross Pay");
            JLabel lblAvgTax = new JLabel("Flat Tax 15%");
            JLabel lblAvgNetPay = new JLabel("Net Pay");
          pColumn1.add(lblTotalEmployees);
          pColumn1.add(txtTrendTotalEmployees);     //txtTrendTotalEmployees
          pColumn1.add(new JLabel                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            &n

This class declaration won't do for loading into a JTabbedPane
public class TrendReport extends JFrame implements ActionListener {Try this in it's place
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TrendRx {
  public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    TrendReport trendReport = new TrendReport();
    f.getContentPane().add(trendReport);
    f.setSize(500,300);
    f.setLocation(100,100);
    f.setVisible(true);
class TrendReport extends JPanel implements ActionListener {
  int width;
  int height;
  JButton button;
  int []bar = new int[4];
  float []flote = {1395,1296,1402,1522};
  String []valuesInput = {"1395","1296","1402","1522"};
  String str = "", title="Title goes here";
  String []barLabels = {
    "pp01, Oct. 2003","pp02, Oct. 2003","pp01, Nov. 2003","pp02, Nov. 2003"
  String []percent = {"","","",""};
  JLabel []JLab = new JLabel[4];
  JTextField titletxt;
  JTextField []Text = new JTextField[5];
  JTextField []labeltxt = new JTextField[5];
  boolean pieChart;
  public TrendReport() {
    setOpaque(false);
    setLayout(new FlowLayout() );
    button = new JButton("Bar TrendReport");
    button.addActionListener(this);
//    for (int k=0; k<4; k++){
//      str = Integer.toString(k+1);
    add(button);
  public void paintComponent(Graphics g) {
    width = getWidth();
    height = getHeight();
    Graphics2D g2 = (Graphics2D)g;                    
    g2.setColor(new Color(223,222,224));
    g2.fillRect(0,0,width,height);
    g2.setColor(Color.orange);
    if(pieChart) {
      g2.fillArc(getW(30), getH(130), getW(220), getH(220), 90, -bar[0]);
      g2.fillRect(getW(270), getH(170), getW(30), getH(20));
    else
      g2.fillRect(getW(30), getH(150), getW(bar[0]), getH(30));
    g2.setColor(Color.green);
    if(pieChart) {
      g2.fillArc(getW(30), getH(130), getW(220), getH(220), 90-bar[0], -bar[1]);
      g2.fillRect(getW(270), getH(210), getW(30), getH(20));
    else
      g2.fillRect(getW(30), getH(190), getW(bar[1]), getH(30));
    g2.setColor(Color.red);
    if(pieChart) {
      g2.fillArc(getW(30), getH(130), getW(220), getH(220),
                 90-(bar[0]+bar[1]), -bar[2]);
      g2.fillRect(getW(270), getH(250), getW(30), getH(20));
    else
      g2.fillRect(getW(30), getH(230), getW(bar[2]), getH(30));
    g2.setColor(Color.blue);
    if(pieChart) {
      g2.fillArc(getW(30), getH(130), getW(220), getH(220),
                 90-(bar[0]+bar[1]+bar[2]), -bar[3]);
      g2.fillRect(getW(270), getH(290), getW(30), getH(20));
    else
      g2.fillRect(getW(30), getH(270), getW(bar[3]), getH(30));
    g2.setColor(Color.black);
    g2.setFont(new Font("Arial", Font.BOLD, 18));
    if(pieChart)
      g2.drawString(title, getW(220), getH(142));
    else
      g2.drawString(title, getW(50), getH(132));
    g2.setFont(new Font("Arial", Font.PLAIN,16));
    int temp=0;
    if(pieChart)
      temp = 185;
    else
      temp = 172;
    for(int j=0; j <4; j++) {
      if(pieChart)
        g2.drawString("$"+valuesInput[j]+" "+barLabels[j]+percent[j],
                      getW(305), getH(temp));//XXXXXXXXXXXXXXX
      else
        g2.drawString("$"+valuesInput[j]+" "+barLabels[j]+percent[j],
                      getW(bar[j]+40), getH(temp));
      temp += 40;
    if(!pieChart){
      g2.drawLine(getW(30), getH(130), getW(30), getH(300));
      g2.drawLine(getW(30), getH(300), getW(430), getH(300));               
      g2.setFont(new Font("Arial", Font.PLAIN,12));
    super.paintComponent(g2);
  private int getW(int dx) {
    return (dx * width) / 550;
  private int getH(int dy) {
    return (dy * height) / 400;
  public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    if(command.equals("Bar TrendReport")){
      button.setText("Pie Chart");
      pieChart=false;
      try {
        int temp =0;
        java.text.DecimalFormat df = new java.text.DecimalFormat("#0.#");
        for (int j=0; j<4; j++){
          //flote[j] = Float.parseFloat(Text[j].getText());//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
          temp += (int)((flote[j]) +0.5);
        for (int k=0; k<4; k++){
          bar[k] = (int)(((flote[k]/temp) * 360)+0.5);
          //barLabels[k] = labeltxt[k].getText();XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
          flote[k] = (flote[k]/temp) *100;
          percent[k] = ": "+df.format(flote[k])+"%";
      catch(Exception message){
        title = "Oops! Complete all fields, enter numbers only";
    if(command.equals("Pie Chart")){
      button.setText("Bar TrendReport");
      pieChart=true;
    repaint();
}

Similar Messages

  • JScrollPane (added to a JPanel, which paints) is visible but does nothing

    Hi. I am writing a program that reads data from files and does paiting using the info. The top level window is a JFrame, which is divided into two parts - A Box which contains the buttons through which the user interacts and a JPanel on which the painting is done. I have added the JPanel to a JScrollPane, but have run into problems there. The JScrollPane is visible (both policies always visible) but it does nothing. I understand that when the drawing is fitting, the ScrollPane is not used. But even if I make the window small or draw something that is not visible in the normal are, the JScrollPane doesn't work. In fact, no knob is visible on either of the two scrollbars. I am pasting the relevant code below:
    //import
    public class MainWindow extends JFrame {
        public static void Main(String[] args) {
            new MainWindow();
        //Declare all the variables here.
        private Box buttionBox;
        private JScrollPane scroller;
        private HelloPanel drawingPanel;   
        //other variables
        //The constructor for the class MainWindow.
        public MainWindow() {
           initComponents();
            this.setLayout(new BorderLayout());
            this.setPreferredSize(new Dimension(900,670));
            //buttonBox containts the buttons - not very relevant to this problem.
            this.getContentPane().add(buttonBox, BorderLayout.WEST);
            //scroller is the JScrollPane
            this.getContentPane().add(scroller, BorderLayout.CENTER);       
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setTitle("My Title");       
            this.setVisible(true);
            this.pack();       
        public void initComponents() {
            buttonBox = Box.createVerticalBox();
            //instantiate the buttons here and add them to the ButtonBox.
            //The event listeners instantiated. Not relevant.       
            //The various components are assigned their appropriate event listeners here.
             //Not relevant.
    //Now adding all the buttons to the box with proper spacing.
            buttonBox.add(Box.createVerticalStrut(20));
            //This is the drawing panel on which the drawing will be done.
            drawingPanel = new HelloPanel();
            scroller = new JScrollPane(drawingPanel);
                    scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            scroller.getHorizontalScrollBar().setUnitIncrement(10);
            scroller.getVerticalScrollBar().setUnitIncrement(10);
        //This inner class is used to define and implement the event listener for handling the checkboxes.
        private class checkBoxListener implements ItemListener{
            public void itemStateChanged(ItemEvent e){
                 drawingPanel.repaint();
                    //Implement actions. Irrelevant
        //This private class is used to define and implement the event listener for the buttons.
        private class buttonListener implements ActionListener {
            //Do this when the button which has an instance of this class as its listener is clicked.       
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() == saveStructureButton){
                  //Implement action. Irrelvant.
        //The panel on which the drawings are done.
        private class HelloPanel extends JPanel {
            //This JPanel is used for drawing the image (for the purpose of saving to disk).
            JComponent c;    //For image. Irrelevant.
            public HelloPanel(){           
                c = this;   //This is necessary for drawing the image to be saved to disk.
                this.setBackground(Color.WHITE);
            //This is the method that actually paints all the drawings whenever a.
            //The shapes theselves can be defined somewhere else, but that paint method must be invoked from here.
            public void paintComponent(Graphics g){
                super.paintComponent(g);    //First of all, clear the panel.
                Graphics2D g2 = (Graphics2D) g;
                g2.fill(new Rectangle2D.Double(40,40,100,100));    //Just for this post.
                g2.drawString("Text", 750, 750);    //To test the scrollpane.
    } I hope this helps you get an idea of what I am trying to do and what the problem might be. Any help would be really appreciated. I have spent hours on this and I have no idea why it doesn't work.
    The actual code is much bigger, so if you need any extra information, please tell me.

    HelloPanel should provide a "public Dimension getPreferredSize()" method.
    With your code you create a simple JPanel and want to draw outside of it, but you never tell the JScrollPane that your HelloPanel is actually bigger than it seems, that's why it does not feel the need to add scroll bars.
    Here's the working code:
    //import
    import javax.swing.*;
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    public class MainWindow extends JFrame {
        public static void main(String[] args) {
            new MainWindow();
        //Declare all the variables here.
        private Box buttionBox;
        private JScrollPane scroller;
        private HelloPanel drawingPanel; 
        //other variables
        //The constructor for the class MainWindow.
        public MainWindow() {
           initComponents();
            this.setLayout(new BorderLayout());
            this.setPreferredSize(new Dimension(900,670));
            //buttonBox containts the buttons - not very relevant to this problem.
            //this.getContentPane().add(buttonBox, BorderLayout.WEST);
            //scroller is the JScrollPane
            this.getContentPane().add(scroller, BorderLayout.CENTER);       
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.setTitle("My Title");       
            this.setVisible(true);
            this.pack();       
        public void initComponents() {
            //buttonBox = Box.createVerticalBox();
            //instantiate the buttons here and add them to the ButtonBox.
            //The event listeners instantiated. Not relevant.       
            //The various components are assigned their appropriate event listeners here.
             //Not relevant.
    //Now adding all the buttons to the box with proper spacing.
            //buttonBox.add(Box.createVerticalStrut(20));
            //This is the drawing panel on which the drawing will be done.
            drawingPanel = new HelloPanel();
            scroller = new JScrollPane(drawingPanel);
                    scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
            scroller.getHorizontalScrollBar().setUnitIncrement(10);
            scroller.getVerticalScrollBar().setUnitIncrement(10);
        //This inner class is used to define and implement the event listener for handling the checkboxes.
        private class checkBoxListener implements ItemListener{
            public void itemStateChanged(ItemEvent e){
                 drawingPanel.repaint();
                    //Implement actions. Irrelevant
        //This private class is used to define and implement the event listener for the buttons.
        private class buttonListener implements ActionListener {
            //Do this when the button which has an instance of this class as its listener is clicked.       
            public void actionPerformed(ActionEvent e) {
                //if (e.getSource() == saveStructureButton){
                  //Implement action. Irrelvant.
        //The panel on which the drawings are done.
        private class HelloPanel extends JPanel {
            //This JPanel is used for drawing the image (for the purpose of saving to disk).
            JComponent c;    //For image. Irrelevant.
            public HelloPanel(){           
                c = this;   //This is necessary for drawing the image to be saved to disk.
                this.setBackground(Color.WHITE);
            //This is the method that actually paints all the drawings whenever a.
            //The shapes theselves can be defined somewhere else, but that paint method must be invoked from here.
            public void paintComponent(Graphics g){
                super.paintComponent(g);    //First of all, clear the panel.
                Graphics2D g2 = (Graphics2D) g;
                g2.fill(new Rectangle2D.Double(40,40,100,100));    //Just for this post.
                g2.drawString("Text", 750, 750);    //To test the scrollpane.
         public Dimension getPreferredSize()
         return new Dimension(750,750);
    }

  • Adding iamge to JPanel but it is not display in it's original size.

    hi,
    I am trying to add Image to JPanel successfully, but it' s visible in panel as a small icon rather then it's original size.
    First i creating a panel class and after that adding this panel to JFrame. I am using BufferedImage. I have tried it all the way but it's not working.Anybody have any idea about the problem.
    Thanks

    rule #1 when you have problem with code: post the code! How do you expect people to help you if you give them nothing but the plea for help?
    rule #2: use the code tags (when you paste your code, select it and press the code button) to format it so it is easy to read.

  • Help with BufferedImage and JPanel

    I have a program that should display some curves, but thats not the problem, the real problem is when i copy the image contained in the JPanel to the buffered image then i draw something there and draw it back to the JPanel. My panel initialy its white but after the operation it gets gray
    Please if some one could help with this
    here is my code divided in three classes
    //class VentanaPrincipal
    package gui;
    import java.awt.BorderLayout;
    import java.awt.FlowLayout;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import javax.swing.BorderFactory;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JSeparator;
    import javax.swing.border.LineBorder;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    * This code was edited or generated using CloudGarden's Jigloo
    * SWT/Swing GUI Builder, which is free for non-commercial
    * use. If Jigloo is being used commercially (ie, by a corporation,
    * company or business for any purpose whatever) then you
    * should purchase a license for each developer using Jigloo.
    * Please visit www.cloudgarden.com for details.
    * Use of Jigloo implies acceptance of these licensing terms.
    * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
    * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
    * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
    public class VentanaPrincipal extends javax.swing.JFrame {
              //Set Look & Feel
              try {
                   javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
              } catch(Exception e) {
                   e.printStackTrace();
         private JMenuItem helpMenuItem;
         private JMenu jMenu5;
         private JMenuItem deleteMenuItem;
         private JSeparator jSeparator1;
         private JMenuItem pasteMenuItem;
         private JLabel jLabel4;
         private JLabel jLabel5;
         private JLabel jLabel3;
         private JLabel jLabel2;
         private JLabel jLabel1;
         private JButton jSPLineButton;
         private JButton jHermiteButton;
         private JButton jBezierButton;
         private JPanel jPanel2;
         private JPanel jPanel1;
         private JMenuItem jResetMenuItem1;
         private JMenuItem copyMenuItem;
         private JMenuItem cutMenuItem;
         private JMenu jMenu4;
         private JMenuItem exitMenuItem;
         private JSeparator jSeparator2;
         private JMenu jMenu3;
         private JMenuBar jMenuBar1;
          * Variables no autogeneradas
         private int botonSeleccionado;
         * Auto-generated main method to display this JFrame
         public static void main(String[] args) {
              VentanaPrincipal inst = new VentanaPrincipal();
              inst.setVisible(true);
         public VentanaPrincipal() {
              super();
              initGUI();
         private void initGUI() {
              try {
                        this.setTitle("Info3 TP 2");
                             jPanel1 = new pizarra();
                             getContentPane().add(jPanel1, BorderLayout.WEST);
                             jPanel1.setPreferredSize(new java.awt.Dimension(373, 340));
                             jPanel1.setMinimumSize(new java.awt.Dimension(10, 342));
                             jPanel1.setBackground(new java.awt.Color(0,0,255));
                             jPanel1.setBorder(BorderFactory.createCompoundBorder(
                                  new LineBorder(new java.awt.Color(0, 0, 0), 1, true),
                                  null));
                             BufferedImage bufimg = (BufferedImage)jPanel1.createImage(jPanel1.getWidth(), jPanel1.getHeight());
                             ((pizarra) jPanel1).setBufferedImage(bufimg);
                             jPanel2 = new JPanel();
                             getContentPane().add(jPanel2, BorderLayout.CENTER);
                             GridBagLayout jPanel2Layout = new GridBagLayout();
                             jPanel2Layout.rowWeights = new double[] {0.0, 0.0, 0.0, 0.0};
                             jPanel2Layout.rowHeights = new int[] {69, 74, 76, 71};
                             jPanel2Layout.columnWeights = new double[] {0.0, 0.0, 0.1};
                             jPanel2Layout.columnWidths = new int[] {83, 75, 7};
                             jPanel2.setLayout(jPanel2Layout);
                                  jBezierButton = new JButton();
                                  jPanel2.add(jBezierButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
                                  jBezierButton.setText("Bezier");
                                  jBezierButton.setFont(new java.awt.Font("Tahoma",0,10));
                                  jBezierButton.addActionListener(new ActionListener() {
                                       public void actionPerformed(ActionEvent evt) {
                                            bezierActionPerformed();
                                  jHermiteButton = new JButton();
                                  jPanel2.add(jHermiteButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
                                  jHermiteButton.setText("Hermite");
                                  jHermiteButton.setFont(new java.awt.Font("Tahoma",0,10));
                                  jSPLineButton = new JButton();
                                  jPanel2.add(jSPLineButton, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
                                  jSPLineButton.setText("SP Line");
                                  jSPLineButton.setFont(new java.awt.Font("Tahoma",0,10));
                                  jLabel1 = new JLabel();
                                  jPanel2.add(jLabel1, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
                                  jLabel1.setText("Posicion Mouse");
                                  jLabel2 = new JLabel();
                                  jPanel2.add(jLabel2, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(12, 0, 0, 0), 0, 0));
                                  jLabel2.setText("X:");
                                  jLabel3 = new JLabel();
                                  jPanel2.add(jLabel3, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 12, 0), 0, 0));
                                  jLabel3.setText("Y:");
                                  jLabel4 = new JLabel();
                                  jPanel2.add(jLabel4, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.NONE, new Insets(12, 0, 0, 0), 0, 0));
                                  jLabel4.setText("-");
                                  jLabel5 = new JLabel();
                                  jPanel2.add(jLabel5, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(0, 0, 12, 0), 0, 0));
                                  jLabel5.setText("-");
                   this.setSize(600, 400);
                        jMenuBar1 = new JMenuBar();
                        setJMenuBar(jMenuBar1);
                             jMenu3 = new JMenu();
                             jMenuBar1.add(jMenu3);
                             jMenu3.setText("Archivo");
                                  jSeparator2 = new JSeparator();
                                  jMenu3.add(jSeparator2);
                                  exitMenuItem = new JMenuItem();
                                  jMenu3.add(exitMenuItem);
                                  exitMenuItem.setText("Exit");
                                  jResetMenuItem1 = new JMenuItem();
                                  jMenu3.add(jResetMenuItem1);
                                  jResetMenuItem1.setText("Reset");
                             jMenu4 = new JMenu();
                             jMenuBar1.add(jMenu4);
                             jMenu4.setText("Edit");
                                  cutMenuItem = new JMenuItem();
                                  jMenu4.add(cutMenuItem);
                                  cutMenuItem.setText("Cut");
                                  copyMenuItem = new JMenuItem();
                                  jMenu4.add(copyMenuItem);
                                  copyMenuItem.setText("Copy");
                                  pasteMenuItem = new JMenuItem();
                                  jMenu4.add(pasteMenuItem);
                                  pasteMenuItem.setText("Paste");
                                  jSeparator1 = new JSeparator();
                                  jMenu4.add(jSeparator1);
                                  deleteMenuItem = new JMenuItem();
                                  jMenu4.add(deleteMenuItem);
                                  deleteMenuItem.setText("Delete");
                             jMenu5 = new JMenu();
                             jMenuBar1.add(jMenu5);
                             jMenu5.setText("Help");
                                  helpMenuItem = new JMenuItem();
                                  jMenu5.add(helpMenuItem);
                                  helpMenuItem.setText("Help");
              } catch (Exception e) {
                   e.printStackTrace();
         private void bezierActionPerformed(){
              botonSeleccionado = 1;
              ((pizarra) jPanel1).setTipoFigura(botonSeleccionado);
              ((pizarra) jPanel1).pintarGrafico();
    //class graphUtils
    package func;
    import java.awt.Image;
    import java.awt.Point;
    import java.awt.image.BufferedImage;
    public class graphUtils {
         public static void dibujarPixel(BufferedImage img, int x, int y, int color){
              img.setRGB(x, y, color);
         public static void dibujarLinea(BufferedImage img, int x0, int y0, int x1, int y1, int color){
            int dx = x1 - x0;
            int dy = y1 - y0;
            if (Math.abs(dx) > Math.abs(dy)) {          // Pendiente m < 1
                float m = (float) dy / (float) dx;     
                float b = y0 - m*x0;
                if(dx < 0) dx = -1; else dx = 1;
                while (x0 != x1) {
                    x0 += dx;
                    dibujarPixel(img, x0, Math.round(m*x0 + b), color);
            } else
            if (dy != 0) {                              // Pendiente m >= 1
                float m = (float) dx / (float) dy;
                float b = x0 - m*y0;
                if(dy < 0) dy = -1; else dy = 1;
                while (y0 != y1) {
                    y0 += dy;
                    dibujarPixel(img, Math.round(m*y0 + b), y0, color);
         public static void dibujarBezier(BufferedImage img, Point puntos, int color){
    //class pizarra
    package gui;
    import javax.swing.*;
    import sun.awt.VerticalBagLayout;
    import sun.security.krb5.internal.bh;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.Point;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.image.BufferedImage;
    import java.util.ArrayList;
    import func.graphUtils;
    * esta clase pizarra extiende la clase JPanel y se agregan las funciones de pintado
    * y rellenado que se muestra en pantalla dentro del panel que se crea con esta clase
    * @author victorg
    public class pizarra extends JPanel implements MouseListener{
         private int tipoFigura;
         BufferedImage bufferImagen;
         Image img;
         Graphics img_gc;
         private Color colorRelleno, colorLinea;
         private Point puntosBezier[] = new Point[3];
         public pizarra(){
              super();          
              addMouseListener(this);
              //this.setBackground(Color.BLUE);
              colorLinea = Color.BLUE;
         public void setTipoFigura(int seleccion){
              // se setea para ver si es bezier, hermite, SP line
              tipoFigura = seleccion;
         public void setTipoRelleno(int seleccion){
         public void setColorRelleno(Color relleno){
              colorRelleno = relleno;          
         public void setColorLinea(Color linea){
              colorLinea = linea;
         public void setBufferedImage(BufferedImage bufimg){
              bufferImagen = bufimg;
         public void pintarGrafico(){
              Graphics g = this.getGraphics();     
              g.setColor(colorLinea);
              //accion ejecutada cuando se selecciona para graficar un poligono
              if(tipoFigura == 1){// bezier
                   if(bufferImagen == null){
                        //mantiene guardada la imagen cuando la pantalla pasa a segundo plano
                        bufferImagen = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
                        this.setBackground(Color.WHITE);                                                  
                        bufferImagen = (BufferedImage)createImage(getWidth(), getHeight());
                        //bufferImagen = this.createImage(getWidth(), getHeight());
                   //g.drawImage(bufferImagen,0,0,this);
                   graphUtils.dibujarLinea(bufferImagen,10, 10, 50, 50, colorLinea.getRGB());
                   g.drawImage(bufferImagen,0,0,this);
         protected void paintComponent(Graphics g) { // llamado al repintar
              //setBackground(colorFondo);
              super.paintComponent(g);
    //          Graphics2D g2 = (Graphics2D)g;          
    //          g2.drawImage(bufferImagen, 0,0, this);          
    //          g2.dispose();     
         public void mouseClicked(MouseEvent arg0) {          
         public void mousePressed(MouseEvent arg0) {
              // TODO Auto-generated method stub
         public void mouseReleased(MouseEvent arg0) {
              // TODO Auto-generated method stub
         public void mouseEntered(MouseEvent arg0) {
              // TODO Auto-generated method stub
         public void mouseExited(MouseEvent arg0) {
              // TODO Auto-generated method stub
    }

    1) Swing related questions should be posted in the Swing forum.
    Custom painting should be done in the paintComponent(..) method. You created a "pintarGraphico" method to do the custom painting, but that method is only execute once. When Java determines that the panel needs to be repainted, the paintComponent() method is executed which simply does a super.paintComponent(), which in turn simply paints the background of the panel overwriting you custom painting.

  • Code Sample: Easy RFC Lookup From XSLT Mappings Using a Java Helper Class

    Hi everyone,
    This is just a shameless plug for my article: <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/05a3d62e-0a01-0010-14bc-adc8efd4ee14">Easy RFC Lookup From XSLT Mappings Using a Java Helper Class</a>. I hope you're interested in reading it, and I welcome your comments in this thread.
    Kind regards,
    Thorsten

    Hi Stefan. Thanks for your post. I have already done that. It still does not work. As a base for my java helper class I have usesd Thorstens code.
    The problem is quite confusing. I will try to ouline both issues here.
    First of all, when try to test from within the Operation Mapping, I always get a java error saying it cannot find the communication channel (it is there and working because I have tested it with the RFCLookup in graphical mapping). I have found a way to work around this, and that is to uncheck the "Use SAP XMLToolkit" checkbox --> switch to test tab, enter my ReceiverService in the parameter tab (header parameter) --> switch back to Definition tab, check the "Use SAP XMLToolkit" checkbox --> switch to Test tab and run the test. Then the XSLT and call to java helper class will work. Of course this is not really something you want to do all the time. Maybe there is a bug.
    Secondly, it never works when I try to do it "live". I am using a file adapter to pick up one file, convert it and a file adapter to drop the converted file. I get the following error code in SXMB_MONI.
    <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    <!--  Request Message Mapping   -->
    <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>Application</SAP:Category>
      <SAP:Code area="MAPPING">TRANSFORMER_CONF_EX</SAP:Code>
      <SAP:P1>ATJ_Accounting2XML_Accounting.xsl</SAP:P1>
      <SAP:P2>http://rd.accounting.logica.com</SAP:P2>
      <SAP:P3>fd552c30-bad9-11dd-9761-c21dac1b818c</SAP:P3>
      <SAP:P4>-1</SAP:P4>
      <SAP:AdditionalText />
      <SAP:Stack>TransformerConfigurationException triggered while loading XSLT mapping ATJ_Accounting2XML_Accounting.xsl; http://rd.accounting.logica.comfd552c30-bad9-11dd-9761-c21dac1b818c-1</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Using an XSLT without a call to a java helper class, works just fine.
    I am totally at a loss here. Any more input would be much appreciated.
    /Patrik

  • JMF code samples?

    Hi,
    I am have just installed JMF and have it working and up and running. I haven't used JMF before and want to learn how program using it! What i want to do is to take a picture from my webcam and save it.
    Are there any library's of code samples or tutorials that anyone can think of that could help me out? Or even books I can read?
    Many Thanks

    I have written a small app that can maybe get you started, its a little rough around the edges but it works :-)
    Code below (BasicWebCam.java):
    If you want the Eclispe project, let me know and I will send it to you.
    import java.awt.Component;
    import java.awt.EventQueue;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import java.io.FileOutputStream;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import javax.media.Buffer;
    import javax.media.CaptureDeviceInfo;
    import javax.media.CaptureDeviceManager;
    import javax.media.Manager;
    import javax.media.MediaLocator;
    import javax.media.Player;
    import javax.media.control.FrameGrabbingControl;
    import javax.media.format.VideoFormat;
    import javax.media.util.BufferToImage;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.border.EmptyBorder;
    import javax.swing.JButton;
    import com.sun.image.codec.jpeg.JPEGCodec;
    import com.sun.image.codec.jpeg.JPEGEncodeParam;
    import com.sun.image.codec.jpeg.JPEGImageEncoder;
    public class BasicWebCam extends JFrame implements ActionListener {
    private JPanel contentPane;
    private JPanel pnlCam = new JPanel();
    public CaptureDeviceInfo captureDeviceInfo;
    public MediaLocator mediaLocator;
    public Player player;
    private Component comp;
    public javax.swing.Timer timer = new javax.swing.Timer(250, (ActionListener) this);
    public Buffer BUF;
    public Image img;
    public BufferToImage BtoI;
    * Launch the application.
    public static void main(String[] args) {
         EventQueue.invokeLater(new Runnable() {
         public void run() {
              try {
              BasicWebCam frame = new BasicWebCam();
              frame.setVisible(true);
              } catch (Exception e) {
              e.printStackTrace();
    * Create the frame.
    public BasicWebCam() {
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         setBounds(100, 100, 353, 327);
         contentPane = new JPanel();
         contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
         setContentPane(contentPane);
         contentPane.setLayout(null);
         pnlCam.setBounds(10, 11, 320, 240);
         contentPane.add(pnlCam);
         JButton btnCapture = new JButton("Capture");
         btnCapture.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent arg0) {
              actionCapture();
         btnCapture.setBounds(124, 262, 89, 23);
         contentPane.add(btnCapture);
         init();
    public void init() {
         String strDevice = "vfw:Microsoft WDM Image Capture (Win32):0";
         mediaLocator = new MediaLocator("vfw://0");
         // FOR LINUX
         // String strDevice = "v4l:Laptop Integrated Webcam:0";
         // mediaLocator = new MediaLocator("v4l://0");
         captureDeviceInfo = CaptureDeviceManager.getDevice(strDevice);
         showVid();
    private void showVid() {
         try {
         player = Manager.createRealizedPlayer(mediaLocator);
         player.start();
         if ((comp = player.getVisualComponent()) != null) {
              comp.setSize(pnlCam.getWidth(), pnlCam.getHeight());
              // comp.setPreferredSize(new Dimension(pnlCapture.getWidth(),
              // pnlCapture.getHeight()));
              pnlCam.add(comp);
         Thread.sleep(5000);
         timer.start(); // start timer
         } catch (Exception e) {
         e.printStackTrace();
    public void actionCapture() {
         // Grab a frame
         // comp.setSize(pnlCapture.getWidth(), pnlCapture.getHeight());
         FrameGrabbingControl fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
         BUF = fgc.grabFrame();
         // Convert it to an image
         BtoI = new BufferToImage((VideoFormat) BUF.getFormat());
         img = BtoI.createImage(BUF);
         // resize
         img = resizeImage(img, pnlCam.getWidth(), pnlCam.getHeight());
         // show the image
         // pnlImage.setImage(img);
         img.getGraphics().drawString(getDateTime("yyyy/MM/dd HH:mm:ss") + " - ColinCoderator", 50, 235);
         // save image
         String fileName = getDateTime("yyyy-MM-dd_HH-mm-ss") + ".jpg";
         String path = "c:/projects/BasicWebCam/" + fileName;
         System.out.println(path);
         // save image
         saveJPG(img, path);
    public static void saveJPG(Image img, String s) {
         BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_RGB);
         Graphics2D g2 = bi.createGraphics();
         g2.drawImage(img, null, null);
         FileOutputStream out = null;
         try {
         out = new FileOutputStream(s);
         } catch (java.io.FileNotFoundException io) {
         System.out.println("File Not Found");
         JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
         JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
         param.setQuality(0.5f, false);
         encoder.setJPEGEncodeParam(param);
         try {
         encoder.encode(bi);
         out.close();
         } catch (java.io.IOException io) {
         System.out.println("IOException");
    public Image resizeImage(Image img, int width, int height) {
         BufferedImage resizedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
         Graphics2D g = resizedImage.createGraphics();
         g.drawImage(img, 0, 0, width, height, null);
         g.dispose();
         return resizedImage;
    public static String getDateTime(String format) {
         DateFormat dateFormat = new SimpleDateFormat(format);
         Calendar cal = Calendar.getInstance();
         return (dateFormat.format(cal.getTime()));
    @Override
    public void actionPerformed(ActionEvent arg0) {
         // TODO Auto-generated method stub
    }

  • Need help.. can someone look at code..

    and tell me what is happening, or rather not happening and
    why....
    This is a neat clock that shows current time and zulu time
    with a disclaimer popup..... Would like to get it working to put on
    my site but can not figure it out.
    It is made up of two files.... first is the html file:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1" />
    <script language-"javascript"
    src="clock.js"></script>
    <!-- InstanceParam name="onloadVal" type="text"
    value="doTime()" -->
    <title>Clock</title>
    </head>
    <body>
    <FORM name=Horloge>
    <TABLE cellSpacing=0 cellPadding=0 width=756
    bgColor=#205670>
    <TBODY>
    <TR>
    <TD height=34><FONT face="Arial, Helvetica,
    sans-serif" color=#ffffcc
    size=-2>Your time </FONT><font face="Arial,
    Helvetica, sans-serif"
    color=#ffffcc size=-1>
    <input value="Not available" name=HreLocale />
    </font></TD>
    <TD height=34><FONT face="Arial, Helvetica,
    sans-serif" color=#ffffcc
    size=-2>UTC time</FONT><font face="Arial,
    Helvetica, sans-serif"
    color=#ffffcc size=-1>
    <input value="Not available" name=HreUTC />
    </font></TD>
    <TD noWrap width=100 height=34>
    <DIV align=center><font color=#ffffcc size=-2>
    <input onclick="MM_popupMsg('Reliable clock times are
    dependant on two sources:\r1. Your computer`s time\r2. Your
    computer`s time zone settings\rPlease verify that both these
    settings are correct before relying on the clock.')" type=button
    value="Clock Disclaimer" name="Clock Disclaimer" />
    </font></DIV></TD>
    <TD noWrap width=67 colSpan=4 height=34>
    <DIV align=center><FONT face="Arial, Helvetica,
    sans-serif" color=#ffffcc
    size=-2></FONT></DIV>
    <DIV align=center><FONT size=+1><A
    href="javascript:seLogger()"><FONT
    face="Arial, Helvetica, sans-serif" color=#ffffcc
    size=-1>Log
    out</FONT></A></FONT></DIV></TD></TR></TBODY></TABLE>
    </form>
    </body>
    </html>
    Then there is a seperate .js file:
    function format(value) {
    if (value < 10) {
    return "0" + value;
    } else {
    return value;
    function putFocus() {
    // Put the cursor in the first text box available
    // or in the specified field with id="init"
    // Params: none
    var f = 0;
    var e = 0;
    var fName;
    if (document.getElementById &&
    document.getElementById('init')) {
    if (document.getElementById('init').type != "hidden") {
    document.getElementById('init').focus();
    } else while (f < document.forms.length &&
    document.forms[f].name != "Horloge") {
    e = 0;
    while (document.forms[f] && e <
    document.forms[f].elements.length) {
    if (document.forms[f].elements[e].type == "text"
    || document.forms[f].elements[e].type == "password") {
    document.forms[f].elements[e].focus();
    fName = document.forms[f].name;
    e=9999;f=9999;
    e++;
    f++;
    function enterAction(obj) {
    // Capture key events at the document level and submit the
    form when the enter key is pressed
    // by a simulated click on the submit button given as
    parameter.
    // Function added by Thierry Husson 2006-05
    // Sample call: <body
    onLoad="enterAction(document.Registered.elements['R-Submit']);">
    if (obj && obj.click) {
    if (document.layers) document.captureEvents(Event.KEYPRESS);
    document.onkeypress = function (evt) {
    var key = document.all ? event.keyCode : evt.which ?
    evt.which : evt.keyCode;
    if (key == 13) {
    obj.click();
    function doTime() {
    months = new Array(12);
    months[0] = "Jan";
    months[1] = "Feb";
    months[2] = "Mar";
    months[3] = "Apr";
    months[4] = "May";
    months[5] = "Jun";
    months[6] = "Jul";
    months[7] = "Aug";
    months[8] = "Sep";
    months[9] = "Oct";
    months[10] = "Nov";
    months[11] = "Dec";
    days = new Array(7);
    days[0] = "Sun";
    days[1] = "Mon";
    days[2] = "Tue";
    days[3] = "Wed";
    days[4] = "Thu";
    days[5] = "Fri";
    days[6] = "Sat";
    strLocalTime = "Your Time: ";
    strUTCTime = "UTC Time: ";
    local = new Date();
    tzOffset = local.getTimezoneOffset()/60;
    localMonth = local.getMonth();
    localDay = local.getDay();
    localDate = local.getDate();
    localYear = local.getYear();
    localHour = local.getHours();
    localMin = local.getMinutes();
    localSec = local.getSeconds();
    UTCDate = new Date(localYear, localMonth, localDate,
    localHour + (tzOffset/1), localMin + ((tzOffset%1)*60), localSec);
    if (localYear < 1900) {
    localYear = 1900 + localYear;
    UTCYear = localYear;
    strLocalTime = format(localDate) + " " + months[localMonth]
    + " " + format(localYear) + " " + localHour + ":" +
    format(localMin) + ":" + format(localSec);
    strUTCTime = format(UTCDate.getDate()) + " " +
    months[UTCDate.getMonth()] + " " + format(UTCYear) + " " +
    UTCDate.getHours() + ":" + format(UTCDate.getMinutes()) + ":" +
    format(UTCDate.getSeconds());
    document.Horloge.HreLocale.value = strLocalTime;
    document.Horloge.HreUTC.value = strUTCTime;
    setTimeout("doTime()", 1000);
    //==============================================================
    // Fonction doAsepTime est basee sur doTime mais modifiee
    pour ne recuperer
    // que les champs utiles soit : AAAA MM JJ HH UTC.
    // Fonction doAsepTime retourne dans :
    // input name="HreAsep value="YYYY MM DD HH" lorsque vide
    (anglais)
    // input name="HreAsep value="AAAA MM JJ HH" lorsque vide
    (francais)
    //==============================================================
    function doAsepTime() {
    // strUTCTime sera retourne a l 'interface (html)
    strUTCTime = "UTC Time: ";
    local = new Date();
    tzOffset = local.getTimezoneOffset()/60;
    AsepLocalMonth = local.getMonth();
    AsepLocalDate = local.getDate();
    AsepLocalYear = local.getYear();
    AsepLocalHour = local.getHours();
    UTCDate = new Date(AsepLocalYear, AsepLocalMonth,
    AsepLocalDate, AsepLocalHour + (tzOffset/1));
    if (AsepLocalYear < 1900) {
    AsepLocalYear = 1900 + AsepLocalYear;
    UTCYear = AsepLocalYear;
    strUTCTime = format(UTCYear) + " " +
    format(UTCDate.getMonth() + 1) + " " + format(UTCDate.getDate()) +
    " " + format(UTCDate.getHours());
    document.Produit.HreAsep.value = strUTCTime;
    // setTimeout("doAsepTime()", 1000);

    Hi. I'm new to Java myself, but I've noticed a few things in your code..you have a bunch of methods inside the braces of your main method, which cannot work. Additional methods must be placed outside the main method, after the ending brace. But actually, if this is a secondary class and these methods will be called from a different class, which it looks to me to be, then you wouldn't need a main method at all. The class variables should go right after the opening brace of the class declaration and then the rest of the methods can be placed after those variables. Try this..
    public class Date
         int day;
         int month;
         int year;
         public Date(int day, int month, int year)
              setDay(day);
              setMonth(month);
              setYear(year);
         public void setDay(int myDay)
              day =myDay;
         public void setMonth(int myMonth)
              month =myMonth;
         public void setYear(int myYear)
              year =myYear;
         public int getDay()
              return day;
         public int getMonth()
              return month;
         public int getYear()
              return year;
         public String displayDate()
              return getMonth() + "/" + getDay() + "/" + getYear();
    Sorry it that's hard to read, I just copied and pasted it, but all I did was eliminate the declaration of the main method, the opening brace, and the closing brace (second to last one at the bottom).
    Hope this helps..Take care.

  • Any code samples for inputting content into content manager 8.1?

    Does anybody know where to find code samples of adding content to the Content Manager
    via the Java API?
    The only code I can find is the "Content Manager Example Portlet" and it is 7.0,
    not 8.1.
    It's not clear from the documentation what the Repository and Path are supposed
    to be named. Perhaps we had a working example, this might help.
    Thanks
    Dave

    Does anybody know where to find code samples of adding content to the Content Manager
    via the Java API?
    The only code I can find is the "Content Manager Example Portlet" and it is 7.0,
    not 8.1.
    It's not clear from the documentation what the Repository and Path are supposed
    to be named. Perhaps we had a working example, this might help.
    Thanks
    Dave

  • Laura, I need some code samples you mentioned...

    Laura,
    I posted a message a few days ago regarding calling Stored Procedures in my JDev 3.1 (JDK 1.2.2) BC4J application. I need to be able to call them two different ways. The first involves passing some parameters to the SP and recieving back the ResultSet. In the other instance I simply need to make a call to them to perform some tasks on the DB side. Nothing will be returned from these SP's. You discussed implementing the SQL as a VO and gave me some code showing me how I might do this. You also mentioned that it is possible to create a method on the AppMod and call this from the JSP client. I need to know which method should work best for me and to get the code samples for the second option.
    Thanks.
    Rob

    Hi,
    Here is the code I used for the custom method on my VO (same could be used from the app module rather than a specific VO). The stored procedure I am calling here performs some calculations and returns an integer value:
    public int getTotalHits(String mon, String year) {
    CallableStatement stmt = null;
    int total;
    String totalhits = "{? = call walkthru.total_hits(?,?)}";
    stmt = getDBTransaction().createCallableStatement(totalhits, 1);
    try
    // Bind the Statement Parameters and Execute this Statement
    stmt.registerOutParameter(1,Types.INTEGER);
    stmt.setString(2,mon);
    stmt.setString(3,year);
    stmt.execute();
    total = stmt.getInt(1);
    catch (Exception ex)
    throw new oracle.jbo.JboException(ex);
    finally
    try
    stmt.close();
    catch (Exception nex)
    return total;
    After adding the custom method to your appmoduleImpl.java file and rebuilt your BC4J project, do the following:
    1. Select the Application Module object and choose Edit from the context menu.
    2. Click on the Client Methods page. You should see the method you added in the Available list.
    3. Select the method and shuttle it to the Selected list.
    4. Click Finish. You should see a new file generated under the application module object node in the Navigator named appmodule.java that contains the client stubs for your method.
    5. Save and rebuild your BC4J project.
    I wrote a custom web bean to use from my JSP page to call the method on my VO:
    public class GetTotals extends oracle.jdeveloper.html.DataWebBeanImpl {
    public void render() {
    int totalhits;
    try
    Row[] rows;
    // Retrieve all records by default, the qView variable is defined in the base class
    qView.setRangeSize(-1);
    qView.first();
    rows = qView.getAllRowsInRange();
    // instantiate a view object for our exported method
    // and call the stored procedure to get the total
    ViewObject vo = qView.getViewObject();
    wtQueryView theView = (wtQueryView) vo;
    totalhits = theView.getTotalHits(session.getValue("m").toString(),session.getValue("y").toString());
    out.println(totalhits);
    } catch(Exception ex)
    throw new RuntimeException(ex.getMessage());
    I just call the render method on this custom web bean from the JSP. I am not passing parameters to the render method of the bean, but instead access the parameters I need from the session:
    session.getValue("m").toString()
    I set these session parameters from the JSP that is called when the user submits their query criteria form. For example:
    // get the view parameter from the form String month = request.getParameter("month");
    String year = request.getParameter("year");
    // store the information for reference later session.putValue("m", month); session.putValue("y", year);
    Hope this helps.

  • Is there a RH standard for formatting code samples?

    In the RH default style sheet, I do not see a pre HTML tag or other tag that will display code samples in a monospaced font.
    I created custom styles for a single line code sample and another style for multiline samples.
    We want our code samples to be shaded. If I shade multiple lines, each line being separated with a paragraph, there is a small amount of
    white space between each line. We do not like this either.
    I then created a custom table style with a single shaded cell. I add my multiline sample code, then I apply the custom paragraph style to get
    the font and spacing between lines that I want.
    Is there a different best practice for this, so that the code sample would be rendered correctly if viewed from other devices that read the HTML and
    may look for the pre HTML tag?
    I am using RoboHelp 9 and I provide the output as Eclipse help. Our help files are integrated into Eclipse help in the Eclipse IDE.
    Thank you.
    Cynthia

    Hi Cynthia
    As much as it pains me to say it, this is one case where using a Form element might be your best bet. I say this because often code samples are used or presented with the intent of copying and pasting into something like Windows Notepad. And if you used the TextArea form element, you can place the code there and make it pretty easy for folks to copy it for use elsewhere.
    I stand to be corrected on this because I am not a "power CSS" person. (meaning I am aware there are complete two and three day classes one might attend on all the nuances of CSS) But RoboHelp won't really do anything to help you a great deal in formatting things. But it might be possible, somehow, to configure CSS to accomplish your goal of making the code look as you want.
    Cheers... Rick

  • Need Help Adding Parameters to addWatermarkFromText using VBA

    After three days of banging my head on a wall, I got this to work:
    Public Sub AddText()
        Dim pdApp As Acrobat.AcroApp
        Dim pdDoc As Acrobat.AcroPDDoc
        Dim jso As Object
        Set pdDoc = CreateObject("AcroExch.PDDoc")
        pdDoc.Open ("c:\Test\Test.pdf")
        Set jso = pdDoc.GetJSObject
        jso.addWatermarkFromText ("Test")
        pdDoc.Save 1, "c:\Test\Test.pdf"
        pdDoc.Close
        Set pdDoc = Nothing
        MsgBox "Done"
    End Sub
    However, every time I try to add parameters to jso.addWatermarkFromText I get an error message - something is wrong with my syntax I suppose but i have tried every example I could find and nothing is working for me.  Please help - all of the default parameters are find, just need the text to be at the top of the page, not the center.

    Where did you get the impression that you can execute JavaScript in Acrobat
    using this method? You really (let me repeat that REALLY) have to read the
    SDK documentation. There no no way around that. Anything that is not
    described in the documentation will not work. There is only one way to
    execute JavaScript using the IAC API, and that is using this call:
    http://livedocs.adobe.com/acrobat_sdk/11/Acrobat11_HTMLHelp/IAC_API_FormsIntro.108.45.html
    However, in this case there is no need to use the executeThisJavaScript
    function, you can use the JSO to add your watermark. Everything you need is
    in the documentation, and as I mentioned before, there is no way around
    reading and understanding the docs. You cannot just google your way through
    a complex problem and try to piece together a solution based on bits and
    pieces you find online. Why do I know this? Because oftentimes I get called
    in after somebody tries that approach to save some money. I then get to
    clean up the mess they made, and then it's not going to be cheap... And
    this is one of the reasons why people are reluctant to provide code samples
    in this forum.
    Using a complex API as the Acrobat SDK requires you to climb a pretty steep
    learning curve, and you have to spend weeks and months (and sometimes
    years) reading and experimenting until you understand how things work. And
    that is why it's usually cheaper and faster to hire somebody to do that
    work for you.
    Back to  your  problem. What have you tried? I only remember seeing your
    call to addWatermarkFromText using just the text argument. BTW: There was
    no need to start a new thread, you should have kept everything in the first
    thread you started, this way everything is in one place. If you've posted
    more in the other thread, then you are making it much harder for us to
    provide help.
    So again, what have you tried and what results have you gotten? What error
    messages did the system produce? When? When you compiled the code, or when
    you tried to execute it?
    Karl Heinz Kremer
    PDF Acrobatics Without a Net
    PDF Software Development, Training and More...
    [email protected]
    http://www.khkonsulting.com
    On Sat, Jul 27, 2013 at 8:31 AM, I Love Mustangs

  • Java Proxy Code Sample

    Hello SAP community. Does anyone have a step-by-step code sample for creating either a jsp or web dynpro application in Netweaver to use a java proxy to connect to XI that will calls a RFC or BAPI in SAP R3?

    Hi
    See the Code sample and pdf help it the SDN samples and tutorials
    https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/f0b0e990-0201-0010-cc96-d7ecd2e51715
    https://www.sdn.sap.com/irj/sdn/developerareas/webdynpro?rid=/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d
    Kind Regards
    Mukesh

  • [svn:osmf:] 11184: Adding new temporal metadata support, including sample app and unit tests.

    Revision: 11184
    Author:   [email protected]
    Date:     2009-10-27 11:08:21 -0700 (Tue, 27 Oct 2009)
    Log Message:
    Adding new temporal metadata support, including sample app and unit tests.
    Added Paths:
        osmf/trunk/apps/samples/framework/CuePointSample/
        osmf/trunk/apps/samples/framework/CuePointSample/.actionScriptProperties
        osmf/trunk/apps/samples/framework/CuePointSample/.flexProperties
        osmf/trunk/apps/samples/framework/CuePointSample/.project
        osmf/trunk/apps/samples/framework/CuePointSample/html-template/
        osmf/trunk/apps/samples/framework/CuePointSample/html-template/AC_OETags.js
        osmf/trunk/apps/samples/framework/CuePointSample/html-template/history/
        osmf/trunk/apps/samples/framework/CuePointSample/html-template/history/history.css
        osmf/trunk/apps/samples/framework/CuePointSample/html-template/history/history.js
        osmf/trunk/apps/samples/framework/CuePointSample/html-template/history/historyFrame.html
        osmf/trunk/apps/samples/framework/CuePointSample/html-template/index.template.html
        osmf/trunk/apps/samples/framework/CuePointSample/html-template/playerProductInstall.swf
        osmf/trunk/apps/samples/framework/CuePointSample/libs/
        osmf/trunk/apps/samples/framework/CuePointSample/src/
        osmf/trunk/apps/samples/framework/CuePointSample/src/CuePointSample.css
        osmf/trunk/apps/samples/framework/CuePointSample/src/CuePointSample.mxml
        osmf/trunk/framework/MediaFramework/org/osmf/metadata/TemporalFacet.as
        osmf/trunk/framework/MediaFramework/org/osmf/metadata/TemporalFacetEvent.as
        osmf/trunk/framework/MediaFramework/org/osmf/metadata/TemporalIdentifier.as
        osmf/trunk/framework/MediaFramework/org/osmf/video/CuePoint.as
        osmf/trunk/framework/MediaFramework/org/osmf/video/CuePointType.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/metadata/TestTemporalFacet.as
        osmf/trunk/framework/MediaFrameworkFlexTest/org/osmf/video/TestCuePoint.as

    Greg -
        The metadata sample demonstrates how metadata can be placed on an IMediaResource, and used to  give the framework more information about the resource.  The MediaFactory uses this information to determine which type of media a given resource points to.  One of the intial problems we encountered when creating a media factory that created MediaElements from URLResources, was the inability to distinguish between image, video, and audio urls, since the extension isn't a guaranteed way.
    The Metadata framework, that was developed last sprint was provided to enable metadata such as XMP, Namevalue, and Cuepoints.  Not all specific classes that hold this data haven't been created yet however.  The logic to add metadata automatically hasn't been placed in the framework yet.
    It's currenty possible to retrieve onPlaystatus, onMetadata, onXMPData, onImagedata, and onCuepoint callbacks:
    var videoElement:VideoElement
    [After videoElement loads]
    videoElement.client.addHandler(NetStreamCodes.ON_XMP_DATA, onXMPData);
    function onXMPData(info:Object):void
       //Process XMP here.
    Hope this helps.

  • Explanation of some code samples

    Hello,
    can you explain me some code samples?
    First:
    try{
    wdContext.currentBapi_Flight_Getlist_InputElement().
    modelObject().execute();
    catch (Exception ex){
    ex.printStackTrace();
    wdContext.nodeOutput().invalidate();
    Second:
    Bapi_Flight_Getlist_Input input =
         new Bapi_Flight_Getlist_Input();
    wdContext.nodeBapi_Flight_Getlist_Input().bind(input);
    input.setDestination_From(new Bapisfldst());
    input.setDestination_To(new Bapisfldst());
    Thanks for your help,
    André

    Hi Andre,
    I hope you know how Rfcs work so I shall start of from there. So i shall explain with the little amount of grasp I have in the topic
    First:
    What the first code does is, to connect to the R/3 system and execute the RFC/BAPI with the input populated in the context node.
    invalidate is used to refresh the output node .
    Second:
    This part of the code is to bind the imported model of the RFC to the context model node and also to instantiate an instance of the structure to input the values into the table(input.setDestination_From(new Bapisfldst())).
    Hope this would explain a bit.
    Do reply with your feedback.
    Regards
    Noufal

  • Where is code sample of OVS in SAP's tutorials ?

    Hi everyone !!
    Please help me !!!
    Where is code sample of 'Advanced Value Help: Object Value Selector'
    in 'Web Dynpro Java Tutorials and Samples NW 2004' ?
    Code sample's link is lost.
    Web Dynpro Java Tutorials and Samples NW 2004
    Web Dynpro Java Tutorials and Samples NW 2004
    Advanced Value Help: Object Value Selector
    https://ecohub.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-technology/wd%20java/wdjava%20archive/web%20dynpro%20valuehelp%20using%20object%20value%20selector.pdf

    Hi,
    try this link,
    Advanced Value Help: Object Value Selector :
    /docs/DOC-8061#51
    right now the code sample is not working? getting the portal runtime error.
    hope this is rectified shortly !.
    Regards,
    ramesh
    Edited by: Ramesh Babu V on Nov 13, 2008 10:14 AM

Maybe you are looking for