Results 1 to 16 of 16
Thread: Swing UI display
- 07-21-2011, 08:31 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 8
- Rep Power
- 0
- 07-21-2011, 08:35 PM #2
If you want help, you'll have to provide an SSCCE (that does NOT mean pasting your entire program here) that demonstrates the problem.
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 07-21-2011, 09:01 PM #3
Member
- Join Date
- Jul 2011
- Posts
- 8
- Rep Power
- 0
Hi,
I have attached a zip file, which contains an image of the screen explaining the problem. Hope, this helps. If any thing required to understand the problem please let me know.
regards,
Prakash B
- 07-21-2011, 09:12 PM #4
Please post the code that is used when you create and show the JOptionPane dialog.
- 07-21-2011, 09:25 PM #5
Member
- Join Date
- Jul 2011
- Posts
- 8
- Rep Power
- 0
public class TermOrder extends UIDialog {
public boolean checkItemNumber() {
JOptionPane.showConfirmDialog(this,
"Item Number/UPC Code Does not Exist", "Error", -1,
0, null);
}
}
- 07-21-2011, 09:29 PM #6
The "this" parameter must have an effect. Try changing it to null.
- 07-21-2011, 09:31 PM #7
Member
- Join Date
- Jul 2011
- Posts
- 8
- Rep Power
- 0
Tried that. This happens with all the dialog. And its sporadic. Once minimized and maximized every thing looks fine.
- 07-21-2011, 09:35 PM #8
Can you make a small executable program that demonstrates your problem?
I don't understand how the components are getting mixed together like you show.
- 07-21-2011, 09:49 PM #9
Member
- Join Date
- Jul 2011
- Posts
- 8
- Rep Power
- 0
As the code follows factory patter, its inter-wired. i will create an executable and i will reply. But we can not replicate it as it is sporadic. Have any one faced this kind of issue before.
-
I've seen this when folks have tried to mix heavy and light weight components, but without code, it's impossible to say what you're doing wrong.
- 07-21-2011, 10:12 PM #11
Member
- Join Date
- Jul 2011
- Posts
- 8
- Rep Power
- 0
Ok, I will reply back with code.
- 11-17-2011, 04:46 PM #12
Member
- Join Date
- Jul 2011
- Posts
- 8
- Rep Power
- 0
Re: Swing UI display
Hi,
The code of Parent Screen which opens child screen is as follows:
The code of Child screen is as followsJava Code:public void callCustomerBrowser() { CustomerBrowser custBrowser = new CustomerBrowser(this); custBrowser.setFrameOwner(this); custBrowser.setSearchValue(gettxtCustomer().getText()); custBrowser.setIFlag(iFlag); custBrowser.setCustOrdType1(getCustOrderType1()); custBrowser.setCustOrdType2(getCustOrderType2()); custBrowser.initialize(itxtCustomer.getText().trim()); }
Scenario: The child screen is opened from parent screen. User selects a record on Child screen and press select button. Usually the child screen is disposed and control goes back to parent screen. The problem is child screen is merging with Parent screen (see attachment). This is happening randomly. Any help would be appreciated.Java Code:import com.iccg.base.ConfigSetting; import com.iccg.base.Configuration; import com.iccg.base.UserSetting; import com.iccg.componentfactory.UIButton; import com.iccg.componentfactory.UIDialog; import com.iccg.componentfactory.UIFrame; import com.iccg.componentfactory.UILabel; import com.iccg.componentfactory.UIPanel; import com.iccg.componentfactory.UIScrollPane; import com.iccg.componentfactory.UITable; import com.iccg.componentfactory.UITextField; import com.iccg.psf.entity.CashOrderInf; import com.iccg.psf.entity.CustomerBrowserInf; import com.iccg.psf.operation.OprCustomer; import com.iccg.util.Common; import com.iccg.util.Language; import com.iccg.util.PSFException; import com.iccg.util.UpperCase; import com.iccg.db.DataStore; import com.iccg.db.DataStoreParameter; import com.iccg.db.InputParam; import com.iccg.db.ResultParam; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.sql.ResultSet; import java.sql.SQLException; import java.util.Vector; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.KeyStroke; import javax.swing.event.TableModelEvent; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; public class CustomerBrowser extends UIDialog implements CustomerBrowserInf { private static final long serialVersionUID = 1L; public CustomerBrowser(UIDialog pDialog) { super(pDialog, true); ibtnOK = null; ibtnCancel = null; ipnlCustomerBrowser = null; iscrRecords = null; ilblSearchCustomer = null; itxtSearchCustomer = null; itblCustomerBrowser = null; iFrame = null; iCustomerQtbl = null; iCustomerNo = null; iSearchValue = ""; iRecordsPerPage = 0; iRecordsOnPage = 0; iPageNumber = 0; } public UIButton getbtnCancel() { if (ibtnCancel == null) { ibtnCancel = new UIButton(); ibtnCancel.setName("btnCancel"); ibtnCancel.setText("Cancel"); ibtnCancel.setBounds(570, 230, 80, 25); ibtnCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { onCancel(); } }); ibtnCancel.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent pKeyEvent) { doEvents(pKeyEvent); } }); } return ibtnCancel; } public UIButton getbtnOK() { if (ibtnOK == null) { ibtnOK = new UIButton(); ibtnOK.setName("btnOK"); ibtnOK.setText("Select"); ibtnOK.setBounds(570, 200, 80, 25); ibtnOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { onOK(); } }); ibtnOK.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent pKeyEvent) { doEvents(pKeyEvent); } }); } return ibtnOK; } public UIButton getbtnNext() { if (ibtnNext == null) { ibtnNext = new UIButton(); ibtnNext.setName("btnNext"); ibtnNext.setText(">>"); ibtnNext.setBounds(480, 275, 80, 25); ibtnNext.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (iRecordsOnPage >= iRecordsPerPage) iPageNumber++; onNext(); ibtnNext.requestFocusInWindow(); } }); ibtnNext.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent pKeyEvent) { if (pKeyEvent.getKeyCode() == 9) { ibtnNext.requestFocusInWindow(); } if (pKeyEvent.getKeyCode() == 37) { getbtnPrevious().requestFocus(); } if (pKeyEvent.getKeyCode() == 39) { getbtnNext().requestFocus(); } doEvents(pKeyEvent); } }); } return ibtnNext; } public UIButton getbtnPrevious() { if (ibtnPrevious == null) { ibtnPrevious = new UIButton(); ibtnPrevious.setName("btnPrevious"); ibtnPrevious.setText("<<"); ibtnPrevious.setBounds(395, 275, 80, 25); ibtnPrevious.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (iPageNumber > 0) iPageNumber--; onNext(); ibtnPrevious.requestFocus(); } }); ibtnPrevious.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent pKeyEvent) { doEvents(pKeyEvent); } }); } return ibtnPrevious; } public UIDialog getFrameOwner() { return iFrame; } public UILabel getlblCustomer() { if (ilblSearchCustomer == null) { ilblSearchCustomer = new UILabel(); ilblSearchCustomer.setName("lblSearchCustomer"); ilblSearchCustomer.setText("Customer Number" + ":"); ilblSearchCustomer.setBounds(490, 12, 160, 20); } return ilblSearchCustomer; } public UILabel getlblCustomerKey() { if (ilblCustomerKey == null) { ilblCustomerKey = new UILabel(); ilblCustomerKey.setName("lblCustomerSearchKey"); ilblCustomerKey.setText("Customer Search Key" + ":"); ilblCustomerKey.setBounds(10, 12, 160, 20); } return ilblCustomerKey; } public UILabel getlblCustomerName() { if (ilblCustomerName == null) { ilblCustomerName = new UILabel(); ilblCustomerName.setName("lblSearchCustomer"); ilblCustomerName.setText("Customer Name" + ":"); ilblCustomerName.setBounds(170, 12, 160, 20); } return ilblCustomerName; } public UILabel getlblTelephone() { if (ilblTelephone == null) { ilblTelephone = new UILabel(); ilblTelephone.setName("lblTelephone"); ilblTelephone.setText("Telephone" + ":"); ilblTelephone.setBounds(330, 12, 160, 20); } return ilblTelephone; } public UIPanel getpnlHeaderCustomerBrowser() { if (ipnlHeaderCustomerBrowser == null) { ipnlHeaderCustomerBrowser = new UIPanel(); ipnlHeaderCustomerBrowser.setName("pnlCustomerBrowser"); ipnlHeaderCustomerBrowser.setLayout(null); ipnlHeaderCustomerBrowser.setVisible(true); ipnlHeaderCustomerBrowser.setPreferredSize(new Dimension( Integer.MAX_VALUE, 75)); getpnlHeaderCustomerBrowser().add(getlblCustomer(), getlblCustomer().getName()); getpnlHeaderCustomerBrowser().add(gettxtCustomer(), gettxtCustomer().getName()); getpnlHeaderCustomerBrowser().add(getlblCustomerName(), getlblCustomerName().getName()); getpnlHeaderCustomerBrowser().add(gettxtCustomerName(), gettxtCustomerName().getName()); getpnlHeaderCustomerBrowser().add(getlblCustomerKey(), getlblCustomerKey().getName()); getpnlHeaderCustomerBrowser().add(gettxtCustomerKey(), gettxtCustomerKey().getName()); getpnlHeaderCustomerBrowser().add(getlblTelephone(), getlblTelephone().getName()); getpnlHeaderCustomerBrowser().add(gettxtTelephone(), gettxtTelephone().getName()); } return ipnlHeaderCustomerBrowser; } public UIPanel getpnlTableCustomerBrowser() { if (ipnlTableCustomerBrowser == null) { ipnlTableCustomerBrowser = new UIPanel(); ipnlTableCustomerBrowser.setName("pnlCustomerBrowser"); ipnlTableCustomerBrowser.setLayout(new BorderLayout()); ipnlTableCustomerBrowser.setVisible(true); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); ipnlTableCustomerBrowser.setPreferredSize(new Dimension( new Dimension(Integer.MAX_VALUE, 189))); //System.out.println(screenSize.width); getpnlTableCustomerBrowser().add(getscrRecords(), BorderLayout.CENTER); getpnlTableCustomerBrowser().add(getpnlEastCustomerBrowser(), BorderLayout.EAST); getpnlTableCustomerBrowser().add(getpnlFooterCustomerBrowser(), BorderLayout.SOUTH); } return ipnlTableCustomerBrowser; } public UIPanel getpnlFooterCustomerBrowser() { if (ipnlFooterCustomerBrowser == null) { ipnlFooterCustomerBrowser = new UIPanel(); ipnlFooterCustomerBrowser.setName("pnlCustomerBrowser"); ipnlFooterCustomerBrowser.setLayout(null); ipnlFooterCustomerBrowser.setVisible(true); ipnlFooterCustomerBrowser.setPreferredSize(new Dimension( Integer.MAX_VALUE, 50)); /* * getpnlFooterCustomerBrowser().add(getbtnOK(), * getbtnOK().getName()); * getpnlFooterCustomerBrowser().add(getbtnCancel(), * getbtnCancel().getName()); */ getpnlFooterCustomerBrowser().add(getbtnNext(), getbtnNext().getName()); getpnlFooterCustomerBrowser().add(getbtnPrevious(), getbtnPrevious().getName()); } return ipnlFooterCustomerBrowser; } public UIPanel getpnlEastCustomerBrowser() { if (ipnlEastCustomerBrowser == null) { ipnlEastCustomerBrowser = new UIPanel(); ipnlEastCustomerBrowser.setName("pnlEastCustomerBrowser"); ipnlEastCustomerBrowser.setLayout(null); ipnlEastCustomerBrowser.setVisible(true); ipnlEastCustomerBrowser.setPreferredSize(new Dimension(189, 189)); getpnlEastCustomerBrowser().add(getbtnOK(), getbtnOK().getName()); getpnlEastCustomerBrowser().add(getbtnCancel(), getbtnCancel().getName()); /* * getpnlEastCustomerBrowser().add(getbtnNext(), * getbtnNext().getName()); * getpnlEastCustomerBrowser().add(getbtnPrevious(), * getbtnPrevious().getName()); */ } return ipnlEastCustomerBrowser; } public UIScrollPane getscrRecords() { if (iscrRecords == null) { iscrRecords = new UIScrollPane(); iscrRecords.setName("scrRecords"); iscrRecords.setVerticalScrollBarPolicy(20); iscrRecords.setHorizontalScrollBarPolicy(30); iscrRecords.setBounds(12, 65, 545, 200); getscrRecords().setViewportView(gettblCustomer()); } return iscrRecords; } public String getSearchValue() { return iSearchValue; } public UITable gettblCustomer() { if (itblCustomerBrowser == null) { itblCustomerBrowser = new UITable(); itblCustomerBrowser.setName("tblCustomerBrowser"); getscrRecords().setColumnHeaderView( itblCustomerBrowser.getTableHeader()); getscrRecords().getViewport().setBackingStoreEnabled(true); itblCustomerBrowser.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent pKeyEvent) { if (pKeyEvent.getKeyCode() == 10) onOK(); if (pKeyEvent.getKeyCode() == 27) onCancel(); if (pKeyEvent.getKeyCode() == 9) getbtnOK().requestFocus(); int keyCode = pKeyEvent.getKeyCode(); int modifiers = pKeyEvent.getModifiers(); if (modifiers == 1 && keyCode == 9) gettxtCustomer().requestFocus(); doEvents(pKeyEvent); } }); itblCustomerBrowser.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent pMouseEvent) { if (pMouseEvent.getClickCount() == 2) onOK(); } }); } return itblCustomerBrowser; } public UITextField gettxtCustomer() { UpperCase uCase = new UpperCase(); uCase.setSize(15); if (itxtSearchCustomer == null) { itxtSearchCustomer = new UITextField(); itxtSearchCustomer.setName("txtSearchCustomer"); itxtSearchCustomer.setBounds(490, 34, 160, 20); itxtSearchCustomer.setDocument(uCase); itxtSearchCustomer.setNextFocusableComponent(gettblCustomer()); itxtSearchCustomer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { onSearch(); } }); itxtSearchCustomer.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent pKeyEvent) { if (pKeyEvent.getKeyCode() == 40) { gettblCustomer().setEnabled(true); gettblCustomer().requestFocus(); // gettxtCustomerName().requestFocus(); } if (pKeyEvent.getKeyCode() == 9) { gettblCustomer().setEnabled(true); gettblCustomer().requestFocus(); } doEvents(pKeyEvent); } }); } return itxtSearchCustomer; } public UITextField gettxtCustomerKey() { UpperCase uCase = new UpperCase(); uCase.setSize(15); if (itxtCustomerKey == null) { itxtCustomerKey = new UITextField(); itxtCustomerKey.setName("txtCustomerKey"); itxtCustomerKey.setBounds(10, 34, 160, 20); itxtCustomerKey.setDocument(uCase); itxtCustomerKey.setNextFocusableComponent(gettxtCustomerName()); itxtCustomerKey.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { onSearch(); } }); itxtCustomerKey.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent pKeyEvent) { if (pKeyEvent.getKeyCode() == 40) { gettblCustomer().setEnabled(true); gettblCustomer().requestFocus(); } if (pKeyEvent.getKeyCode() == 9) { gettxtCustomerName().requestFocus(); } doEvents(pKeyEvent); } }); } return itxtCustomerKey; } public UITextField gettxtCustomerName() { UpperCase uCase = new UpperCase(); uCase.setSize(15); if (itxtCustomerName == null) { itxtCustomerName = new UITextField(); itxtCustomerName.setName("txtCustomerName"); itxtCustomerName.setBounds(170, 34, 160, 20); itxtCustomerName.setDocument(uCase); itxtCustomerName.setNextFocusableComponent(gettxtTelephone()); itxtCustomerName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { onSearch(); } }); itxtCustomerName.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent pKeyEvent) { if (pKeyEvent.getKeyCode() == 40) { gettblCustomer().setEnabled(true); gettblCustomer().requestFocus(); } if (pKeyEvent.getKeyCode() == 9) { gettxtTelephone().setEnabled(true); gettxtTelephone().requestFocus(); } doEvents(pKeyEvent); } }); } return itxtCustomerName; } public UITextField gettxtTelephone() { UpperCase uCase = new UpperCase(); uCase.setSize(15); if (itxtTelephone == null) { itxtTelephone = new UITextField(); itxtTelephone.setName("itxtTelephone"); itxtTelephone.setBounds(330, 34, 160, 20); itxtTelephone.setNextFocusableComponent(gettxtCustomer()); itxtTelephone.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { onSearch(); } }); itxtTelephone.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent pKeyEvent) { if (pKeyEvent.getKeyCode() == 40) { gettblCustomer().setEnabled(true); gettblCustomer().requestFocus(); } if (pKeyEvent.getKeyCode() == 9) { gettxtCustomer().setEnabled(true); gettxtCustomer().requestFocus(); } doEvents(pKeyEvent); } }); } return itxtTelephone; } public void onCancel() { dispose(); } public void onOK() { if (itblCustomerBrowser.getRowCount() > 0) { iCustomerNo = itblCustomerBrowser.getValueAt( itblCustomerBrowser.getSelectedRow(), 3).toString(); } else { iCustomerNo = ""; } ((CustomerBrowserInf) getFrameOwner()).setCustomer(iCustomerNo); dispose(); } public void setFrameOwner(UIDialog pFrame) { iFrame = pFrame; } // public void getBrowserRecords(String pValue,String pSearchname,String // pSearchtel) public void getBrowserRecords() throws PSFException, SQLException { int cono = Integer.parseInt(Configuration .getParameter(ConfigSetting.COMPANY_NO)); Vector prevData = null; TableColumnModel tbcCustModel = null; TableColumn tbcCust = null; // iFlag = 1; if (iCustomerQtbl == null) { iCustomerQtbl = new CustomerBrowserTableModel(); iCustomerQtbl.setTotalRows(new Vector(5)); } prevData = iCustomerQtbl.getTotalRows(); prevData.clear(); String columnData[]; Vector moduleData = new Vector(10);// goa 3/15/2011 DataStoreParameter dataStoreParameter[] = new DataStoreParameter[10];// goa // 3/15/2011 dataStoreParameter[0] = new InputParam(gettxtCustomerKey().getText() .trim()); dataStoreParameter[1] = new InputParam(gettxtCustomerName().getText() .trim()); dataStoreParameter[2] = new InputParam(gettxtTelephone().getText() .trim()); dataStoreParameter[3] = new InputParam(gettxtCustomer().getText() .trim()); dataStoreParameter[4] = new InputParam(getCustOrdType1());// goa // 3/15/2011 dataStoreParameter[5] = new InputParam(getCustOrdType2());// goa // 3/15/2011 dataStoreParameter[6] = new InputParam(cono); dataStoreParameter[7] = new InputParam(iPageNumber * iRecordsPerPage); dataStoreParameter[8] = new InputParam(iRecordsPerPage); dataStoreParameter[9] = new InputParam(iFlag); iRecordsOnPage = 0; // AR 'Records Per Page' counter for (ResultSet resultSet = UserSetting.dataStore.executeQuery( "spCustomerF4", dataStoreParameter); resultSet.next(); moduleData .addElement(columnData)) { columnData = new String[5]; // Check for NULLs here if (resultSet.getObject(1) != null) columnData[0] = resultSet.getString(1).trim(); else columnData[0] = ""; if (resultSet.getObject(2) != null) columnData[1] = resultSet.getString(2).trim(); else columnData[1] = ""; if (resultSet.getObject(3) != null) columnData[2] = resultSet.getString(3).trim(); else columnData[2] = ""; if (resultSet.getObject(4) != null) columnData[3] = resultSet.getString(4).trim(); else columnData[3] = ""; if (resultSet.getObject(5) != null) columnData[4] = resultSet.getString(5).trim(); else columnData[4] = ""; prevData.add(columnData); iRecordsOnPage++; } iCustomerQtbl.setTotalRows(prevData); gettblCustomer().setModel(iCustomerQtbl); gettblCustomer().tableChanged( new TableModelEvent(iCustomerQtbl, 1, 1, -1, 0)); gettblCustomer().repaint(); tbcCustModel = gettblCustomer().getColumnModel(); tbcCust = tbcCustModel.getColumn(0); tbcCust.setMinWidth(85); //tbcCust.setPreferredWidth(160); tbcCust = tbcCustModel.getColumn(1); tbcCust.setMinWidth(200); //tbcCust.setPreferredWidth(160); tbcCust = tbcCustModel.getColumn(2); tbcCust.setMinWidth(90); //tbcCust.setPreferredWidth(160); tbcCust = tbcCustModel.getColumn(3); tbcCust.setMinWidth(120); //tbcCust.setPreferredWidth(160); tbcCust = tbcCustModel.getColumn(4); tbcCust.setMinWidth(70); //tbcCust.setPreferredWidth(160); itblCustomerBrowser.setAutoResizeMode(0); gettblCustomer().tableChanged( new TableModelEvent(iCustomerQtbl, 1, 1, -1, 0)); gettblCustomer().repaint(); if (prevData.size() > 0) gettblCustomer().setRowSelectionInterval(0, 0); gettxtCustomer().requestFocusInWindow(); } public void doEvents(KeyEvent pKeyEvent) { if (pKeyEvent.getKeyCode() == 33) { if (iPageNumber > 0) { iPageNumber--; onNext(); } } if (pKeyEvent.getKeyCode() == 34) { if (iRecordsOnPage >= iRecordsPerPage) iPageNumber++; onNext(); } if (pKeyEvent.getKeyCode() == 27 || pKeyEvent.getKeyCode() == 123) { onCancel(); } } public UIPanel getpnlCustomerContentPane() { // String imageName = ConfigSetting.IMAGES_PATH+"Picture1.png"; if (ipnlCustomerContentPane == null) { ipnlCustomerContentPane = new UIPanel(); ipnlCustomerContentPane.setName("UIFrameContentPane"); // ipnlClientMenuContentPane.setBackground(Color.WHITE); ipnlCustomerContentPane.setLayout(new BorderLayout()); ipnlCustomerContentPane.add(getpnlHeaderCustomerBrowser(), BorderLayout.NORTH); /* * ipnlCustomerContentPane.add(getpnlFooterCustomerBrowser(), * BorderLayout.SOUTH); */ ipnlCustomerContentPane.add(getpnlTableCustomerBrowser(), BorderLayout.CENTER); /* * ipnlCustomerContentPane.add(getpnlEastCustomerBrowser(), * BorderLayout.EAST); */ } return ipnlCustomerContentPane; } public boolean initialize(String search) { boolean retVal = true; iRecordsPerPage = 10; setName("dlgCustomerBrowser"); setDefaultCloseOperation(2); setBounds(129, 70, 665, 340); setTitle("Customer Browser"); gettxtCustomer().setText(search); String imageName = null; imageName = ConfigSetting.IMAGES_PATH; imageName = imageName + "PSFIcon.gif"; ImageIcon icon = new ImageIcon(imageName); try { getBrowserRecords(); doCenter(getFrameOwner()); setContentPane(getpnlCustomerBrowser()); gettxtCustomer().requestFocusInWindow(); } catch (PSFException re) { re.displayMessage("CustomerBrowser", "initialize"); return false; } catch (SQLException se) { (new PSFException(se.getErrorCode(), se.toString())) .displayMessage("CustomerBrowser", "initialize"); return false; } catch (NullPointerException ne) { (new PSFException(1, ne.toString())).displayMessage( "CustomerBrowser", "initialize"); return false; } finally { try { UserSetting.dataStore.closeQueryStatement(); } catch (PSFException re) { (new PSFException(3, re.toString())).displayMessage( "CustomerBrowser", "initialize"); return false; } } addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { onCancel(); } }); KeyStroke escapeKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false); Action escapeAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { onCancel(); } }; getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( escapeKeyStroke, "ESCAPE"); getRootPane().getActionMap().put("ESCAPE", escapeAction); setVisible(true); return retVal; } public UIPanel getpnlCustomerBrowser() { if (ipnlCustomerBrowser == null) { ipnlCustomerBrowser = new UIPanel(); ipnlCustomerBrowser.setName("pnlCustomerBrowser"); ipnlCustomerBrowser.setLayout(null); ipnlCustomerBrowser.setVisible(true); getpnlCustomerBrowser().add(getlblCustomer(), getlblCustomer().getName()); getpnlCustomerBrowser().add(gettxtCustomer(), gettxtCustomer().getName()); getpnlCustomerBrowser().add(getlblCustomerName(), getlblCustomerName().getName()); getpnlCustomerBrowser().add(gettxtCustomerName(), gettxtCustomerName().getName()); getpnlCustomerBrowser().add(getlblCustomerKey(), getlblCustomerKey().getName()); getpnlCustomerBrowser().add(gettxtCustomerKey(), gettxtCustomerKey().getName()); getpnlCustomerBrowser().add(getlblTelephone(), getlblTelephone().getName()); getpnlCustomerBrowser().add(gettxtTelephone(), gettxtTelephone().getName()); getpnlCustomerBrowser().add(getscrRecords(), getscrRecords().getName()); getpnlCustomerBrowser().add(getbtnOK(), getbtnOK().getName()); getpnlCustomerBrowser().add(getbtnCancel(), getbtnCancel().getName()); getpnlCustomerBrowser().add(getbtnNext(), getbtnNext().getName()); getpnlCustomerBrowser().add(getbtnPrevious(), getbtnPrevious().getName()); } return ipnlCustomerBrowser; } public void onSearch() { String search = gettxtCustomer().getText().trim(); String searchname = gettxtCustomerName().getText().trim(); String searchtel = gettxtTelephone().getText().trim(); iPageNumber = 0; // AR Get back to the first page try { iCustomerQtbl.setTotalRows(new Vector()); getBrowserRecords(); } catch (PSFException re) { re.displayMessage("CustomerBrowser", "onSearch"); dispose(); } catch (SQLException se) { (new PSFException(se.getErrorCode(), se.toString())) .displayMessage("CustomerBrowser", "onSearch"); dispose(); } catch (NullPointerException ne) { (new PSFException(1, ne.toString())).displayMessage( "CustomerBrowser", "onSearch"); dispose(); } finally { try { UserSetting.dataStore.closeQueryStatement(); } catch (PSFException re) { (new PSFException(3, re.toString())).displayMessage( "CustomerBrowser", "onSearch"); dispose(); } } gettxtCustomerKey().requestFocus(); } public void setSearchValue(String pSearchValue) { iSearchValue = pSearchValue; } public void setIFlag(int pIFlag) { iFlag = pIFlag; } public void onNext() { String search = gettxtCustomer().getText().trim(); String searchnext = gettxtCustomerName().getText().trim(); String searchtel = gettxtTelephone().getText().trim(); try { getBrowserRecords(); } catch (PSFException re) { re.displayMessage("CustomerBrowser", "onSearch"); dispose(); } catch (SQLException se) { (new PSFException(se.getErrorCode(), se.toString())) .displayMessage("CustomerBrowser", "onSearch"); dispose(); } catch (NullPointerException ne) { (new PSFException(1, ne.toString())).displayMessage( "CustomerBrowser", "onSearch"); dispose(); } finally { try { UserSetting.dataStore.closeQueryStatement(); } catch (PSFException re) { (new PSFException(3, re.toString())).displayMessage( "CustomerBrowser", "onSearch"); dispose(); } } } public void setCustomer(String s) { } // start goa 3/15/2011 public void setCustOrdType1(String custOrdType1) { CustOrdType1 = custOrdType1; } public String getCustOrdType1() { return CustOrdType1; } public void setCustOrdType2(String custOrdType2) { CustOrdType2 = custOrdType2; } public String getCustOrdType2() { return CustOrdType2; } // end goa 3/15/2011 private UIButton ibtnOK; private UIButton ibtnNext; private UIButton ibtnPrevious; private UIButton ibtnCancel; private UIPanel ipnlCustomerBrowser; private UIPanel ipnlHeaderCustomerBrowser; private UIPanel ipnlFooterCustomerBrowser; private UIPanel ipnlEastCustomerBrowser; private UIPanel ipnlTableCustomerBrowser; private UIPanel ipnlCustomerContentPane; private UIScrollPane iscrRecords; private UILabel ilblSearchCustomer; private UITextField itxtSearchCustomer; private UILabel ilblCustomerKey; private UILabel ilblCustomerName; private UILabel ilblTelephone; private UITextField itxtCustomerKey; private UITextField itxtCustomerName; private UITextField itxtTelephone; private UITable itblCustomerBrowser; private UIDialog iFrame; private CustomerBrowserTableModel iCustomerQtbl; private String iCustomerNo; private int iPageNumber; private int iFlag; private String iSearchValue; private String CustOrdType1;// goa 3/15/2011 private String CustOrdType2;// goa 3/15/2011 private int iRecordsPerPage; private int iRecordsOnPage; private int iRecords; private UIFrame iframe; }
regards,
Prakash BLast edited by Norm; 11-17-2011 at 05:20 PM. Reason: added code tags
- 11-17-2011, 05:14 PM #13
Re: Swing UI display
The first 'S' in SSCCE stands for "short". That is certainly not short.
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 11-20-2011, 01:34 PM #14
Member
- Join Date
- Jul 2011
- Posts
- 8
- Rep Power
- 0
Re: Swing UI display
The following is the Parent dialog (Cash Order screen)code which will open the child dialog (Customer search browser screen) on f4 key press
Java Code:public class CashOrder extends UIDialog { //instance variable declarations for dialog components private UITextField itxtCustomer; // Constructor which sets the parent frame public CashOrder(UIFrame pParentFrame) { //calling super class constructor passing the instance of parent frame super(pParentFrame); //initializing the instance variables itxtCustomer = null; }//end construtor //getter method which returns the instance of textfield public UITextField gettxtCustomer() { if (itxtCustomer == null) { //Setting the upper case document UpperCase uppercase = new UpperCase(); uppercase.setSize(10); itxtCustomer = new UITextField(uppercase, null, 0); itxtCustomer.setName("txtCustomer"); itxtCustomer.setBounds(90, 59, 100, 20); //adding key listner itxtCustomer.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent pKeyEvent) { int keyCode = pKeyEvent.getKeyCode(); int modifiers = pKeyEvent.getModifiers(); focus = true; //on f4 key if((modifiers!=1 || keyCode!=115)&& pKeyEvent.getKeyCode()==115 && pKeyEvent.getSource() == itxtCustomer) { focus = false; //this method opens the child dialog callCustomerBrowser(); if(Common.isBlank(gettxtCustomer().getText())){ gettxtCustomer().grabFocus(); return; }//end if setHeaderData(); focus = true; gettxtAddressNumber().requestFocusInWindow(); }//end if //on enter if (pKeyEvent.getKeyCode() == 10) if (checkCustomer()) { gettxtAddressNumber().grabFocus(); setHeaderData(); }//end if }//end of keyPressed });//end of addKeyListener //adding focus listner itxtCustomer.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent evt) { if(gettxtCustomer().isEditable()) { if(focus) { if (checkCustomer()) { //gettxtAddressNumber().grabFocus(); setHeaderData(); }else{ focus = false; } } } } }); } return itxtCustomer; }//end of gettxtCustomer /*** This method opens the customer search browser upon pressing F4 in the Cash Order Screen on the Customer Number Field. public void callCustomerBrowser() { //refer below CustomerBrowser class CustomerBrowser custBrowser = new CustomerBrowser(this); custBrowser.setFrameOwner(this); custBrowser.setSearchValue(gettxtCustomer().getText()); custBrowser.setIFlag(iFlag); custBrowser.setCustOrdType1(getCustOrderType1()); custBrowser.setCustOrdType2(getCustOrderType2()); custBrowser.initialize(itxtCustomer.getText().trim()); }//end of callCustomerBrowser }//end of class The following is the child dialog (Customer search browser screen)code which is opened from Parent dialog (Cash Order screen)on f4 key press public class CustomerBrowser extends UIDialog { public CustomerBrowser(UIDialog pDialog) { //pDialog is CashOrder instance super(pDialog, true); } //This method retuns the instance of select button public UIButton getbtnOK() { if (ibtnOK == null) { ibtnOK = new UIButton(); ibtnOK.setName("btnOK"); ibtnOK.setText("Select"); ibtnOK.setBounds(570, 200, 80, 25); ibtnOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { onOK(); } }); ibtnOK.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent pKeyEvent) { doEvents(pKeyEvent); } }); } return ibtnOK; } public UIDialog getFrameOwner() { return iFrame; } //This method disposes the dialog when cancel button is clicked public void onCancel() { dispose(); } //this method is called when select button is pressed //this is where this screen merges in to the parent screen (CashOrder screen) public void onOK() { if (itblCustomerBrowser.getRowCount() > 0) { iCustomerNo = itblCustomerBrowser.getValueAt( itblCustomerBrowser.getSelectedRow(), 3).toString(); } else { iCustomerNo = ""; } ((CustomerBrowserInf) getFrameOwner()).setCustomer(iCustomerNo); dispose(); } public void setFrameOwner(UIDialog pFrame) { iFrame = pFrame; } //this method retrieves data from database as a vector and set it in this dialogs jtable public void getBrowserRecords() throws PSFException, SQLException { int cono = Integer.parseInt(Configuration.getParameter(ConfigSetting.COMPANY_NO)); Vector prevData = null; TableColumnModel tbcCustModel = null; TableColumn tbcCust = null; // iFlag = 1; if (iCustomerQtbl == null) { iCustomerQtbl = new CustomerBrowserTableModel(); iCustomerQtbl.setTotalRows(new Vector(5)); } OprOrders iOprDelMethod = new OprOrders(cono, "", "", 0); prevData = iOprDelMethod.getCustomerBrowsRecord(gettxtCustomerKey().getText().trim(), gettxtCustomerName().getText().trim(),gettxtTelephone().getText().trim(), gettxtCustomer().getText().trim(), getCustOrdType1(),getCustOrdType2(),cono,iPageNumber,iRecordsPerPage,iFlag); iRecordsOnPage = iOprDelMethod.getRecordsOnPage(); iCustomerQtbl.setTotalRows(prevData); gettblCustomer().setModel(iCustomerQtbl); gettblCustomer().tableChanged(new TableModelEvent(iCustomerQtbl, 1, 1, -1, 0)); gettblCustomer().repaint(); tbcCustModel = gettblCustomer().getColumnModel(); tbcCust = tbcCustModel.getColumn(0); tbcCust.setMinWidth(85); //tbcCust.setPreferredWidth(160); tbcCust = tbcCustModel.getColumn(1); tbcCust.setMinWidth(200); //tbcCust.setPreferredWidth(160); tbcCust = tbcCustModel.getColumn(2); tbcCust.setMinWidth(90); //tbcCust.setPreferredWidth(160); tbcCust = tbcCustModel.getColumn(3); tbcCust.setMinWidth(120); //tbcCust.setPreferredWidth(160); tbcCust = tbcCustModel.getColumn(4); tbcCust.setMinWidth(70); //tbcCust.setPreferredWidth(160); itblCustomerBrowser.setAutoResizeMode(0); gettblCustomer().tableChanged(new TableModelEvent(iCustomerQtbl, 1, 1, -1, 0)); gettblCustomer().repaint(); if (prevData.size() > 0) gettblCustomer().setRowSelectionInterval(0, 0); gettxtCustomer().requestFocusInWindow(); } public void doEvents(KeyEvent pKeyEvent) { if (pKeyEvent.getKeyCode() == 33) { if (iPageNumber > 0) { iPageNumber--; onNext(); } } if (pKeyEvent.getKeyCode() == 34) { if (iRecordsOnPage >= iRecordsPerPage) iPageNumber++; onNext(); } if (pKeyEvent.getKeyCode() == 27 || pKeyEvent.getKeyCode() == 123) { onCancel(); } } //to show the dialog public boolean initialize(String search) { boolean retVal = true; iRecordsPerPage = 10; setName("dlgCustomerBrowser"); setDefaultCloseOperation(2); setBounds(129, 70, 665, 340); setTitle("Customer Browser"); gettxtCustomer().setText(search); String imageName = null; imageName = ConfigSetting.IMAGES_PATH; imageName = imageName + "PSFIcon.gif"; ImageIcon icon = new ImageIcon(imageName); try { //populates data in to the table of this dialog getBrowserRecords(); doCenter(getFrameOwner()); setContentPane(getpnlCustomerBrowser()); gettxtCustomer().requestFocusInWindow(); } catch (PSFException re) { re.displayMessage("CustomerBrowser", "initialize"); return false; } catch (SQLException se) { (new PSFException(se.getErrorCode(), se.toString())) .displayMessage("CustomerBrowser", "initialize"); return false; } catch (NullPointerException ne) { new PSFException(1, ne.toString())).displayMessage("CustomerBrowser", "initialize"); return false; } finally { try { UserSetting.dataStore.closeQueryStatement(); } catch (PSFException re) { (new PSFException(3, re.toString())).displayMessage( "CustomerBrowser", "initialize"); return false; } } addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { onCancel(); }}); KeyStroke escapeKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0, false); Action escapeAction = new AbstractAction() { public void actionPerformed(ActionEvent e) { onCancel(); } }; getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeKeyStroke, "ESCAPE"); getRootPane().getActionMap().put("ESCAPE", escapeAction); setVisible(true); return retVal; }//end of initialize //returns the panel of this dialog public UIPanel getpnlCustomerBrowser() { if (ipnlCustomerBrowser == null) { ipnlCustomerBrowser = new UIPanel(); ipnlCustomerBrowser.setName("pnlCustomerBrowser"); ipnlCustomerBrowser.setLayout(null); ipnlCustomerBrowser.setVisible(true); getpnlCustomerBrowser().add(getlblCustomer(),getlblCustomer().getName()); getpnlCustomerBrowser().add(gettxtCustomer(),gettxtCustomer().getName()); } return ipnlCustomerBrowser; }//end of getpnlCustomerBrowser }//end of class
The child screen is merging in to parent screen when select button is pressed in child screen
please find attachment.Last edited by Norm; 11-20-2011 at 01:48 PM. Reason: added code tags
- 11-20-2011, 01:49 PM #15
Re: Swing UI display
Please edit your last post and insert proper indentations. Your unformatted code is hard to read.
- 11-20-2011, 02:19 PM #16
Similar Threads
-
Display only certain contents of text file and edit display
By blkshrk81 in forum New To JavaReplies: 1Last Post: 12-01-2010, 06:35 PM -
What is the different between Text format display on web browser and display on midle
By Basit781 in forum CLDC and MIDPReplies: 1Last Post: 05-31-2010, 08:46 AM -
how to do display hexadecimal value in jtextfield in swing
By santhosh_el in forum AWT / SwingReplies: 4Last Post: 04-08-2009, 05:51 AM -
How to display a list of items and on click display subitems?
By mandyj in forum New To JavaReplies: 8Last Post: 12-29-2008, 07:12 AM -
Swing program to display JVM information
By satya007 in forum AWT / SwingReplies: 3Last Post: 11-13-2007, 09:59 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks