
-----------------------------------
Tallguy
Thu Oct 04, 2012 5:02 pm

JPanel hurts my brain
-----------------------------------
Greetings All!!!

I am once again back into java  :?  Here is my dilemma i am using the GUI's in JPanel (ONLY) to create a GUI for a calculator. I just can not for the life of me get it to appear on my screen, the array holds the String values to be used in GridLayout. i am only able to BorderLayout || FlowLayout || GridLayout. I can do this in about 10 min using JFrame, but we are not allowed to touch it.

Here is the code that matters

Any help would be awesome

   [code]

import java.awt.*;
import javax.swing.*;

public class CalculatorView extends JPanel {
	private static final long serialVersionUID = 1L;

	public CalculatorView() {

	}
	
	public  void addButton() {
		
		JPanel content = new JPanel(new BorderLayout());
		 
		int width =  256;
		    int height = 256;
		    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
		    int x = (screen.width-width)/2;
		    int y = (screen.height-height)/2;
		    setBounds(x,y,width,height);

		JPanel buttons = new JPanel();
		buttons.setLayout(new GridLayout(4,5,5,10));
		
	    content.setBorder(BorderFactory.createEmptyBorder (0,2,5,2));

		String [] values = { "7", "8", "9","/", "P","4","5","6","*","\u221A","1","2","3","-","C","0",".","+/-","+","="};

        for (int i=0; i