Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Inventory system layout issues  (Read 724 times)
0 Members and 2 Guests are viewing this topic.
Offline straydoginc

Jr. Member
**

Posts: 69



« on: 2006-01-19 10:07:21 »

Okay, below is the code for the Character information area of my Inventory system for my game.

The problems im having are the following:

1. How in the world do I paint or write my strings to my panel?
2. How do i do it so i get a nice titled border layout like the equipable area and the inventory list?

Code>>>
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
/*
 * 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)


thanx for any help given!
Offline g666

Sr. Member
**

Posts: 388



« Reply #1 on: 2006-01-19 16:12:31 »


1. How in the world do I paint or write my strings to my panel?


I wouldnt bother tryng to do this, just use JLabel (but if you want to draw on a compoentn i find its best to extend JComponent rether than jpanel)

2. How do i do it so i get a nice titled border layout like the equipable area and the inventory list?

jcomponent.setBorder(BorderFactory.createTitledBorder("Inventory"));

desperately seeking sanity
Offline straydoginc

Jr. Member
**

Posts: 69



« Reply #2 on: 2006-01-20 10:45:05 »

If i use JLabel is my paintComponent Method overiting my JLabel?
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.055 seconds with 19 queries.