List of usage examples for javax.swing JMenu setIcon
@BeanProperty(visualUpdate = true, description = "The button's default icon") public void setIcon(Icon defaultIcon)
From source file:JFlap_2.EditingGraphViewer1.java
/** * @param args the command line arguments */// w w w.j a v a 2 s. c om public static void main(String[] args) { EditingGraphViewer1 sgv = new EditingGraphViewer1(); // Layout<V, E>, VisualizationViewer<V,E> Layout<Integer, String> layout = new StaticLayout(sgv.g); layout.setSize(new Dimension(300, 300)); VisualizationViewer<Integer, String> vv = new VisualizationViewer<Integer, String>(layout); vv.setPreferredSize(new Dimension(350, 350)); // Show vertex and edge labels vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); EditingModalGraphMouse gm = new EditingModalGraphMouse(vv.getRenderContext(), sgv.vertexFactory, sgv.edgeFactory); vv.setGraphMouse(gm); JFrame frame = new JFrame("Editing Graph Viewer 1"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); JMenuBar menuBar = new JMenuBar(); JMenu modeMenu = gm.getModeMenu(); modeMenu.setText("Mouse Mode"); modeMenu.setIcon(null); modeMenu.setPreferredSize(new Dimension(80, 20)); menuBar.add(modeMenu); frame.setJMenuBar(menuBar); gm.setMode(ModalGraphMouse.Mode.EDITING); frame.pack(); frame.setVisible(true); }
From source file:Submenu.java
public static void main(final String args[]) { JFrame frame = new JFrame("MenuSample Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu);// w ww. jav a 2s . c o m // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New", KeyEvent.VK_N); fileMenu.add(newMenuItem); // Edit->Options Submenu, O - Mnemonic, at.gif - Icon Image File JMenu findOptionsMenu = new JMenu("Options"); Icon atIcon = new ImageIcon("at.gif"); findOptionsMenu.setIcon(atIcon); findOptionsMenu.setMnemonic(KeyEvent.VK_O); fileMenu.add(findOptionsMenu); // ButtonGroup for radio buttons ButtonGroup directionGroup = new ButtonGroup(); // Edit->Options->Forward, F - Mnemonic, in group JRadioButtonMenuItem forwardMenuItem = new JRadioButtonMenuItem("Forward", true); forwardMenuItem.setMnemonic(KeyEvent.VK_F); findOptionsMenu.add(forwardMenuItem); directionGroup.add(forwardMenuItem); // Edit->Options->Backward, B - Mnemonic, in group JRadioButtonMenuItem backwardMenuItem = new JRadioButtonMenuItem("Backward"); backwardMenuItem.setMnemonic(KeyEvent.VK_B); findOptionsMenu.add(backwardMenuItem); directionGroup.add(backwardMenuItem); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:MediumPopupSample.java
public static void main(String args[]) { ActionListener menuListener = new MenuActionListener(); JFrame frame = new JFrame("MenuSample Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar menuBar = new JMenuBar(); // File Menu, F - Mnemonic JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic(KeyEvent.VK_F); menuBar.add(fileMenu);/*from ww w . j av a2s .c o m*/ // File->New, N - Mnemonic JMenuItem newMenuItem = new JMenuItem("New", KeyEvent.VK_N); newMenuItem.addActionListener(menuListener); fileMenu.add(newMenuItem); // File->Open, O - Mnemonic JMenuItem openMenuItem = new JMenuItem("Open", KeyEvent.VK_O); openMenuItem.addActionListener(menuListener); fileMenu.add(openMenuItem); // File->Close, C - Mnemonic JMenuItem closeMenuItem = new JMenuItem("Close", KeyEvent.VK_C); closeMenuItem.addActionListener(menuListener); fileMenu.add(closeMenuItem); // Separator fileMenu.addSeparator(); // File->Save, S - Mnemonic JMenuItem saveMenuItem = new JMenuItem("Save", KeyEvent.VK_S); saveMenuItem.addActionListener(menuListener); fileMenu.add(saveMenuItem); // Separator fileMenu.addSeparator(); // File->Exit, X - Mnemonic JMenuItem exitMenuItem = new JMenuItem("Exit", KeyEvent.VK_X); exitMenuItem.addActionListener(menuListener); fileMenu.add(exitMenuItem); // Edit Menu, E - Mnemonic JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic(KeyEvent.VK_E); menuBar.add(editMenu); // Edit->Cut, T - Mnemonic, CTRL-X - Accelerator JMenuItem cutMenuItem = new JMenuItem("Cut", KeyEvent.VK_T); cutMenuItem.addActionListener(menuListener); KeyStroke ctrlXKeyStroke = KeyStroke.getKeyStroke("control X"); cutMenuItem.setAccelerator(ctrlXKeyStroke); editMenu.add(cutMenuItem); // Edit->Copy, C - Mnemonic, CTRL-C - Accelerator JMenuItem copyMenuItem = new JMenuItem("Copy", KeyEvent.VK_C); copyMenuItem.addActionListener(menuListener); KeyStroke ctrlCKeyStroke = KeyStroke.getKeyStroke("control C"); copyMenuItem.setAccelerator(ctrlCKeyStroke); editMenu.add(copyMenuItem); // Edit->Paste, P - Mnemonic, CTRL-V - Accelerator, Disabled JMenuItem pasteMenuItem = new JMenuItem("Paste", KeyEvent.VK_P); pasteMenuItem.addActionListener(menuListener); KeyStroke ctrlVKeyStroke = KeyStroke.getKeyStroke("control V"); pasteMenuItem.setAccelerator(ctrlVKeyStroke); pasteMenuItem.setEnabled(false); editMenu.add(pasteMenuItem); // Separator editMenu.addSeparator(); // Edit->Find, F - Mnemonic, F3 - Accelerator JMenuItem findMenuItem = new JMenuItem("Find", KeyEvent.VK_F); findMenuItem.addActionListener(menuListener); KeyStroke f3KeyStroke = KeyStroke.getKeyStroke("F3"); findMenuItem.setAccelerator(f3KeyStroke); editMenu.add(findMenuItem); // Edit->Options Submenu, O - Mnemonic, at.gif - Icon Image File JMenu findOptionsMenu = new JMenu("Options"); Icon atIcon = new ImageIcon("at.gif"); findOptionsMenu.setIcon(atIcon); findOptionsMenu.setMnemonic(KeyEvent.VK_O); // ButtonGroup for radio buttons ButtonGroup directionGroup = new ButtonGroup(); // Edit->Options->Forward, F - Mnemonic, in group JRadioButtonMenuItem forwardMenuItem = new JRadioButtonMenuItem("Forward", true); forwardMenuItem.addActionListener(menuListener); forwardMenuItem.setMnemonic(KeyEvent.VK_F); findOptionsMenu.add(forwardMenuItem); directionGroup.add(forwardMenuItem); // Edit->Options->Backward, B - Mnemonic, in group JRadioButtonMenuItem backwardMenuItem = new JRadioButtonMenuItem("Backward"); backwardMenuItem.addActionListener(menuListener); backwardMenuItem.setMnemonic(KeyEvent.VK_B); findOptionsMenu.add(backwardMenuItem); directionGroup.add(backwardMenuItem); // Separator findOptionsMenu.addSeparator(); // Edit->Options->Case Sensitive, C - Mnemonic JCheckBoxMenuItem caseMenuItem = new JCheckBoxMenuItem("Case Sensitive"); caseMenuItem.addActionListener(menuListener); caseMenuItem.setMnemonic(KeyEvent.VK_C); findOptionsMenu.add(caseMenuItem); editMenu.add(findOptionsMenu); frame.setJMenuBar(menuBar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:ToggleSample.java
public static void main(String args[]) { JFrame frame = new JFrame("JToggleButtonMenuItem Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new JMenuBar(); JMenu file = new JMenu("File"); file.setMnemonic('f'); JMenuItem newItem = new JMenuItem("New", 'N'); file.add(newItem);/*from w ww . j ava 2 s. c om*/ JMenuItem openItem = new JMenuItem("Open", 'O'); file.add(openItem); JMenuItem closeItem = new JMenuItem("Close", 'C'); file.add(closeItem); file.addSeparator(); JMenuItem saveItem = new JMenuItem("Save", 'S'); file.add(saveItem); file.addSeparator(); JMenuItem exitItem = new JMenuItem("Exit", 'X'); file.add(exitItem); bar.add(file); JMenu edit = new JMenu("Edit"); JMenuItem cutItem = new JMenuItem("Cut", 'T'); cutItem.setAccelerator(KeyStroke.getKeyStroke('X', Event.CTRL_MASK)); edit.add(cutItem); JMenuItem copyItem = new JMenuItem("Copy", 'C'); copyItem.setAccelerator(KeyStroke.getKeyStroke('C', Event.CTRL_MASK)); edit.add(copyItem); JMenuItem pasteItem = new JMenuItem("Paste", 'P'); pasteItem.setAccelerator(KeyStroke.getKeyStroke('V', Event.CTRL_MASK)); pasteItem.setEnabled(false); edit.add(pasteItem); edit.addSeparator(); JMenuItem findItem = new JMenuItem("Find", 'F'); findItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); edit.add(findItem); edit.setMnemonic('e'); Icon atIcon = new ImageIcon("at.gif"); JMenu findOptions = new JMenu("Options"); findOptions.setIcon(atIcon); findOptions.setMnemonic('O'); ButtonGroup directionGroup = new ButtonGroup(); JRadioButtonMenuItem forward = new JRadioButtonMenuItem("Forward", true); findOptions.add(forward); directionGroup.add(forward); JRadioButtonMenuItem backward = new JRadioButtonMenuItem("Backward"); findOptions.add(backward); directionGroup.add(backward); findOptions.addSeparator(); JCheckBoxMenuItem caseItem = new JCheckBoxMenuItem("Case Insensitive"); findOptions.add(caseItem); edit.add(findOptions); JToggleButtonMenuItem toggleItem = new JToggleButtonMenuItem("Ballon Help"); toggleItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Selected"); } }); edit.add(toggleItem); bar.add(edit); frame.setJMenuBar(bar); frame.setSize(350, 250); frame.setVisible(true); }
From source file:MenuX.java
public static void main(String args[]) { ActionListener actionListener = new MenuActionListener(); MenuKeyListener menuKeyListener = new MyMenuKeyListener(); ChangeListener cListener = new MyChangeListener(); MenuListener menuListener = new MyMenuListener(); MenuSelectionManager manager = MenuSelectionManager.defaultManager(); manager.addChangeListener(cListener); JFrame frame = new JFrame("MenuSample Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar bar = new VerticalMenuBar(); // JMenuBar bar = new JMenuBar(); // File Menu, F - Mnemonic JMenu file = new JMenu("File"); file.setMnemonic(KeyEvent.VK_F); file.addChangeListener(cListener);// ww w . j av a 2 s .c o m file.addMenuListener(menuListener); file.addMenuKeyListener(menuKeyListener); JPopupMenu popupMenu = file.getPopupMenu(); popupMenu.setLayout(new GridLayout(3, 3)); bar.add(file); // File->New, N - Mnemonic JMenuItem newItem = new JMenuItem("New", KeyEvent.VK_N); newItem.addActionListener(actionListener); newItem.addChangeListener(cListener); newItem.addMenuKeyListener(menuKeyListener); file.add(newItem); // File->Open, O - Mnemonic JMenuItem openItem = new JMenuItem("Open", KeyEvent.VK_O); openItem.addActionListener(actionListener); openItem.addChangeListener(cListener); openItem.addMenuKeyListener(menuKeyListener); file.add(openItem); // File->Close, C - Mnemonic JMenuItem closeItem = new JMenuItem("Close", KeyEvent.VK_C); closeItem.addActionListener(actionListener); closeItem.addChangeListener(cListener); closeItem.addMenuKeyListener(menuKeyListener); file.add(closeItem); // Separator file.addSeparator(); // File->Save, S - Mnemonic JMenuItem saveItem = new JMenuItem("Save", KeyEvent.VK_S); saveItem.addActionListener(actionListener); saveItem.addChangeListener(cListener); saveItem.addMenuKeyListener(menuKeyListener); file.add(saveItem); // Separator file.addSeparator(); // File->Exit, X - Mnemonic JMenuItem exitItem = new JMenuItem("Exit", KeyEvent.VK_X); exitItem.addActionListener(actionListener); exitItem.addChangeListener(cListener); exitItem.addMenuKeyListener(menuKeyListener); file.add(exitItem); // Edit Menu, E - Mnemonic JMenu edit = new JMenu("Edit"); edit.setMnemonic(KeyEvent.VK_E); edit.addChangeListener(cListener); edit.addMenuListener(menuListener); edit.addMenuKeyListener(menuKeyListener); bar.add(edit); // Edit->Cut, T - Mnemonic, CTRL-X - Accelerator JMenuItem cutItem = new JMenuItem("Cut", KeyEvent.VK_T); cutItem.addActionListener(actionListener); cutItem.addChangeListener(cListener); cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK)); cutItem.addMenuKeyListener(menuKeyListener); edit.add(cutItem); // Edit->Copy, C - Mnemonic, CTRL-C - Accelerator JMenuItem copyItem = new JMenuItem("Copy", KeyEvent.VK_C); copyItem.addActionListener(actionListener); copyItem.addChangeListener(cListener); copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK)); copyItem.addMenuKeyListener(menuKeyListener); copyItem.setEnabled(false); edit.add(copyItem); // Edit->Paste, P - Mnemonic, CTRL-V - Accelerator, Disabled JMenuItem pasteItem = new JMenuItem("Paste", KeyEvent.VK_P); pasteItem.addActionListener(actionListener); pasteItem.addChangeListener(cListener); pasteItem.addMenuKeyListener(menuKeyListener); pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK)); pasteItem.setEnabled(false); edit.add(pasteItem); // Separator edit.addSeparator(); // Edit->Find, F - Mnemonic, F3 - Accelerator JMenuItem findItem = new JMenuItem("Find", KeyEvent.VK_F); findItem.addActionListener(actionListener); findItem.addChangeListener(cListener); findItem.addMenuKeyListener(menuKeyListener); findItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0)); edit.add(findItem); // Edit->Options Submenu, O - Mnemonic, at.gif - Icon Image File JMenu findOptions = new JMenu("Options"); findOptions.addChangeListener(cListener); findOptions.addMenuListener(menuListener); findOptions.addMenuKeyListener(menuKeyListener); Icon atIcon = new ImageIcon("at.gif"); findOptions.setIcon(atIcon); findOptions.setMnemonic(KeyEvent.VK_O); // ButtonGrou for radio buttons ButtonGroup directionGroup = new ButtonGroup(); // Edit->Options->Forward, F - Mnemonic, in group JRadioButtonMenuItem forward = new JRadioButtonMenuItem("Forward", true); forward.addActionListener(actionListener); forward.addChangeListener(cListener); forward.addMenuKeyListener(menuKeyListener); forward.setMnemonic(KeyEvent.VK_F); findOptions.add(forward); directionGroup.add(forward); // Edit->Options->Backward, B - Mnemonic, in group JRadioButtonMenuItem backward = new JRadioButtonMenuItem("Backward"); backward.addActionListener(actionListener); backward.addChangeListener(cListener); backward.addMenuKeyListener(menuKeyListener); backward.setMnemonic(KeyEvent.VK_B); findOptions.add(backward); directionGroup.add(backward); // Separator findOptions.addSeparator(); // Edit->Options->Case Sensitive, C - Mnemonic JCheckBoxMenuItem caseItem = new JCheckBoxMenuItem("Case Sensitive"); caseItem.addActionListener(actionListener); caseItem.addChangeListener(cListener); caseItem.addMenuKeyListener(menuKeyListener); caseItem.setMnemonic(KeyEvent.VK_C); findOptions.add(caseItem); edit.add(findOptions); frame.setJMenuBar(bar); // frame.getContentPane().add(bar, BorderLayout.EAST); frame.setSize(350, 250); frame.setVisible(true); }
From source file:net.sf.jabref.gui.menus.RightClickMenu.java
/** * Remove all types from the menu.//from w w w .ja v a 2 s. co m * Then cycle through all available values, and add them. */ public static void populateSpecialFieldMenu(JMenu menu, SpecialField field, JabRefFrame frame) { menu.setText(field.getMenuString()); menu.setIcon(((IconTheme.FontBasedIcon) field.getRepresentingIcon()).createSmallIcon()); for (SpecialFieldValue val : field.getValues()) { menu.add(val.getMenuAction(frame)); } }
From source file:net.sf.jabref.gui.RightClickMenu.java
/** * Remove all types from the menu.//from ww w . ja va 2 s .c o m * Then cycle through all available values, and add them. */ public static void populateSpecialFieldMenu(JMenu menu, SpecialField field, JabRefFrame frame) { //menu.removeAll(); menu.setText(field.getMenuString()); menu.setIcon(((IconTheme.FontBasedIcon) field.getRepresentingIcon()).createSmallIcon()); for (SpecialFieldValue val : field.getValues()) { menu.add(val.getMenuAction(frame)); } }
From source file:levelBuilder.DialogMaker.java
/** * Various routines necessary for displaying graph. *//*w ww . j ava 2 s .c o m*/ private static void displayGraph() { JFrame frame = new JFrame("Dialog Maker"); layout = new KKLayout<DialogNode, Double>(g); VisualizationViewer<DialogNode, Double> vv = new VisualizationViewer<DialogNode, Double>(layout); layout.setSize(new Dimension(windowWidth, windowHeight)); vv.setPreferredSize(new Dimension(windowWidth, windowHeight)); //Changes fields in node properties window when a node is selected pickedState = vv.getPickedVertexState(); pickedState.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { Object subject = e.getItem(); if (subject instanceof DialogNode) { selectedNode = (DialogNode) subject; textField.setText(selectedNode.getText()); npcBox.setSelected(selectedNode.getIsNPC()); String working = ""; for (int c = 0; c < selectedNode.getChildren().length; c++) { if (c == 0) working += selectedNode.getChildren()[c].getText(); else working += "," + selectedNode.getChildren()[c].getText(); } if (working.equals("null")) working = ""; childrenField.setText(working.replace("]", "").replace("[", "")); working = Arrays.toString(selectedNode.getProbSets().get(strategy)); if (working.equals("null")) working = ""; probSetField.setText(working.replace("]", "").replace("[", "").replace(" ", "")); } } }); //Colors vertices according to 'initial', 'end', or 'middle' status. vv.getRenderContext().setVertexFillPaintTransformer(new Transformer<DialogNode, Paint>() { @Override public Paint transform(DialogNode n) { if (n.getText().equals("initial")) return new Color(100, 255, 100); if (n.getChildren().length == 0) return new Color(255, 100, 100); return new Color(100, 100, 255); } }); //Labels vertices with node text. vv.getRenderContext().setVertexLabelTransformer(new Transformer<DialogNode, String>() { @Override public String transform(DialogNode n) { return n.getText().split(" ")[0]; } }); //Draws shape of vertices according to player or non-player status. vv.getRenderContext().setVertexShapeTransformer(new Transformer<DialogNode, Shape>() { @Override public Shape transform(DialogNode n) { if (n.getIsNPC()) return new Rectangle(-15, -15, 30, 30); else return new Ellipse2D.Double(-15.0, -15.0, 30.0, 30.0); } }); //Labels edges with probability of child being selected under the current strategy. vv.getRenderContext().setEdgeLabelTransformer(new Transformer<Double, String>() { @Override public String transform(Double e) { DialogNode source = g.getSource(e); if (source.getProbSets().size() > 0) for (int c = 0; c < source.getChildren().length; c++) if (source.getChildren()[c].equals(g.getDest(e))) { if (source.getProbSets().get(strategy) != null) return Double.toString(source.getProbSets().get(strategy)[c]); else //If node does not have probSet for that strategy, default to strategy 0. return Double.toString(source.getProbSets().get(0)[c]); } return null; } }); vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR); //Routines for editing mode. EditingModalGraphMouse<DialogNode, Double> gm = new EditingModalGraphMouse<DialogNode, Double>( vv.getRenderContext(), //Runs when a new node is created. new Factory<DialogNode>() { @Override public DialogNode create() { DialogNode n = new DialogNode(isNPCBoxChecked, textField.getText(), new ArrayList<double[]>(), new DialogNode[0]); dg.addNode(n); return n; } }, //Runs when a new edge is created. new Factory<Double>() { @Override public Double create() { addedEdgeID = Math.random(); return addedEdgeID; } }); vv.setGraphMouse(gm); //Frame and mode menu. JMenuBar menuBar = new JMenuBar(); JMenu modeMenu = gm.getModeMenu(); modeMenu.setText("Mouse Mode"); modeMenu.setIcon(null); modeMenu.setPreferredSize(new Dimension(100, 20)); menuBar.add(modeMenu); frame.setJMenuBar(menuBar); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(vv); frame.pack(); frame.setVisible(true); // //Sets position of each node. // for (DialogNode n : nodeMap.values()) { // Point2D.Double point = new Point2D.Double(n.getX(), n.getY()); // if (point.x != 0.0 && point.y != 0.0) // layout.setLocation(n, point); // } }
From source file:ec.nbdemetra.chainlinking.outlineview.ChainLinkingChart.java
private JMenu newExportMenu() { DemetraUI demetraUI = DemetraUI.getDefault(); JMenu rslt = new JMenu("Export image to"); rslt.setIcon(demetraUI.getPopupMenuIcon(FontAwesome.FA_FLOPPY_O)); JMenuItem copy = new ActionMenuItem(ChartCommand.copyImage().toAction(chartPanel)); copy.setText("Clipboard..."); copy.setIcon(demetraUI.getPopupMenuIcon(FontAwesome.FA_CLIPBOARD)); JMenuItem file = new ActionMenuItem(ChartCommand.saveImage().toAction(chartPanel)); file.setText("File..."); file.setIcon(demetraUI.getPopupMenuIcon(FontAwesome.FA_PICTURE_O)); rslt.add(copy);/*from w ww. j ava 2 s. c o m*/ rslt.add(file); return rslt; }
From source file:ec.nbdemetra.sa.revisionanalysis.RevisionAnalysisChart.java
private JMenu newExportMenu() { DemetraUI demetraUI = DemetraUI.getDefault(); JMenu result = new JMenu("Export image to"); result.setIcon(demetraUI.getPopupMenuIcon(FontAwesome.FA_FLOPPY_O)); JMenuItem copy = new ActionMenuItem(ChartCommand.copyImage().toAction(chartPanel)); copy.setIcon(demetraUI.getPopupMenuIcon(FontAwesome.FA_CLIPBOARD)); copy.setText("Clipboard"); JMenuItem file = new ActionMenuItem(ChartCommand.saveImage().toAction(chartPanel)); file.setIcon(demetraUI.getPopupMenuIcon(FontAwesome.FA_PICTURE_O)); file.setText("File..."); result.add(copy);//from ww w. j ava 2 s. c om result.add(file); return result; }