我是 JAVA 编程的新手,我正在尝试制作一个内存修改 GUI 程序,下面是代码。我的 JTextField 太大了有关如何解决此问题的任何建议?如果找到另一种方法来完成上述任务,我将不胜感激。感谢您的时间
JMenuBar menubar;
JMenu data,array,linkedlist,strings,stacks,tree,graphs,queues;
JMenuItem dtypeint,dtypefloat,dtypechar;
public GUI(){
super("Data Structures Assignment");
System.out.println("Select the Above mentioned Options for Memory Modification");
setLayout(new FlowLayout());
menubar = new JMenuBar();
add(menubar);
data = new JMenu("Basic Data Types");
menubar.add(data);
array = new JMenu("Arrays");
menubar.add(array);
linkedlist = new JMenu("Linked List");
menubar.add(linkedlist);
strings = new JMenu("Strings");
menubar.add(strings);
stacks = new JMenu("Stacks");
menubar.add(stacks);
tree = new JMenu("Tree");
menubar.add(tree);
graphs = new JMenu("Graphs");
menubar.add(graphs);
queues = new JMenu("Queues");
menubar.add(queues);
dtypeint = new JMenuItem("Integer");
data.add(dtypeint);
dtypefloat = new JMenuItem("Float");
data.add(dtypefloat);
dtypechar = new JMenuItem("Character");
data.add(dtypechar);
setJMenuBar(menubar);
thehandler handler = new thehandler();
dtypeint.addActionListener(handler);
dtypefloat.addActionListener(handler);
dtypechar.addActionListener(handler);
}
private class thehandler implements ActionListener{
public void actionPerformed(ActionEvent event){
if(event.getSource()==dtypeint){
setLayout(new GridLayout());
Frame F = new JFrame();
F.setVisible(true);
F.setSize(200,200);
final JTextField item1;
item1 = new JTextField("Word Size");
item1.setColumns(15);
F.add(item1);
}
}
}
}