ive been trying to get underway on this program for my java class but i cant even get the first two elements to appear. anyone know why my JFrame is blank? edit: it looks like in the copy and past from Jgrasp the code got a little funky looking so be gentle. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TenNumbers { public static void main(String [] args) { ManyNumbers mn = new ManyNumbers("To be Named Later - Program 6"); } } class ManyNumbers extends JFrame { public static final int MAX_NUM = 10; JTextField [] nums = new JTextField[MAX_NUM]; JButton newNums = new JButton("New Numbers"); JTextField text1 = new JTextField(); public ManyNumbers(String s) { super(s); setLayout(new FlowLayout()); pack(); setVisible(true); ; setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
I dont remember much from AWT / Swing coding, but it looks like you need to add the components to the frame using ManyNumbers.add(nums); and so on in the ManyNumbers method. I could be wrong, as I havent programmed AWT / Swing in years.