Here is the main window code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FlashCardsMain extends JFrame{
JPanel everything;
SouthButtons southButtons;
public FlashCardsMain(){
super("Flash Cards");
southButtons = new SouthButtons();
everything = new JPanel();
everything.setLayout(new BorderLayout());
everything.add( southButtons, BorderLayout.SOUTH);
setContentPane(everything);
setSize(300,200);
setLocation(50,50);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args){
FlashCardsMain main = new FlashCardsMain();
}
}
Here is the code that contains the info about the buttons I tried to display:
public class SouthButtons extends JPanel{
FlashCardDeck cardDeck;
JToolBar toolbox; // the toolbox that will hold the buttons
JButton backButton; // the button that will go to the previous school
JButton flipButton; // the button that will show the reverse side of the card
JButton nextButton; // the button that will go to the next card
public SouthButtons(){
backButton = new JButton();
backButton.addActionListener(new BackButton()); // add actionlistener to backButton
backButton.setVisible(true);
flipButton = new JButton();
flipButton.addActionListener(new FlipButton()); // add actionlistener to flipButton
flipButton.setVisible(true);
nextButton = new JButton();
nextButton.addActionListener(new NextButton()); // add actionlistener to nextButton
nextButton.setVisible(true);
toolbox = new JToolBar("Flashcard control"); // add the buttons to the toolbox
toolbox.add(backButton);
toolbox.add(flipButton);
toolbox.add(nextButton);
toolbox.setVisible(true);
}
private class BackButton implements ActionListener{
public void actionPerformed(ActionEvent evt){
cardDeck.currentCard--; // go to the previous card
}
}
private class FlipButton implements ActionListener{
public void actionPerformed(ActionEvent evt){
if(cardDeck.viewingSide1) cardDeck.viewingSide1 = false; // flip the card
else cardDeck.viewingSide1 = true;
}
}
private class NextButton implements ActionListener{
public void actionPerformed(ActionEvent evt){
cardDeck.currentCard++; // go to the next card
}
}
}











