Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (529)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  A Random-ish Question  (Read 458 times)
0 Members and 1 Guest are viewing this topic.
Offline tyeeeee1
« Posted 2013-01-25 00:10:28 »

I took a little two-week break from Java because I was spending a bunch of my free time on it and figured I'd be thinking differently when I got back... anyways the first thing that I started writing was a class to construct JPanels but while writing it it sort of turned into a JButton creation class. Anyways, my question is: "Is there any reason for me to finish this class and get it working?"

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  
62  
63  
64  
65  
66  
class MenuPanels
{
   private boolean isVisible = false;
   private int insets = 0;
   private JButton[] buttonArray;
   private int[] buttonXArray, buttonYArray;
   
   public MenuPanels(int amountOfButtons)
   {
      buttonArray = new JButton[amountOfButtons];
      buttonXArray = new Int[amountOfbuttons];
      buttonYArray = new Int[amountOfbuttons];
   }
   
   public void insetsSetter(int insets)
   {
      this.insets = insets;
   }
   
   public void buttonXSetter(int buttonIndex, int xValue)
   {
      buttonXArray[buttonIndex] = xValue;
   }
   
   public void buttonYSetter(int buttonIndex, int xValue)
   {
      buttonYArray[buttonIndex] = yValue;
   }
   
   public void buttonSetter(int buttonIndex, String buttonName, String buttonText, int boundsX, int boundsY, int width, int height, boolean hasBorder, boolean hasFocusPainted, boolean hasContentAreaFilled, boolean hasIcon, String normalIconPath, String rolloverIconPath, String pressedIconPath, boolean hasTooltip, String tooltipText)
   {
      JButton buttonName = new JButton(""+buttonText+"");
      buttonName.setBounds(boundsX + insets.left, boundsY + insets.top, width, height);
     
      if (hasBorder == false)
         buttonName.setBorder(null);
     
      if (hasFocusPainted == false)
         buttonName.setFocusPainted(false);
     
      if (hasContentAreaFilled == false)
         buttonName.setContentAreaFilled(false);
         
      if (hasIcon == true)
      {
         Icon buttonName+Icon = new ImageIcon(""+normalIconPath+"");
         Icon buttonName+Rollover = new ImageIcon(""+rolloverIconPath+"");
         Icon buttonName+Pressed = new ImageIcon(""+pressedIconPath+"");
         buttonName.setIcon(buttonName+Icon);
         buttonName.setRolloverIcon(buttonName+Rollover);
         buttonName.setPressedIcon(buttonName+Pressed);
      }
     
      if (hasTooltip == true)
         buttonName.setToolTiptext(""+tooltipText+"");
     
         buttonArray[buttonIndex] = buttonName;
      }
     
      // End of setters, beginning of getters.
     
      public JButton buttonGetter(int buttonIndex)
      {
         return buttonArray[buttonIndex]; //This would feed into the Panel creation stuff if you finish writing the class.
     }
}


The class is probably riddled with bugs and most likely wont work at the moment, it's more of a rough outline of the class I guess.
Offline sproingie

JGO Kernel


Medals: 201



« Reply #1 - Posted 2013-01-25 01:16:18 »

What is with this bizarre
""+someString+""
thing you have going on?  Stop doing that.

Also, you don't need to do
if (something == true)
.  Just use
if (something)
or
if (!something)
to compare it against false.

Your setter methods have bizarre names, and stuffing everything into arrays is probably not wise either.

My advice for finishing that class is to rewrite it entirely.
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 128
Projects: 4
Exp: 3 years



« Reply #2 - Posted 2013-01-25 01:26:07 »

What is with this bizarre
""+someString+""
thing you have going on?  Stop doing that.

Agreed, "" is an empty string literal (contains nothing). And I agree with the rest of what he said too, setters and getters should be named  set...() and get...() not setter() and getter() -___-

Having an array of x and ys for buttons makes no sense, the x and y should be fields of the button class, if not, then just make your ownl class extend JButton.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline tyeeeee1
« Reply #3 - Posted 2013-01-25 01:49:35 »

I've edited the class a bit; My question was more-so to ask what a class like this would be used for, I know it's horribly written and that's because it's not supposed to be a working class, it's an outline of a class.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 741
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2013-01-25 08:39:10 »

My question was more-so to ask what a class like this would be used for
This is somewhat of an odd question, especially as you said you realized the class was terrible. I'm sorry, but it simply has no use.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (31 views)
2014-07-18 06:55:21

Zero Volt (27 views)
2014-07-17 23:47:54

danieldean (23 views)
2014-07-17 23:41:23

MustardPeter (24 views)
2014-07-16 23:30:00

Cero (39 views)
2014-07-16 00:42:17

Riven (41 views)
2014-07-14 18:02:53

OpenGLShaders (28 views)
2014-07-14 16:23:47

Riven (28 views)
2014-07-14 11:51:35

quew8 (25 views)
2014-07-13 13:57:52

SHC (61 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!