wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JApplet shows nothing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JApplet shows nothing" Watch "JApplet shows nothing" New topic
Author

JApplet shows nothing

Payam Mamaani
Greenhorn

Joined: Jul 04, 2001
Posts: 7
I'm running an applet it initializes and starts but unfortunately it dosn't show anything.
Here is the code:
import java.awt.event.*;
import java.sql.*;
import javax.swing.*;
import java.util.Vector;
import java.awt.*;
import java.applet.Applet;
public class Project1 extends javax.swing.JApplet implements ActionListener
{
public void actionPerformed(ActionEvent e) {}
Container c;
myCombo mycom;
reportList rprt;
dbTools db;
private int wailTag;
private int reservoirTag;
private int fieldTag;

private String fstr = "";
private String rstr = "";
public void initialVariables()
{
c.removeAll();
setSize (600,451);
setSize (600,450);
//show();
validate();
db.rows.removeAllElements();
db.columnHeads.removeAllElements();
fstr = "";
rstr = "";
wailTag = 0;
reservoirTag = 0;
fieldTag = 0;
}

public void Report(String query)
{
final resReport2 resReport = new resReport2(c);
db.getTable(query);
c.removeAll();
setSize(600,451);
final String tempArray[] = new String [120];
if (db.rows.size() >= 1 )
{
db.readFirstItem(tempArray); //* reurns head of vector
//* in an Array
db.rows.remove(1); //* Removes first item

resReport.showComponents(c);
resReport.addValues(tempArray);
resReport.addButtons(c);
}
else
{
resReport.showNoRecord(c);
resReport.addButtons(c);
}
resReport.refreshButton.addActionListener (new ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
initialVariables();
showFieldCombo();
}
}
);
resReport.nextButton.addActionListener (new ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
if (db.rows.size() > 1 )
{
db.readFirstItem(tempArray); //* reurns head of vector
//* in an Array
if (db.rows.size() > 1 )
db.rows.remove(1); //* Removes first item
c.removeAll();
resReport.showComponents(c);
resReport.addValues(tempArray);
resReport.addButtons(c);
//show();
validate();
}
else
{
c.removeAll();
resReport.showNoRecord(c);
resReport.addButtons(c);
setSize (600,451);
setSize (600,450);
//show();
validate();
}
}
}
);
resReport.moreInfoButtons();
//show();
validate();

}
public void showWailCombo()
{
//------- Wail Combo Box
int index = mycom.reservoirCombo.getSelectedIndex(); //get selected nuber
Object fldname = mycom.reservoirCombo.getItemAt(index); //get selected item
String fldnameStr = fldname.toString(); //covert item to string
//String rstr ="";
int l1 = fldnameStr.length();
for (int i=1; i<= (l1-2); i++ )
rstr += fldnameStr.charAt(i);

//preparing Query
String q2 = "SELECT Wails FROM Wails WHERE";
q2 += " Reservoir Like '";
q2 += rstr;
q2 += "'";
if (fstr.equalsIgnoreCase("ALL"))
q2 = "SELECT Wails FROM Wails";

db.rows.removeAllElements();
db.columnHeads.removeAllElements();

db.getTable(q2);
Vector items2 = new Vector();
for (int i=0; i<db.rows.size(); i++)>
items2.addElement( db.rows.elementAt( (i)));
mycom.initWailCombo(items2);

mycom.wailCombo.addItemListener ( new ItemListener ()
{
public void itemStateChanged ( ItemEvent e)
{
;
}
}
);

if ( db.rows.isEmpty())
{
JTextField noRec = new JTextField ("No match found");
noRec.setEditable(false);
noRec.setBounds(160, 160, 160, 30);
wailTag = 1;
c.removeAll();
c.add(noRec);
mycom.addFieldCombo(c);
mycom.addReservoirCombo(c);
//mycom.addWailCombo(c);
mycom.addformButtons(c);
//show();
validate();
}
else
{
wailTag = 1;
c.removeAll();
mycom.addFieldCombo(c);
mycom.addReservoirCombo(c);
mycom.addWailCombo(c);
mycom.addformButtons(c);
//show();
validate();
}
}

public void showReservoirCombo()
{
//--- Reservoir Combo Box

int index = mycom.fieldCombo.getSelectedIndex(); //get selected nuber
Object fldname = mycom.fieldCombo.getItemAt(index); //get selected item
String fldnameStr = fldname.toString(); //covert item to string

//String fstr ="";
int l1 = fldnameStr.length();
for (int i=1; i<= (l1-2); i++ )
fstr += fldnameStr.charAt(i);

//preparing Query
String q1 = "SELECT Reservoirs FROM Reservoirs WHERE";
q1 += " Field Like '";
q1 += fstr;
q1 += "'";
if ( fstr.equalsIgnoreCase("ALL") )
q1 = "SELECT Reservoirs FROM Reservoirs";

db.rows.removeAllElements();
db.columnHeads.removeAllElements();

db.getTable(q1);
Vector items1 = new Vector();
if ( db.rows.isEmpty())
{
JTextField noRec = new JTextField ("No match found");
noRec.setEditable(false);
noRec.setBounds(160, 100, 160, 30);
c.removeAll();

c.add(noRec);
mycom.addFieldCombo(c);
mycom.addformButtons(c);
reservoirTag= 1;
//show();
validate();
}
else
{
for (int i=0; i<db.rows.size(); i++)>
items1.addElement( db.rows.elementAt( (i)));
mycom.initReservoirCombo(items1);
mycom.reservoirCombo.addActionListener ( new ActionListener ()
{
public void actionPerformed ( ActionEvent e1)
{
if (wailTag == 1)
{
c.remove(mycom.wailCombo);
wailTag = 0;
}
showWailCombo();
}
}
);

c.removeAll();
mycom.addFieldCombo(c);
mycom.addReservoirCombo(c);
mycom.addformButtons(c);
reservoirTag = 1;
//show();
validate();
}
}
public void showFieldCombo ()
{
db.getTable("SELECT Fields FROM Fields ");
Vector items = new Vector();
for (int i=0; i<db.rows.size(); i++)>
items.addElement( db.rows.elementAt( (i)));
//--- Field Combo Box
mycom.initFieldCombo(items);

mycom.fieldCombo.addActionListener(new ActionListener()
{
public void actionPerformed ( ActionEvent e2)
{
if (reservoirTag == 1)
{
c.remove(mycom.reservoirCombo);
reservoirTag = 0;
}
if (wailTag == 1)
{
c.remove(mycom.wailCombo);
wailTag = 0;
}
showReservoirCombo();
}
}
);

mycom.addFieldCombo(c);
//show();
validate();
goToReport();
}

public void showReportsForm()
{
rprt = new reportList(c);
rprt.addformButtons(c);
rprt.prevButton.addActionListener (new ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
initialVariables();
showFieldCombo();
}
}
);

rprt.reportButton2.addActionListener ( new ActionListener ()
{
public void actionPerformed ( ActionEvent e)
{
int index = mycom.reservoirCombo.getSelectedIndex(); //get selected nuber
Object fldname = mycom.reservoirCombo.getItemAt(index); //get selected item
String fldnameStr = fldname.toString(); //covert item to string
rstr ="";
int l1 = fldnameStr.length();
for (int i=1; i<= (l1-2); i++ )
rstr += fldnameStr.charAt(i);

//preparing Query
String q1 = "SELECT * FROM Report2 WHERE";
q1 += " Reservoir_Name LIKE '";
q1 += rstr;
q1 += "'";
if (fstr.equalsIgnoreCase("ALL"))
q1 = "SELECT * FROM Report2";
if ( rstr.equalsIgnoreCase("null") )
q1 = "";
db.rows.removeAllElements();
db.columnHeads.removeAllElements();
Report (q1);
}
}
);

//show();
validate();
}

public void goToReport()
{
mycom.addformButtons(c);
mycom.reportButton.addActionListener (new ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
c.removeAll();
showReportsForm();
setSize (600,451);
setSize (600,450);
//show();
validate();
}
}
);
mycom.refreshButton.addActionListener (new ActionListener ()
{
public void actionPerformed (ActionEvent e)
{
initialVariables();
showFieldCombo();
}
}
);
}

public void ComboBoxShow()
{
db = new dbTools();
db.Connectdb();
c = getContentPane();
mycom = new myCombo(c);
//--- Initialize boolean variables
wailTag = 0;
reservoirTag = 0;
fieldTag = 0;

showFieldCombo();

//----------- show GUI
setSize (600,450);
//show();
validate();

}
public void init()
{
Project1 myProject = new Project1();
myProject.ComboBoxShow();
}

}

Thanks in advance,
Payam
Payam Mamaani
Greenhorn

Joined: Jul 04, 2001
Posts: 7
I changed the code and now it works.
here is the changed part:
public void init()
{
Project1 myProject = new Project1();

myProject.c = getContentPane();
myProject.ComboBoxShow(myProject.c);
}
Payam Mamaani
Greenhorn

Joined: Jul 04, 2001
Posts: 7
I changed the code and now it works.
here is the changed part:
public void init()
{
Project1 myProject = new Project1();

myProject.c = getContentPane();
myProject.ComboBoxShow(myProject.c);
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JApplet shows nothing