您好,我一直无法让我的组合框列出文本文件中的项目。当我这样做时,我想问一下当我改变我的组合框时我的 radioButton 是否会动态改变,或者这会不会太麻烦?
import java.awt.GridLayout;
import java.util.Arrays;
import java.util.Scanner;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import java.io.*;
public class MovieSelection extends JFrame {
private JRadioButton selection1;
private JRadioButton selection2;
private JRadioButton selection3;
private JPanel moviePanel;
private JLabel priceLabel;
private JComboBox movieBox;
private ButtonGroup bg;
private String[] movieName = { "RED", "Taken", "Star Trek", "Star Wars",
"Avatar" };
public MovieSelection() {
super("Please select your movie");
setSize(800, 400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new GridLayout(15, 4));
setLocationRelativeTo(null);
// PrintWriter outputFile = new PrintWriter(TheMovies.txt);
buildMoviePanel();
add(moviePanel);
setVisible(true);
}
private class MovieLists implements ActionListener {
public void actionPerformed(ActionEvent e) {
Scanner inputFile = new Scanner(TheMovies.txt);
while (inputFile.hasNext()) {
String nextMovieName = inputFile.nextLine();
}
JComboBox cb = (JComboBox) e.getSource();
String Themovie = (String) cb.getSelectedItem();
}
}
}