Problem: I am not sure how use the array when to build JButtons.
Goal: An example of what I want to do would be to use the first array to input the name of the JButtons and the second array to input the text onto the button.
This is what I have so far
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.*;
class array extends JFrame
{
String [][] foodButton = {{"tofuBurgerButton", "Tofu Burger"},
{"cajunChickenButton", "Cajun Chicken"},
{"buffaloWingsButton", "Buffalo Wings"},
{"rainbowFilletButton", "Rainbow Fillet"},
{"riceCrackerButton", "Rice Cracker"},
{"noSaltFriesButton", "No Salt Fries"},
{"zucchiniButton", "Zucchini"},
{"brownRiceButton", "Brown Rice"},
{"cafeMochaButton", "Cafe Mocha"},
{"cafeLatteButton", "Cafe Latte"},
{"espressoButton", "Espresso"},
{"oolongTeaButton", "Oolong Tea"}};
JFrame arrayTestFrame;
public static void main(String [] args)
{
new array();
}
public void array()
{
arrayTestMain();
setVisible(true);
}
public void arrayTestMain()
{
arrayTestFrame();
arrayTestButton();
arrayTestPanel();
}
public void arrayTestFrame()
{
setSize(500, 500);
setTitle("Welcome to array test");
setLocation(150, 250);
}
//Help
public void arrayTestButton()
{
for (int i = 0; i < foodButton.length; i++)
for (int j = 0; j < foodButton.length; j++)
{
foodButton[i][j] = new JButton (foodButton[i][j]);
}
}
//Help
public void arrayTestPanel()
{
JPanel arrayPanel;
arrayPanel = new JPanel();
arrayPanel.add(foodButton[i][j]);
}
}