So I just found the Netbeans JFrame Form referenced in an online tutorial to help with layout (my textbook hadn't made mention of it in the GUI section, at least that I've seen!) Since I'm having a difficult time with the layout of the program I'm working on (I can't get the text area to behave itself and stay in the center of the window instead of taking up the entire window!) I thought a visual aid might be helpful, however, as you might have guessed I already have a large amount of code sunk into this program. Is it possible to link a new JFrame Form with an existing class? If so, how would I go about doing it? I can provide my code if you need it, but we're talking 500 lines of code in just one of the main three classes.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package theproblem;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.TextArea;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
/**
*
* @author Heather
*/
public class TheProblem {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
JFrame window2 = new JFrame();
TextArea battleLogging = new TextArea(3,10);
JScrollPane logScrollPane = new JScrollPane(battleLogging);
JLabel BattleLog = new JLabel();
JLabel p1HPLabel= new JLabel();
JLabel p2HPLabel= new JLabel();
String attack1ButtonContents = "Just an attack";
String attack2ButtonContents = "Just another attack";
JButton attack1=new JButton(attack1ButtonContents);
JButton attack2=new JButton(attack2ButtonContents);
window2.setLayout(new BorderLayout());
window2.setSize(400,400);
JPanel attackPanel = new JPanel();
attackPanel.add(attack1);
attackPanel.add(attack2);
// attack1 = new JButton(p1A1);
// attack2 = new JButton(p1A2);
// attack1.addActionListener(new Attack1());
// attack2.addActionListener(new Attack2());
//window2.add(attackPanel, BorderLayout.CENTER);
window2.add(battleLogging, BorderLayout.CENTER);
battleLogging.setEditable(false);
logScrollPane.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
logScrollPane.setPreferredSize(new Dimension(50, 50));
//battleLogging.setLineWrap(true);
//battleLogging.setWrapStyleWord(true);
window2.add(BattleLog, BorderLayout.NORTH);
window2.add(p1HPLabel, BorderLayout.WEST);
window2.add(p2HPLabel, BorderLayout.EAST);
window2.setVisible(true);
window2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}