i finally came up with a small project to keep me busy for a while. i am writing a "copy" of windows Calculator program(in the standard view). if you have windows and could give your ideas on how to lay it out so it looks the same it would help some. so far, ignoring the menubar, i have a border layout with the TextField taking up north, and a panel with a grid layout taking center. however, this wont work because the top row has less components than the rest of the rows.
maybe if i give the panel a border layout, add a panel to it in north with a flow layout, and a panel to it in center with a grid layout?
panel1 - GridLayout(1,3,5,5) for the Backspace/CE/C buttons
panel2 - GridLayout(4,5,5,5) for the numeric/operater buttons
panel3 - BorderLayout - panel1 in NORTH, panel2 in CENTER
panel4 - GridLayout(5,1,5,5) for the Memory buttons and the blank button(?)
panel5 - BorderLayout - panel4 in WEST, panel3 in CENTER
panel6 - BorderLayout - JTextfield in NORTH, panel5 in CENTER
i post my code so far here if anyone is interested:
Joined: Jun 09, 2003
here's your same code a bit shorter, with a JLabel/loweredBevelBorder instead of uneditable JTextField
I had one too many panels in my first post - the one adding the textfield, which can be added directly to the frame
(will need size tweaking when menuBar added)
thanks Michael, i figured out the extra panel was just the contentPane. your code is much shorter. i knew there had to be a way to loop through some of that stuff. i will look it over more closely later. i am bound to learn from it. now that i have it looking like a calculator i am finding that making it act like one is much harder. even if i dont finish it i will learn from it though. besides it is the first project idea i have had in a while. thanks again for helping me get started on it.
just compiled and ran your code. i see you managed to make it the same size as the microsoft version. now i for sure will have to read it to find out how.