Y
Yumex85
Hello,
Here it is a simple frame i made, with a menubar and several menus I
added to menubar. Now I wanna add sub items to each menu. As you can
see below, to add to menus, i made a loop, but now i dont know how i
could add the sub items in each menu, coz i dont know the name of each
object i created . do They all have "menu" name? Are they
automatically kept in an array?
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
public class ABNAplic {
JFrame mainFrame;
JPanel mainPanel;
String[] menuLista =
{"Cadastros","Consultas","Relatórios","Processamentos","Reconciliações","Logs
e Consistências","Sobre","Sair"};
public static void main(String[] args) {
ABNAplic mainGui = new ABNAplic();
mainGui.go();
}
public void go() {
mainFrame = new JFrame("Gestão de Operações Financeiras Banco Real
ABN Amro");
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
for(String menus:menuLista) {
JMenu menu = new JMenu(menus);
menuBar.add(menu);
}
mainFrame.setJMenuBar(menuBar);
mainFrame.setSize(700,700);
mainFrame.setVisible(true);
}
}
Here it is a simple frame i made, with a menubar and several menus I
added to menubar. Now I wanna add sub items to each menu. As you can
see below, to add to menus, i made a loop, but now i dont know how i
could add the sub items in each menu, coz i dont know the name of each
object i created . do They all have "menu" name? Are they
automatically kept in an array?
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;
public class ABNAplic {
JFrame mainFrame;
JPanel mainPanel;
String[] menuLista =
{"Cadastros","Consultas","Relatórios","Processamentos","Reconciliações","Logs
e Consistências","Sobre","Sair"};
public static void main(String[] args) {
ABNAplic mainGui = new ABNAplic();
mainGui.go();
}
public void go() {
mainFrame = new JFrame("Gestão de Operações Financeiras Banco Real
ABN Amro");
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menuBar = new JMenuBar();
for(String menus:menuLista) {
JMenu menu = new JMenu(menus);
menuBar.add(menu);
}
mainFrame.setJMenuBar(menuBar);
mainFrame.setSize(700,700);
mainFrame.setVisible(true);
}
}