647 * @param c the component whose size and position are to be recorded in the map.
648 * @param m the map in which the information is to be recorded
649 * @see #restoreBounds
650 */
651 protected static void saveBounds(Component c, Map<String, String> m) {
652 Rectangle r = c.getBounds();
653 m.put("x", String.valueOf(r.x));
654 m.put("y", String.valueOf(r.y));
655 m.put("w", String.valueOf(r.width));
656 m.put("h", String.valueOf(r.height));
657 }
658
659
660 /**
661 * Restore the screen size and position for a component from information
662 * in a map object.
663 * @param c the component whose size and position are to be restored.
664 * @param m the map in which the information is to be recorded
665 * @see #saveBounds
666 */
667 protected static void restoreBounds(Component c, Map m) {
668 try {
669 String xs = (String) (m.get("x"));
670 String ys = (String) (m.get("y"));
671 String ws = (String) (m.get("w"));
672 String hs = (String) (m.get("h"));
673 if (xs != null && ys != null && ws != null && hs != null) {
674 Rectangle restored = new Rectangle(Integer.parseInt(xs),
675 Integer.parseInt(ys),
676 Integer.parseInt(ws),
677 Integer.parseInt(hs));
678
679 restored = getScreenBounds().intersection(restored);
680 if (!restored.isEmpty()) {
681 c.setBounds(restored);
682 }
683
684 }
685 }
686 catch (NumberFormatException e) {
687 // ignore
688 }
689 }
690
691 public static Rectangle getScreenBounds() {
692 // Consider multi-display environment
774
775 JMenuItem[] jmi = mgrs[i].getFileMenuPrimaries();
776 if (jmi != null) {
777 for (int j = 0; j < jmi.length; j++)
778 m.add(jmi[j]);
779 }
780
781 } // for
782
783 // add secondary items before prefs, close, exit
784 for (int i = 0; i < mgrs.length; i++) {
785 JMenuItem[] jmi = mgrs[i].getFileMenuSecondaries();
786 if (jmi != null) {
787 for (int j = 0; j < jmi.length; j++)
788 m.add(jmi[j]);
789 m.addSeparator();
790 }
791
792 } // for
793
794 List fileHistory = desktop.getFileHistory();
795 // if (!fileHistory.isEmpty()) {
796 JMenu hm = uif.createMenu("dt.file.recentwd");
797 if (!fileHistory.isEmpty()) {
798 int n = 0;
799
800 for (Iterator i = fileHistory.iterator(); i.hasNext(); ) {
801 Desktop.FileHistoryEntry h = (Desktop.FileHistoryEntry) (i.next());
802 if (!h.file.exists())
803 continue;
804 String s = uif.getI18NString("dt.file.historyX.mit",
805 new Object[] {new Integer(n), h.file.getPath()});
806 JMenuItem mi = new JMenuItem(s);
807 mi.setActionCommand(HISTORY);
808 mi.addActionListener(this);
809 mi.putClientProperty(this, h);
810 if (n < 10)
811 mi.setMnemonic(Character.forDigit(n, 10));
812 n++;
813 hm.add(mi);
814 }
815 } else {
816 JMenuItem noEntries = new JMenuItem(i18n.getString("fh.empty"));
817 noEntries.setEnabled(false);
818 hm.add(noEntries);
819
820 }
821 m.add(hm);
|
647 * @param c the component whose size and position are to be recorded in the map.
648 * @param m the map in which the information is to be recorded
649 * @see #restoreBounds
650 */
651 protected static void saveBounds(Component c, Map<String, String> m) {
652 Rectangle r = c.getBounds();
653 m.put("x", String.valueOf(r.x));
654 m.put("y", String.valueOf(r.y));
655 m.put("w", String.valueOf(r.width));
656 m.put("h", String.valueOf(r.height));
657 }
658
659
660 /**
661 * Restore the screen size and position for a component from information
662 * in a map object.
663 * @param c the component whose size and position are to be restored.
664 * @param m the map in which the information is to be recorded
665 * @see #saveBounds
666 */
667 protected static void restoreBounds(Component c, Map<String, String> m) {
668 try {
669 String xs = (m.get("x"));
670 String ys = (m.get("y"));
671 String ws = (m.get("w"));
672 String hs = (m.get("h"));
673 if (xs != null && ys != null && ws != null && hs != null) {
674 Rectangle restored = new Rectangle(Integer.parseInt(xs),
675 Integer.parseInt(ys),
676 Integer.parseInt(ws),
677 Integer.parseInt(hs));
678
679 restored = getScreenBounds().intersection(restored);
680 if (!restored.isEmpty()) {
681 c.setBounds(restored);
682 }
683
684 }
685 }
686 catch (NumberFormatException e) {
687 // ignore
688 }
689 }
690
691 public static Rectangle getScreenBounds() {
692 // Consider multi-display environment
774
775 JMenuItem[] jmi = mgrs[i].getFileMenuPrimaries();
776 if (jmi != null) {
777 for (int j = 0; j < jmi.length; j++)
778 m.add(jmi[j]);
779 }
780
781 } // for
782
783 // add secondary items before prefs, close, exit
784 for (int i = 0; i < mgrs.length; i++) {
785 JMenuItem[] jmi = mgrs[i].getFileMenuSecondaries();
786 if (jmi != null) {
787 for (int j = 0; j < jmi.length; j++)
788 m.add(jmi[j]);
789 m.addSeparator();
790 }
791
792 } // for
793
794 List<Desktop.FileHistoryEntry> fileHistory = desktop.getFileHistory();
795 // if (!fileHistory.isEmpty()) {
796 JMenu hm = uif.createMenu("dt.file.recentwd");
797 if (!fileHistory.isEmpty()) {
798 int n = 0;
799
800 for (Iterator<Desktop.FileHistoryEntry> i = fileHistory.iterator(); i.hasNext(); ) {
801 Desktop.FileHistoryEntry h = (i.next());
802 if (!h.file.exists())
803 continue;
804 String s = uif.getI18NString("dt.file.historyX.mit",
805 new Object[] {new Integer(n), h.file.getPath()});
806 JMenuItem mi = new JMenuItem(s);
807 mi.setActionCommand(HISTORY);
808 mi.addActionListener(this);
809 mi.putClientProperty(this, h);
810 if (n < 10)
811 mi.setMnemonic(Character.forDigit(n, 10));
812 n++;
813 hm.add(mi);
814 }
815 } else {
816 JMenuItem noEntries = new JMenuItem(i18n.getString("fh.empty"));
817 noEntries.setEnabled(false);
818 hm.add(noEntries);
819
820 }
821 m.add(hm);
|