I have a class that extends JFrame with ten radio buttons on it, and I've used a variety of JPanels and GridLayouts to help me place them correctly. I'm attempting to make it so that when you select a combination of radio buttons, the program will draw a line between each of the radio buttons in the order you've selected them. However, I can't get anything to appear. I'm not sure if I'm not overridding the right method, if I should be using Graphics2D, if the panels are hiding whatever I'm drawing...preferably, I'd like a solution that doesn't have me overriding a JPanel or something like that.
public void paintComponent(Graphics g)
{
super.update(g);
if(buttonsSelected>1)
{
g.setColor(new Color(0xE3, 0xC9, 0x39));
for(int k=0;k>4&&lastButton[k+1]!=-1;k++)
{
g.drawLine(buttonTest[lastButton[k]].getX(), buttonTest[lastButton[k]].getY(), buttonTest[lastButton[k+1]].getX(), buttonTest[lastButton[k]].getY());
System.out.println("Ole!");
}
}
}
Additionally, here is part of the code I'm using to draw the panes
int j=0;
for(int k=0;k<10;k++)
{
buttonTest[k]=new JRadioButton();
buttonTest[k].setActionCommand(Integer.toString(k));
buttonTest[k].setToolTipText(powersDin[k]);
buttonTest[k].addActionListener(new GoddessListener());
buttonTest[k].setEnabled(false);
}
buttonTest[0].setEnabled(true);
buttonTest[6].setEnabled(true);
buttonTest[9].setEnabled(true);
paneGrids[0]=new JPanel();
paneGrids[0].setLayout(new GridLayout(1,7));
paneGrids[0].add(new JLabel()); //adding a blank JLabel lets me pad out the empty cells I don't want to fill
paneGrids[0].add(new JLabel());
paneGrids[0].add(new JLabel());
paneGrids[0].add(buttonTest[j++]);
paneGrids[0].add(new JLabel());
paneGrids[0].add(new JLabel());
paneGrids[0].add(new JLabel());