Member Avatar for Bhargavi V

My main idea is to link the three combo boxes

I had taken appSet, app, package comboboxes

Now when I select one iten in appSet then the remaining two comboboxes should show the data related to the selected item in the appSet

and when I select one item in the app combo box then the package combo box should show the related items of the item which I had selected in the app combo box.

I had used a piece of code but it showing the following errors when I am executing

and there are no errors in the code
AWT-EventQueue-0" java.lang.NullPointerException
at client.cpm.dailyT20.CBRCPMDailyT20View.appComboBox_actionPerformed(CBRCPMDailyT20View.java:235)
at client.cpm.dailyT20.CBRCPMDailyT20View.access$1(CBRCPMDailyT20View.java:234)
at client.cpm.dailyT20.CBRCPMDailyT20View$2.actionPerformed(CBRCPMDailyT20View.java:227)
at javax.swing.JComboBox.fireActionEvent(Unknown Source)
at javax.swing.JComboBox.contentsChanged(Unknown Source)
at javax.swing.JComboBox.intervalRemoved(Unknown Source)
at javax.swing.AbstractListModel.fireIntervalRemoved(Unknown Source)
at javax.swing.DefaultComboBoxModel.removeAllElements(Unknown Source)
at javax.swing.JComboBox.removeAllItems(Unknown Source)
at client.cpm.dailyT20.CBRCPMDailyT20View.appSetComboBox_actionPerformed(CBRCPMDailyT20View.java:187)
at client.cpm.dailyT20.CBRCPMDailyT20View.access$0(CBRCPMDailyT20View.java:183)
at client.cpm.dailyT20.CBRCPMDailyT20View$1.actionPerformed(CBRCPMDailyT20View.java:175)
at javax.swing.JComboBox.fireActionEvent(Unknown Source)
at javax.swing.JComboBox.setSelectedItem(Unknown Source)
at javax.swing.JComboBox.setSelectedIndex(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

I am including the code here

package client.cpm.dailyT20; import java.awt.Cursor; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import java.sql.Date; import java.util.ArrayList; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JDesktopPane; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.event.InternalFrameEvent; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import cbrdataejb.entity.CBRCommentPK; import cbrdataejb.session.CBRCPMDailyT20FactTable; import cbrdataejb.session.CBRCPMDailyT20FactTableRemote; import cbrutil.CBRCursor; import cbrutil.CBRError; import cbrutil.CBRExcelDriver; import cbrutil.CBRUserPreferences; import client.cpm.dailyT20.detail.CBRCPMDailyT20DetailView; import client.cpm.dailyT20.table.CBRCPMDailyT20FailCellRenderer; import client.cpm.dailyT20.table.CBRCPMDailyT20SuccessCellRenderer; import com.borland.dbswing.TableScrollPane; import com.borland.dx.dataset.StorageDataSet; import common.ui.CBRCommentCellRenderer; import common.ui.CBRCommentedTable; import common.ui.CBRCommentedView; import common.ui.CBRDefaultTable; @SuppressWarnings("serial") public class CBRCPMDailyT20View extends CBRCommentedView { // EJB private CBRCPMDailyT20FactTableRemote factTableRemote; // GUI attributes private JPanel toolbarPanel = null; //private JLabel dateLabel = null; //private ADateField dateField = null; private JLabel appSetLabel = null; private JLabel appLabel = null; private JLabel packageLabel = null; private JComboBox appSetComboBox = null; private JComboBox appComboBox = null; private JComboBox packageComboBox = null; private JButton okButton = null; private JButton T20histButton = null; private JButton T20confButton = null; private JButton printButton = null; private JButton saveAsButton = null; private TableScrollPane tableScrollPane = null; private CBRCommentedTable table = null; public CBRCPMDailyT20View(JDesktopPane desktopPane) { super(desktopPane); try { initialize(); process(); } catch (Exception e) { e.printStackTrace(); } } protected CBRDefaultTable getTableToBePrinted() { return this.getTable(); } public String getAppSet() { return this.getAppSetComboBox().getSelectedItem().toString(); } public String getApp() { return this.getAppComboBox().getSelectedItem().toString(); } private void initialize() throws Exception { // EJB initialization factTableRemote = (CBRCPMDailyT20FactTableRemote) super.getContext() .lookup(CBRCPMDailyT20FactTable.RemoteJNDIName); // Initialize Data-source factTableRemote.init(CBRUserPreferences.instance().getDataSource(), "PRD-CPM", CBRUserPreferences.instance().getPortServer()); // Desktop Pane initialization setTitle("CPM - T20 DTS Log Report-Summary Data"); this.setPreferredSize(new Dimension(1000, 800)); this.setMinimumSize(new Dimension(750, 600)); // Display of this view getContentPane().setLayout(new GridBagLayout()); getContentPane().add( this.getToolbarPanel(), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); getContentPane().add( this.getTableScrollPane(), new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0)); } private JPanel getToolbarPanel() { if (this.toolbarPanel == null) { this.toolbarPanel = new JPanel(); this.toolbarPanel.setLayout(new GridBagLayout()); this.toolbarPanel.add(this.getAppSetLabel(), new GridBagConstraints( 2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); this.toolbarPanel.add(this.getAppSetComboBox(),new GridBagConstraints( 3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); this.toolbarPanel.add(this.getAppLabel(), new GridBagConstraints( 4, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); this.toolbarPanel.add(this.getAppComboBox(),new GridBagConstraints( 5, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); this.toolbarPanel.add(this.getPackageLabel(), new GridBagConstraints( 6, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); this.toolbarPanel.add(this.getPackageComboBox(), new GridBagConstraints( 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,new Insets(5, 0, 5, 5), 0, 0)); this.toolbarPanel.add(this.getOkButton(), new GridBagConstraints( 8, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); this.toolbarPanel.add(this.getPrintButton(),new GridBagConstraints( 9, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 5), 0, 0)); this.toolbarPanel.add(this.getSaveAsButton(),new GridBagConstraints( 10, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,new Insets(5, 0, 5, 0), 0, 0)); this.toolbarPanel.add(this.getT20ConfButton(),new GridBagConstraints (8, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,new Insets(5, 0, 5, 5), 0, 0)); this.toolbarPanel.add(this.getT20HistButton(),new GridBagConstraints (9, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,new Insets(5, 0, 5, 5), 0, 0)); } return this.toolbarPanel; } // creating AppSet Label private JLabel getAppSetLabel() { if (this.appSetLabel == null) { this.appSetLabel = new JLabel("App Set:"); } return this.appSetLabel; } //Getting data into APPSet Combo Box private JComboBox getAppSetComboBox() { if (this.appSetComboBox == null) { this.appSetComboBox = new JComboBox(); // Populate the App Set list this.appSetComboBox.addItem("All Application"); ArrayList<String> anAppSetList = CBRCPMDailyT20AppManager.instance() .getAppSetList(); for (int i = 0; i < anAppSetList.size(); i++) { this.appSetComboBox.addItem(anAppSetList.get(i)); } this.appSetComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent eventset) { appSetComboBox_actionPerformed(eventset); } }); } return this.appSetComboBox; } //Implementing the action listener private void appSetComboBox_actionPerformed(ActionEvent eventset) { String appSet = this.getAppSetComboBox().getSelectedItem().toString(); //String appSet = "AMADEUS_ABG"; this.appSetComboBox.setSelectedItem(appSet); this.getAppComboBox().removeAllItems(); this.getPackageComboBox().removeAllItems(); this.appComboBox.addItem("All Application"); this.packageComboBox.addItem("All Application"); ArrayList<String> anAppList = CBRCPMDailyT20AppManager.instance() .getAppList(appSet);//replace by appSet for (int i = 0; i < anAppList.size(); i++) { this.appComboBox.addItem(anAppList.get(i)); } ArrayList<String> anPackageList = CBRCPMDailyT20AppManager.instance() .getPackageList(appSet);//replace by appSet for (int l = 0; l < anPackageList.size(); l++) { this.packageComboBox.addItem(anPackageList.get(l)); } this.appComboBox.setSelectedIndex(0); this.packageComboBox.setSelectedIndex(0); } //creating App Label private JLabel getAppLabel() { if (this.appLabel == null) { this.appLabel = new JLabel("Application:"); } return this.appLabel; } //Getting data for App Combo Box private JComboBox getAppComboBox() { if (this.appComboBox == null) { this.appComboBox = new JComboBox(); // Populate the App list this.appComboBox.addItem("All Application"); ArrayList<String> anAppList = CBRCPMDailyT20AppManager.instance() .getAppList(); for (int j = 0; j < anAppList .size(); j++) { this.appComboBox.addItem(anAppList .get(j)); } this.appComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent eventpack) { appComboBox_actionPerformed(eventpack); } }); } return this.appComboBox; } private void appComboBox_actionPerformed(ActionEvent eventpack) { String app = this.getAppComboBox().getSelectedItem().toString(); //String appSet = "AMADEUS_ABG"; this.appComboBox.setSelectedItem(app); this.getPackageComboBox().removeAllItems(); this.packageComboBox.addItem("All Application"); ArrayList<String> anPackageList = CBRCPMDailyT20AppManager.instance() .getPackageList(app);//replace by app for (int j = 0; j < anPackageList.size(); j++) { this.packageComboBox.addItem(anPackageList.get(j)); } this.packageComboBox.setSelectedIndex(0); } /*private void appComboBox_actionPerformed(ActionEvent event) { String appSetCombo = this.getAppSetComboBox().getSelectedItem().toString(); String app = this.getAppComboBox().getSelectedItem().toString(); //String appSetCombo = "AMADEUS_CPM"; //String app = "FINANCE"; this.appComboBox.setSelectedItem(app); this.appSetComboBox.setSelectedItem(appSetCombo); this.getPackageComboBox().removeAllItems(); this.packageComboBox.addItem("All Package"); ArrayList<String> anPackageList = CBRCPMDailyT20AppManager.instance() .getPackageList(appSetCombo, app); for (int i = 0; i < anPackageList.size(); i++) { this.packageComboBox.addItem(anPackageList.get(i)); } this.packageComboBox.setSelectedIndex(0); }*/ // Creating package Label private JLabel getPackageLabel() { if (this.packageLabel == null) { this.packageLabel = new JLabel("Package:"); } return this.packageLabel; } //Getting Data for package combo box private JComboBox getPackageComboBox() { if (this.packageComboBox == null) { this.packageComboBox = new JComboBox(); // Populate the Package list this.packageComboBox.addItem("All Package"); ArrayList<String> anPackageList = CBRCPMDailyT20AppManager.instance() .getPackageList(); for (int i = 0; i < anPackageList.size(); i++) { this.packageComboBox.addItem(anPackageList.get(i)); } } return this.packageComboBox; } private JButton getOkButton() { if (this.okButton == null) { this.okButton = new JButton("OK"); // Add a listener this.okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { okButton_actionPerformed(event); } }); } return this.okButton; } private void okButton_actionPerformed(ActionEvent event) { process(); } private JButton getPrintButton() { if (this.printButton == null) { this.printButton = new JButton("Print"); // Add a listener this.printButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { printButton_actionPerformed(event); } }); } return this.printButton; } private void printButton_actionPerformed(ActionEvent event) { printTable(getTable()); } private JButton getSaveAsButton() { if (this.saveAsButton == null) { this.saveAsButton = new JButton("Save As..."); // Add a listener this.saveAsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { saveAsButton_actionPerformed(event); } }); } return this.saveAsButton; } private void saveAsButton_actionPerformed(ActionEvent event) { try { CBRExcelDriver excel = new CBRExcelDriver(); excel.saveFile(this, this.getTable(), "CPM Daily T20 FactTable"); } catch (Exception e) { e.printStackTrace(); } } private JButton getT20HistButton() { if (this.T20histButton == null) { this.T20histButton = new JButton("T20History"); // Add a listener this.T20histButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { T20histButton_actionPerformed(event); } }); } return this.T20histButton; } private void T20histButton_actionPerformed(ActionEvent event){ } private JButton getT20ConfButton() { if (this.T20confButton == null) { this.T20confButton = new JButton("T20Config"); // Add a listener this.T20confButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { T20confButton_actionPerformed(event); } }); } return this.T20confButton; } private void T20confButton_actionPerformed(ActionEvent event){ /*CBRCPMDailyT20ConfView cpmDailyT20ConfView = new CBRCPMDailyT20ConfView(this.getDesktopPane()); cpmDailyT20ConfView.setBounds(0, 0, 1000, 700); cpmDailyT20ConfView.setLocation(0, 0); cpmDailyT20ConfView.setVisible(true);*/ } private TableScrollPane getTableScrollPane() { if (this.tableScrollPane == null) { this.tableScrollPane = new TableScrollPane(); // Associate the OLA table to the table scroll pane this.tableScrollPane.getViewport().add(this.getTable(), null); this.tableScrollPane.setBorder(BorderFactory.createEtchedBorder()); } return this.tableScrollPane; } private CBRDefaultTable getTable() { if (this.table == null) { this.table = new CBRCommentedTable(this); this.table.getTableHeader().setReorderingAllowed(false); this.table.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { table_mouseClicked(event); } }); this.table.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent event) { table_mouseMoved(event); } }); } return this.table; } /*private void table_mouseClicked(MouseEvent event) { Point origin = event.getPoint(); int row = this.getTable().rowAtPoint(origin); int column = this.getTable().columnAtPoint(origin); if (row == -1 || column == -1) { return; } if (event.getClickCount() == 1) { int logFileColId = this.getTable().getColumnModel().getColumnIndex( "Log File"); if (column == logFileColId) { String logFilePath = this.getTable().getValueAt(row, column) .toString(); String shortLogFilePath = logFilePath.substring(logFilePath .indexOf("CPMData")); try { JTextArea textArea = new JTextArea(); textArea.read(new FileReader( "\\\\muceap10.muc.amadeus.net\\Everest_Webfolders\\" + shortLogFilePath), null); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); JOptionPane optionPane = new JOptionPane(scrollPane, JOptionPane.INFORMATION_MESSAGE); JDialog dialog = optionPane.createDialog(this, logFilePath); dialog.setSize(750, 500); dialog.setLocation(50, 50); dialog.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } } }*/ private void table_mouseClicked(MouseEvent event) { Point origin = event.getPoint(); int row = this.getTable().rowAtPoint(origin); //int column = this.getTable().columnAtPoint(origin); /*if (row == -1 || column == -1) { return; } if (event.getClickCount() == 1) { int logFileColId = this.getTable().getColumnModel().getColumnIndex( "Log File"); if (column == logFileColId) { String logFilePath = this.getTable().getValueAt(row, column) .toString(); String shortLogFilePath = logFilePath.substring(logFilePath .indexOf("CPMData")); try { JTextArea textArea = new JTextArea(); textArea.read(new FileReader( "\\\\muceap10.muc.amadeus.net\\Everest_Webfolders\\" + shortLogFilePath), null); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); JOptionPane optionPane = new JOptionPane(scrollPane, JOptionPane.INFORMATION_MESSAGE); JDialog dialog = optionPane.createDialog(this, logFilePath); dialog.setSize(750, 500); dialog.setLocation(50, 50); dialog.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } } else*/ if (event.getClickCount() == 2) { // Wait Cursor. CBRCursor waitCursor = new CBRCursor(this); try { // Get one month back in the past int appSetColumnIndex = this.getTable() .convertColumnIndexToView( this.getTable().getColumn("ApplicationSet") .getModelIndex()); String appSet = (String) this.getTable().getValueAt(row, appSetColumnIndex); int appColumnIndex = this.getTable().convertColumnIndexToView( this.getTable().getColumn("Application").getModelIndex()); String app = (String) this.getTable().getValueAt(row, appColumnIndex); int packageColumnIndex = this.getTable().convertColumnIndexToView( this.getTable().getColumn("Package").getModelIndex()); String packageS = (String) this.getTable().getValueAt(row, packageColumnIndex); // Get Counting data CBRCPMDailyT20DetailView detailView = new CBRCPMDailyT20DetailView( this.getDesktopPane(), appSet, app, packageS); detailView.setBounds(0, 0, 900, 600); detailView.setLocation(50, 50); detailView.show(); } catch (Exception e) { e.printStackTrace(); } finally { waitCursor.reset(); } } } private void table_mouseMoved(MouseEvent event) { Point origin = event.getPoint(); int row = this.getTable().rowAtPoint(origin); int col = this.getTable().columnAtPoint(origin); if ((row == -1) || (col == -1)) { return; } String columnName = this.getTable().getColumnName(col); if ((columnName.equals("ApplicationSet")) || (columnName.equals("Application")) || (columnName.equals("Package"))){ this.getTable().setCursor(new Cursor(Cursor.HAND_CURSOR)); } else { this.getTable().setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } private void process() { // Wait Cursor. CBRCursor waitCursor = new CBRCursor(this); try { // Get the chosen application String appSet = this.getAppSetComboBox().getSelectedItem().toString(); String app = this.getAppComboBox().getSelectedItem().toString(); String packageS = this.getPackageComboBox().getSelectedItem().toString(); // Get daily data StorageDataSet data = new StorageDataSet(); factTableRemote.getData(appSet,app,packageS).loadDataSet(data); // Associate the dataset with the table component. this.getTable().setDataSet(data); // Define the cell customization of the table TableColumnModel tableColumnModel = this.getTable() .getColumnModel(); for (int col = 0; col < this.getTable().getColumnCount(); col++) { String columnName = this.getTable().getColumnName(col); TableColumn column = tableColumnModel.getColumn(col); if (columnName.equals("ApplicationSet")) { column.setCellRenderer(new CBRCommentCellRenderer(this)); column.setPreferredWidth(100); } else if (columnName.equals("Application")) { column.setPreferredWidth(120); } else if (columnName.equals("Package")) { column.setPreferredWidth(300); } else if ((columnName.equals("SE_Min")) || (columnName.equals("SE_Max")) || (columnName.equals("SE_Avg"))) { column.setCellRenderer(new CBRCPMDailyT20SuccessCellRenderer()); column.setPreferredWidth(60); } else if ((columnName.equals("FE_Max")) || (columnName.equals("FE_Min")) || (columnName.equals("FE_Avg"))) { column.setCellRenderer(new CBRCPMDailyT20FailCellRenderer()); column.setPreferredWidth(60); } else if ((columnName.equals("SE")) || (columnName.equals("FE"))) { column.setPreferredWidth(40); } else if (columnName.equals("Last_Execution")){ column.setPreferredWidth(80); } } // Make the GUI visible. this.getTable().setVisible(true); } catch (Exception e) { CBRError.displayServerError(this, e); } finally { waitCursor.reset(); } } @Override protected void this_internalFrameClosed(InternalFrameEvent e) { try { factTableRemote.remove(); CBRCPMDailyT20AppManager.instance().removeEJB(); } catch (Exception ex) { } } @Override public CBRCommentPK getCommentKey(int currentRowNumber, int currentColumnNumber, CBRCommentedTable currentTable) { try { int appColId = currentTable.getColumnModel().getColumnIndex( "ApplicationSet"); int catColId = currentTable.getColumnModel().getColumnIndex( "Package"); String appValue = currentTable.getValueAt(currentRowNumber, appColId).toString(); String catValue = currentTable.getValueAt(currentRowNumber, catColId).toString(); String commentKey = appValue + "-" + catValue; Date date = Date.valueOf("2009-01-01"); return new CBRCommentPK("CPM - T20 DTS Log Report", commentKey, date); } catch (Exception e) { e.printStackTrace(); } return null; } @Override public CBRCommentPK getCurrentCommentKey() { try { int rowId = this.getTable().getSelectedRow(); if (rowId == -1) { return null; } int appColId = this.getTable().getColumnModel().getColumnIndex( "ApplicationSet"); int catColId = this.getTable().getColumnModel().getColumnIndex( "Package"); String appValue = this.getTable().getValueAt(rowId, appColId) .toString(); String catValue = this.getTable().getValueAt(rowId, catColId) .toString(); String commentKey = appValue + "-" + catValue; Date date = Date.valueOf("2009-01-01"); return new CBRCommentPK("CPM - T20 DTS Log Report Detail", commentKey, date); } catch (Exception e) { e.printStackTrace(); } return null; } }

So can any one please help me

It is very urgent and it is my first time experience in programming

I dont have any exp before
and I dont have any collegues to help

Thank in Advance

Member Avatar for stultuske

looks like you have nothing selected when the code on line 235 runs

you can verify whether or not this is the problem, by putting that line in comment, and undo the comment on the line below, and retry the program

Member Avatar for Bhargavi V

no , but I am passing it to the following line

this.appComboBox.setSelectedItem(app);

so I had just declared it as String

can you ones check clearly please

Member Avatar for thamilvaanan
this.getAppComboBox().getSelectedItem().toString();

Is the one throws this exception.
So check this.getAppComboBox() is null or not.

Just comment

this.getAppComboBox().getSelectedItem().toString();

and next to that add this and test it.

if(this.getAppComboBox()==null) { System.out.println("this.getAppComboBox() is returned a null value"); }
Member Avatar for Bhargavi V

I had used the code like this for APPSET combobox and implemented actionListener

//Getting data into APPSet Combo Box private JComboBox getAppSetComboBox() { if (this.appSetComboBox == null) { this.appSetComboBox = new JComboBox(); // Populate the App Set list this.appSetComboBox.addItem("All Application"); ArrayList<String> anAppSetList = CBRCPMDailyT20AppManager.instance() .getAppSetList(); for (int i = 0; i < anAppSetList.size(); i++) { this.appSetComboBox.addItem(anAppSetList.get(i)); } this.appSetComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent eventset) { appSetComboBox_actionPerformed(eventset); } }); } return this.appSetComboBox; }

Here I had implmented the action Listener for both the Comboboxes(For App and for Package)

So when selected an item in the AppSet combobox the related items to the selected on should be loaded into the APP and PACKAGE comboboxes

I am getting the data as said above and code is as this

//Implementing the action listener private void appSetComboBox_actionPerformed(ActionEvent eventset) { String appSet = this.getAppSetComboBox().getSelectedItem().toString(); //String appSet = "AMADEUS_ABG"; this.appSetComboBox.setSelectedItem(appSet); this.getAppComboBox().removeAllItems(); this.getPackageComboBox().removeAllItems(); this.appComboBox.addItem("All Application"); this.packageComboBox.addItem("All Application"); ArrayList<String> anAppList = CBRCPMDailyT20AppManager.instance() .getAppList(appSet);//replace by appSet for (int i = 0; i < anAppList.size(); i++) { this.appComboBox.addItem(anAppList.get(i)); } ArrayList<String> anPackageList = CBRCPMDailyT20AppManager.instance() .getPackageList(appSet);//replace by appSet for (int l = 0; l < anPackageList.size(); l++) { this.packageComboBox.addItem(anPackageList.get(l)); } this.appComboBox.setSelectedIndex(0); this.packageComboBox.setSelectedIndex(0); }

But now the problem is I am not getting the Table data when I am selecting the ComboBox filters If I comment this code then I am getting the data in the table
can you please tell me anything wrong

this.getPackageComboBox().removeAllItems(); this.packageComboBox.addItem("All Application"); ArrayList<String> anPackageList = CBRCPMDailyT20AppManager.instance() .getPackageList(appSet);//replace by appSet for (int l = 0; l < anPackageList.size(); l++) { this.packageComboBox.addItem(anPackageList.get(l)); }

and the code for table data is as follows

package cbrdataejb.session; import java.rmi.RemoteException; import javax.ejb.Remove; import javax.ejb.Stateful; import javax.ejb.TransactionAttribute; import javax.ejb.TransactionAttributeType; import cbrdataejb.database.CBRMSSQLDataBean; import cbrutil.CBRConstants; import com.borland.dx.dataset.DataSetData; import com.borland.dx.sql.dataset.Load; import com.borland.dx.sql.dataset.QueryDataSet; import com.borland.dx.sql.dataset.QueryDescriptor; @Stateful public class CBRCPMDailyT20FactTable extends CBRMSSQLDataBean implements CBRCPMDailyT20FactTableRemote { public static final String RemoteJNDIName = CBRConstants.EARFileName + CBRCPMDailyT20FactTable.class.getSimpleName() + "/remote"; public CBRCPMDailyT20FactTable() { } public void init(String db2DataSource, String msSqlDataSource, String portServer) { super.create(db2DataSource, msSqlDataSource, portServer); } @Remove public void remove() { } @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public DataSetData getAppSetList() throws RemoteException { QueryDataSet queryDataSet = new QueryDataSet(); try { // Set and open the connection if is not already open! if (!(m_msSqlDatabase.isOpen())) { m_msSqlDatabase.setConnection(m_msSqlDatabase.getDataSource().getConnection()); } StringBuffer selectQuery = new StringBuffer(); selectQuery.append("SELECT APPLICATION_SET as IDAppSet, count(*)"); selectQuery.append(" FROM T20_Summary"); selectQuery.append(" GROUP BY APPLICATION_SET"); selectQuery.append(" ORDER BY APPLICATION_SET"); queryDataSet.setQuery(new QueryDescriptor(this.m_msSqlDatabase, selectQuery.toString(), null, true, Load.ALL)); queryDataSet.open(); return DataSetData.extractDataSet(queryDataSet); } catch (Exception e) { e.printStackTrace(); throw new RemoteException("getAppSetList", e); } finally { try { queryDataSet.close(); this.close(); } catch (Exception e) { } } } @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public DataSetData getAppList(String appSet) throws RemoteException { QueryDataSet queryDataSet = new QueryDataSet(); String appSetFil = ""; if (appSet.equals("All Application") == false) { appSetFil = appSet; } try { // Set and open the connection if is not already open! if (!(m_msSqlDatabase.isOpen())) { m_msSqlDatabase.setConnection(m_msSqlDatabase.getDataSource().getConnection()); } StringBuffer selectQuery = new StringBuffer(); selectQuery.append("SELECT distinct APPLICATION as IDApp, count(*)"); selectQuery.append(" FROM T20_Summary"); selectQuery.append(" where APPLICATION_SET LIKE'%" + appSetFil + "%'"); selectQuery.append(" GROUP BY APPLICATION"); selectQuery.append(" ORDER BY APPLICATION"); queryDataSet.setQuery(new QueryDescriptor(this.m_msSqlDatabase, selectQuery.toString(), null, true, Load.ALL)); queryDataSet.open(); return DataSetData.extractDataSet(queryDataSet); } catch (Exception e) { e.printStackTrace(); throw new RemoteException("getAppList", e); } finally { try { queryDataSet.close(); this.close(); } catch (Exception e) { } } } @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public DataSetData getAppList() throws RemoteException { QueryDataSet queryDataSet = new QueryDataSet(); try { // Set and open the connection if is not already open! if (!(m_msSqlDatabase.isOpen())) { m_msSqlDatabase.setConnection(m_msSqlDatabase.getDataSource().getConnection()); } StringBuffer selectQuery = new StringBuffer(); selectQuery.append("SELECT distinct APPLICATION as IDApp, count(*)"); selectQuery.append(" FROM T20_Summary"); selectQuery.append(" GROUP BY APPLICATION"); selectQuery.append(" ORDER BY APPLICATION"); queryDataSet.setQuery(new QueryDescriptor(this.m_msSqlDatabase, selectQuery.toString(), null, true, Load.ALL)); queryDataSet.open(); return DataSetData.extractDataSet(queryDataSet); } catch (Exception e) { e.printStackTrace(); throw new RemoteException("getAppList", e); } finally { try { queryDataSet.close(); this.close(); } catch (Exception e) { } } } @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) //public DataSetData getPackageList(String appSet, String app) throws RemoteException { public DataSetData getPackageList(String appSet) throws RemoteException { QueryDataSet queryDataSet = new QueryDataSet(); String appSetFil = ""; //String appFil = ""; if (appSet.equals("All Application") == false) { appSetFil = appSet; } /*if (app.equals("All Application") == false) { appFil = app; }*/ try { // Set and open the connection if is not already open! if (!(m_msSqlDatabase.isOpen())) { m_msSqlDatabase.setConnection(m_msSqlDatabase.getDataSource().getConnection()); } StringBuffer selectQuery = new StringBuffer(); selectQuery.append("SELECT distinct PACKAGE as IDPackage, count(*)"); selectQuery.append(" FROM T20_Summary"); selectQuery.append(" where APPLICATION_SET LIKE'%" + appSetFil + "%'"); //selectQuery.append(" AND APPLICATION LIKE'%" + appFilP + "%'"); selectQuery.append(" GROUP BY PACKAGE "); selectQuery.append(" ORDER BY PACKAGE "); queryDataSet.setQuery(new QueryDescriptor(this.m_msSqlDatabase, selectQuery.toString(), null, true, Load.ALL)); queryDataSet.open(); return DataSetData.extractDataSet(queryDataSet); } catch (Exception e) { e.printStackTrace(); throw new RemoteException("getPackageList", e); } finally { try { queryDataSet.close(); this.close(); } catch (Exception e) { } } } @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public DataSetData getPackageList() throws RemoteException { QueryDataSet queryDataSet = new QueryDataSet(); try { // Set and open the connection if is not already open! if (!(m_msSqlDatabase.isOpen())) { m_msSqlDatabase.setConnection(m_msSqlDatabase.getDataSource().getConnection()); } StringBuffer selectQuery = new StringBuffer(); selectQuery.append("SELECT distinct PACKAGE as IDPackage, count(*)"); selectQuery.append(" FROM T20_Summary"); selectQuery.append(" GROUP BY PACKAGE "); selectQuery.append(" ORDER BY PACKAGE "); queryDataSet.setQuery(new QueryDescriptor(this.m_msSqlDatabase, selectQuery.toString(), null, true, Load.ALL)); queryDataSet.open(); return DataSetData.extractDataSet(queryDataSet); } catch (Exception e) { e.printStackTrace(); throw new RemoteException("getPackageList", e); } finally { try { queryDataSet.close(); this.close(); } catch (Exception e) { } } } @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public DataSetData getData(String appSet, String app, String packageS ) throws RemoteException { //public DataSetData getData(String appSet, String app, String packageS ) throws RemoteException { QueryDataSet queryDataSet = new QueryDataSet(); try { // set value for filter String appSetFil = ""; String appFil = ""; String packageFil = ""; if (appSet.equals("All Application") == false) { appSetFil = appSet; } if (app.equals("All Application") == false) { appFil = app; } if (packageS.equals("All Package") == false) { packageFil = packageS; } // Set and open the connection if is not already open! if (!(m_msSqlDatabase.isOpen())) { m_msSqlDatabase.setConnection(m_msSqlDatabase.getDataSource().getConnection()); } StringBuffer selectQuery = new StringBuffer(); selectQuery.append("select APPLICATION_SET as ApplicationSet,"); selectQuery.append(" APPLICATION as Application,"); selectQuery.append(" PACKAGE as Package,"); selectQuery.append(" SUCCESS_EXECUTIONS as SE,"); selectQuery.append(" SUCCESS_MIN_TIME as SE_Min,"); selectQuery.append(" SUCCESS_MAX_TIME as SE_Max,"); selectQuery.append(" SUCCESS_AVG_TIME as SE_Avg, "); selectQuery.append(" FAILED_EXECUTIONS as FE,"); selectQuery.append(" FAILED_MIN_TIME as FE_Max,"); selectQuery.append(" FAILED_MAX_TIME as FE_Min,"); selectQuery.append(" FAILED_AVG_TIME as FE_Avg,"); selectQuery.append(" LAST_EXECUTION_DATE as Last_Execution"); selectQuery.append(" from T20_Summary"); selectQuery.append(" where "); if (appSet.equals("All Application") == false) { selectQuery.append(" APPLICATION_SET LIKE'" + appSetFil + "'AND"); } selectQuery.append(" APPLICATION LIKE '%" + appFil + "%'"); selectQuery.append(" AND PACKAGE LIKE '%" + packageFil + "%'"); //selectQuery.append(" where APPLICATION_SET LIKE'%" + appSetFil + "%'"); //selectQuery.append(" AND APPLICATION LIKE '%" + appFil + "%'"); //selectQuery.append(" AND PACKAGE LIKE'%" + packageFil + "%'"); selectQuery.append(" order by LAST_EXECUTION_DATE desc, APPLICATION_SET , APPLICATION, PACKAGE"); queryDataSet.setQuery(new QueryDescriptor(this.m_msSqlDatabase, selectQuery.toString(), null, true, Load.ALL)); queryDataSet.open(); return DataSetData.extractDataSet(queryDataSet); } catch (Exception e) { e.printStackTrace(); throw new RemoteException("getData", e); } finally { try { queryDataSet.close(); this.close(); } catch (Exception e) { } } } }

Thanks in advance

Member Avatar for Bhargavi V
this.getAppComboBox().removeAllItems();

I had used this in the APPSET action Listener as shown below

private void appSetComboBox_actionPerformed(ActionEvent eventset) { String appSet = this.getAppSetComboBox().getSelectedItem().toString(); //String appSet = "AMADEUS_ABG"; this.appSetComboBox.setSelectedItem(appSet); this.getAppComboBox().removeAllItems(); //this.getPackageComboBox().removeAllItems(); this.appComboBox.addItem("All Application"); //this.packageComboBox.addItem("All Application"); ArrayList<String> anAppList = CBRCPMDailyT20AppManager.instance() .getAppList(appSet);//replace by appSet for (int i = 0; i < anAppList.size(); i++) { this.appComboBox.addItem(anAppList.get(i)); } /*ArrayList<String> anPackageList = CBRCPMDailyT20AppManager.instance() .getPackageList(appSet);//replace by appSet for (int l = 0; l < anPackageList.size(); l++) { this.packageComboBox.addItem(anPackageList.get(l)); }*/ this.appComboBox.setSelectedIndex(0); this.packageComboBox.setSelectedIndex(0); }

When I comment this I am not getting the error

this.getAppComboBox().removeAllItems();

But the data in APP Combobox will not be removed before adding the new data regarding the filter

So what can I do to avoid this

Thanks in advance,

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.