import java.awt.*;
import javax.swing.*;
public class template2
{
//sets up a main panel that other components can be added to
public static void main(String[] args)
{
JFrame frame = new JFrame("Template");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// sets up main panel
JPanel mainPanel = new JPanel();
mainPanel.setBackground( new Color(220,250,0) );
mainPanel.setPreferredSize( new Dimension(100, 100) );
JLabel label1 = new JLabel ("one");
//sets up 2nd panel
JPanel subPanel2 = new JPanel();
subPanel2.setPreferredSize(new Dimension(400,100) );
mainPanel.add(subPanel2);
JLabel label2 = new JLabel ("two");
//add main panel to the content pane for this frame
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setVisible(true);
}
}
So far I have everything compiling but I am suppose to make two panels where the jframe is split in half. Beyond that I need one panel to say "one" and one to say "Two". If anyone could help me out I'd really appreciate it.

New Topic/Question
Reply
MultiQuote









|