Hello all,
I've got an assignment due on thursday that is very easy, but I have one bug that is driving me nuts.
The assigment is to just create a basic GUI with 1 label, a text box, and a few check boxes, so it's not that hard. The problem is that it compiles fine with no errors or anything, but when I run it, nothing is showing up in the window unless I use the mouse to click the lower right corner of the window and resize it. Then the items show up.
It has been about 2 years since I've taken CS I (Got all the other stuff out of the way :mrgreen: ) but now, I'm a little rusty...
Here is my code:
/*
* Tiny App
*
*/
import javax.swing.*;
import java.awt.*;
public class TinyApp
{
public static void main(String[] args)
{
// Set-up JFrame
JFrame jfWindows = new JFrame("Search Box");
jfWindows.setSize(400, 150);
jfWindows.setVisible(true);
// Set up Container for controls
Container cp = jfWindows.getContentPane();
cp.setLayout(new BorderLayout());
// Pane to hold the search box and label
JPanel jpSearch = new JPanel();
jpSearch.setLayout(new FlowLayout(FlowLayout.CENTER));
cp.add(jpSearch, BorderLayout.NORTH);
// Search label
JLabel lblSearch = new JLabel("Enter key phrase: ");
jpSearch.add(lblSearch);
// Search text box
JTextField jtfSearch = new JTextField(20);
jpSearch.add(jtfSearch);
// Bottom Panel
JPanel jpYear = new JPanel();
jpYear.setLayout(new FlowLayout(FlowLayout.CENTER));
cp.add(jpYear, BorderLayout.SOUTH);
// Create Year Checkboxes
JCheckBox jcb1998 = new JCheckBox("1998");
jpYear.add(jcb1998);
JCheckBox jcb1999 = new JCheckBox("1999");
jpYear.add(jcb1999);
JCheckBox jcb2000 = new JCheckBox("2000");
jpYear.add(jcb2000);
JCheckBox jcb2001 = new JCheckBox("2001");
jpYear.add(jcb2001);
}
}
Thank you in advance for any help. This but is driving me nuts. I have even shown it to a couple of the TA's in the CS lab and they are a bit baffled by it.
Thank you,
Paul Allen (Antiparadigm)