Zolf
asked on
OutOfMemoryError: Java heap space
hello there,
i have a java application with JTree and the jtree is created from the db and when a tree node is clicked.data is displayed onthe right side of the jsplitpane.when i keep opening the tree nodes for about 8-9 tree nodes.i get this error.please help me solve this problem.
Exception in thread "Thread-40" java.lang.OutOfMemoryError : Java heap space
at javax.swing.text.GapConten t.allocate Array(Unkn own Source)
at javax.swing.text.GapVector .<init>(Un known Source)
at javax.swing.text.GapConten t.<init>(U nknown Source)
at javax.swing.text.html.HTML Document.< init>(Unkn own Source)
at javax.swing.plaf.basic.Bas icHTML$Bas icDocument .<init>(Un known Source)
at javax.swing.plaf.basic.Bas icHTML$Bas icEditorKi t.createDe faultDocum ent(Unknow n Source)
at javax.swing.plaf.basic.Bas icHTML.cre ateHTMLVie w(Unknown Source)
at javax.swing.plaf.basic.Bas icHTML.upd ateRendere r(Unknown Source)
at javax.swing.plaf.basic.Bas icButtonLi stener.pro pertyChang e(Unknown Source)
at java.beans.PropertyChangeS upport.fir ePropertyC hange(Unkn own Source)
at java.beans.PropertyChangeS upport.fir ePropertyC hange(Unkn own Source)
at java.awt.Component.firePro pertyChang e(Unknown Source)
at javax.swing.AbstractButton .setText(U nknown Source)
at src.com.victa.TreeTableInt ernalFrame .createTer minalButto nsPanel(Tr eeTableInt ernalFrame .java:1070 )
at src.com.victa.TreeTableInt ernalFrame $2.run(Tre eTableInte rnalFrame. java:458)
at java.lang.Thread.run(Unkno wn Source)
i have a java application with JTree and the jtree is created from the db and when a tree node is clicked.data is displayed onthe right side of the jsplitpane.when i keep opening the tree nodes for about 8-9 tree nodes.i get this error.please help me solve this problem.
Exception in thread "Thread-40" java.lang.OutOfMemoryError
at javax.swing.text.GapConten
at javax.swing.text.GapVector
at javax.swing.text.GapConten
at javax.swing.text.html.HTML
at javax.swing.plaf.basic.Bas
at javax.swing.plaf.basic.Bas
at javax.swing.plaf.basic.Bas
at javax.swing.plaf.basic.Bas
at javax.swing.plaf.basic.Bas
at java.beans.PropertyChangeS
at java.beans.PropertyChangeS
at java.awt.Component.firePro
at javax.swing.AbstractButton
at src.com.victa.TreeTableInt
at src.com.victa.TreeTableInt
at java.lang.Thread.run(Unkno
You may need to increase the heap size of the application.
use
-Xmx512m
on the command line of the java if you want to set the max heap size as 512M.
-Xmx512m
on the command line of the java if you want to set the max heap size as 512M.
I think you should explore your codes and release unnecessary arrays and objects you are no longer use them or at least you don't need them this very soon.
ASKER
Ajay-Singh:
the ram on my system is 512.if i give it all 512 then wont it reduce my system performance.my aplication starts using JNLP
mnrz:
can you please help me more on your comment.please help me sort this.
post the code written when a node is being clicked
ASKER
public class TreeTableInternalFrame extends JInternalFrame
{
public final String CITY_CO_DSLAM_PANEL = "city_co_dslam_panel";
public final String CO_DETALED_PANEL = "co_detaled_panel";
public final String MDF_PANEL = "mdf_panel";
public final String BUTTON_PANEL = "button_panel";
public final String SPLITTER_PANEL = "splitter_panel";
private ImageIcon testIcon;
private ImageIcon cityIcon;
private ImageIcon coIcon;
private ImageIcon dslamIcon;
private ImageIcon linecardIcon;
private ImageIcon refreshIcon;
private ImageIcon mapIcon;
private ImageIcon cityMap;
private ImageIcon dslamGroupIcon;
private ImageIcon splitterGroupIcon;
private ImageIcon mdfGroupIcon;
private ImageIcon mdfIcon;
private ImageIcon splitterIcon;
private DefaultMutableTreeNode lastSelectedNode;
private JTree tree;
private JTable cityTable;
private JTable coTable;
private JTable dslamTable;
private JTable linecardTable;
private JTabbedPane tabPane;
private JLabel label;
private JPopupMenu treePopupMenu;
private Vector cityCollect;
private Vector coCollect;
private Vector dslamCollect;
private Vector linecardCollect;
private Vector mdfCollect;
private Vector splitterCollect;
private Vector cityPrivilegeCollect;
private Vector coPrivilegeCollect;
private Vector dslamPrivilegeCollect;
private Vector linecardPrivilegeCollect;
private Vector mdfPrivilegeCollect;
private Vector splitterPrivilegeCollect;
private JPanel rightCardPanel = null;
private JLabel coId;
private JLabel coFarsiName;
private JLabel coEnglishName;
private JPanel innerCardPanel = null;
private JTabbedPane mdfTabPane;
private JTabbedPane splitterTabPane;
private JTable mdfTable;
private JTable splitterTable;
PictMenuFrameDemo JFParentFrame;
int pk;
int fk;
ImageIcon iIcon;
JPanel mapPane;
JScrollPane jspMap;
int buttonNo;
JPanel coDetaledPanel;
private ThumbnailPanel thnPanel;
private Connection connection;
private JScrollPane jspPhoto;
private String homeDir = "";
private ImageIcon addIcon;
private ImageIcon delIcon;
private ImageIcon photoIcon;
boolean flag = true;
JSplitPane splitPane;
TreePath selPath;
DefaultMutableTreeNode coselect;
Vector cov = null;
CoRow co;
Vector vc= null;
TreePath[] paths;
TreePath paths1;
Object [] o;
JProgressBar progressBar;
JPanel buttonPanel = null;
int privilege = 0;
int city_id = 0;
public TreeTableInternalFrame(fin al PictMenuFrameDemo frame)
{
super("Bücht Automation",
true, //resizable
true, //closable
true, //maximizable
true);//iconifiable
Dimension deskSize = frame.getDesktop().getSize ();
setSize((int)deskSize.getW idth(), (int)deskSize.getHeight()) ;
//Set the window's location.
setLocation(0, 0);
JFParentFrame = frame;
privilege = Login.privilege;
//privilege = 1;
//get database result in to collections
//initCollections(PictMenu FrameDemo. getDBConne ction());
if(privilege == 1 || privilege == 0)
{
initCollections(PictMenuFr ameDemo.ge tDBConnect ion());
}
else if(privilege == 2)
{
city_id = Login.cityView;
initPrivilegeCollections(P ictMenuFra meDemo.get DBConnecti on(),city_ id);
}
else if(privilege == 3)
{
city_id = Login.cityView;
initPrivilegeCollections(P ictMenuFra meDemo.get DBConnecti on(),city_ id);
}
progressBar = new JProgressBar();
testIcon = new ImageIcon(getClass().getRe source("/i mages/dsla mIcon.png" ));
//cityIcon = new ImageIcon(Toolkit.getDefau ltToolkit( ).createIm age("image s/cityIcon .png"));
cityIcon = new ImageIcon(getClass().getRe source("/i mages/city Icon.png") );
//coIcon = new ImageIcon(Toolkit.getDefau ltToolkit( ).createIm age("image s/coIcon.p ng"));
coIcon = new ImageIcon(getClass().getRe source("/i mages/coIc on.png"));
//dslamIcon = new ImageIcon(Toolkit.getDefau ltToolkit( ).createIm age("image s/dslamIco n.png"));
dslamIcon = new ImageIcon(getClass().getRe source("/i mages/dsla mIcon.png" ));
//linecardIcon = new ImageIcon(Toolkit.getDefau ltToolkit( ).createIm age("image s/cardIcon .png"));
linecardIcon = new ImageIcon(getClass().getRe source("/i mages/card Icon.png") );
refreshIcon = new ImageIcon(getClass().getRe source("/i mages/refr esh.jpg")) ;
mapIcon = new ImageIcon(getClass().getRe source("/i mages/map. png"));
//ImageIcon iIcon = null;
dslamGroupIcon = new ImageIcon(getClass().getRe source("/i mages/dsIc on.PNG"));
splitterGroupIcon = new ImageIcon(getClass().getRe source("/i mages/spIc on.PNG"));
mdfGroupIcon = new ImageIcon(getClass().getRe source("/i mages/mIco n.PNG"));
mdfIcon = new ImageIcon(getClass().getRe source("/i mages/mdfI con.PNG")) ;
splitterIcon = new ImageIcon(getClass().getRe source("/i mages/spli tterIcon.P NG"));
addIcon = new ImageIcon(getClass().getRe source("/i mages/addI con.PNG")) ;
delIcon = new ImageIcon(getClass().getRe source("/i mages/delI con.PNG")) ;
photoIcon = new ImageIcon(getClass().getRe source("/i mages/phot oIcon.png" ));
//set layout for frame content panel
Container cp = getContentPane();
cp.setLayout(new BorderLayout());
//create toolbar
JToolBar toolbar = createToolbar();
cp.add(toolbar, BorderLayout.NORTH);
// create popup menu for tree
//treePopupMenu = createPopupMenu();
// create tree element
// createAndInitPrivilegeTree ();
//createAndInitTree();
if(privilege == 1 || privilege == 0)
{
createAndInitTree();
}
else if(privilege == 2)
{
createAndInitPrivilegeTree ();
}
else if(privilege == 3)
{
createAndInitPrivilegeTree ();
}
tree.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent me) {
Object obj = tree.getLastSelectedPathCo mponent();
if(obj != null) {
DefaultMutableTreeNode select = (DefaultMutableTreeNode)ob j;
//System.out.print("select != lastSelectedNode ");
//System.out.println(selec t != lastSelectedNode);
if (select != lastSelectedNode)
{
Object uObject = select.getUserObject();
pk = ((BaseRow)uObject).getPrim aryKey();
fk = ((BaseRow)uObject).getFore ignKey();
//System.out.println(pk);
//System.out.println(fk);
switch(((BaseRow)uObject). getType()) {
case BaseRow.CITY_TYPE : {
changeCard(rightCardPanel, CITY_CO_DSLAM_PANEL);
int index = 0;
if(privilege == 1 || privilege == 0)
{
index= Collections.binarySearch(c ityCollect , obj, new PrimaryKeyComparator());
}
else if(privilege == 2)
{
index = Collections.binarySearch(c ityPrivile geCollect, obj, new PrimaryKeyComparator());
}
else if(privilege == 3)
{
index = Collections.binarySearch(c ityPrivile geCollect, obj, new PrimaryKeyComparator());
}
cityTable.setRowSelectionI nterval(in dex, index);
cityTable.scrollRectToVisi ble(cityTa ble.getCel lRect(inde x, 0, true));
tabPane.setSelectedIndex(0 );
fk = ((BaseRow)uObject).getFore ignKey();
ImageIcon im = getIm(fk);
label.setIcon(im);
//System.out.println("Mous e Image "+fk);
//iIcon = getImage(fk);
//updateMapPanel(fk);
initChildrenTables(select) ;
int cityId = ((CityRow)uObject).getCity Id().intVa lue();
thnPanel.clear();
fillThumbnails(false, cityId);
thnPanel.sort();
thnPanel.recountOnResize(j spPhoto.ge tViewport( ).getWidth ());
thnPanel.repaint();
break;
}
case BaseRow.CO_TYPE : {
changeCard(rightCardPanel, CITY_CO_DSLAM_PANEL);
Vector cov = getNodesThisLevel(coCollec t, select);
int selIndex = Collections.binarySearch(c ov, select, new PrimaryKeyComparator());
if (!isSameBranch(select,last SelectedNo de)) {
removeAllRows(coTable);
initCoTable(cov);
}
coTable.setRowSelectionInt erval(selI ndex, selIndex);
tabPane.setSelectedIndex(1 );
initChildrenTables(select) ;
initParentsTables(select);
break;
}
case BaseRow.DSLAM_TYPE : {
changeCard(rightCardPanel, CITY_CO_DSLAM_PANEL);
Vector cod = getNodesThisLevel(dslamCol lect, select);
int selIndex = Collections.binarySearch(c od, select, new PrimaryKeyComparator());
if (!isSameBranch(select,last SelectedNo de)) {
removeAllRows(dslamTable);
initDslamTable(cod);
}
dslamTable.setRowSelection Interval(s elIndex, selIndex);
tabPane.setSelectedIndex(2 );
initChildrenTables(select) ;
initParentsTables(select);
break;
}
case BaseRow.LINECARD_TYPE : {
changeCard(rightCardPanel, CITY_CO_DSLAM_PANEL);
Vector col = getNodesThisLevel(linecard Collect, select);
int selIndex = Collections.binarySearch(c ol, select, new PrimaryKeyComparator());
if (!isSameBranch(select,last SelectedNo de))
{
removeAllRows(linecardTabl e);
initLinecardTable(col);
}
linecardTable.setRowSelect ionInterva l(selIndex , selIndex);
tabPane.setSelectedIndex(3 );
initParentsTables(select);
break;
}
case BaseRow.NAME_TYPE : {
String name = ((BaseRow)uObject).toStrin g();
if (name.equals("DSLAM"))
{
changeCard(rightCardPanel, CITY_CO_DSLAM_PANEL);
DefaultMutableTreeNode pselect = (DefaultMutableTreeNode)se lect.getPa rent();
//System.out.println("AFTE R "+pselect);
Vector cov = getNodesThisLevel(coCollec t, pselect);
//System.out.println("DSLA M "+cov.size());
int selIndex = Collections.binarySearch(c ov, pselect, new PrimaryKeyComparator());
if (!isSameBranch(pselect,las tSelectedN ode))
{
removeAllRows(coTable);
initCoTable(cov);
}
coTable.setRowSelectionInt erval(selI ndex, selIndex);
tabPane.setSelectedIndex(2 );
initChildrenTables(pselect );
initParentsTables(pselect) ;
}
else
{
changeCard(rightCardPanel, CO_DETALED_PANEL);
DefaultMutableTreeNode pselect = (DefaultMutableTreeNode)se lect.getPa rent();
co = (CoRow)pselect.getUserObje ct();
if (name.equals("TERMINAL"))
{
//System.out.println("INSI DE ");
//System.out.println("AFTE R "+co.getCoId().toString()+ " "+co.getCoEngName()+" "+co.getCoDirection());
//changeCard(innerCardPane l, MDF_PANEL);
coselect = (DefaultMutableTreeNode)se lect.getPa rent();
//return mdfData;
//Vector getMdfCollection(Connectio n connect,int id)
DefaultMutableTreeNode terminal = (DefaultMutableTreeNode)se lect;
//System.out.println("afte r C "+terminal);
cov = getTerminalNodesThisLevel( mdfCollect , coselect);
//System.out.println("afte r TERMINAL CLCIKED"+cov.toString());
vc = getTerminalPriNodesThisLev el(mdfColl ect, coselect);
//System.out.println("afte r TERMINAL CLCIKED"+vc.toString());
//Vector v = getMdfCollection(frame.get DBConnecti on(),int id);
buttonNo = cov.size();
//System.out.println("afte r Vector "+buttonNo);
//rightCardPanel.removeAll ();//Array s.asList(n ode.getPat h())
//System.out.println("afte r Vector "+Arrays.asList(coselect.g etPath())) ;
///////TreeNode tn = coselect.getPath();
paths = tree.getSelectionPaths();
paths1 = tree.getSelectionPath();
Object[]path = null;
if(paths == null)
return;
for(int i=0;i<paths.length;i++)
{
path = paths[i].getPath();
for (int j=0; j<path.length; j++)
{
//System.out.print(path[j] + "/");
}
}
// System.out.println("-"+pat hs1);
//expandNode(tree, paths1);
//tree.expandPath(paths1);
//tree.setSelectionPath(pa ths1);
coDetaledPanel = createTerminalPanel(create Buttons(bu ttonNo,cov ,vc,paths1 ,terminal) ,co.getCoD irection() .intValue( ));
rightCardPanel.add(coDetal edPanel, CO_DETALED_PANEL);
changeCard(rightCardPanel, CO_DETALED_PANEL);
changeCard(innerCardPanel, MDF_PANEL);
rightCardPanel.revalidate( );
rightCardPanel.repaint();
}
/*else if (name.equals("SPLITTER"))
{
changeCard(innerCardPanel, SPLITTER_PANEL);
splitterTabPane.setSelecte dIndex(0);
}*/
}
break;
}
case BaseRow.MDF_TYPE : {
changeCard(rightCardPanel, CO_DETALED_PANEL);
changeCard(innerCardPanel, BUTTON_PANEL);
//System.out.println("INSI DE MDF");
DefaultMutableTreeNode pselect = (DefaultMutableTreeNode)se lect.getPa rent().get Parent();
CoRow co = (CoRow)pselect.getUserObje ct();
Vector cov = getNodesThisLevel(mdfColle ct, select);
int selIndex = Collections.binarySearch(c ov, select, new PrimaryKeyComparator());
final Progress p = new Progress();
try
{
p.runProgress();
}
catch(Exception e)
{
e.printStackTrace ();
}
Thread t = new Thread(new Runnable(){
public void run()
{
try
{
//System.out.println("INSI DE TRY");
buttonPanel = createTerminalButtonsPanel (pk);
JScrollPane jspMap = new JScrollPane(buttonPanel,JS crollPane. VERTICAL_S CROLLBAR_A S_NEEDED,
JScrollPane.HORIZONTAL_SCR OLLBAR_AS_ NEEDED);
innerCardPanel.add(jspMap, BUTTON_PANEL);
changeCard(rightCardPanel, CO_DETALED_PANEL);
changeCard(innerCardPanel, BUTTON_PANEL);
p.hide();
}
catch(Exception e)
{
e.printStackTrace ();
}
}
});
/*Thread th = new Thread(new Runnable() {
public void run() {
try
{
p.runProgress();
}
catch(Exception e)
{
e.printStackTrace ();
}
}
});*/
// th.start();
t.start();
// th.destroy();
if (!isSameBranch(select, lastSelectedNode))
{
//System.out.println("pk "+pk);
//removeAllRows(mdfTable);
//initMdfTable(cov);
}
//mdfTable.setRowSelection Interval(s elIndex, selIndex);
break;
}
/*case BaseRow.SPLITTER_TYPE : {
changeCard(rightCardPanel, CO_DETALED_PANEL);
changeCard(innerCardPanel, SPLITTER_PANEL);
DefaultMutableTreeNode pselect = (DefaultMutableTreeNode)se lect.getPa rent().get Parent();
CoRow co = (CoRow)pselect.getUserObje ct();
coId.setText(co.getCoId(). toString() );
coFarsiName.setText(co.get CoFarsiNam e());
coEnglishName.setText(co.g etCoEngNam e());
Vector cov = getNodesThisLevel(splitter Collect, select);
int selIndex = Collections.binarySearch(c ov, select, new PrimaryKeyComparator());
if (!isSameBranch(select, lastSelectedNode))
{
removeAllRows(splitterTabl e);
initSplitterTable(cov);
}
splitterTable.setRowSelect ionInterva l(selIndex , selIndex);
break;
}*/
}
lastSelectedNode = select;
}
}
}
public void mouseReleased(MouseEvent me)
{
if (me.isPopupTrigger())
{
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)tr ee.getLast SelectedPa thComponen t();
//treePopupMenu.show(me.ge tComponent (), me.getX(), me.getY());
selPath = tree.getPathForLocation(me .getX(), me.getY());
//System.out.println(selPa th.getLast PathCompon ent());
//System.out.println("selP ath.getPat h() "+Arrays.asList(selPath.ge tPath()));
o = selPath.getPath();
/*for(int i=0;i<o.length;i++)
{
System.out.println("path "+o[i]);
}*/
//System.out.println("path "+selPath.getPathCount());
Object ob = selPath.getPathComponent(1 );
//System.out.println("path q "+ob);
Object obj = selPath.getLastPathCompone nt();
String str= null;
if(obj != null)
{
DefaultMutableTreeNode selectNode = (DefaultMutableTreeNode)ob j;
//System.out.println("sele ctNode "+selectNode.getLeafCount( ));
//System.out.println("sele ctNode "+selPath.getParentPath(). getLastPat hComponent ());
str = selPath.getParentPath().ge tLastPathC omponent() .toString( );
//System.out.println("sele ctNode "+str);
if (selectNode != lastSelectedNode)
{
//System.out.println(selec tNode);
Object uObject = selectNode.getUserObject() ;
///System.out.println("clc iked +++ "+uObject);
//System.out.println("FK "+((BaseRow)uObject).getPr imaryKey() );
pk = ((BaseRow)uObject).getPrim aryKey();
//System.out.println(" pk "+pk);
}
}
if(selPath.getPathCount()= = 2)
{
treePopupMenu = createPopupMenuCo();
treePopupMenu.show(me.getC omponent() , me.getX(), me.getY());
//System.out.println("path ss ");
}
if(selPath.getPathCount()= = 3)
{
treePopupMenu = createPopupMenuDslam();
treePopupMenu.show(me.getC omponent() , me.getX(), me.getY());
//System.out.println("path ss ");
}
/*if(selPath.getPathCount( )== 5)
{
treePopupMenu = createPopupMenuLinecard();
treePopupMenu.show(me.getC omponent() , me.getX(), me.getY());
//System.out.println("path ss ");
} */
if(selPath.getPathCount()= = 6)
{
treePopupMenu = createPopupMenuLine();
treePopupMenu.show(me.getC omponent() , me.getX(), me.getY());
//System.out.println("path ss ");
}
if(str.equals("DSLAM"))
{
treePopupMenu = createPopupMenuLinecard();
treePopupMenu.show(me.getC omponent() , me.getX(), me.getY());
}
if(str.equals("TERMINAL"))
{
treePopupMenu = createPopupMenuTerminal();
treePopupMenu.show(me.getC omponent() , me.getX(), me.getY());
}
/*if(str.equals("SPLITTER" ))
{
treePopupMenu = createPopupMenuSplitter();
treePopupMenu.show(me.getC omponent() , me.getX(), me.getY());
}*/
}
}
});
JScrollPane jsp = new JScrollPane(tree, JScrollPane.VERTICAL_SCROL LBAR_AS_NE EDED,
JScrollPane.HORIZONTAL_SCR OLLBAR_AS_ NEEDED);
rightCardPanel = new JPanel();
rightCardPanel.setLayout(n ew CardLayout());
//create tab panel
tabPane = new JTabbedPane();
JPanel cityPane = new JPanel(new BorderLayout());
//createCityTable();
if(privilege == 1 || privilege == 0)
{
createCityTable();
}
else if(privilege == 2)
{
createCityPrivilegeTable() ;
}
else if(privilege == 3)
{
createCityPrivilegeTable() ;
}
JScrollPane jspCity = new JScrollPane(cityTable, JScrollPane.VERTICAL_SCROL LBAR_AS_NE EDED,
JScrollPane.HORIZONTAL_SCR OLLBAR_NEV ER);
cityPane.add(jspCity, BorderLayout.CENTER);
tabPane.addTab(" City ", cityIcon, cityPane);
JPanel coPane = new JPanel(new BorderLayout());
createCoTable();
JScrollPane jspCo = new JScrollPane(coTable, JScrollPane.VERTICAL_SCROL LBAR_AS_NE EDED,
JScrollPane.HORIZONTAL_SCR OLLBAR_NEV ER);
coPane.add(jspCo, BorderLayout.CENTER);
tabPane.addTab(" Co ", coIcon, coPane);
JPanel dslamPane = new JPanel(new BorderLayout());
createDslamTable();
JScrollPane jspDslam = new JScrollPane(dslamTable, JScrollPane.VERTICAL_SCROL LBAR_AS_NE EDED,
JScrollPane.HORIZONTAL_SCR OLLBAR_NEV ER);
dslamPane.add(jspDslam, BorderLayout.CENTER);
tabPane.addTab(" Dslam ", dslamIcon, dslamPane);
JPanel linecardPane = new JPanel(new BorderLayout());
createlinecardTable();
JScrollPane jspLinecard = new JScrollPane(linecardTable, JScrollPane.VERTICAL_SCROL LBAR_AS_NE EDED,
JScrollPane.HORIZONTAL_SCR OLLBAR_NEV ER);
linecardPane.add(jspLineca rd, BorderLayout.CENTER);
tabPane.addTab(" Linecard ", linecardIcon, linecardPane);
mapPane = new JPanel(new BorderLayout());
label = getImage(fk);
//System.out.println("fore ign "+fk);
//iIcon = DBImage.dbImage(29);
//iIcon = DBImage.dbImage(fk);
//cityMap = new ImageIcon(getClass().getRe source("/i mages/tehr an.gif"));
//System.out.print("Image "+iIcon);
jspMap = new JScrollPane(label,JScrollP ane.VERTIC AL_SCROLLB AR_AS_NEED ED,
JScrollPane.HORIZONTAL_SCR OLLBAR_NEV ER);
mapPane.add(jspMap, BorderLayout.CENTER);
tabPane.addTab(" Map ", mapIcon, mapPane);
JPanel photoPane = new JPanel(new BorderLayout());
JToolBar photoControlPanel = new JToolBar();
photoControlPanel.setFloat able(false );
JButton addPhoto = new JButton(addIcon);
addPhoto.addMouseListener( new MouseAdapter() {
public void mousePressed(MouseEvent me) {
BaseRow row = (BaseRow)lastSelectedNode. getUserObj ect();
//System.out.println("butt on clicked");
if (row.getType() == BaseRow.CO_TYPE)
{
int coId = ((CoRow)row).getCoId().int Value();
String coName = ((CoRow)row).getCoEngName( );
String startDir = "";
if (homeDir.length() == 0)
{
startDir = (String)System.getProperty ("user.dir ", "c:\\");
}
else
{
startDir = homeDir;
}
JFileChooser fc = new JFileChooser(startDir);
fc.addChoosableFileFilter( new PictExtentionFilter());
fc.setDialogTitle("UpLoad picture into DB");
fc.setFileSelectionMode(JF ileChooser .FILES_AND _DIRECTORI ES);
fc.setMultiSelectionEnable d(false);
fc.setApproveButtonText("L oad");
if (fc.showDialog(frame, "Load") == JFileChooser.APPROVE_OPTIO N )
{
File file = fc.getSelectedFile();
String name = file.getName();
String path = file.getPath();
String ext = "";
if (name.indexOf(".") > 0)
{
ext = name.substring(name.indexO f(".") + 1);
}
String data = readPhotoFromFile(path);
//int aid = insertPhoto(data, name, path, ext, coId);
int aid = insertPhoto(data, name, path, ext, coId);
if (aid != -1)
{
thnPanel.addElement(aid, name, coId, coName, data);
thnPanel.recountOnResize(j spPhoto.ge tViewport( ).getWidth ());
thnPanel.repaint();
homeDir = path;
}
}
}
}
});
photoControlPanel.add(addP hoto);
JButton delPhoto = new JButton(delIcon);
delPhoto.addMouseListener( new MouseAdapter() {
public void mousePressed(MouseEvent me) {
int si = thnPanel.getSelectedIndex( );
if (si != -1) {
int aid = thnPanel.getSelectedId();
deletePhotoFromDB(aid);
thnPanel.removeElement(si) ;
}
}
});
photoControlPanel.add(delP hoto);
photoPane.add(photoControl Panel, BorderLayout.NORTH);
thnPanel = new ThumbnailPanel(this);
jspPhoto = new JScrollPane(thnPanel, JScrollPane.VERTICAL_SCROL LBAR_ALWAY S,
JScrollPane.HORIZONTAL_SCR OLLBAR_NEV ER);
jspPhoto.addComponentListe ner(new ComponentAdapter() {
public void componentResized(Component Event ce) {
thnPanel.recountOnResize(j spPhoto.ge tViewport( ).getWidth ());
}
});
photoPane.add(jspPhoto, BorderLayout.CENTER);
tabPane.addTab(" Photo ", photoIcon, photoPane);
rightCardPanel.add(tabPane , CITY_CO_DSLAM_PANEL);
//JPanel coDetaledPanel = createCoDetaledPanel();
//System.out.println("AFTE R"+co.getC oId().toSt ring()+" "+co.getCoEngName());
coDetaledPanel = createTerminalPanel(create Buttons(bu ttonNo,cov ,vc,null,n ull),0);
rightCardPanel.add(coDetal edPanel, CO_DETALED_PANEL);
rightCardPanel.revalidate( );
rightCardPanel.repaint();
splitPane = new JSplitPane(JSplitPane.HORI ZONTAL_SPL IT, jsp, rightCardPanel);
splitPane.setDividerLocati on(160);
cp.add(splitPane, BorderLayout.CENTER);
addInternalFrameListener(n ew InternalFrameAdapter() {
public void internalFrameClosing(Inter nalFrameEv ent ife) {
frame.setInnerFrameNull();
}
});
}//end of constr
/*public void run()
{
System.out.println("Hello from zzzzzz thread!");
while(true)
{
// wait for the signal from the GUI
try{synchronized(this){wai t();}}
catch (InterruptedException e){}
// simulate some long-running process like parsing a large file
buttonPanel = createTerminalButtonsPanel (pk);
}
} */
public JLabel getImage(int fkey)
{
ImageIcon iIcon = DBImage.dbImage(fkey);
JLabel label = new JLabel(iIcon);
return label;
}
public ImageIcon getIm(int fkey)
{
ImageIcon iIcon = DBImage.dbImage(fkey);
return iIcon;
}
public void updateMapPanel(int fk)
{
label = getImage(fk);
jspMap = new JScrollPane(label,JScrollP ane.VERTIC AL_SCROLLB AR_AS_NEED ED,
JScrollPane.HORIZONTAL_SCR OLLBAR_NEV ER);
mapPane.add(jspMap, BorderLayout.CENTER);
tabPane.addTab(" Map ", mapIcon, mapPane);
//rightCardPanel.add(tabPa ne, CITY_CO_DSLAM_PANEL);
}
private void changeCard(JPanel panel, String cardName)
{
//System.out.println("insi de changeCard CLCIKED "+cardName);
((CardLayout)panel.getLayo ut()).show (panel, cardName);
}
public JPanel createTerminalButtonsPanel (int pk)
{
JPanel panel = new JPanel();
JButton[] buttons = new JButton[200];
int num_port =0;
//JButton butt = new JButton();
try
{
String dslamLinecard= "SELECT dbo.Bookht_Terminals.TERMI NAL_ID, dbo.Bookht_Terminal_Brands .NUM_PORT "+
"FROM dbo.Bookht_Terminals INNER JOIN "+
"dbo.Bookht_Terminal_Brand s ON dbo.Bookht_Terminals.TERMI NAL_B_ID = dbo.Bookht_Terminal_Brands .TERMINAL_ B_ID WHERE (dbo.Bookht_Terminals.TERM INAL_ID = '"+pk+"')";
//System.out.println("Quer y "+dslamLinecard);
Connection connect = PictMenuFrameDemo.getDBCon nection();
Statement s = connect.createStatement();
ResultSet r = s.executeQuery(dslamLineca rd);
while(r.next())
{
num_port = r.getInt("NUM_PORT");
}
}
catch (SQLException sqle)
{
System.err.println("Can't get Terminal collection from database : " + sqle.getMessage());
}
int i=0;
final int pklinecard = pk;
//panel.setComponentOrient ation(Comp onentOrien tation.RIG HT_TO_LEFT );
panel.setBorder(new EmptyBorder(15, 15, 15, 15));
//System.out.println("num_ port "+num_port);
if(num_port > 54 && num_port <= 100)
{
//System.out.println("num_ port 1 "+num_port);
panel.setComponentOrientat ion(Compon entOrienta tion.LEFT_ TO_RIGHT);
panel.setLayout(new GridLayout(10, 10, 15, 15));
panel.setPreferredSize(new Dimension(1500,700));
}
else if(num_port > 100 && num_port <= 200)
{
//System.out.println("num_ port 2 "+num_port);
panel.setComponentOrientat ion(Compon entOrienta tion.LEFT_ TO_RIGHT);
panel.setLayout(new GridLayout(20, 10, 15, 15));
panel.setPreferredSize(new Dimension(1500,1400));
//System.out.println(panel .getLayout ());
}
else if(num_port > 0 && num_port <= 54)
{
//System.out.println("num_ port 3 "+num_port);
panel.setComponentOrientat ion(Compon entOrienta tion.RIGHT _TO_LEFT);
panel.setLayout(new GridLayout(9, 6, 15, 15));
panel.setPreferredSize(new Dimension(1000,600));
}
int block = 0;
int row = 0;
int slot = 0;
int dportno = 0;
int tport_no = 0;
int terminal_port_id = 0;
int portal_state_id = 0;
int co_id = 0;
ActionListener actionListener = null;
String ip = null;
String str2 = null;
ResultSet rs;
ResultSet rs1=null;
//String dslamLinecard= "Select t.co_id,tp.portal_state_id ,tp.termin al_id,tp.t erminal_po rt_id,lc.s lot,ds.ip, dsl.dport_ no,tp.tpor t_no,t.ter minalblock ,t.termina lrow From bookht_terminal_ports tp,bookht_DSLPorts dsl,bookht_linecards lc,dslams ds,bookht_terminals t Where tp.terminal_id = '"+pk+"' "+" and t.terminal_id = tp.terminal_id and tp.dslport_id = dsl.dslport_id and dsl.linecard_id = lc.linecard_id and lc.dslam_id = ds.id order by tp.tport_no";
String dslamLinecard= "SELECT t.CO_ID, tp.PORTAL_STATE_ID,tp.Phon eNumber, tp.TERMINAL_ID, tp.TERMINAL_PORT_ID, lc.SLOT, ds.IP, dsl.DPORT_NO, tp.TPORT_NO, t.TERMINALBLOCK,t.TERMINAL ROW FROM dbo.Bookht_LineCards AS lc INNER JOIN dbo.Bookht_DSLPorts AS dsl ON lc.LINECARD_ID = dsl.LINECARD_ID INNER JOIN dbo.DSLAMS AS ds ON lc.DSLAM_ID = ds.ID RIGHT OUTER JOIN dbo.Bookht_Terminal_Ports AS tp INNER JOIN dbo.Bookht_Terminals AS t ON tp.TERMINAL_ID = t.TERMINAL_ID ON dsl.DSLPORT_ID = tp.DSLPORT_ID WHERE (tp.TERMINAL_ID = '"+pk+"') ORDER BY tp.TPORT_NO";
//System.out.println("Quer y "+dslamLinecard);
Connection connect = PictMenuFrameDemo.getDBCon nection();
try
{
Statement st = connect.createStatement();
Statement st1 = connect.createStatement();
rs = st.executeQuery(dslamLinec ard);
while(rs.next())
{
co_id = rs.getInt("co_id");
}
//String customerName = SimpleJdbc.getCustomerName (co_id);
//System.out.println(custo merName);
rs1 = st.executeQuery(dslamLinec ard);
if(ip == null || slot==0 || dportno == 0 )
{
str2 = " ";
}
else
{
str2 = ip+" - "+slot+" - "+dportno;
}
while(rs1.next())
{
portal_state_id = rs1.getInt("portal_state_i d");
slot = rs1.getInt("SLOT");
//System.out.println(slot) ;
ip = rs1.getString("IP");
dportno = rs1.getInt("dport_no");
block = rs1.getInt("terminalblock" );
row = rs1.getInt("terminalrow");
tport_no = rs1.getInt("tport_no");
//terminal_id = rs1.getInt("terminal_port_ id");
terminal_port_id = rs1.getInt("terminal_port_ id");
//String customerName = SimpleJdbc.getCustomerName (block,row ,tport_no, co_id);
String customerName = rs1.getString("PhoneNumber ");
//customerName = "2222222222";
/*if(((portal_state_id == 1) || (portal_state_id == 2)) && customerName != null )
{
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '4' WHERE terminal_id ='"+pk+"' AND tport_no ='"+tport_no +"'";
//System.out.println(termi naPortQuer y);
st1.executeUpdate(terminaP ortQuery);
}*/
int flag = 0;
String label = null;
if(ip == null || slot==0 || dportno == 0 )
{
str2 = " ";
//str2 = ip+" - "+slot+" - "+dportno;
flag = 1;
}
else
{
str2 = ip+" - "+slot+" - "+dportno;
flag = 1;
}
String str = block+" - "+row+" - "+tport_no;
if(flag == 0)
{
////label = "<html><center>"+str+"<cen ter></html >";
if(customerName == null)
{
label = "<html><center>"+str+"<br> "+str2+"<b r>"+" "+"<center></html>";
}
else
{
label = "<html><center>"+str+"<br> "+str2+"<b r>"+custom erName+"<c enter></ht ml>";
}
}
else
{
if(customerName == null)
{
label = "<html><center>"+str+"<br> "+str2+"<b r>"+" "+"<center></html>";
}
else
{
label = "<html><center>"+str+"<br> "+str2+"<b r>"+custom erName+"<c enter></ht ml>";
}
}
/*if(((portal_state_id == 1) || (portal_state_id == 2)) && customerName != null )
{
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '4' WHERE terminal_id ='"+pk+"' AND tport_no ='"+tport_no +"'";
System.out.println(termina PortQuery) ;
st.executeUpdate(terminaPo rtQuery);
}*/
buttons[i] = new JButton();
final JPopupMenu menu = new JPopupMenu();
// Create and add a menu item
JMenuItem portMap = new JMenuItem("Define Port Mapping");
JMenuItem portState = new JMenuItem("Set Port State");
JMenuItem portHistory = new JMenuItem("Port History");
JMenuItem assignBucht = new JMenuItem("Assign Bucht");
JMenuItem freeBucht = new JMenuItem("Free Bucht");
menu.add(portMap);
portMap.addActionListener( actionList ener);
portState.addActionListene r(actionLi stener);
portHistory.addActionListe ner(action Listener);
assignBucht.addActionListe ner(action Listener);
freeBucht.addActionListene r(actionLi stener);
menu.add(portState);
menu.add(new JSeparator());
menu.add(portHistory);
menu.add(new JSeparator());
menu.add(assignBucht);
menu.add(freeBucht);
ActionListener list = new ButtonData(terminal_port_i d,pklineca rd,tport_n o,customer Name);
portMap.addActionListener( list);
portState.addActionListene r(list);
portHistory.addActionListe ner(list);
assignBucht.addActionListe ner(list);
freeBucht.addActionListene r(list);
//Integer tPortNo = new Integer(terminal_port_id);
//System.out.println(tPort No.toStrin g());
//portMap.setActionCommand (tPortNo.t oString()) ;
buttons[i].setMargin(new Insets(0,0,0,0));
buttons[i].setFont(new Font("Arial", Font.PLAIN, 12));
buttons[i].setBorder(null) ;
buttons[i].setVerticalAlig nment(Swin gConstants .TOP);
buttons[i].setHorizontalAl ignment(Sw ingConstan ts.CENTER) ;
//buttons[i].setBorderPain ted(false) ;
buttons[i].setFocusPainted (false);
buttons[i].setText(label);
if(((portal_state_id == 1) || (portal_state_id == 2)) && customerName != null )
//if(customerName != null && portal_state_id == 2)
{//In TCI
Connection connects = PictMenuFrameDemo.getDBCon nection();
Statement ste = connects.createStatement() ;
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '8' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi naPortQuer y);
//System.exit(0);
ste.executeUpdate(terminaP ortQuery);
buttons[i].setBackground(n ew Color(235, 199, 158));
}
else if((ip != null && customerName == null) && (portal_state_id == 4 || portal_state_id == 7 || portal_state_id == 9))
{
Connection connects = PictMenuFrameDemo.getDBCon nection();
Statement ste = connects.createStatement() ;
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '11' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi naPortQuer y);
//System.exit(0);
ste.executeUpdate(terminaP ortQuery);
buttons[i].setBackground(n ew Color(173, 234, 234));
}
else if((ip != null && customerName == null) && (portal_state_id == 10 ))
{
Connection connects = PictMenuFrameDemo.getDBCon nection();
Statement ste = connects.createStatement() ;
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '2' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi naPortQuer y);
//System.exit(0);
ste.executeUpdate(terminaP ortQuery);
buttons[i].setBackground(C olor.WHITE );
}
else if((ip != null && customerName != null) && (portal_state_id == 11 ))
{
Connection connects = PictMenuFrameDemo.getDBCon nection();
Statement ste = connects.createStatement() ;
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '4' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi naPortQuer y);
//System.exit(0);
ste.executeUpdate(terminaP ortQuery);
buttons[i].setBackground(C olor.WHITE );
}
/*else if((ip != null && customerName != null) && (portal_state_id == 8 ))
{
Connection connects = PictMenuFrameDemo.getDBCon nection();
Statement ste = connects.createStatement() ;
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '4' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi naPortQuer y);
//System.exit(0);
ste.executeUpdate(terminaP ortQuery);
buttons[i].setBackground(C olor.WHITE );
}*/
else
{
if(portal_state_id == 1)
{//no mapping
buttons[i].setBackground(C olor.GRAY) ;
}
else if(portal_state_id == 2)
{//ready to use
buttons[i].setBackground(C olor.WHITE );
}
else if(portal_state_id == 3)
{//problem
buttons[i].setBackground(n ew Color(153, 102, 0));
}
else if(portal_state_id == 4)
{//Active User - Used
buttons[i].setBackground(C olor.GREEN );
}
else if(portal_state_id == 5)
{//Reserved
buttons[i].setBackground(C olor.BLUE) ;
}
else if(portal_state_id == 6)
{//Out of Service
buttons[i].setBackground(C olor.RED);
}
else if(portal_state_id == 7)
{//Approved Krone
buttons[i].setBackground(C olor.ORANG E);
}
else if(portal_state_id == 8)
{//Under Constr
buttons[i].setBackground(n ew Color(235, 199, 158));
}
else if(portal_state_id == 9)
{//Installed not used
buttons[i].setBackground(C olor.PINK) ;
}
else if(portal_state_id == 10)
{//PCM/PGS
buttons[i].setBackground(C olor.LIGHT _GRAY);
}
else if(portal_state_id == 11)
{//Questionable Bookht label.setBackground(new Color(255, 0, 0));
buttons[i].setBackground(n ew Color(173, 234, 234));
}
}
panel.add(buttons[i]);
// Set the component to show the popup menu
buttons[i].addMouseListene r(new MouseAdapter() {
public void mousePressed(MouseEvent evt) {
if (evt.isPopupTrigger()) {
menu.show(evt.getComponent (), evt.getX(), evt.getY());
}
}
public void mouseReleased(MouseEvent evt) {
if (evt.isPopupTrigger()) {
menu.show(evt.getComponent (), evt.getX(), evt.getY());
}
}
});
i++;
}//while
}
catch (SQLException sqle)
{
System.err.println("Can't get Terminal collection from database : " + sqle.getMessage());
}
/*catch (ClassNotFoundException csqle)
{
System.err.println("Can't get Ports collection from database : " + csqle.getMessage());
} */
return panel;
}
private JPanel createTerminalPanel(JButto n[] buttons,int dirc)
{
//System.out.println(butto ns.length) ;
GridBagLayout layout = new GridBagLayout();
JPanel p = new JPanel(layout);
innerCardPanel = new JPanel(new CardLayout());
GridBagConstraints constraints = new GridBagConstraints();
JPanel panel = new JPanel(new BorderLayout(0, 20));
constraints.anchor=GridBag Constraint s.NORTH;
constraints.ipadx=0;
constraints.ipady=0;
constraints.fill=GridBagCo nstraints. BOTH;
constraints.insets=new Insets(5,5,5,5);
int direction = dirc;
// Add first row of components
constraints.gridx=0;
constraints.gridy=0;
for(int i = 0;i < buttons.length;i++)
{
if (direction == 0)
{
// horizontal
constraints.gridx = i % 5;
constraints.gridy = i / 5;
}
else
{
// vertical
constraints.gridx = i / 5;
constraints.gridy = i % 5;
}
layout.setConstraints(butt ons[i],con straints);
p.add(buttons[i]);
}
innerCardPanel.add(p, MDF_PANEL);
/*JPanel buttonPanel = createButtonsPanel();
innerCardPanel.add(buttonP anel, BUTTON_PANEL);*/
//panel.add(label);
panel.add(BorderLayout.CEN TER,innerC ardPanel);
return panel;
}
class NodeExpander implements ActionListener
{
private DefaultMutableTreeNode node = null;
private DefaultMutableTreeNode select= null;
TreePath treePath = null;
public NodeExpander(DefaultMutabl eTreeNode node)
{
this.node = node;
}
public NodeExpander()
{
}
public void actionPerformed(ActionEven t e)
{
String str = e.getActionCommand();
String [] splitStr = str.split("-");
select = new DefaultMutableTreeNode(str );
tree.addTreeSelectionListe ner(new OidSelectionListener());
ResultSet rs;
int terminalID = 0;
TreeNode [] tn = node.getPath();
//System.out.println("Tree Node City "+tn[1]+" CO "+tn[2]+" Block "+splitStr[0]+" Row "+splitStr[1]);
//String terminalQuery = "select terminalrow,terminalblock from terminals WHERE terminal_id= '"+pk+"'";
String terminalQuery = " select t.terminal_id from bookht_terminals t, bookht_TelCenter co, city ci where co.CITYID = ci.pkid and co.NAME = '"+tn[2]+"'"+ "and ci.CITY = '"+tn[1]+"'"+ " and t.terminalblock = '"+splitStr[0]+"'"+ " and t.terminalrow ='"+splitStr[1]+"'"+ "";
//System.out.println(termi nalQuery);
//System.exit(0);
Connection connect = PictMenuFrameDemo.getDBCon nection();
try
{
Statement st = connect.createStatement();
rs = st.executeQuery(terminalQu ery);
rs.next();
terminalID = rs.getInt("terminal_id");
}
catch (SQLException sqle)
{
System.err.println("Can't get Terminal collection from database 1: " + sqle.getMessage());
}
JPanel buttonPanel = createTerminalButtonsPanel (terminalI D);
JScrollPane jspMap = new JScrollPane(buttonPanel,JS crollPane. VERTICAL_S CROLLBAR_A S_NEEDED,
JScrollPane.HORIZONTAL_SCR OLLBAR_AS_ NEEDED);
innerCardPanel.add(jspMap, BUTTON_PANEL);
//JPanel buttonPanel = createButtonsPanel(str);
//innerCardPanel.add(butto nPanel, BUTTON_PANEL);
// System.out.println("Path "+Arrays.asList(node.getPa th()));
//System.out.println("Leaf Node "+node);
//System.out.println("Pare nt Node "+node.getParent());
//System.out.println("Chil d Count "+node.getChildCount());
//tree.expandPath(new TreePath(((DefaultMutableT reeNode)(n ode.getPar ent())).ge tPath()));
if (node.getChildCount() >= 0)
{
//System.out.println("INSI DE IF "+node.getChildCount());
for (Enumeration en = node.children(); en.hasMoreElements(); )
{
DefaultMutableTreeNode n = (DefaultMutableTreeNode)en .nextEleme nt();
//System.out.println("Leaf Count "+n);
//System.out.println("Path "+Arrays.asList(n.getPath( )));
if (!n.isLeaf())
continue;
if (n.toString().equals(str))
{
tree.expandPath(new TreePath(n.getPath()));
tree.setSelectionPath(new TreePath(n.getPath()));
break;
}
}
}
//changeCard(rightCardPane l, CO_DETALED_PANEL);
//changeCard(innerCardPane l, BUTTON_PANEL);
//tree.expandPath(new TreePath(node.getPath()));
//System.out.println("Path "+Arrays.asList(node.getPa th()));
//tree.setSelectionPath(ne w TreePath(select.getPath()) );
//System.out.println("Path "+select.getParent());
//paths.pathByAddingChild( select);
}
}
{
public final String CITY_CO_DSLAM_PANEL = "city_co_dslam_panel";
public final String CO_DETALED_PANEL = "co_detaled_panel";
public final String MDF_PANEL = "mdf_panel";
public final String BUTTON_PANEL = "button_panel";
public final String SPLITTER_PANEL = "splitter_panel";
private ImageIcon testIcon;
private ImageIcon cityIcon;
private ImageIcon coIcon;
private ImageIcon dslamIcon;
private ImageIcon linecardIcon;
private ImageIcon refreshIcon;
private ImageIcon mapIcon;
private ImageIcon cityMap;
private ImageIcon dslamGroupIcon;
private ImageIcon splitterGroupIcon;
private ImageIcon mdfGroupIcon;
private ImageIcon mdfIcon;
private ImageIcon splitterIcon;
private DefaultMutableTreeNode lastSelectedNode;
private JTree tree;
private JTable cityTable;
private JTable coTable;
private JTable dslamTable;
private JTable linecardTable;
private JTabbedPane tabPane;
private JLabel label;
private JPopupMenu treePopupMenu;
private Vector cityCollect;
private Vector coCollect;
private Vector dslamCollect;
private Vector linecardCollect;
private Vector mdfCollect;
private Vector splitterCollect;
private Vector cityPrivilegeCollect;
private Vector coPrivilegeCollect;
private Vector dslamPrivilegeCollect;
private Vector linecardPrivilegeCollect;
private Vector mdfPrivilegeCollect;
private Vector splitterPrivilegeCollect;
private JPanel rightCardPanel = null;
private JLabel coId;
private JLabel coFarsiName;
private JLabel coEnglishName;
private JPanel innerCardPanel = null;
private JTabbedPane mdfTabPane;
private JTabbedPane splitterTabPane;
private JTable mdfTable;
private JTable splitterTable;
PictMenuFrameDemo JFParentFrame;
int pk;
int fk;
ImageIcon iIcon;
JPanel mapPane;
JScrollPane jspMap;
int buttonNo;
JPanel coDetaledPanel;
private ThumbnailPanel thnPanel;
private Connection connection;
private JScrollPane jspPhoto;
private String homeDir = "";
private ImageIcon addIcon;
private ImageIcon delIcon;
private ImageIcon photoIcon;
boolean flag = true;
JSplitPane splitPane;
TreePath selPath;
DefaultMutableTreeNode coselect;
Vector cov = null;
CoRow co;
Vector vc= null;
TreePath[] paths;
TreePath paths1;
Object [] o;
JProgressBar progressBar;
JPanel buttonPanel = null;
int privilege = 0;
int city_id = 0;
public TreeTableInternalFrame(fin
{
super("Bücht Automation",
true, //resizable
true, //closable
true, //maximizable
true);//iconifiable
Dimension deskSize = frame.getDesktop().getSize
setSize((int)deskSize.getW
//Set the window's location.
setLocation(0, 0);
JFParentFrame = frame;
privilege = Login.privilege;
//privilege = 1;
//get database result in to collections
//initCollections(PictMenu
if(privilege == 1 || privilege == 0)
{
initCollections(PictMenuFr
}
else if(privilege == 2)
{
city_id = Login.cityView;
initPrivilegeCollections(P
}
else if(privilege == 3)
{
city_id = Login.cityView;
initPrivilegeCollections(P
}
progressBar = new JProgressBar();
testIcon = new ImageIcon(getClass().getRe
//cityIcon = new ImageIcon(Toolkit.getDefau
cityIcon = new ImageIcon(getClass().getRe
//coIcon = new ImageIcon(Toolkit.getDefau
coIcon = new ImageIcon(getClass().getRe
//dslamIcon = new ImageIcon(Toolkit.getDefau
dslamIcon = new ImageIcon(getClass().getRe
//linecardIcon = new ImageIcon(Toolkit.getDefau
linecardIcon = new ImageIcon(getClass().getRe
refreshIcon = new ImageIcon(getClass().getRe
mapIcon = new ImageIcon(getClass().getRe
//ImageIcon iIcon = null;
dslamGroupIcon = new ImageIcon(getClass().getRe
splitterGroupIcon = new ImageIcon(getClass().getRe
mdfGroupIcon = new ImageIcon(getClass().getRe
mdfIcon = new ImageIcon(getClass().getRe
splitterIcon = new ImageIcon(getClass().getRe
addIcon = new ImageIcon(getClass().getRe
delIcon = new ImageIcon(getClass().getRe
photoIcon = new ImageIcon(getClass().getRe
//set layout for frame content panel
Container cp = getContentPane();
cp.setLayout(new BorderLayout());
//create toolbar
JToolBar toolbar = createToolbar();
cp.add(toolbar, BorderLayout.NORTH);
// create popup menu for tree
//treePopupMenu = createPopupMenu();
// create tree element
// createAndInitPrivilegeTree
//createAndInitTree();
if(privilege == 1 || privilege == 0)
{
createAndInitTree();
}
else if(privilege == 2)
{
createAndInitPrivilegeTree
}
else if(privilege == 3)
{
createAndInitPrivilegeTree
}
tree.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent me) {
Object obj = tree.getLastSelectedPathCo
if(obj != null) {
DefaultMutableTreeNode select = (DefaultMutableTreeNode)ob
//System.out.print("select
//System.out.println(selec
if (select != lastSelectedNode)
{
Object uObject = select.getUserObject();
pk = ((BaseRow)uObject).getPrim
fk = ((BaseRow)uObject).getFore
//System.out.println(pk);
//System.out.println(fk);
switch(((BaseRow)uObject).
case BaseRow.CITY_TYPE : {
changeCard(rightCardPanel,
int index = 0;
if(privilege == 1 || privilege == 0)
{
index= Collections.binarySearch(c
}
else if(privilege == 2)
{
index = Collections.binarySearch(c
}
else if(privilege == 3)
{
index = Collections.binarySearch(c
}
cityTable.setRowSelectionI
cityTable.scrollRectToVisi
tabPane.setSelectedIndex(0
fk = ((BaseRow)uObject).getFore
ImageIcon im = getIm(fk);
label.setIcon(im);
//System.out.println("Mous
//iIcon = getImage(fk);
//updateMapPanel(fk);
initChildrenTables(select)
int cityId = ((CityRow)uObject).getCity
thnPanel.clear();
fillThumbnails(false, cityId);
thnPanel.sort();
thnPanel.recountOnResize(j
thnPanel.repaint();
break;
}
case BaseRow.CO_TYPE : {
changeCard(rightCardPanel,
Vector cov = getNodesThisLevel(coCollec
int selIndex = Collections.binarySearch(c
if (!isSameBranch(select,last
removeAllRows(coTable);
initCoTable(cov);
}
coTable.setRowSelectionInt
tabPane.setSelectedIndex(1
initChildrenTables(select)
initParentsTables(select);
break;
}
case BaseRow.DSLAM_TYPE : {
changeCard(rightCardPanel,
Vector cod = getNodesThisLevel(dslamCol
int selIndex = Collections.binarySearch(c
if (!isSameBranch(select,last
removeAllRows(dslamTable);
initDslamTable(cod);
}
dslamTable.setRowSelection
tabPane.setSelectedIndex(2
initChildrenTables(select)
initParentsTables(select);
break;
}
case BaseRow.LINECARD_TYPE : {
changeCard(rightCardPanel,
Vector col = getNodesThisLevel(linecard
int selIndex = Collections.binarySearch(c
if (!isSameBranch(select,last
{
removeAllRows(linecardTabl
initLinecardTable(col);
}
linecardTable.setRowSelect
tabPane.setSelectedIndex(3
initParentsTables(select);
break;
}
case BaseRow.NAME_TYPE : {
String name = ((BaseRow)uObject).toStrin
if (name.equals("DSLAM"))
{
changeCard(rightCardPanel,
DefaultMutableTreeNode pselect = (DefaultMutableTreeNode)se
//System.out.println("AFTE
Vector cov = getNodesThisLevel(coCollec
//System.out.println("DSLA
int selIndex = Collections.binarySearch(c
if (!isSameBranch(pselect,las
{
removeAllRows(coTable);
initCoTable(cov);
}
coTable.setRowSelectionInt
tabPane.setSelectedIndex(2
initChildrenTables(pselect
initParentsTables(pselect)
}
else
{
changeCard(rightCardPanel,
DefaultMutableTreeNode pselect = (DefaultMutableTreeNode)se
co = (CoRow)pselect.getUserObje
if (name.equals("TERMINAL"))
{
//System.out.println("INSI
//System.out.println("AFTE
//changeCard(innerCardPane
coselect = (DefaultMutableTreeNode)se
//return mdfData;
//Vector getMdfCollection(Connectio
DefaultMutableTreeNode terminal = (DefaultMutableTreeNode)se
//System.out.println("afte
cov = getTerminalNodesThisLevel(
//System.out.println("afte
vc = getTerminalPriNodesThisLev
//System.out.println("afte
//Vector v = getMdfCollection(frame.get
buttonNo = cov.size();
//System.out.println("afte
//rightCardPanel.removeAll
//System.out.println("afte
///////TreeNode tn = coselect.getPath();
paths = tree.getSelectionPaths();
paths1 = tree.getSelectionPath();
Object[]path = null;
if(paths == null)
return;
for(int i=0;i<paths.length;i++)
{
path = paths[i].getPath();
for (int j=0; j<path.length; j++)
{
//System.out.print(path[j]
}
}
// System.out.println("-"+pat
//expandNode(tree, paths1);
//tree.expandPath(paths1);
//tree.setSelectionPath(pa
coDetaledPanel = createTerminalPanel(create
rightCardPanel.add(coDetal
changeCard(rightCardPanel,
changeCard(innerCardPanel,
rightCardPanel.revalidate(
rightCardPanel.repaint();
}
/*else if (name.equals("SPLITTER"))
{
changeCard(innerCardPanel,
splitterTabPane.setSelecte
}*/
}
break;
}
case BaseRow.MDF_TYPE : {
changeCard(rightCardPanel,
changeCard(innerCardPanel,
//System.out.println("INSI
DefaultMutableTreeNode pselect = (DefaultMutableTreeNode)se
CoRow co = (CoRow)pselect.getUserObje
Vector cov = getNodesThisLevel(mdfColle
int selIndex = Collections.binarySearch(c
final Progress p = new Progress();
try
{
p.runProgress();
}
catch(Exception e)
{
e.printStackTrace ();
}
Thread t = new Thread(new Runnable(){
public void run()
{
try
{
//System.out.println("INSI
buttonPanel = createTerminalButtonsPanel
JScrollPane jspMap = new JScrollPane(buttonPanel,JS
JScrollPane.HORIZONTAL_SCR
innerCardPanel.add(jspMap,
changeCard(rightCardPanel,
changeCard(innerCardPanel,
p.hide();
}
catch(Exception e)
{
e.printStackTrace ();
}
}
});
/*Thread th = new Thread(new Runnable() {
public void run() {
try
{
p.runProgress();
}
catch(Exception e)
{
e.printStackTrace ();
}
}
});*/
// th.start();
t.start();
// th.destroy();
if (!isSameBranch(select, lastSelectedNode))
{
//System.out.println("pk "+pk);
//removeAllRows(mdfTable);
//initMdfTable(cov);
}
//mdfTable.setRowSelection
break;
}
/*case BaseRow.SPLITTER_TYPE : {
changeCard(rightCardPanel,
changeCard(innerCardPanel,
DefaultMutableTreeNode pselect = (DefaultMutableTreeNode)se
CoRow co = (CoRow)pselect.getUserObje
coId.setText(co.getCoId().
coFarsiName.setText(co.get
coEnglishName.setText(co.g
Vector cov = getNodesThisLevel(splitter
int selIndex = Collections.binarySearch(c
if (!isSameBranch(select, lastSelectedNode))
{
removeAllRows(splitterTabl
initSplitterTable(cov);
}
splitterTable.setRowSelect
break;
}*/
}
lastSelectedNode = select;
}
}
}
public void mouseReleased(MouseEvent me)
{
if (me.isPopupTrigger())
{
DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode)tr
//treePopupMenu.show(me.ge
selPath = tree.getPathForLocation(me
//System.out.println(selPa
//System.out.println("selP
o = selPath.getPath();
/*for(int i=0;i<o.length;i++)
{
System.out.println("path "+o[i]);
}*/
//System.out.println("path
Object ob = selPath.getPathComponent(1
//System.out.println("path
Object obj = selPath.getLastPathCompone
String str= null;
if(obj != null)
{
DefaultMutableTreeNode selectNode = (DefaultMutableTreeNode)ob
//System.out.println("sele
//System.out.println("sele
str = selPath.getParentPath().ge
//System.out.println("sele
if (selectNode != lastSelectedNode)
{
//System.out.println(selec
Object uObject = selectNode.getUserObject()
///System.out.println("clc
//System.out.println("FK "+((BaseRow)uObject).getPr
pk = ((BaseRow)uObject).getPrim
//System.out.println(" pk "+pk);
}
}
if(selPath.getPathCount()=
{
treePopupMenu = createPopupMenuCo();
treePopupMenu.show(me.getC
//System.out.println("path
}
if(selPath.getPathCount()=
{
treePopupMenu = createPopupMenuDslam();
treePopupMenu.show(me.getC
//System.out.println("path
}
/*if(selPath.getPathCount(
{
treePopupMenu = createPopupMenuLinecard();
treePopupMenu.show(me.getC
//System.out.println("path
} */
if(selPath.getPathCount()=
{
treePopupMenu = createPopupMenuLine();
treePopupMenu.show(me.getC
//System.out.println("path
}
if(str.equals("DSLAM"))
{
treePopupMenu = createPopupMenuLinecard();
treePopupMenu.show(me.getC
}
if(str.equals("TERMINAL"))
{
treePopupMenu = createPopupMenuTerminal();
treePopupMenu.show(me.getC
}
/*if(str.equals("SPLITTER"
{
treePopupMenu = createPopupMenuSplitter();
treePopupMenu.show(me.getC
}*/
}
}
});
JScrollPane jsp = new JScrollPane(tree, JScrollPane.VERTICAL_SCROL
JScrollPane.HORIZONTAL_SCR
rightCardPanel = new JPanel();
rightCardPanel.setLayout(n
//create tab panel
tabPane = new JTabbedPane();
JPanel cityPane = new JPanel(new BorderLayout());
//createCityTable();
if(privilege == 1 || privilege == 0)
{
createCityTable();
}
else if(privilege == 2)
{
createCityPrivilegeTable()
}
else if(privilege == 3)
{
createCityPrivilegeTable()
}
JScrollPane jspCity = new JScrollPane(cityTable, JScrollPane.VERTICAL_SCROL
JScrollPane.HORIZONTAL_SCR
cityPane.add(jspCity, BorderLayout.CENTER);
tabPane.addTab(" City ", cityIcon, cityPane);
JPanel coPane = new JPanel(new BorderLayout());
createCoTable();
JScrollPane jspCo = new JScrollPane(coTable, JScrollPane.VERTICAL_SCROL
JScrollPane.HORIZONTAL_SCR
coPane.add(jspCo, BorderLayout.CENTER);
tabPane.addTab(" Co ", coIcon, coPane);
JPanel dslamPane = new JPanel(new BorderLayout());
createDslamTable();
JScrollPane jspDslam = new JScrollPane(dslamTable, JScrollPane.VERTICAL_SCROL
JScrollPane.HORIZONTAL_SCR
dslamPane.add(jspDslam, BorderLayout.CENTER);
tabPane.addTab(" Dslam ", dslamIcon, dslamPane);
JPanel linecardPane = new JPanel(new BorderLayout());
createlinecardTable();
JScrollPane jspLinecard = new JScrollPane(linecardTable,
JScrollPane.HORIZONTAL_SCR
linecardPane.add(jspLineca
tabPane.addTab(" Linecard ", linecardIcon, linecardPane);
mapPane = new JPanel(new BorderLayout());
label = getImage(fk);
//System.out.println("fore
//iIcon = DBImage.dbImage(29);
//iIcon = DBImage.dbImage(fk);
//cityMap = new ImageIcon(getClass().getRe
//System.out.print("Image "+iIcon);
jspMap = new JScrollPane(label,JScrollP
JScrollPane.HORIZONTAL_SCR
mapPane.add(jspMap, BorderLayout.CENTER);
tabPane.addTab(" Map ", mapIcon, mapPane);
JPanel photoPane = new JPanel(new BorderLayout());
JToolBar photoControlPanel = new JToolBar();
photoControlPanel.setFloat
JButton addPhoto = new JButton(addIcon);
addPhoto.addMouseListener(
public void mousePressed(MouseEvent me) {
BaseRow row = (BaseRow)lastSelectedNode.
//System.out.println("butt
if (row.getType() == BaseRow.CO_TYPE)
{
int coId = ((CoRow)row).getCoId().int
String coName = ((CoRow)row).getCoEngName(
String startDir = "";
if (homeDir.length() == 0)
{
startDir = (String)System.getProperty
}
else
{
startDir = homeDir;
}
JFileChooser fc = new JFileChooser(startDir);
fc.addChoosableFileFilter(
fc.setDialogTitle("UpLoad picture into DB");
fc.setFileSelectionMode(JF
fc.setMultiSelectionEnable
fc.setApproveButtonText("L
if (fc.showDialog(frame, "Load") == JFileChooser.APPROVE_OPTIO
{
File file = fc.getSelectedFile();
String name = file.getName();
String path = file.getPath();
String ext = "";
if (name.indexOf(".") > 0)
{
ext = name.substring(name.indexO
}
String data = readPhotoFromFile(path);
//int aid = insertPhoto(data, name, path, ext, coId);
int aid = insertPhoto(data, name, path, ext, coId);
if (aid != -1)
{
thnPanel.addElement(aid, name, coId, coName, data);
thnPanel.recountOnResize(j
thnPanel.repaint();
homeDir = path;
}
}
}
}
});
photoControlPanel.add(addP
JButton delPhoto = new JButton(delIcon);
delPhoto.addMouseListener(
public void mousePressed(MouseEvent me) {
int si = thnPanel.getSelectedIndex(
if (si != -1) {
int aid = thnPanel.getSelectedId();
deletePhotoFromDB(aid);
thnPanel.removeElement(si)
}
}
});
photoControlPanel.add(delP
photoPane.add(photoControl
thnPanel = new ThumbnailPanel(this);
jspPhoto = new JScrollPane(thnPanel, JScrollPane.VERTICAL_SCROL
JScrollPane.HORIZONTAL_SCR
jspPhoto.addComponentListe
public void componentResized(Component
thnPanel.recountOnResize(j
}
});
photoPane.add(jspPhoto, BorderLayout.CENTER);
tabPane.addTab(" Photo ", photoIcon, photoPane);
rightCardPanel.add(tabPane
//JPanel coDetaledPanel = createCoDetaledPanel();
//System.out.println("AFTE
coDetaledPanel = createTerminalPanel(create
rightCardPanel.add(coDetal
rightCardPanel.revalidate(
rightCardPanel.repaint();
splitPane = new JSplitPane(JSplitPane.HORI
splitPane.setDividerLocati
cp.add(splitPane, BorderLayout.CENTER);
addInternalFrameListener(n
public void internalFrameClosing(Inter
frame.setInnerFrameNull();
}
});
}//end of constr
/*public void run()
{
System.out.println("Hello from zzzzzz thread!");
while(true)
{
// wait for the signal from the GUI
try{synchronized(this){wai
catch (InterruptedException e){}
// simulate some long-running process like parsing a large file
buttonPanel = createTerminalButtonsPanel
}
} */
public JLabel getImage(int fkey)
{
ImageIcon iIcon = DBImage.dbImage(fkey);
JLabel label = new JLabel(iIcon);
return label;
}
public ImageIcon getIm(int fkey)
{
ImageIcon iIcon = DBImage.dbImage(fkey);
return iIcon;
}
public void updateMapPanel(int fk)
{
label = getImage(fk);
jspMap = new JScrollPane(label,JScrollP
JScrollPane.HORIZONTAL_SCR
mapPane.add(jspMap, BorderLayout.CENTER);
tabPane.addTab(" Map ", mapIcon, mapPane);
//rightCardPanel.add(tabPa
}
private void changeCard(JPanel panel, String cardName)
{
//System.out.println("insi
((CardLayout)panel.getLayo
}
public JPanel createTerminalButtonsPanel
{
JPanel panel = new JPanel();
JButton[] buttons = new JButton[200];
int num_port =0;
//JButton butt = new JButton();
try
{
String dslamLinecard= "SELECT dbo.Bookht_Terminals.TERMI
"FROM dbo.Bookht_Terminals INNER JOIN "+
"dbo.Bookht_Terminal_Brand
//System.out.println("Quer
Connection connect = PictMenuFrameDemo.getDBCon
Statement s = connect.createStatement();
ResultSet r = s.executeQuery(dslamLineca
while(r.next())
{
num_port = r.getInt("NUM_PORT");
}
}
catch (SQLException sqle)
{
System.err.println("Can't get Terminal collection from database : " + sqle.getMessage());
}
int i=0;
final int pklinecard = pk;
//panel.setComponentOrient
panel.setBorder(new EmptyBorder(15, 15, 15, 15));
//System.out.println("num_
if(num_port > 54 && num_port <= 100)
{
//System.out.println("num_
panel.setComponentOrientat
panel.setLayout(new GridLayout(10, 10, 15, 15));
panel.setPreferredSize(new
}
else if(num_port > 100 && num_port <= 200)
{
//System.out.println("num_
panel.setComponentOrientat
panel.setLayout(new GridLayout(20, 10, 15, 15));
panel.setPreferredSize(new
//System.out.println(panel
}
else if(num_port > 0 && num_port <= 54)
{
//System.out.println("num_
panel.setComponentOrientat
panel.setLayout(new GridLayout(9, 6, 15, 15));
panel.setPreferredSize(new
}
int block = 0;
int row = 0;
int slot = 0;
int dportno = 0;
int tport_no = 0;
int terminal_port_id = 0;
int portal_state_id = 0;
int co_id = 0;
ActionListener actionListener = null;
String ip = null;
String str2 = null;
ResultSet rs;
ResultSet rs1=null;
//String dslamLinecard= "Select t.co_id,tp.portal_state_id
String dslamLinecard= "SELECT t.CO_ID, tp.PORTAL_STATE_ID,tp.Phon
//System.out.println("Quer
Connection connect = PictMenuFrameDemo.getDBCon
try
{
Statement st = connect.createStatement();
Statement st1 = connect.createStatement();
rs = st.executeQuery(dslamLinec
while(rs.next())
{
co_id = rs.getInt("co_id");
}
//String customerName = SimpleJdbc.getCustomerName
//System.out.println(custo
rs1 = st.executeQuery(dslamLinec
if(ip == null || slot==0 || dportno == 0 )
{
str2 = " ";
}
else
{
str2 = ip+" - "+slot+" - "+dportno;
}
while(rs1.next())
{
portal_state_id = rs1.getInt("portal_state_i
slot = rs1.getInt("SLOT");
//System.out.println(slot)
ip = rs1.getString("IP");
dportno = rs1.getInt("dport_no");
block = rs1.getInt("terminalblock"
row = rs1.getInt("terminalrow");
tport_no = rs1.getInt("tport_no");
//terminal_id = rs1.getInt("terminal_port_
terminal_port_id = rs1.getInt("terminal_port_
//String customerName = SimpleJdbc.getCustomerName
String customerName = rs1.getString("PhoneNumber
//customerName = "2222222222";
/*if(((portal_state_id == 1) || (portal_state_id == 2)) && customerName != null )
{
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '4' WHERE terminal_id ='"+pk+"' AND tport_no ='"+tport_no +"'";
//System.out.println(termi
st1.executeUpdate(terminaP
}*/
int flag = 0;
String label = null;
if(ip == null || slot==0 || dportno == 0 )
{
str2 = " ";
//str2 = ip+" - "+slot+" - "+dportno;
flag = 1;
}
else
{
str2 = ip+" - "+slot+" - "+dportno;
flag = 1;
}
String str = block+" - "+row+" - "+tport_no;
if(flag == 0)
{
////label = "<html><center>"+str+"<cen
if(customerName == null)
{
label = "<html><center>"+str+"<br>
}
else
{
label = "<html><center>"+str+"<br>
}
}
else
{
if(customerName == null)
{
label = "<html><center>"+str+"<br>
}
else
{
label = "<html><center>"+str+"<br>
}
}
/*if(((portal_state_id == 1) || (portal_state_id == 2)) && customerName != null )
{
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '4' WHERE terminal_id ='"+pk+"' AND tport_no ='"+tport_no +"'";
System.out.println(termina
st.executeUpdate(terminaPo
}*/
buttons[i] = new JButton();
final JPopupMenu menu = new JPopupMenu();
// Create and add a menu item
JMenuItem portMap = new JMenuItem("Define Port Mapping");
JMenuItem portState = new JMenuItem("Set Port State");
JMenuItem portHistory = new JMenuItem("Port History");
JMenuItem assignBucht = new JMenuItem("Assign Bucht");
JMenuItem freeBucht = new JMenuItem("Free Bucht");
menu.add(portMap);
portMap.addActionListener(
portState.addActionListene
portHistory.addActionListe
assignBucht.addActionListe
freeBucht.addActionListene
menu.add(portState);
menu.add(new JSeparator());
menu.add(portHistory);
menu.add(new JSeparator());
menu.add(assignBucht);
menu.add(freeBucht);
ActionListener list = new ButtonData(terminal_port_i
portMap.addActionListener(
portState.addActionListene
portHistory.addActionListe
assignBucht.addActionListe
freeBucht.addActionListene
//Integer tPortNo = new Integer(terminal_port_id);
//System.out.println(tPort
//portMap.setActionCommand
buttons[i].setMargin(new Insets(0,0,0,0));
buttons[i].setFont(new Font("Arial", Font.PLAIN, 12));
buttons[i].setBorder(null)
buttons[i].setVerticalAlig
buttons[i].setHorizontalAl
//buttons[i].setBorderPain
buttons[i].setFocusPainted
buttons[i].setText(label);
if(((portal_state_id == 1) || (portal_state_id == 2)) && customerName != null )
//if(customerName != null && portal_state_id == 2)
{//In TCI
Connection connects = PictMenuFrameDemo.getDBCon
Statement ste = connects.createStatement()
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '8' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi
//System.exit(0);
ste.executeUpdate(terminaP
buttons[i].setBackground(n
}
else if((ip != null && customerName == null) && (portal_state_id == 4 || portal_state_id == 7 || portal_state_id == 9))
{
Connection connects = PictMenuFrameDemo.getDBCon
Statement ste = connects.createStatement()
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '11' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi
//System.exit(0);
ste.executeUpdate(terminaP
buttons[i].setBackground(n
}
else if((ip != null && customerName == null) && (portal_state_id == 10 ))
{
Connection connects = PictMenuFrameDemo.getDBCon
Statement ste = connects.createStatement()
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '2' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi
//System.exit(0);
ste.executeUpdate(terminaP
buttons[i].setBackground(C
}
else if((ip != null && customerName != null) && (portal_state_id == 11 ))
{
Connection connects = PictMenuFrameDemo.getDBCon
Statement ste = connects.createStatement()
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '4' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi
//System.exit(0);
ste.executeUpdate(terminaP
buttons[i].setBackground(C
}
/*else if((ip != null && customerName != null) && (portal_state_id == 8 ))
{
Connection connects = PictMenuFrameDemo.getDBCon
Statement ste = connects.createStatement()
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '4' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi
//System.exit(0);
ste.executeUpdate(terminaP
buttons[i].setBackground(C
}*/
else
{
if(portal_state_id == 1)
{//no mapping
buttons[i].setBackground(C
}
else if(portal_state_id == 2)
{//ready to use
buttons[i].setBackground(C
}
else if(portal_state_id == 3)
{//problem
buttons[i].setBackground(n
}
else if(portal_state_id == 4)
{//Active User - Used
buttons[i].setBackground(C
}
else if(portal_state_id == 5)
{//Reserved
buttons[i].setBackground(C
}
else if(portal_state_id == 6)
{//Out of Service
buttons[i].setBackground(C
}
else if(portal_state_id == 7)
{//Approved Krone
buttons[i].setBackground(C
}
else if(portal_state_id == 8)
{//Under Constr
buttons[i].setBackground(n
}
else if(portal_state_id == 9)
{//Installed not used
buttons[i].setBackground(C
}
else if(portal_state_id == 10)
{//PCM/PGS
buttons[i].setBackground(C
}
else if(portal_state_id == 11)
{//Questionable Bookht label.setBackground(new Color(255, 0, 0));
buttons[i].setBackground(n
}
}
panel.add(buttons[i]);
// Set the component to show the popup menu
buttons[i].addMouseListene
public void mousePressed(MouseEvent evt) {
if (evt.isPopupTrigger()) {
menu.show(evt.getComponent
}
}
public void mouseReleased(MouseEvent evt) {
if (evt.isPopupTrigger()) {
menu.show(evt.getComponent
}
}
});
i++;
}//while
}
catch (SQLException sqle)
{
System.err.println("Can't get Terminal collection from database : " + sqle.getMessage());
}
/*catch (ClassNotFoundException csqle)
{
System.err.println("Can't get Ports collection from database : " + csqle.getMessage());
} */
return panel;
}
private JPanel createTerminalPanel(JButto
{
//System.out.println(butto
GridBagLayout layout = new GridBagLayout();
JPanel p = new JPanel(layout);
innerCardPanel = new JPanel(new CardLayout());
GridBagConstraints constraints = new GridBagConstraints();
JPanel panel = new JPanel(new BorderLayout(0, 20));
constraints.anchor=GridBag
constraints.ipadx=0;
constraints.ipady=0;
constraints.fill=GridBagCo
constraints.insets=new Insets(5,5,5,5);
int direction = dirc;
// Add first row of components
constraints.gridx=0;
constraints.gridy=0;
for(int i = 0;i < buttons.length;i++)
{
if (direction == 0)
{
// horizontal
constraints.gridx = i % 5;
constraints.gridy = i / 5;
}
else
{
// vertical
constraints.gridx = i / 5;
constraints.gridy = i % 5;
}
layout.setConstraints(butt
p.add(buttons[i]);
}
innerCardPanel.add(p, MDF_PANEL);
/*JPanel buttonPanel = createButtonsPanel();
innerCardPanel.add(buttonP
//panel.add(label);
panel.add(BorderLayout.CEN
return panel;
}
class NodeExpander implements ActionListener
{
private DefaultMutableTreeNode node = null;
private DefaultMutableTreeNode select= null;
TreePath treePath = null;
public NodeExpander(DefaultMutabl
{
this.node = node;
}
public NodeExpander()
{
}
public void actionPerformed(ActionEven
{
String str = e.getActionCommand();
String [] splitStr = str.split("-");
select = new DefaultMutableTreeNode(str
tree.addTreeSelectionListe
ResultSet rs;
int terminalID = 0;
TreeNode [] tn = node.getPath();
//System.out.println("Tree
//String terminalQuery = "select terminalrow,terminalblock from terminals WHERE terminal_id= '"+pk+"'";
String terminalQuery = " select t.terminal_id from bookht_terminals t, bookht_TelCenter co, city ci where co.CITYID = ci.pkid and co.NAME = '"+tn[2]+"'"+ "and ci.CITY = '"+tn[1]+"'"+ " and t.terminalblock = '"+splitStr[0]+"'"+ " and t.terminalrow ='"+splitStr[1]+"'"+ "";
//System.out.println(termi
//System.exit(0);
Connection connect = PictMenuFrameDemo.getDBCon
try
{
Statement st = connect.createStatement();
rs = st.executeQuery(terminalQu
rs.next();
terminalID = rs.getInt("terminal_id");
}
catch (SQLException sqle)
{
System.err.println("Can't get Terminal collection from database 1: " + sqle.getMessage());
}
JPanel buttonPanel = createTerminalButtonsPanel
JScrollPane jspMap = new JScrollPane(buttonPanel,JS
JScrollPane.HORIZONTAL_SCR
innerCardPanel.add(jspMap,
//JPanel buttonPanel = createButtonsPanel(str);
//innerCardPanel.add(butto
// System.out.println("Path "+Arrays.asList(node.getPa
//System.out.println("Leaf
//System.out.println("Pare
//System.out.println("Chil
//tree.expandPath(new TreePath(((DefaultMutableT
if (node.getChildCount() >= 0)
{
//System.out.println("INSI
for (Enumeration en = node.children(); en.hasMoreElements(); )
{
DefaultMutableTreeNode n = (DefaultMutableTreeNode)en
//System.out.println("Leaf
//System.out.println("Path
if (!n.isLeaf())
continue;
if (n.toString().equals(str))
{
tree.expandPath(new TreePath(n.getPath()));
tree.setSelectionPath(new TreePath(n.getPath()));
break;
}
}
}
//changeCard(rightCardPane
//changeCard(innerCardPane
//tree.expandPath(new TreePath(node.getPath()));
//System.out.println("Path
//tree.setSelectionPath(ne
//System.out.println("Path
//paths.pathByAddingChild(
}
}
ASKER
case BaseRow.MDF_TYPE : {
------
is part of the node is used mostly.i mean it is expanded and creates Jbuttons onthe right side.
Zolf, -Xmx512m is just a limit; you can set it without much risk.
If your application really needs 256 then set -Xmx256m.
;JOOP!
If your application really needs 256 then set -Xmx256m.
;JOOP!
why do you define a thread inside ? however this thread will terminate but its object will remain in heap, because innerCardPanel is refering to them in heap.
buttonPanel = createTerminalButtonsPanel (pk);
JScrollPane jspMap = new JScrollPane(buttonPanel,JS crollPane. VERTICAL_S CROLLBAR_A S_NEEDED,
JScrollPane.HORIZONTAL_SCR OLLBAR_AS_ NEEDED);
innerCardPanel.add(jspMap, BUTTON_PANEL);
changeCard(rightCardPanel, CO_DETALED_PANEL);
changeCard(innerCardPanel, BUTTON_PANEL);
buttonPanel = createTerminalButtonsPanel
JScrollPane jspMap = new JScrollPane(buttonPanel,JS
JScrollPane.HORIZONTAL_SCR
innerCardPanel.add(jspMap,
changeCard(rightCardPanel,
changeCard(innerCardPanel,
ASKER
sciuriware:
how do i know how much memory my application requires.
mnrz:
please tell me what shouild i do now.appreciate your help.should i get rid of that thread
ASKER
mnrz:
that thread i use to show a progrss bar while it finishes displaying the Jbutton with data from db.
try to see if it works fine with no progress bar and no thread and then post the result here
ASKER
i removed the progress bar and the thread.but i get that heap error.the exception is below along with the code i changed.
case BaseRow.MDF_TYPE : {
changeCard(rightCardPanel,
changeCard(innerCardPanel,
//System.out.println("INSI
DefaultMutableTreeNode pselect = (DefaultMutableTreeNode)se
CoRow co = (CoRow)pselect.getUserObje
Vector cov = getNodesThisLevel(mdfColle
int selIndex = Collections.binarySearch(c
/*final Progress p = new Progress();
try
{
p.runProgress();
}
catch(Exception e)
{
e.printStackTrace ();
}
Thread t = new Thread(new Runnable(){
public void run()
{
try
{*/
System.out.println("INSIDE
buttonPanel = createTerminalButtonsPanel
JScrollPane jspMap = new JScrollPane(buttonPanel,JS
JScrollPane.HORIZONTAL_SCR
innerCardPanel.add(jspMap,
changeCard(rightCardPanel,
changeCard(innerCardPanel,
//p.hide();
/*}
catch(Exception e)
{
e.printStackTrace ();
}
}
});*/
// th.start();
//////////////////////////
// th.destroy();
if (!isSameBranch(select, lastSelectedNode))
{
}
break;
}
Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError
at java.util.Arrays.copyOfRan
at java.lang.String.<init>(Un
at java.lang.StringBuilder.to
at javax.swing.plaf.basic.Bas
at javax.swing.plaf.basic.Bas
at javax.swing.JComponent.set
at javax.swing.AbstractButton
at javax.swing.JMenuItem.setU
at javax.swing.JMenuItem.upda
at javax.swing.JMenuItem.init
at javax.swing.JMenuItem.<ini
at javax.swing.JMenuItem.<ini
at src.com.victa.TreeTableInt
at src.com.victa.TreeTableInt
at java.awt.AWTEventMulticast
at java.awt.Component.process
at javax.swing.JComponent.pro
at java.awt.Component.process
at java.awt.Container.process
at java.awt.Component.dispatc
at java.awt.Container.dispatc
at java.awt.Component.dispatc
at java.awt.LightweightDispat
at java.awt.LightweightDispat
at java.awt.LightweightDispat
at java.awt.Container.dispatc
at java.awt.Window.dispatchEv
at java.awt.Component.dispatc
at java.awt.EventQueue.dispat
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
at java.awt.EventDispatchThre
ASKER
also my createTerminalButtonsPanel
what is in this line:
src.com.victa.TreeTableInt ernalFrame .createTer minalButto nsPanel(Tr eeTableInt ernalFrame .java:1036 )
>>TreeTableInternalFrame.j ava:1036
src.com.victa.TreeTableInt
>>TreeTableInternalFrame.j
ASKER
this line is in that createTerminalButtonsPanel
JMenuItem assignBucht = new JMenuItem("Assign Bucht");
you can see the code for that method in my first comment
first, you didn't close you connections at all, before getting new connection from the PictMenuFrameDemo.getDBCon nection(); you should close your last connection
second, the createTerminalButtonsPanel () method returns a JPanel that contains lots of objects before calling this method for second time you should remove the last returned JPanel or aligible it to be GCed by the JVM, you can set it to null or release all objects inside
second, the createTerminalButtonsPanel
take a look here:
JPanel buttonPanel = createTerminalButtonsPanel (terminalI D);
JScrollPane jspMap = new JScrollPane(buttonPanel,JS crollPane. VERTICAL_S CROLLBAR_A S_NEEDED,
JScrollPane.HORIZONTAL_SCR OLLBAR_AS_ NEEDED);
innerCardPanel.add(jspMap, BUTTON_PANEL);
each time user clicks on a node you create a JPanel and a JScrollPane and add it to innserCardPanel, next time that user click on another node and you add another JScrollPane to innerCardPanel !!!!
you must somehow release the last one
JPanel buttonPanel = createTerminalButtonsPanel
JScrollPane jspMap = new JScrollPane(buttonPanel,JS
JScrollPane.HORIZONTAL_SCR
innerCardPanel.add(jspMap,
each time user clicks on a node you create a JPanel and a JScrollPane and add it to innserCardPanel, next time that user click on another node and you add another JScrollPane to innerCardPanel !!!!
you must somehow release the last one
ASKER
mnrz
can you please help me to close the connection and get rid of previous objects.can you guide me more in my code.please
cheers
zolf
ASKER
i added a finally clause which closes the jdbc objects.but when i add the connect.close i get error saying connection is closed.then when i comment the two connect.close it works but i again get that heap space error.my code is below showing that finally clause
public JPanel createTerminalButtonsPanel
{
JPanel panel = new JPanel();
JButton[] buttons = new JButton[200];
int num_port =0;
//JButton butt = new JButton();
Connection connect = null;
Statement s = null;
ResultSet r = null;
try
{
String dslamLinecard= "SELECT dbo.Bookht_Terminals.TERMI
"FROM dbo.Bookht_Terminals INNER JOIN "+
"dbo.Bookht_Terminal_Brand
//System.out.println("Quer
connect = PictMenuFrameDemo.getDBCon
s = connect.createStatement();
r = s.executeQuery(dslamLineca
while(r.next())
{
num_port = r.getInt("NUM_PORT");
}
}
catch (SQLException sqle)
{
System.err.println("Can't get Terminal collection from database : " + sqle.getMessage());
}
finally
{
try
{
if (r != null)
r.close();
}
catch (Exception e)
{
// it's a good idea to log it!
System.err.println("Cannot
}
try
{
if (s != null)
s.close();
}
catch (Exception e)
{
// it's a good idea to log it!
System.err.println("Cannot
}
/*try
{
if (connect != null)
connect.close();
}
catch (SQLException e)
{
// it's a good idea to log it!
System.err.println("Cannot
}*/
}
int i=0;
final int pklinecard = pk;
//panel.setComponentOrient
panel.setBorder(new EmptyBorder(15, 15, 15, 15));
//System.out.println("num_
if(num_port > 54 && num_port <= 100)
{
//System.out.println("num_
panel.setComponentOrientat
panel.setLayout(new GridLayout(10, 10, 15, 15));
panel.setPreferredSize(new
}
else if(num_port > 100 && num_port <= 200)
{
//System.out.println("num_
panel.setComponentOrientat
panel.setLayout(new GridLayout(20, 10, 15, 15));
panel.setPreferredSize(new
//System.out.println(panel
}
else if(num_port > 0 && num_port <= 54)
{
//System.out.println("num_
panel.setComponentOrientat
panel.setLayout(new GridLayout(9, 6, 15, 15));
panel.setPreferredSize(new
}
int block = 0;
int row = 0;
int slot = 0;
int dportno = 0;
int tport_no = 0;
int terminal_port_id = 0;
int portal_state_id = 0;
int co_id = 0;
ActionListener actionListener = null;
String ip = null;
String str2 = null;
ResultSet rs = null;
ResultSet rs1=null;
//String dslamLinecard= "Select t.co_id,tp.portal_state_id
String dslamLinecard= "SELECT t.CO_ID, tp.PORTAL_STATE_ID,tp.Phon
//System.out.println("Quer
connect = PictMenuFrameDemo.getDBCon
Statement st = null;
try
{
st = connect.createStatement();
// Statement st1 = connect.createStatement();
rs = st.executeQuery(dslamLinec
while(rs.next())
{
co_id = rs.getInt("co_id");
}
//String customerName = SimpleJdbc.getCustomerName
//System.out.println(custo
rs1 = st.executeQuery(dslamLinec
if(ip == null || slot==0 || dportno == 0 )
{
str2 = " ";
}
else
{
str2 = ip+" - "+slot+" - "+dportno;
}
while(rs1.next())
{
portal_state_id = rs1.getInt("portal_state_i
slot = rs1.getInt("SLOT");
//System.out.println(slot)
ip = rs1.getString("IP");
dportno = rs1.getInt("dport_no");
block = rs1.getInt("terminalblock"
row = rs1.getInt("terminalrow");
tport_no = rs1.getInt("tport_no");
//terminal_id = rs1.getInt("terminal_port_
terminal_port_id = rs1.getInt("terminal_port_
//String customerName = SimpleJdbc.getCustomerName
String customerName = rs1.getString("PhoneNumber
//customerName = "2222222222";
/*if(((portal_state_id == 1) || (portal_state_id == 2)) && customerName != null )
{
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '4' WHERE terminal_id ='"+pk+"' AND tport_no ='"+tport_no +"'";
//System.out.println(termi
st1.executeUpdate(terminaP
}*/
int flag = 0;
String label = null;
if(ip == null || slot==0 || dportno == 0 )
{
str2 = " ";
//str2 = ip+" - "+slot+" - "+dportno;
flag = 1;
}
else
{
str2 = ip+" - "+slot+" - "+dportno;
flag = 1;
}
String str = block+" - "+row+" - "+tport_no;
if(flag == 0)
{
////label = "<html><center>"+str+"<cen
if(customerName == null)
{
label = "<html><center>"+str+"<br>
}
else
{
label = "<html><center>"+str+"<br>
}
}
else
{
if(customerName == null)
{
label = "<html><center>"+str+"<br>
}
else
{
label = "<html><center>"+str+"<br>
}
}
/*if(((portal_state_id == 1) || (portal_state_id == 2)) && customerName != null )
{
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '4' WHERE terminal_id ='"+pk+"' AND tport_no ='"+tport_no +"'";
System.out.println(termina
st.executeUpdate(terminaPo
}*/
buttons[i] = new JButton();
final JPopupMenu menu = new JPopupMenu();
// Create and add a menu item
JMenuItem portMap = new JMenuItem("Define Port Mapping");
JMenuItem portState = new JMenuItem("Set Port State");
JMenuItem portHistory = new JMenuItem("Port History");
JMenuItem assignBucht = new JMenuItem("Assign Bucht");
JMenuItem freeBucht = new JMenuItem("Free Bucht");
menu.add(portMap);
portMap.addActionListener(
portState.addActionListene
portHistory.addActionListe
assignBucht.addActionListe
freeBucht.addActionListene
menu.add(portState);
menu.add(new JSeparator());
menu.add(portHistory);
menu.add(new JSeparator());
menu.add(assignBucht);
menu.add(freeBucht);
ActionListener list = new ButtonData(terminal_port_i
portMap.addActionListener(
portState.addActionListene
portHistory.addActionListe
assignBucht.addActionListe
freeBucht.addActionListene
//Integer tPortNo = new Integer(terminal_port_id);
//System.out.println(tPort
//portMap.setActionCommand
buttons[i].setMargin(new Insets(0,0,0,0));
buttons[i].setFont(new Font("Arial", Font.PLAIN, 12));
buttons[i].setBorder(null)
buttons[i].setVerticalAlig
buttons[i].setHorizontalAl
//buttons[i].setBorderPain
buttons[i].setFocusPainted
buttons[i].setText(label);
if(((portal_state_id == 1) || (portal_state_id == 2)) && customerName != null )
//if(customerName != null && portal_state_id == 2)
{//In TCI
Connection connects = PictMenuFrameDemo.getDBCon
Statement ste = connects.createStatement()
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '8' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi
//System.exit(0);
ste.executeUpdate(terminaP
buttons[i].setBackground(n
}
else if((ip != null && customerName == null) && (portal_state_id == 4 || portal_state_id == 7 || portal_state_id == 9))
{
Connection connects = PictMenuFrameDemo.getDBCon
Statement ste = connects.createStatement()
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '11' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi
//System.exit(0);
ste.executeUpdate(terminaP
buttons[i].setBackground(n
}
else if((ip != null && customerName == null) && (portal_state_id == 10 ))
{
Connection connects = PictMenuFrameDemo.getDBCon
Statement ste = connects.createStatement()
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '2' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi
//System.exit(0);
ste.executeUpdate(terminaP
buttons[i].setBackground(C
}
else if((ip != null && customerName != null) && (portal_state_id == 11 ))
{
Connection connects = PictMenuFrameDemo.getDBCon
Statement ste = connects.createStatement()
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '4' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi
//System.exit(0);
ste.executeUpdate(terminaP
buttons[i].setBackground(C
}
/*else if((ip != null && customerName != null) && (portal_state_id == 8 ))
{
Connection connects = PictMenuFrameDemo.getDBCon
Statement ste = connects.createStatement()
String terminaPortQuery = "UPDATE bookht_terminal_ports SET portal_state_id = '4' WHERE terminal_port_id ='"+terminal_port_id +"'";
//System.out.println(termi
//System.exit(0);
ste.executeUpdate(terminaP
buttons[i].setBackground(C
}*/
else
{
if(portal_state_id == 1)
{//no mapping
buttons[i].setBackground(C
}
else if(portal_state_id == 2)
{//ready to use
buttons[i].setBackground(C
}
else if(portal_state_id == 3)
{//problem
buttons[i].setBackground(n
}
else if(portal_state_id == 4)
{//Active User - Used
buttons[i].setBackground(C
}
else if(portal_state_id == 5)
{//Reserved
buttons[i].setBackground(C
}
else if(portal_state_id == 6)
{//Out of Service
buttons[i].setBackground(C
}
else if(portal_state_id == 7)
{//Approved Krone
buttons[i].setBackground(C
}
else if(portal_state_id == 8)
{//Under Constr
buttons[i].setBackground(n
}
else if(portal_state_id == 9)
{//Installed not used
buttons[i].setBackground(C
}
else if(portal_state_id == 10)
{//PCM/PGS
buttons[i].setBackground(C
}
else if(portal_state_id == 11)
{//Questionable Bookht label.setBackground(new Color(255, 0, 0));
buttons[i].setBackground(n
}
}
panel.add(buttons[i]);
// Set the component to show the popup menu
buttons[i].addMouseListene
public void mousePressed(MouseEvent evt) {
if (evt.isPopupTrigger()) {
menu.show(evt.getComponent
}
}
public void mouseReleased(MouseEvent evt) {
if (evt.isPopupTrigger()) {
menu.show(evt.getComponent
}
}
});
i++;
}//while
}
catch (SQLException sqle)
{
System.err.println("Can't get Terminal collection from database : " + sqle.getMessage());
}
finally
{
try
{
if (rs != null)
rs.close();
}
catch (Exception e)
{
// it's a good idea to log it!
System.err.println("Cannot
}
try
{
if (rs1 != null)
rs1.close();
}
catch (Exception e)
{
// it's a good idea to log it!
System.err.println("Cannot
}
try
{
if (st != null)
st.close();
}
catch (Exception e)
{
// it's a good idea to log it!
System.err.println("Cannot
}
/*try
{
if (connect != null)
connect.close();
}
catch (SQLException e)
{
// it's a good idea to log it!
System.err.println("Cannot
}*/
}
/*catch (ClassNotFoundException csqle)
{
System.err.println("Can't get Ports collection from database : " + csqle.getMessage());
} */
return panel;
}
ASKER
for that second comment of yours regarding that JPanel and scrollpane.i changed my code like this below but i still get that error.can you please correct me.
>>second, the createTerminalButtonsPanel
case BaseRow.MDF_TYPE : {
changeCard(rightCardPanel,
changeCard(innerCardPanel,
//System.out.println("INSI
DefaultMutableTreeNode pselect = (DefaultMutableTreeNode)se
CoRow co = (CoRow)pselect.getUserObje
Vector cov = getNodesThisLevel(mdfColle
int selIndex = Collections.binarySearch(c
JScrollPane jspMap = null;
System.out.println("INSIDE
buttonPanel = null;
buttonPanel = createTerminalButtonsPanel
jspMap = new JScrollPane(buttonPanel,JS
JScrollPane.HORIZONTAL_SCR
innerCardPanel.add(jspMap,
changeCard(rightCardPanel,
changeCard(innerCardPanel,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks mnrz for your time and help.
that innerCardPanel.removeAll()
but then it only displays the compoents for the first node and then nothing happens when i click on other jtree nodes.
i will close this question and open another question.
but you could request a refund for your question instead of accepting solution
and please try this one
in your code you have:
JScrollPane jspMap = ....
define this as an instance variable in your class
private JScrollPane jspMap;
and each time you click on a node first you set the jspMap to null
jspMap = null;
jspMap = new JScrollPane(buttonPanel,JS crollPane. VERTICAL_S CROLLBAR_A S_NEEDED,J ScrollPane .HORIZONTA L_SCROLLBA R_AS_NEEDE D);
hope this work
and please try this one
in your code you have:
JScrollPane jspMap = ....
define this as an instance variable in your class
private JScrollPane jspMap;
and each time you click on a node first you set the jspMap to null
jspMap = null;
jspMap = new JScrollPane(buttonPanel,JS
hope this work
ASKER
thanks for that comment i did that.but still no luck.i think your previous comment to remove the old panel should solve the problem.but i dont know where to start from since i have finished the application and it is being used by users.