the problem im faceing here in my code is
The events that i want to happen are not occuring after i select an item from the combobox,and also all other components are showing the same faulty behaviour.
the faulty behaviour that they are showing is they are not firing the events when something is selected from them but they are firing the events if i minimize and then maximize the window.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.net.URL;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Vector;
import java.awt.TextField;
import java.awt.event.*;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.DropMode;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JDialog;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.TransferHandler;
import javax.swing.table.DefaultTableModel;




public class JVariousExamples extends JFrame implements ActionListener
{
	JFrame aFrame= new JFrame("First Frame");
	public class JEvent extends JApplet 
	{
		Image eventlogo1;
	    ImageIcon eventlogo2;
	  public void init(String r,String a){
		eventlogo1 = getImage(getCodeBase(r),a);
		eventlogo2 = new ImageIcon("Database.gif");
		
		
	             }
	  public URL getCodeBase(String x)
	  {
		  java.net.URL imgURL = JEvent.class.getResource(x);
		 return imgURL;
	  }
	  
	  
	  public void paint (Graphics g)
	          {
	         g.drawImage(eventlogo1,0,0,this);
	        g.drawImage(eventlogo1,0,120, getWidth(), getHeight()-100, this);
	        eventlogo2.paintIcon(this, g, 180, 0);
	        
	          }
	  }


	
JButton b= new JButton("Test");
JButton b1= new JButton("Save");
JButton b2= new JButton("Cancel");
JButton b3= new JButton("Wizard");
JButton Add = new JButton("Add");
JButton Remove = new JButton("Remove");
JButton print=new JButton("Print");

JRadioButton Yes = new JRadioButton("Yes");
JRadioButton No = new JRadioButton("No");
JRadioButton LineGraph = new JRadioButton("LineGraph");
JRadioButton PieGraph = new JRadioButton("PieGraph");
JComboBox XAxis;
JComboBox YAxis=new JComboBox();

JTextField text= new JTextField(10);
//JTextField text1= new JTextField(10);
JTextField text2= new JTextField(10);
JTextField text3= new JTextField(10);
JTextField text4= new JTextField(10);
JTextField text5= new JTextField(10);
TextField text6= new TextField(10);

JLabel title = new JLabel("Database JDBC Connection :");
JLabel name = new JLabel("Name:");
JLabel jdbcdriver = new JLabel("JDBC Driver:");
JLabel jdbcurl = new JLabel("JDBC URL:");
JLabel serveradress = new JLabel("Server Address:");
JLabel database = new JLabel("Data Base:");
JLabel uasername = new JLabel("User Name:");
JLabel password = new JLabel("Password:");
JLabel display = new JLabel("GOT CONNECTED TO DATA BASE");
JCheckBox checkbox=new JCheckBox("Show Query");
JTextArea txt;
String[] ifint=new String[50];  
String[] ifnotint=new String[50];  
JTable table;


String[] jdbcdrivers = {"Oracle(oracle.jdbc.driver.OracleDriver)","Java","Sun"};//has to go to model class
JComboBox jdbcdriverlist = new JComboBox(jdbcdrivers);
JComboBox tablelist;
JComboBox list;
static Insets insets = new Insets(0, 0, 0, 0);


GridBagLayout c= new GridBagLayout();
GridBagConstraints d = new GridBagConstraints();
GridBagConstraints a = new GridBagConstraints();
GridBagConstraints e = new GridBagConstraints();

ArrayList<String> listofusers = null;
ArrayList<String> details = null;
JList lst= null;
JList lst1=null;
String[] somearray= new String[1000];
DefaultListModel from = new DefaultListModel();
DefaultListModel copy = new DefaultListModel();
DefaultListModel move = new DefaultListModel();
JPanel p= new JPanel(new GridBagLayout());
JFrame f = new JFrame("List Frame");
JFrame newframe= new JFrame("Second Frame");
JFrame fr= new JFrame("Final frame");
JPanel pn=new JPanel(new GridBagLayout());

JPanel pane;
final DBConnectionclass dbob= new DBConnectionclass();

protected void set_a(int z)
{
	
	a.anchor=z;
}

protected void set_d(int x, int y)
{
	d.gridx=x;
	d.gridy=y;
	
	}
private static void addComponent(Container container, Component component, int gridx, int gridy,
	      int gridwidth, int gridheight, int anchor, int fill,int ipadx,int ipady) {
	    GridBagConstraints gbc = new GridBagConstraints(gridx, gridy, gridwidth, gridheight, 1.0, 1.0,
	        anchor, fill, insets, ipadx,ipady );
	    container.add(component, gbc);
	  }


protected void set_e(int x, int y,int width,int height,int fill)
{
	e.gridx=x;
	e.gridy=y;
	e.gridwidth=width;
	e.gridheight=height;
	e.fill=fill;
	}

 public JVariousExamples()
{
super("Change Message");

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);






JPanel panel= new JPanel();
panel.setLayout(c);

//Positioning all the components


set_a(GridBagConstraints.PAGE_START);


//for label
set_a(GridBagConstraints.CENTER);
a.insets=new Insets(0,0,5,0);
c.setConstraints(title,a);
panel.add(title);

//for label
set_d(1,1);

c.setConstraints(name,d);
panel.add(name);
//for text box
set_e(2,1,1,1,GridBagConstraints.HORIZONTAL);

c.setConstraints(text,e);
panel.add(text);

//for label
set_d(1,2);
c.setConstraints(jdbcdriver,d);
panel.add(jdbcdriver);
//for text
set_e(2,2,1,1,GridBagConstraints.HORIZONTAL);
c.setConstraints(jdbcdriverlist,e);
panel.add(jdbcdriverlist);


//for label
set_d(1,3);
c.setConstraints(jdbcurl,d);
panel.add(jdbcurl);
//for text
set_e(2,3,1,1,GridBagConstraints.HORIZONTAL);
text2.setFocusable(false);
c.setConstraints(text2,e);
panel.add(text2);

//for label
set_d(1,4);
c.setConstraints(serveradress,d);
panel.add(serveradress);
//for text
set_e(2,4,1,1,GridBagConstraints.HORIZONTAL);
c.setConstraints(text3,e);
panel.add(text3);

//for label
set_d(1,5);
c.setConstraints(database,d);
panel.add(database);
//for text
set_e(2,5,1,1,GridBagConstraints.HORIZONTAL);
c.setConstraints(text4,e);
panel.add(text4);
set_d(3,5);
c.setConstraints(b3,d);
panel.add(b3);
b3.addActionListener(this);

//for label
set_d(1,6);
c.setConstraints(uasername,d);
panel.add(uasername);
//for text
set_e(2,6,1,1,GridBagConstraints.HORIZONTAL);
c.setConstraints(text5,e);
panel.add(text5);

//for label
set_d(1,7);
c.setConstraints(password,d);
panel.add(password);
//for text
set_e(2,7,1,1,GridBagConstraints.HORIZONTAL);
text6.setEchoChar('*');
c.setConstraints(text6,e);
panel.add(text6);

//for button
set_d(1,8);
c.setConstraints(b,d);
panel.add(b);
b.addActionListener(this);
//for button
set_d(2,8);
c.setConstraints(b1,d);
panel.add(b1);
b1.addActionListener(this);
//for button
set_d(3,8);
c.setConstraints(b2,d);
panel.add(b2);
b2.addActionListener(this);
//for label
set_d(2,11);
display.setVisible(false);
c.setConstraints(display,d);
panel.add(display);


//panel.add(panel1);

setContentPane(panel);

///USING LAYERED PANE




panel.setBackground(Color.BLUE);
panel.setBounds(100,100,600,500);
panel.setOpaque(true);

JPanel panel1= new ImagePanel("Database.gif");
panel1.setLayout(c);
set_e(0,0,100,100,GridBagConstraints.HORIZONTAL);
 JEvent j = new JEvent();
 JLabel picture = new JLabel();
 picture.setIcon(j.eventlogo2);
 c.setConstraints(picture,a);
 panel1.add(picture);
panel1.setBackground(Color.RED);

panel1.setOpaque(true);

JLayeredPane lpane= new JLayeredPane();
//adding the two layers into layeredpane
lpane.setBounds(0,0,1000,1000);
lpane.add(panel,new Integer(0),0);
lpane.add(panel1,new Integer(1),0);


aFrame.setPreferredSize(new Dimension(1000, 1000));
aFrame.add(lpane, BorderLayout.CENTER); 
aFrame.pack();
aFrame.setSize(1000,1000);
aFrame.add(lpane);
aFrame.setVisible(true);
aFrame.addWindowListener(new WindowAdapter()
{  public void windowClosing(WindowEvent e)
         {
	      System.out.println("Exit via windowClosing."); 
	      System.exit(0);
         }
});

}
 private class listItemListener implements ItemListener{
	 public void itemStateChanged(ItemEvent e){
		if(e.getStateChange()== ItemEvent.SELECTED)
		{
			
			
			JComboBox cb = (JComboBox)e.getSource();
			final String st = (String)cb.getSelectedItem();
			ArrayList<String> listoftables = dbob.getArrayofTables(st);
			String[] tablearray= new String[500];
			tablearray = listoftables.toArray(tablearray);
		    tablelist= new JComboBox(tablearray);
		    addComponent(p,tablelist,3,0,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		    addComponent(p,new JLabel("Tabel Name"),2,0,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		    tablelist.addItemListener(new ItemListener(){
		   	 public void itemStateChanged(ItemEvent e)
		   	 {
		   		 if(e.getStateChange()==ItemEvent.SELECTED)
		   		 {
		   			newframe.validate();
		   			newframe.setVisible(false);
		   			newframe.setVisible(true);
		   			 
		   			JComboBox cb = (JComboBox)e.getSource();
					String st1 = (String)cb.getSelectedItem();
		   			details=dbob.getDetails(st, st1);
		   			somearray = details.toArray(somearray);
		   			for(int i=0;i<somearray.length;i++)
		   			{
		   				from.addElement(somearray[i]);
		   			}
		   			lst = new JList(from);
		   			lst.setTransferHandler(new FromTransferHandler());
		   			lst.setDragEnabled(true);
		   			lst.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
		   			lst.setLayoutOrientation(JList.VERTICAL);
		   			lst.setVisibleRowCount(-1);
		   			JScrollPane listScroller = new JScrollPane(lst);
		   			listScroller.setPreferredSize(new Dimension(250, 80));
		   			addComponent(p,new JLabel("Source"),0,1,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			addComponent(p,listScroller,0,2,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			
                   
					
					lst1= new JList(move);
					
					lst1.setTransferHandler(new ToTransferHandler(TransferHandler.COPY));
					
					lst1.setDropMode(DropMode.INSERT);
					lst.setLayoutOrientation(JList.VERTICAL);
		   			lst.setVisibleRowCount(-1);
		   			JScrollPane listScroller1 = new JScrollPane(lst1);
		   			listScroller1.setPreferredSize(new Dimension(250, 80));
		   			addComponent(p,new JLabel("Destination"),2,1,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			addComponent(p,listScroller1,2,2,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			
		   			
					
					
					
					addComponent(p,Add,1,2,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
					Add.addActionListener(new ActionListener(){
						public void actionPerformed(ActionEvent e)
						{
							Object selected[] = lst.getSelectedValues();
							int size = selected.length;
						    for (int i = 0; i < size; i++) {
						      move.add(i, selected[i]);
						}
					}});
					
                    
					
					addComponent(p,Remove,1,3,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
					Remove.addActionListener(new ActionListener(){
						public void actionPerformed(ActionEvent e) {
						       Object selected[] = lst1.getSelectedValues();
						       for (int i = selected.length - 1; i >= 0; --i) {
								      move.removeElement(selected[i]);
								    }
								    lst1.getSelectionModel().clearSelection();
						     }
						}
					);
					
					addComponent(p,new JLabel("Inclde Graph"),0,4,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
					
					addComponent(p,Yes,1,4,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                    Yes.addItemListener(new ItemListener()
                    {
                    	public void itemStateChanged(ItemEvent e)
                    	{
                    		
        					addComponent(p,new JLabel("Graph Type"),0,5,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
        					
                            addComponent(p,LineGraph,1,5,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                            
                            addComponent(p,PieGraph,2,5,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                            
                            
                            String[] axis=new String[100];
                            for(int i=0;i<move.getSize();i++){
                            	axis[i]=(String) move.getElementAt(i);
                            }
                            XAxis= new JComboBox(axis);
                            addComponent(p,XAxis,1,6,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                           
                            
                          
                            try{
                            	int x=0;
                            	Connection con= DBConnectionclass.getOracleJDBCConnection(text2.getText(), text5.getText(),text6.getText());
                            for(int i=0;i<axis.length;i++){
                            PreparedStatement ps=con.prepareStatement("SELECT ? FROM ALL_TAB_COLS AC, DATATYPE D  WHERE AC.OWNER = ? AND D.DATATYPENAME = AC.DATA_TYPE AND AC.TABLE_NAME = ? AND D.DATATYPENAME != 'XMLTYPE'");
                            ps.setString(1,axis[i]);
                            ps.setString(2, (String)list.getSelectedItem());
                            ps.setString(3, (String)tablelist.getSelectedItem());
                            ResultSet rs=ps.executeQuery();
                            ResultSetMetaData rsmd = rs.getMetaData();
                            for(int j=1;j<rsmd.getColumnCount();j++)
                               {
                            if(rsmd.getColumnTypeName(j).equalsIgnoreCase("int"))
                                   {
                            	       ifint[x]=rsmd.getColumnName(j); 
                                       x++;
                                       System.out.println(ifint[x]);
                                   }
                            
                               }
                            }
                            YAxis = new JComboBox(ifint);
                            addComponent(p,YAxis,2,6,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                            }
                            catch(SQLException ex){System.err.println("SQLException: " + ex.getMessage());}
                            
                            addComponent(p,checkbox,0,6,1,1,GridBagConstraints.FIRST_LINE_START,GridBagConstraints.HORIZONTAL,-1,-1);
                            checkbox.addActionListener(new ActionListener()
                            {
                                public void actionPerformed(ActionEvent e)
                                {
                                	
                                	String ps="SELECT "+gString(move)+
                                	          " \n FROM ALL_TAB_COLS AC, DATATYPE D " +
                                	          "\n WHERE AC.OWNER = "+(String)list.getSelectedItem()+ " AND D.DATATYPENAME = AC.DATA_TYPE AND AC.TABLE_NAME = "+(String)tablelist.getSelectedItem()+" AND D.DATATYPENAME != 'XMLTYPE'";                     
                                	System.out.println(ps);
                                	txt= new JTextArea(ps);
                        			JScrollPane scl = new JScrollPane(txt);
                        			scl.setPreferredSize(new Dimension(50,50));
                        			addComponent(p,scl,0,7,1,1,GridBagConstraints.FIRST_LINE_START,GridBagConstraints.HORIZONTAL,0,0);
                        			
                        			String[] axis1=new String[100];
                                    for(int i=0;i<move.getSize();i++){
                                    	axis1[i]=(String) move.getElementAt(i);
                                    }
                        			
                        			
                        			///to show the data in the form of grid
                        	    	try{
                        	    		
                        	    		
                        	    		Connection con1= DBConnectionclass.getOracleJDBCConnection(text2.getText(), text5.getText(),text6.getText());
                        			 	String querey="SELECT "+gString(move)+" FROM "+(String)tablelist.getSelectedItem()+" GROUP BY "+gString(move);                        	    
                        			 PreparedStatement ps1=con1.prepareStatement(querey);
                                     ResultSet rs=ps1.executeQuery();
                                    ResultSetMetaData rsmd = rs.getMetaData();
                                    
                                    	
                                    DefaultTableModel model= new DefaultTableModel();  
                                    	String cols[]=new String[rsmd.getColumnCount()];   
                                    	for(int i=0;i< cols.length;++i)       
                                    	{         
                                    		cols[i]= rsmd.getColumnLabel(i+1);     
                                    		}         
                                    	model.setColumnIdentifiers(cols);
                                    	while(rs.next())   
                                    	{         
                                    		Object data[]= new Object[cols.length];
                                    		for(int i=0;i< data.length;++i)  
                                    		{              
                                    			data[i]=rs.getObject(i+1); 
                                    			}        
                                    		model.addRow(data); 
                                    		} 
                                    	
                                    table = new JTable(model);
                                    
                                    
                                    addComponent(pn,new JScrollPane(table),1,1,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                                    addComponent(pn,print,1,2,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                                     print.addActionListener(new ActionListener()
                                     {
                                    										
										public void actionPerformed(ActionEvent e) {
											// TODO Auto-generated method stub
											PrintableDocument.printComponent(pn);
										}
                                     }
                                     
                                     
                                     );
                                    
                                    
                                    
                                    
                                    
                                                                  	
                        			
                                  
                                   setContentPane(pn);
                                   fr.add(pn);
                                   fr.setVisible(true);
                                   fr.setSize(1000,1000);
                                	   }      
                                   
                                   catch(SQLException ex){System.err.println("SQLException: " + ex.getMessage());}
                                   
                                   
                                }
                            });
                           
                            
                            
                            
                    }});
                   
                    addComponent(p,No,2,4,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
				     
				    }
		   	 }
		    });
		    
		 
           
		}
		
	}
 }
 
 public String gString(DefaultListModel mv){
	 int i=0;
	 String str="";
	 for(;i<mv.getSize()-1;i++)
     {
     	str=str + mv.getElementAt(i)+", \n";
     	
     }
	 if(i<mv.getSize())
	 {str=str + mv.getElementAt(i);}
 	return str;}
 public String gtString(DefaultListModel mv){
	 int i=0;	
	 String str="";
	 for(;i<mv.getSize()-1;i++)
     {
     	str=str +"AC."+ mv.getElementAt(i)+",";
     	
     }
	 if(i<mv.getSize())
	 {str=str+"AC."+mv.getElementAt(i);}
 	return str;}
 
 
 
 public static void main(String[] args)
 {
 new JVariousExamples();
 }

public void actionPerformed(ActionEvent e)
{
	
	
	Object source = e.getSource();
	if(source==b3)
	{
		text2.setFocusable(true);
		text2.setText("jdbc:oracle:thin:@"+text3.getText()+":1521:"+text4.getText());
	}else if (source==b)
	{
		
		dbob.url=text2.getText();
		dbob.userid=text5.getText();
		dbob.password=text6.getText();
		DBConnectionclass.getOracleJDBCConnection(dbob.url, dbob.userid,dbob.password);
		boolean show=true;
		DBConnectionclass.getOracleJDBCConnection(dbob.url, dbob.userid,dbob.password).equals(show);
		if(show)
				{display.setVisible(true);};
	}else if(source==b1)
	{
		
		aFrame.setVisible(false);
		pane=new JPanel();
		DBConnectionclass.getOracleJDBCConnection(text2.getText(), text5.getText(),text6.getText());
	
		//Arrraylist for schemas
		listofusers = dbob.getArrayofUsers();
		String[] strarray = new String[109];
		strarray=listofusers.toArray(strarray);
		System.out.println(strarray.length);
		list= new JComboBox(strarray);
		
			
		ItemListener ict = new listItemListener();
		list.addItemListener(ict);
		addComponent(p,list,1,0,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		
		/*/*set_d(0,0);
		c.setConstraints(new JLabel("Schema name"), d);
		pane.add(new JLabel("Schema name"));*/
		addComponent(p,new JLabel("SchemaName"),0,0,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		/*/*set_d(1,0);
		c.setConstraints(list,d);
		pane.add(list);
		setContentPane(pane);*/
		setContentPane(p);
		
		newframe.setVisible(true);
		//newframe.add(pane);
		newframe.add(p);
		newframe.setSize(2000,2000);
				
				
		}
	else if(source==b2)
	{
		 System.exit(0);

	}
	
	}

class FromTransferHandler extends TransferHandler {
    public int getSourceActions(JComponent comp) {
        return COPY_OR_MOVE;
    }

    private int index = 0;

    public Transferable createTransferable(JComponent comp) {
        
    	index = lst.getSelectedIndex();
        if (index < 0 || index >= lst.getModel().getSize()) {
            return null;
        }

        return new StringSelection((String)lst.getSelectedValue());
    }
    
    public void exportDone(JComponent comp, Transferable trans, int action) {
        if (action != MOVE) {
            return;
        }
         
        from.removeElementAt(index);
        //somearray.removeElementAt(index);
    }
}

class ToTransferHandler extends TransferHandler {
    int action;
    
    public ToTransferHandler(int action) {
        this.action = action;
    }
    
    public boolean canImport(TransferHandler.TransferSupport support) {
        // for the demo, we will only support drops (not clipboard paste)
        if (!support.isDrop()) {
            return false;
        }

        // we only import Strings
        if (!support.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            return false;
        }

        // check if the source actions contain the desired action -
        // either copy or move, depending on what was specified when
        // this instance was created
        boolean actionSupported = (action & support.getSourceDropActions()) == action;
        if (actionSupported) {
            support.setDropAction(action);
            return true;
        }

        // the desired action is not supported, so reject the transfer
        return false;
    }

    public boolean importData(TransferHandler.TransferSupport support) {
        // if we cannot handle the import, say so
        if (!canImport(support)) {
            return false;
        }

        // fetch the drop location
        JList.DropLocation dl = (JList.DropLocation)support.getDropLocation();

        int index = dl.getIndex();

        // fetch the data and bail if this fails
        String data;
        try {
            data = (String)support.getTransferable().getTransferData(DataFlavor.stringFlavor);
        } catch (UnsupportedFlavorException e) {
            return false;
        } catch (java.io.IOException e) {
            return false;
        }

        JList list = (JList)support.getComponent();
        DefaultListModel model = (DefaultListModel)list.getModel();
        model.insertElementAt(data, index);

        Rectangle rect = list.getCellBounds(index, index);
        list.scrollRectToVisible(rect);
        list.setSelectedIndex(index);
        list.requestFocusInWindow();

        return true;
    }  
} 

class FromTransferHandler1 extends TransferHandler {
    public int getSourceActions(JComponent comp) {
        return COPY_OR_MOVE;
    }

    private int index = 0;

    public Transferable createTransferable(JComponent comp) {
        
    	index = lst1.getSelectedIndex();
        if (index < 0 || index >= lst1.getModel().getSize()) {
            return null;
        }

        return new StringSelection((String)lst1.getSelectedValue());
    }
    
    public void exportDone(JComponent comp, Transferable trans, int action) {
        if (action != MOVE) {
            return;
        }
         
        move.removeElementAt(index);
        //somearray.removeElementAt(index);
    }
}

}

Edited 5 Years Ago by peter_budo: Removing quote on text

Please reduce the code.
What methods are called when you do what?
And what methods should be called when you click or select? Use a debugger and use the results to improve your code.

Then, if you know all that information, you can ask here, and I'll try to help you.

here i first added a "list" combobox to the frame and wrote a itemlistener to it,after the control enters inside the item statechanged method when i select an item from the "list combobox i have to c "tablelist" combobox in the frame but i could only c it if i minimise and maximise the window.And after that when i again select an item from the "tablelist" combobox i have to c the "source" and "destination" components in the frame but this also coul be seen only if i min and max the window.And even the rest of the components that are present in the give code are behaving in the same way.

private class listItemListener implements ItemListener{
	 public void itemStateChanged(ItemEvent e){
		if(e.getStateChange()== ItemEvent.SELECTED)
		{
			
			
			JComboBox cb = (JComboBox)e.getSource();
			final String st = (String)cb.getSelectedItem();
			ArrayList<String> listoftables = dbob.getArrayofTables(st);
			String[] tablearray= new String[500];
			tablearray = listoftables.toArray(tablearray);
		    tablelist= new JComboBox(tablearray);
		    addComponent(p,tablelist,3,0,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		    addComponent(p,new JLabel("Tabel Name"),2,0,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		    tablelist.addItemListener(new ItemListener(){
		   	 public void itemStateChanged(ItemEvent e)
		   	 {
		   		 if(e.getStateChange()==ItemEvent.SELECTED)
		   		 {
		   			newframe.validate();
		   			newframe.setVisible(false);
		   			newframe.setVisible(true);
		   			 
		   			JComboBox cb = (JComboBox)e.getSource();
					String st1 = (String)cb.getSelectedItem();
		   			details=dbob.getDetails(st, st1);
		   			somearray = details.toArray(somearray);
		   			for(int i=0;i<somearray.length;i++)
		   			{
		   				from.addElement(somearray[i]);
		   			}
		   			lst = new JList(from);
		   			lst.setTransferHandler(new FromTransferHandler());
		   			lst.setDragEnabled(true);
		   			lst.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
		   			lst.setLayoutOrientation(JList.VERTICAL);
		   			lst.setVisibleRowCount(-1);
		   			JScrollPane listScroller = new JScrollPane(lst);
		   			listScroller.setPreferredSize(new Dimension(250, 80));
		   			addComponent(p,new JLabel("Source"),0,1,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			addComponent(p,listScroller,0,2,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			
                   
					
					lst1= new JList(move);
					
					lst1.setTransferHandler(new ToTransferHandler(TransferHandler.COPY));
					
					lst1.setDropMode(DropMode.INSERT);
					lst.setLayoutOrientation(JList.VERTICAL);
		   			lst.setVisibleRowCount(-1);
		   			JScrollPane listScroller1 = new JScrollPane(lst1);
		   			listScroller1.setPreferredSize(new Dimension(250, 80));
		   			addComponent(p,new JLabel("Destination"),2,1,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			addComponent(p,listScroller1,2,2,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			
		   			
					
					
					
					addComponent(p,Add,1,2,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
					Add.addActionListener(new ActionListener(){
						public void actionPerformed(ActionEvent e)
						{
							Object selected[] = lst.getSelectedValues();
							int size = selected.length;
						    for (int i = 0; i < size; i++) {
						      move.add(i, selected[i]);
						}
					}});
					
                    
					
					addComponent(p,Remove,1,3,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
					Remove.addActionListener(new ActionListener(){
						public void actionPerformed(ActionEvent e) {
						       Object selected[] = lst1.getSelectedValues();
						       for (int i = selected.length - 1; i >= 0; --i) {
								      move.removeElement(selected[i]);
								    }
								    lst1.getSelectionModel().clearSelection();
						     }
						}
					);
					
					addComponent(p,new JLabel("Inclde Graph"),0,4,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
					
					addComponent(p,Yes,1,4,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                    Yes.addItemListener(new ItemListener()
                    {
                    	public void itemStateChanged(ItemEvent e)
                    	{
                    		
        					addComponent(p,new JLabel("Graph Type"),0,5,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
        					
                            addComponent(p,LineGraph,1,5,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                            
                            addComponent(p,PieGraph,2,5,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                            
                            
                            String[] axis=new String[100];
                            for(int i=0;i<move.getSize();i++){
                            	axis[i]=(String) move.getElementAt(i);
                            }
                            XAxis= new JComboBox(axis);
                            addComponent(p,XAxis,1,6,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                           
                            
                          
                            try{
                            	int x=0;
                            	Connection con= DBConnectionclass.getOracleJDBCConnection(text2.getText(), text5.getText(),text6.getText());
                            for(int i=0;i<axis.length;i++){
                            PreparedStatement ps=con.prepareStatement("SELECT ? FROM ALL_TAB_COLS AC, DATATYPE D  WHERE AC.OWNER = ? AND D.DATATYPENAME = AC.DATA_TYPE AND AC.TABLE_NAME = ? AND D.DATATYPENAME != 'XMLTYPE'");
                            ps.setString(1,axis[i]);
                            ps.setString(2, (String)list.getSelectedItem());
                            ps.setString(3, (String)tablelist.getSelectedItem());
                            ResultSet rs=ps.executeQuery();
                            ResultSetMetaData rsmd = rs.getMetaData();
                            for(int j=1;j<rsmd.getColumnCount();j++)
                               {
                            if(rsmd.getColumnTypeName(j).equalsIgnoreCase("int"))
                                   {
                            	       ifint[x]=rsmd.getColumnName(j); 
                                       x++;
                                       System.out.println(ifint[x]);
                                   }
                            
                               }
                            }
                            YAxis = new JComboBox(ifint);
                            addComponent(p,YAxis,2,6,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                            }
                            catch(SQLException ex){System.err.println("SQLException: " + ex.getMessage());}
                            
                            addComponent(p,checkbox,0,6,1,1,GridBagConstraints.FIRST_LINE_START,GridBagConstraints.HORIZONTAL,-1,-1);
                            checkbox.addActionListener(new ActionListener()
                            {
                                public void actionPerformed(ActionEvent e)
                                {
                                	
                                	String ps="SELECT "+gString(move)+
                                	          " \n FROM ALL_TAB_COLS AC, DATATYPE D " +
                                	          "\n WHERE AC.OWNER = "+(String)list.getSelectedItem()+ " AND D.DATATYPENAME = AC.DATA_TYPE AND AC.TABLE_NAME = "+(String)tablelist.getSelectedItem()+" AND D.DATATYPENAME != 'XMLTYPE'";                     
                                	System.out.println(ps);
                                	txt= new JTextArea(ps);
                        			JScrollPane scl = new JScrollPane(txt);
                        			scl.setPreferredSize(new Dimension(50,50));
                        			addComponent(p,scl,0,7,1,1,GridBagConstraints.FIRST_LINE_START,GridBagConstraints.HORIZONTAL,0,0);
                        			
                        			String[] axis1=new String[100];
                                    for(int i=0;i<move.getSize();i++){
                                    	axis1[i]=(String) move.getElementAt(i);
                                    }
                        			
                        			
                        			///to show the data in the form of grid
                        	    	try{
                        	    		
                        	    		
                        	    		Connection con1= DBConnectionclass.getOracleJDBCConnection(text2.getText(), text5.getText(),text6.getText());
                        			 	String querey="SELECT "+gString(move)+" FROM "+(String)tablelist.getSelectedItem()+" GROUP BY "+gString(move);                        	    
                        			 PreparedStatement ps1=con1.prepareStatement(querey);
                                     ResultSet rs=ps1.executeQuery();
                                    ResultSetMetaData rsmd = rs.getMetaData();
                                    
                                    	
                                    DefaultTableModel model= new DefaultTableModel();  
                                    	String cols[]=new String[rsmd.getColumnCount()];   
                                    	for(int i=0;i< cols.length;++i)       
                                    	{         
                                    		cols[i]= rsmd.getColumnLabel(i+1);     
                                    		}         
                                    	model.setColumnIdentifiers(cols);
                                    	while(rs.next())   
                                    	{         
                                    		Object data[]= new Object[cols.length];
                                    		for(int i=0;i< data.length;++i)  
                                    		{              
                                    			data[i]=rs.getObject(i+1); 
                                    			}        
                                    		model.addRow(data); 
                                    		} 
                                    	
                                    table = new JTable(model);
                                    
                                    
                                    addComponent(pn,new JScrollPane(table),1,1,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                                    addComponent(pn,print,1,2,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                                     print.addActionListener(new ActionListener()
                                     {
                                    										
										public void actionPerformed(ActionEvent e) {
											// TODO Auto-generated method stub
											PrintableDocument.printComponent(pn);
										}
                                     }
                                     
                                     
                                     );
                                    
                                    
                                    
                                    
                                    
                                                                  	
                        			
                                  
                                   setContentPane(pn);
                                   fr.add(pn);
                                   fr.setVisible(true);
                                   fr.setSize(1000,1000);
                                	   }      
                                   
                                   catch(SQLException ex){System.err.println("SQLException: " + ex.getMessage());}
                                   
                                   
                                }
                            });
                           
                            
                            
                            
                    }});
                   
                    addComponent(p,No,2,4,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
				     
				    }
		   	 }
		    });
		    
		 
           
		}
		
	}
 }

Please!

The text you are writing is NOT readable. Can you please use capital letters, and normal full stops in your sentences? I am NOT able to help you this way.
If your English is not good: that does not matter. But normal sentences are not such a big deal to ask right?

here i first added a "list" combobox to the frame and wrote a itemlistener to it .after the control enters into a item state changed method when i select an item from the "list" combobox i should be able to see the "tablelist" combobox in the frame but i could only see it if i minimise and maximise the window.after that when i again select an item from the tablelist combobox i should be able to see the "source" and "destination" components in the frame but even these also are seen only if i min and max the window.this has to be repeated for the succeding components in the frame.this is my problem ,,and i hope u got it now.

I saw your quote, but it is NOT readable.

As I said:

- Make normal sentences using a full-stop (.), and the the RETURN key on your keyboard.
- Use capital letters to start a sentence (ABCDEFGHIJKLMNOPQRSTUVWXYZ).

After an item has been selected from the combobox,the next event occurs only if i minimise and maximise the window.

This is the problem.

Each and every event after this(combobox) is having the same behaviour.

Great improvement!

Please add a little code, not the entire program, to emphasize the question.
Did you add an ActionListener to your comboBox?

public class ComboBoxDemo ... implements ActionListener {
    . . .
        petList.addActionListener(this) {
    . . .
    public void actionPerformed(ActionEvent e) {
        JComboBox cb = (JComboBox)e.getSource();
        String petName = (String)cb.getSelectedItem();
        updateLabel(petName);
    }
    . . .
}

From: http://download.oracle.com/javase/tutorial/uiswing/components/combobox.html#listeners

Does the ActionListener fire off when you actually change a thing in the combobox? Test that as well.
You can do a check in the eventListener if the object firing off the event is the comboBox, if not you can ignore the event.

I added a itemlistener to the JCombobox.

And from the code you can see that i have used itemstatechanged method.

In this method i am taking e.getStateChange()==ItemEvent.SELECTED as the deciding factor.

Here is the code were it has to show two new components in the frame.

But its showing me only if i minimise and maximise the window.

private class listItemListener implements ItemListener{
	 public void itemStateChanged(ItemEvent e){
		if(e.getStateChange()== ItemEvent.SELECTED)
		{
			
			
			JComboBox cb = (JComboBox)e.getSource();
			final String st = (String)cb.getSelectedItem();
			ArrayList<String> listoftables = dbob.getArrayofTables(st);
			String[] tablearray= new String[500];
			tablearray = listoftables.toArray(tablearray);
		    tablelist= new JComboBox(tablearray);
		    addComponent(p,tablelist,3,0,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		    addComponent(p,new JLabel("Tabel Name"),2,0,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);

OK. I assume you have a variable in your program, that represents the comboBox?
If so (I assumed your comboBox is named myComboBox):

private class listItemListener implements ItemListener{
	 public void itemStateChanged(ItemEvent e){
if (e.getSource == myComboBox) {
		if(e.getStateChange()== ItemEvent.SELECTED)
		{
			JComboBox cb = (JComboBox)e.getSource();
			final String st = (String)cb.getSelectedItem();
			}
}
}

Also try the following, check if there is any output when you select a differrent item in the list. Check now if there is any output when you resize the window.

private class listItemListener implements ItemListener{
	 public void itemStateChanged(ItemEvent e){
if (e.getSource == myComboBox) {
		if(e.getStateChange()== ItemEvent.SELECTED)
		{
			System.out.println(e.getSource().getSelectedItem());
			}
}
}

No there's no variable that represents the combobox.

And coming to the printing statement.Its telling that no getSelectedItme in the object e.getSource().

Once observe the code at lines 658,659,660.Only this is the JCombobox that has been given the listener.
And these lines are after the itemlsitener.

Could you please put down the line of code in which you add the Listener to the ComboBox? I think there is somthing wrong there.

Usually, it is done this way:

class MyClass implements ActionListener { // Your main class implements ActionListener, so you can use this class as an ActionListener.

JComboBox myComboBox = new JComboBox();

MyClass () {
// inside constuctor, or init function
// ...
// add items to the JComboBox
myComboBox.addActionListener(this);
// ...
}

void actionPerformed(ActionEvent e) {
if (e.getSource() == myComboBox) {
 // handle the action, from your JComboBox
}
}
}

Edited 5 Years Ago by hiddepolen: n/a

private class listItemListener implements ItemListener{
	 public void itemStateChanged(ItemEvent e){
		 if(e.getStateChange()== ItemEvent.SELECTED)
		{
		   ...........
list= new JComboBox(strarray);
		ItemListener ict = new listItemListener();
		list.addItemListener(ict);

Looks good, however why are you making the Listener a ItemListener instead of your own class, a listItemListener?

ItemListener ict = new listItemListener();

That might be the problem.

Even if i change the listener to instance of class listItemListener its not working.

The problem is still there.

Did you test if the itemStateChanged method is actually called? (Put a System.out.println() with some text in there and check that.

But when i add a print statement before the if statement im getting the printable statement twice.

And the problem still exists.

The method will be called twice, once when you click on the comboBox, and one more time when you select something. You need to save a reference to the comboBox object somewhere, so you can compare the sender of the call to the method.
That way the code inside the if statements should not be called on a resize, and only on a selection change.

Could u be little more clear.
Should i compare the sender's ref with the event's source like this if(e.getSource()==mycombobox) And if so where should i place this line of code .
Sholud i place it between these two lines

public void itemStateChanged(ItemEvent ie)
		   	{
                                  if(e.getSource()==mycombobox)
                                     {
                                      if(ie.getStateChange()==ItemEvent.SELECTED)
		   		   {
                                            .....

Edited 5 Years Ago by peter_budo: Keep It Clear - Do use code tags when posting any code

Yes, both pieces of source would be a good idea. First a check if you've got the right object, then if the call message is the right one.

I checked in that way.But its not working.

The problem is still there.

It might be lengthy but please do have little patience.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.net.URL;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Vector;
import java.awt.TextField;
import java.awt.event.*;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.DropMode;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JDialog;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.TransferHandler;
import javax.swing.table.DefaultTableModel;

public class JVariousExamples extends JFrame implements ActionListener
{
	JFrame aFrame= new JFrame("First Frame");
	public class JEvent extends JApplet 
	{
		Image eventlogo1;
	    ImageIcon eventlogo2;
	  public void init(String r,String a){
		eventlogo1 = getImage(getCodeBase(r),a);
		eventlogo2 = new ImageIcon("Database.gif");
		
	             }
	  public URL getCodeBase(String x)
	  {
		  java.net.URL imgURL = JEvent.class.getResource(x);
		 return imgURL;
	  }
	 
	  public void paint (Graphics g)
	          {
	         g.drawImage(eventlogo1,0,0,this);
	        g.drawImage(eventlogo1,0,120, getWidth(), getHeight()-100, this);
	        eventlogo2.paintIcon(this, g, 180, 0);
	        
	          }
	  }

JButton b= new JButton("Test");
JButton b1= new JButton("Save");
JButton b2= new JButton("Cancel");
JButton b3= new JButton("Wizard");
JButton Add = new JButton("Add");
JButton Remove = new JButton("Remove");
JButton print=new JButton("Print");

JRadioButton Yes = new JRadioButton("Yes");
JRadioButton No = new JRadioButton("No");
JRadioButton LineGraph = new JRadioButton("LineGraph");
JRadioButton PieGraph = new JRadioButton("PieGraph");
JComboBox XAxis;
JComboBox YAxis=new JComboBox();

JTextField text= new JTextField(10);
//JTextField text1= new JTextField(10);
JTextField text2= new JTextField(10);
JTextField text3= new JTextField(10);
JTextField text4= new JTextField(10);
JTextField text5= new JTextField(10);
TextField text6= new TextField(10);

JLabel title = new JLabel("Database JDBC Connection :");
JLabel name = new JLabel("Name:");
JLabel jdbcdriver = new JLabel("JDBC Driver:");
JLabel jdbcurl = new JLabel("JDBC URL:");
JLabel serveradress = new JLabel("Server Address:");
JLabel database = new JLabel("Data Base:");
JLabel uasername = new JLabel("User Name:");
JLabel password = new JLabel("Password:");
JLabel display = new JLabel("GOT CONNECTED TO DATA BASE");
JCheckBox checkbox=new JCheckBox("Show Query");
JTextArea txt;
String[] ifint=new String[50];  
String[] ifnotint=new String[50];  
JTable table;


String[] jdbcdrivers = {"Oracle(oracle.jdbc.driver.OracleDriver)","Java","Sun"};//has to go to model class
JComboBox jdbcdriverlist = new JComboBox(jdbcdrivers);
JComboBox tablelist=new JComboBox();
JComboBox list;

static Insets insets = new Insets(0, 0, 0, 0);


GridBagLayout c= new GridBagLayout();
GridBagConstraints d = new GridBagConstraints();
GridBagConstraints a = new GridBagConstraints();
GridBagConstraints e = new GridBagConstraints();

ArrayList<String> listofusers = null;
ArrayList<String> details = null;

String[] somearray= new String[1000];
DefaultListModel from = new DefaultListModel();
DefaultListModel copy = new DefaultListModel();
DefaultListModel move = new DefaultListModel();
JList lst=new JList(from);
JList lst1=new JList(move);
JScrollPane listScroller = new JScrollPane(lst);
JScrollPane listScroller1 = new JScrollPane(lst1);
JPanel p= new JPanel(new GridBagLayout());
JFrame f = new JFrame("List Frame");
JFrame newframe= new JFrame("Second Frame");
JFrame fr= new JFrame("Final frame");
JPanel pn=new JPanel(new GridBagLayout());

JPanel pane;
final DBConnectionclass dbob= new DBConnectionclass();

protected void set_a(int z)
{
		a.anchor=z;
}
protected void set_d(int x, int y)
{
	d.gridx=x;
	d.gridy=y;
		}
private static void addComponent(Container container, Component component, int gridx, int gridy,
	      int gridwidth, int gridheight, int anchor, int fill,int ipadx,int ipady) {
	    GridBagConstraints gbc = new GridBagConstraints(gridx, gridy, gridwidth, gridheight, 1.0, 1.0,
	        anchor, fill, insets, ipadx,ipady );
	    container.add(component, gbc);
	  }
protected void set_e(int x, int y,int width,int height,int fill)
{
	e.gridx=x;
	e.gridy=y;
	e.gridwidth=width;
	e.gridheight=height;
	e.fill=fill;
	}
public JVariousExamples()
{
super("Change Message");

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel= new JPanel();
panel.setLayout(c);
//Positioning all the components
set_a(GridBagConstraints.PAGE_START);
//for label
set_a(GridBagConstraints.CENTER);
a.insets=new Insets(0,0,5,0);
c.setConstraints(title,a);
panel.add(title);
//for label
set_d(1,1);
c.setConstraints(name,d);
panel.add(name);
//for text box
set_e(2,1,1,1,GridBagConstraints.HORIZONTAL);
c.setConstraints(text,e);
panel.add(text);
//for label
set_d(1,2);
c.setConstraints(jdbcdriver,d);
panel.add(jdbcdriver);
//for text
set_e(2,2,1,1,GridBagConstraints.HORIZONTAL);
c.setConstraints(jdbcdriverlist,e);
panel.add(jdbcdriverlist);
//for label
set_d(1,3);
c.setConstraints(jdbcurl,d);
panel.add(jdbcurl);
//for text
set_e(2,3,1,1,GridBagConstraints.HORIZONTAL);
text2.setFocusable(false);
c.setConstraints(text2,e);
panel.add(text2);
//for label
set_d(1,4);
c.setConstraints(serveradress,d);
panel.add(serveradress);
//for text
set_e(2,4,1,1,GridBagConstraints.HORIZONTAL);
c.setConstraints(text3,e);
panel.add(text3);
//for label
set_d(1,5);
c.setConstraints(database,d);
panel.add(database);
//for text
set_e(2,5,1,1,GridBagConstraints.HORIZONTAL);
c.setConstraints(text4,e);
panel.add(text4);
set_d(3,5);
c.setConstraints(b3,d);
panel.add(b3);
b3.addActionListener(this);
//for label
set_d(1,6);
c.setConstraints(uasername,d);
panel.add(uasername);
//for text
set_e(2,6,1,1,GridBagConstraints.HORIZONTAL);
c.setConstraints(text5,e);
panel.add(text5);
//for label
set_d(1,7);
c.setConstraints(password,d);
panel.add(password);
//for text
set_e(2,7,1,1,GridBagConstraints.HORIZONTAL);
text6.setEchoChar('*');
c.setConstraints(text6,e);
panel.add(text6);
//for button
set_d(1,8);
c.setConstraints(b,d);
panel.add(b);
b.addActionListener(this);
//for button
set_d(2,8);
c.setConstraints(b1,d);
panel.add(b1);
b1.addActionListener(this);
//for button
set_d(3,8);
c.setConstraints(b2,d);
panel.add(b2);
b2.addActionListener(this);
//for label
set_d(2,11);
display.setVisible(false);
c.setConstraints(display,d);
panel.add(display);
//panel.add(panel1);
setContentPane(panel);
///USING LAYERED PANE
panel.setBackground(Color.BLUE);
panel.setBounds(100,100,600,500);
panel.setOpaque(true);
JPanel panel1= new ImagePanel("Database.gif");
panel1.setLayout(c);
set_e(0,0,100,100,GridBagConstraints.HORIZONTAL);
 JEvent j = new JEvent();
 JLabel picture = new JLabel();
 picture.setIcon(j.eventlogo2);
 c.setConstraints(picture,a);
 panel1.add(picture);
panel1.setBackground(Color.RED);
panel1.setOpaque(true);
JLayeredPane lpane= new JLayeredPane();
//adding the two layers into layeredpane
lpane.setBounds(0,0,1000,1000);
lpane.add(panel,new Integer(0),0);
lpane.add(panel1,new Integer(1),0);
aFrame.setPreferredSize(new Dimension(1000, 1000));
aFrame.add(lpane, BorderLayout.CENTER); 
aFrame.pack();
aFrame.setSize(1000,1000);
aFrame.add(lpane);
aFrame.setVisible(true);
aFrame.addWindowListener(new WindowAdapter()
{  public void windowClosing(WindowEvent e)
         {
	      System.out.println("Exit via windowClosing."); 
	      System.exit(0);
         }
});
}
public String gString(DefaultListModel mv){
	 int i=0;
	 String str="";
	 for(;i<mv.getSize()-1;i++)
     {
     	str=str + mv.getElementAt(i)+", \n";
     	
     }
	 if(i<mv.getSize())
	 {str=str + mv.getElementAt(i);}
 	return str;}
public String gtString(DefaultListModel mv){
	 int i=0;	
	 String str="";
	 for(;i<mv.getSize()-1;i++)
     {
     	str=str +"AC."+ mv.getElementAt(i)+",";
     	
     }
	 if(i<mv.getSize())
	 {str=str+"AC."+mv.getElementAt(i);}
 	return str;}
public static void main(String[] args)
 {
 new JVariousExamples();
 }
public void actionPerformed(ActionEvent e)
{
	
	
	Object source = e.getSource();
	if(source==b3)
	{
		text2.setFocusable(true);
		text2.setText("jdbc:oracle:thin:@"+text3.getText()+":1521:"+text4.getText());
	}else if (source==b)
	{
		dbob.url=text2.getText();
		dbob.userid=text5.getText();
		dbob.password=text6.getText();
		DBConnectionclass.getOracleJDBCConnection(dbob.url, dbob.userid,dbob.password);
		boolean show=true;
		DBConnectionclass.getOracleJDBCConnection(dbob.url, dbob.userid,dbob.password).equals(show);
		if(show)
				{display.setVisible(true);};
	}else if(source==b1)
	{
		
		aFrame.setVisible(false);
		pane=new JPanel();
		DBConnectionclass.getOracleJDBCConnection(text2.getText(), text5.getText(),text6.getText());
	
		//Arrraylist for schemas
		listofusers = dbob.getArrayofUsers();
		String[] strarray = new String[109];
		strarray=listofusers.toArray(strarray);
		System.out.println(strarray.length);
		list= new JComboBox(strarray);
		list.addItemListener(new listItemListener());
		addComponent(p,list,1,0,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		addComponent(p,new JLabel("SchemaName"),0,0,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		setContentPane(p);
		newframe.setVisible(true);
		newframe.add(p);
		newframe.setSize(2000,2000);
		
		}
	else if(source==b2)
	{
		 System.exit(0);

	}
	
	}
private class listItemListener implements ItemListener{
	 public void itemStateChanged(ItemEvent e){
		    addComponent(p,tablelist,3,0,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		    addComponent(p,new JLabel("Tabel Name"),2,0,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		 if(e.getStateChange()== ItemEvent.SELECTED)
		  {
			JComboBox cb = (JComboBox)e.getSource();
			final String st = (String)cb.getSelectedItem();
			ArrayList<String> listoftables = dbob.getArrayofTables(st);
			String[] tablearray= new String[500];
			tablearray = listoftables.toArray(tablearray);
			for(int i=0;i<tablearray.length;i++)
			{
				tablelist.addItem(tablearray[i]);
			}
			tablelist.setVisible(true);
			tablelist.addItemListener(new ItemListener(){
		   	public void itemStateChanged(ItemEvent ie)
		   	{
		   		if(ie.getSource()==tablelist){
		   			
	   			if(ie.getStateChange()==ItemEvent.SELECTED)
		   		 {
	   				JComboBox cb = (JComboBox)ie.getSource();
					String st1 = (String)cb.getSelectedItem();
		   			details=dbob.getDetails(st, st1);
		   			somearray = details.toArray(somearray);
		   			
		   			((DefaultListModel) lst.getModel()).clear();
		   			for(int i=0;i<somearray.length;i++)
		   			{
		   				((DefaultListModel) lst.getModel()).addElement(somearray[i]);
		   			}
		   	
		   			lst.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
		   			lst.setLayoutOrientation(JList.VERTICAL);
		   			lst.setVisibleRowCount(-1);
		   			//listScroller.add(lst);
		   			listScroller = new JScrollPane(lst); 
		   			listScroller.setPreferredSize(new Dimension(250, 80));
		   			listScroller.setVisible(true);
		   			lst.setLayoutOrientation(JList.VERTICAL);
		   			lst.setVisibleRowCount(-1);
		   			listScroller1 = new JScrollPane(lst1);
		   			listScroller1.setVisible(true);
		   			listScroller1.setPreferredSize(new Dimension(250, 80));
		   			addComponent(p,new JLabel("Source"),0,1,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			addComponent(p,listScroller,0,2,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			addComponent(p,new JLabel("Destination"),2,1,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			addComponent(p,listScroller1,2,2,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			addComponent(p,Add,1,2,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1); 
		   			addComponent(p,Remove,1,3,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			addComponent(p,new JLabel("Inclde Graph"),0,4,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
					addComponent(p,Yes,1,4,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
	                addComponent(p,No,2,4,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
		   			Add.setVisible(true);
					Add.addActionListener(new ActionListener(){
						public void actionPerformed(ActionEvent e)
						{
							Object selected[] = lst.getSelectedValues();
							int size = selected.length;
						    for (int i = 0; i < size; i++) {
						      move.add(i, selected[i]);
						}
					}});
					Remove.setVisible(true);
					Remove.addActionListener(new ActionListener(){
						public void actionPerformed(ActionEvent e) {
						       Object selected[] = lst1.getSelectedValues();
						       for (int i = selected.length - 1; i >= 0; --i) {
								      move.removeElement(selected[i]);
								    }
								    lst1.getSelectionModel().clearSelection();
						     }
						}
					);
					Yes.setVisible(true);
                   Yes.addItemListener(new ItemListener()
                   {
                   	public void itemStateChanged(ItemEvent e)
                   	{                   		
       					addComponent(p,new JLabel("Graph Type"),0,5,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
       					addComponent(p,LineGraph,1,5,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                        addComponent(p,PieGraph,2,5,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                        String[] axis=new String[100];
                           for(int i=0;i<move.getSize();i++){
                           	axis[i]=(String) move.getElementAt(i);
                           }
                           XAxis= new JComboBox(axis);
                           addComponent(p,XAxis,1,6,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                           try{
                           	int x=0;
                           	Connection con= DBConnectionclass.getOracleJDBCConnection(text2.getText(), text5.getText(),text6.getText());
                           for(int i=0;i<axis.length;i++){
                           PreparedStatement ps=con.prepareStatement("SELECT ? FROM ALL_TAB_COLS AC, DATATYPE D  WHERE AC.OWNER = ? AND D.DATATYPENAME = AC.DATA_TYPE AND AC.TABLE_NAME = ? AND D.DATATYPENAME != 'XMLTYPE'");
                           ps.setString(1,axis[i]);
                           ps.setString(2, (String)list.getSelectedItem());
                           ps.setString(3, (String)tablelist.getSelectedItem());
                           ResultSet rs=ps.executeQuery();
                           ResultSetMetaData rsmd = rs.getMetaData();
                           for(int j=1;j<rsmd.getColumnCount();j++)
                              {
                           if(rsmd.getColumnTypeName(j).equalsIgnoreCase("int"))
                                  {
                           	       ifint[x]=rsmd.getColumnName(j); 
                                      x++;
                                      System.out.println(ifint[x]);
                                  }
                              }
                           }
                           YAxis = new JComboBox(ifint);
                           addComponent(p,YAxis,2,6,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                           }
                           catch(SQLException ex){System.err.println("SQLException: " + ex.getMessage());}
                           addComponent(p,checkbox,0,6,1,1,GridBagConstraints.FIRST_LINE_START,GridBagConstraints.HORIZONTAL,-1,-1);
                           checkbox.addActionListener(new ActionListener()
                           {
                               public void actionPerformed(ActionEvent e)
                               {
                               	String ps="SELECT "+gString(move)+
                               	          " \n FROM ALL_TAB_COLS AC, DATATYPE D " +
                               	          "\n WHERE AC.OWNER = "+(String)list.getSelectedItem()+ " AND D.DATATYPENAME = AC.DATA_TYPE AND AC.TABLE_NAME = "+(String)tablelist.getSelectedItem()+" AND D.DATATYPENAME != 'XMLTYPE'";                     
                               	System.out.println(ps);
                               	txt= new JTextArea(ps);
                       			JScrollPane scl = new JScrollPane(txt);
                       			scl.setPreferredSize(new Dimension(50,50));
                       			addComponent(p,scl,0,7,1,1,GridBagConstraints.FIRST_LINE_START,GridBagConstraints.HORIZONTAL,0,0);
                       			String[] axis1=new String[100];
                                   for(int i=0;i<move.getSize();i++){
                                   	axis1[i]=(String) move.getElementAt(i);
                                   }
                       			///to show the data in the form of grid
                       	    	try{
                       	    		Connection con1= DBConnectionclass.getOracleJDBCConnection(text2.getText(), text5.getText(),text6.getText());
                       			 	String querey="SELECT "+gString(move)+" FROM "+(String)tablelist.getSelectedItem()+" GROUP BY "+gString(move);                        	    
                       			    PreparedStatement ps1=con1.prepareStatement(querey);
                                    ResultSet rs=ps1.executeQuery();
                                   ResultSetMetaData rsmd = rs.getMetaData();
                                   DefaultTableModel model= new DefaultTableModel();  
                                   	String cols[]=new String[rsmd.getColumnCount()];   
                                   	for(int i=0;i< cols.length;++i)       
                                   	{         
                                   		cols[i]= rsmd.getColumnLabel(i+1);     
                                   		}         
                                   	model.setColumnIdentifiers(cols);
                                   	while(rs.next())   
                                   	{         
                                   		Object data[]= new Object[cols.length];
                                   		for(int i=0;i< data.length;++i)  
                                   		{              
                                   			data[i]=rs.getObject(i+1); 
                                   			}        
                                   		model.addRow(data); 
                                   		} 
                                   table = new JTable(model);
                                   addComponent(pn,new JScrollPane(table),1,1,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                                   addComponent(pn,print,1,2,1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,-1,-1);
                                    print.addActionListener(new ActionListener()
                                    {
                                    	public void actionPerformed(ActionEvent e) {
											// TODO Auto-generated method stub
											PrintableDocument.printComponent(pn);
										}
                                    }
                                   );
                                 setContentPane(pn);
                                  fr.add(pn);
                                  fr.setVisible(true);
                                  fr.setSize(1000,1000);
                               	   }      
                                 catch(SQLException ex){System.err.println("SQLException: " + ex.getMessage());}
                               }
                           });
                   }});
				     
				  }
		   	 }
		   	}
		    });
		}
	}
}
}

Do you have the DBConnectionclass and PrintableDocument class? Java cant find them. I want to run your program, so that I can test it. If there are any SQL passwords, just delete them, I'll use my own for testing.

This is the DBConnectionclass and itdoesnt have any userid and password given in it.

import java.sql.Array;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.swing.AbstractListModel;

import org.omg.CORBA.Request;


public class DBConnectionclass {
	String[] str= new String[100];
	static  String userid;
	static  String password;
	static String url ;
	static Connection con ;
	 //static DBConnectionclass db= new DBConnectionclass();
	public static void main(String[] args) 
	throws Exception {
		
	    Connection con = getOracleJDBCConnection(url,userid,password);
	    if(con!= null){
	       System.out.println("Got Connection.");
	       DatabaseMetaData meta = con.getMetaData();
	       System.out.println("Driver Name : "+meta.getDriverName());
	       System.out.println("Driver Version : "+meta.getDriverVersion());

	    }else{
		    System.out.println("Could not Get Connection");
	    }
	}

	public static Connection getOracleJDBCConnection(String url,String userid, String password)
	{

		try {
			Class.forName("oracle.jdbc.driver.OracleDriver");

			} catch(java.lang.ClassNotFoundException e) {
			System.err.print("ClassNotFoundException:");
			System.err.println(e.getMessage());
		}

		try {
		   con = DriverManager.getConnection(url, userid, password);
		   System.out.println("Got Connected");
		} catch(SQLException ex) {
			System.err.println("SQLException: " + ex.getMessage());
		}

		return con;
	}
	public ArrayList<String> getArrayofUsers() 
	{
		ArrayList<String> result = null;
		
		try{
			
			
		Statement stmt = null;
		ResultSet rs = null;
		
				
	   ArrayList<String> result1 = new ArrayList<String>();
		
	    stmt=con.createStatement();
		rs = stmt.executeQuery( "Select username from all_users" );
		int length = rs.getFetchSize();
		String row;
		
		while (rs.next())
		            {   
                              
                            	  row=rs.getString("username");
                            	  System.out.println(row);
					              result1.add(row);				              
		            }    
		result= result1;
		}
		catch(SQLException ex){
			System.err.println("SQLException: " + ex.getMessage());
		}
		
		return result;
	}
	public ArrayList<String> getArrayofTables(String str) 
	{
		ArrayList<String> result2 = null;
		
		try{
		
		Statement stmt = null;
		ResultSet rs = null;
						
	    ArrayList<String> result3 = new ArrayList<String>();
		stmt=con.createStatement();
		String x = str;
		System.out.println(x);
		/*String query;
		query="SELECT TABLE_NAME FROM ALL_ALL_TABLES minus SELECT TABLE_NAME FROM ALL_ALL_TABLES WHERE TABLE_NAME LIKE'%BIN$%' AND TABLE_NAME LIKE '%RUPD$%' and owner='x' ORDER BY TABLE_NAME "; 
		System.out.println(query);
		*/
		PreparedStatement ps = con.prepareStatement("SELECT OWNER,TABLE_NAME FROM ALL_ALL_TABLES WHERE OWNER=?  minus SELECT OWNER,TABLE_NAME FROM ALL_ALL_TABLES WHERE TABLE_NAME LIKE'%BIN$%' AND TABLE_NAME LIKE '%RUPD$%' AND OWNER =? ");
		ps.setString(1,x);
		ps.setString(2,x);
		//rs = stmt.executeQuery(query);
		System.out.println(ps);
		rs=ps.executeQuery();
		String row1;
		while (rs.next())
		            {   
                              
                            	  row1=rs.getString(2);
                            	  System.out.println(row1);
					              result3.add(row1);				              
		            }    
		result2= result3;
		System.out.println("hello");
		}
		catch(SQLException ex){
			System.err.println("SQLException: " + ex.getMessage());
		}
		
		return result2;
	}
	public ArrayList<String> getDetails(String str1,String str2){
		ArrayList<String> result5= null;
		try{
			Statement stmt = null;
			ResultSet rs = null;
			ArrayList<String> result4 = new ArrayList<String>();
			stmt=con.createStatement();
			String x1 = str1;
			String x2= str2;
			System.out.println(x1+","+x2);
			PreparedStatement ps = con.prepareStatement("SELECT AC.COLUMN_NAME FROM ALL_TAB_COLS AC, DATATYPE D WHERE AC.OWNER = ? AND D.DATATYPENAME = AC.DATA_TYPE AND AC.TABLE_NAME = ? AND D.DATATYPENAME != 'XMLTYPE'");
			ps.setString(1,x1);
			ps.setString(2,x2);
			rs=ps.executeQuery();
			String row1;
			while (rs.next())
			            {   
	                              
	                            	  row1=rs.getString(1);
	                            	  System.out.println(row1);
						              result4.add(row1);				              
			            }
		     result5=result4;
		
		}
		catch(SQLException ex){
			System.err.println("SQLException: " + ex.getMessage());
		}
		return result5;
	}
}

And this is the Printabledocument class.

import java.awt.*;
import javax.swing.*;
import java.awt.print.*;
public class PrintableDocument implements Printable 
{  
	private Component compent;  
	public static void printComponent(Component c) 
	{   
		new PrintableDocument(c).print(); 
		}    
	public PrintableDocument(Component compent) 
	{    
		this.compent = compent; 
		}   
	public void print()
	{    
		PrinterJob printJob = PrinterJob.getPrinterJob();
		printJob.setPrintable(this); 
		if(printJob.printDialog())  
			try 
		{     
				printJob.print(); 
				}    
		catch(PrinterException pe) 
		{    
			System.out.println("Error printing: " + pe);  
			} 
		}   
	public int print(Graphics g, PageFormat pageFormat, int pageIndex)
	{    
		if (pageIndex > 0) 
		{      
			return(NO_SUCH_PAGE);  
			}    
		else 
		{    
			Graphics2D graph = (Graphics2D)g;  
			graph.translate(pageFormat.getImageableX(), pageFormat.getImageableY());   
			disableBuffering(compent);   
			compent.paint(graph);     
			enableBuffering(compent);  
			return(PAGE_EXISTS);    
			}  
		}   
	public static void disableBuffering(Component c) 
	{    
		RepaintManager currentManager = RepaintManager.currentManager(c);   
		currentManager.setDoubleBufferingEnabled(false); 
		}    
	public static void enableBuffering(Component c) 
	{    
		RepaintManager currentManager = RepaintManager.currentManager(c);
		currentManager.setDoubleBufferingEnabled(true);
		}
	}
This article has been dead for over six months. Start a new discussion instead.