作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
......
public void launchFrame(){
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(500,500);
f.setVisible(true);
f.setLocationRelativeTo(null);
JLabel nameL=new JLabel("Title", SwingConstants.LEFT);
String[] FormOptions = {"Choose","Text Field","Password Field","Button","Radio Button","Check Box","Drop Down Menu"};
String[] NormalOptions = {"Choose","Write Text", "Upload Picture", "Frame", "I-Frame"};
JTextField nameTF=new JTextField(10);
final JPanel comboPanel = new JPanel();
JLabel comboLbl = new JLabel("Form:");
JComboBox forms=new JComboBox(FormOptions);
comboPanel.add(comboLbl);
comboPanel.add(forms);
comboPanel.add(nameL);
comboPanel.add(nameTF);
final JPanel comboPanel1 = new JPanel();
comboPanel1.setVisible(false);
JLabel comboLbl1 = new JLabel("Normal HTML:");
JComboBox Normals = new JComboBox(NormalOptions);
comboPanel1.add(comboLbl1);
comboPanel1.add(Normals);
JButton HTML = new JButton( "Form or Normal");
HTML.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent event)
{
comboPanel1.setVisible(!comboPanel1.isVisible());
comboPanel.setVisible(!comboPanel.isVisible());
}
});
f.add(comboPanel, BorderLayout.NORTH);
f.add(comboPanel1, BorderLayout.CENTER);
f.add(HTML,BorderLayout.SOUTH);
f.setVisible(true);
static String[] info = new String[500];//Here i need help
}
public static void main(String args[]){
BasicGuiTest gui = new BasicGuiTest();
gui.launchFrame();
}
//What Should i do here? I want to get whether the user is choosing form or Normal as
//well as its options..
private class GetInfo implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
info[i]=comboPanel.getSelectedItem
}
//Then i will output the string array to a text file..
最佳答案
或者,您可以避免重新发明轮子并使用内置的 java Preferences API?
http://docs.oracle.com/javase/1.4.2/docs/guide/lang/preferences.html
关于java - 我如何将用户从 GUI 给出的输入存储到字符串数组以供将来在 java 中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11428491/
我是一名优秀的程序员,十分优秀!