/** Initialize and update the items. */ @Override public void initItems() { if (!initialized) { return; } removeAll(); JMenuItem mit = add(newWindowAction); setMenuShortCutAccelerator(mit, 'N'); ArrayList<GeoGebraFrame> ggbInstances = GeoGebraFrame.getInstances(); int size = ggbInstances.size(); if (size == 1) return; addSeparator(); StringBuilder sb = new StringBuilder(); ButtonGroup bg = new ButtonGroup(); JRadioButtonMenuItem mi; int current = -1; for (int i = 0; i < size; i++) { GeoGebraFrame ggb = ggbInstances.get(i); AppD application = ggb.getApplication(); if (app == application) current = i; } for (int i = 0; i < size; i++) { GeoGebraFrame ggb = ggbInstances.get(i); AppD application = ggb.getApplication(); sb.setLength(0); sb.append(i + 1); if (application != null) // Michael Borcherds 2008-03-03 bugfix if (application.getCurrentFile() != null) { sb.append(" "); sb.append(application.getCurrentFile().getName()); } mi = new JRadioButtonMenuItem(sb.toString()); if (application == this.app) mi.setSelected(true); ActionListener al = new RequestFocusListener(ggb); mi.addActionListener(al); if (i == ((current + 1) % size)) setMenuShortCutShiftAccelerator(mi, 'N'); else if (i == ((current - 1 + size) % size)) setMenuShortCutShiftAltAccelerator(mi, 'N'); bg.add(mi); add(mi); } // support for right-to-left languages app.setComponentOrientation(this); }