Okay, below is the code for the Character information area of my Inventory system for my game.
The problems im having are the following:
- How in the world do I paint or write my strings to my panel?
- How do i do it so i get a nice titled border layout like the equipable area and the inventory list?
Code>>>
/*
* Created on Dec 14, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.inventory;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
/**
* @author zalexander
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class InvCharPane extends JPanel{
private String textString1 = new String();
public InvCharPane() {
JLabel invCharText = new JLabel();
invCharText.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
invCharText.setText(textString1);
JPanel charPanel = new JPanel();
TitledBorder charPanelTitle = BorderFactory.createTitledBorder("Character Information");
charPanel.setLayout(new BorderLayout());
charPanel.setPreferredSize(new Dimension(100, 480));
charPanel.add(invCharText);
//charPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
charPanel.setBorder(charPanelTitle);
/**
JFrame invCharFrame = new JFrame("Character Information");
invCharFrame.setSize(100,480);
Container invCharContent = invCharFrame.getContentPane();
invCharContent.setBackground(Color.white);
invCharContent.setLayout(null);
invCharContent.add(charPanel);
invCharFrame.setVisible(true);
*/
}
public void paintComponent(Graphics charPane) {
super.paintComponent(charPane);
textString1 = "Character Pane Text";
charPane.drawString(textString1,10,10);
}
}
here is a screen shot of the first rendered version of the inventory system in full. (minus of course the few bugs im working on above)
http://data.memberclicks.com/site/si/invScreenPreview.gif
thanx for any help given!