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?”
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.