{"id":10265,"date":"2015-08-26T07:41:25","date_gmt":"2015-08-26T11:41:25","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/?p=10265"},"modified":"2015-08-24T08:46:19","modified_gmt":"2015-08-24T12:46:19","slug":"jlist-examples","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=10265","title":{"rendered":"JList Examples"},"content":{"rendered":"<pre>All examples, except for FileTransfer use WindowUtilities.java and ExitListener.java.\r\nWindowUtilities.java: \r\nimport javax.swing.*;\r\nimport java.awt.*;\u00a0\u00a0 \/\/ For Color and Container classes.\r\n\r\n\/** A few utilities that simplify using windows in Swing. \r\n\u00a0*\r\n\u00a0 *\/\r\n\r\npublic class WindowUtilities {\r\n\r\n\u00a0 \/** Tell system to use native look and feel, as in previous\r\n\u00a0\u00a0 *\u00a0 releases. Metal (Java) LAF is the default otherwise.\r\n\u00a0\u00a0 *\/\r\n\r\n\u00a0 public static void setNativeLookAndFeel() {\r\n\u00a0\u00a0\u00a0 try {\r\n\u00a0\u00a0\u00a0\u00a0 UIManager.setLookAndFeel(\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UIManager.getSystemLookAndFeelClassName());\r\n\u00a0\u00a0\u00a0 } catch(Exception e) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(\"Error setting native LAF: \" + e);\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0 }\r\n\r\n\u00a0 public static void setJavaLookAndFeel() {\r\n\u00a0\u00a0\u00a0 try {\r\n\u00a0\u00a0\u00a0\u00a0 UIManager.setLookAndFeel(\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UIManager.getCrossPlatformLookAndFeelClassName());\r\n\u00a0\u00a0\u00a0 } catch(Exception e) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(\"Error setting Java LAF: \" + e);\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0 }\r\n\r\n\u00a0\u00a0 public static void setMotifLookAndFeel() {\r\n\u00a0\u00a0\u00a0 try {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 UIManager.setLookAndFeel(\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"com.sun.java.swing.plaf.motif.MotifLookAndFeel\");\r\n\u00a0\u00a0\u00a0 } catch(Exception e) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(\"Error setting Motif LAF: \" + e);\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0 }\r\n\r\n\u00a0 \/** A simplified way to see a JPanel or other Container. Pops\r\n\u00a0\u00a0 *\u00a0 up a JFrame with specified Container as the content pane.\r\n\u00a0\u00a0 *\/\r\n\r\n\u00a0 public static JFrame openInJFrame(Container content,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int width,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int height,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 String title,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Color bgColor) {\r\n\u00a0\u00a0\u00a0 JFrame frame = new JFrame(title);\r\n\u00a0\u00a0\u00a0 frame.setBackground(bgColor);\r\n\u00a0\u00a0\u00a0 content.setBackground(bgColor);\r\n\u00a0\u00a0\u00a0 frame.setSize(width, height);\r\n\u00a0\u00a0\u00a0 frame.setContentPane(content);\r\n\u00a0\u00a0\u00a0 frame.addWindowListener(new ExitListener());\r\n\u00a0\u00a0\u00a0 frame.setVisible(true);\r\n\u00a0\u00a0\u00a0 return(frame);\r\n\u00a0 }\r\n\r\n\u00a0 \/** Uses Color.white as the background color. *\/\r\n\r\n\u00a0 public static JFrame openInJFrame(Container content,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int width,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int height,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 String title) {\r\n\u00a0\u00a0\u00a0 return(openInJFrame(content, width, height,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 title, Color.white));\r\n\u00a0 }\r\n\r\n\u00a0 \/** Uses Color.white as the background color, and the\r\n\u00a0\u00a0 *\u00a0 name of the Container's class as the JFrame title.\r\n\u00a0\u00a0 *\/\r\n\r\n\u00a0 public static JFrame openInJFrame(Container content,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int width,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int height) {\r\n\u00a0\u00a0\u00a0 return(openInJFrame(content, width, height,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 content.getClass().getName(),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Color.white));\r\n\u00a0 }\r\n}\r\n**\/\/\r\nExitListener.java.:\r\nimport java.awt.*;\r\nimport java.awt.event.*;\r\n\r\n\/** A listener that you attach to the top-level JFrame of\r\n\u00a0*\u00a0 your application, so that quitting the frame exits the \r\n\u00a0*\u00a0 application.\r\n\u00a0*\r\n\u00a0 *\/\r\npublic class ExitListener extends WindowAdapter {\r\n\u00a0 public void windowClosing(WindowEvent event) {\r\n\u00a0\u00a0\u00a0 System.exit(0);\r\n\u00a0 }\r\n}\r\n**\/\/<\/pre>\n<p style=\"text-align: justify;\">JList Examples<\/p>\n<p>* JListSimpleExample.java Illustrates creating a simple list. In this example, all the entries for the list are stored in a String array and later supplied in the JList constructor. In addition, a private class, ValueReporter, implements a ListSelectionListener to display the last entry in the list selected by the user.<\/p>\n<pre>\r\nimport java.awt.*;\r\nimport javax.swing.*;\r\nimport javax.swing.event.*;\r\nimport javax.swing.border.*;\r\n\r\n\/** Simple JList example illustrating\r\n\u00a0* \u00a0\r\n\r\n\r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0 Creating a JList, which we do by passing values \r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 directly to the JList constructor, rather than \r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 using a ListModel, and\r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0 Attaching a listener to determine when values change.\r\n\u00a0\u00a0\u00a0\u00a0 * \u00a0\r\n\r\n\r\n\u00a0*\/\r\n\r\npublic class JListSimpleExample extends JFrame {\r\n\u00a0 public static void main(String[] args) {\r\n\u00a0\u00a0\u00a0 new JListSimpleExample();\r\n\u00a0 }\r\n\r\n\u00a0 private JList sampleJList;\r\n\u00a0 private JTextField valueField;\r\n\u00a0 \r\n\u00a0 public JListSimpleExample() {\r\n\u00a0\u00a0\u00a0 super(\"Creating a Simple JList\");\r\n\u00a0\u00a0\u00a0 WindowUtilities.setNativeLookAndFeel();\r\n\u00a0\u00a0\u00a0 addWindowListener(new ExitListener());\r\n\u00a0\u00a0\u00a0 Container content = getContentPane();\r\n\r\n\u00a0\u00a0\u00a0 \/\/ Create the JList, set the number of visible rows, add a\r\n\u00a0\u00a0\u00a0 \/\/ listener, and put it in a JScrollPane.\r\n\u00a0\u00a0\u00a0 String[] entries = { \"Entry 1\", \"Entry 2\", \"Entry 3\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"Entry 4\", \"Entry 5\", \"Entry 6\" };\r\n\u00a0\u00a0\u00a0 sampleJList = new JList(entries);\r\n\u00a0\u00a0\u00a0 sampleJList.setVisibleRowCount(4);\r\n\u00a0\u00a0\u00a0 sampleJList.addListSelectionListener(new ValueReporter());\r\n\u00a0\u00a0\u00a0 JScrollPane listPane = new JScrollPane(sampleJList);\r\n\u00a0\u00a0\u00a0 Font displayFont = new Font(\"Serif\", Font.BOLD, 18);\r\n\u00a0\u00a0\u00a0 sampleJList.setFont(displayFont);\r\n\r\n\u00a0\u00a0\u00a0 JPanel listPanel = new JPanel();\r\n\u00a0\u00a0\u00a0 listPanel.setBackground(Color.white);\r\n\u00a0\u00a0\u00a0 Border listPanelBorder =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 BorderFactory.createTitledBorder(\"Sample JList\");\r\n\u00a0\u00a0\u00a0 listPanel.setBorder(listPanelBorder);\r\n\u00a0\u00a0\u00a0 listPanel.add(listPane);\r\n\u00a0\u00a0\u00a0 content.add(listPanel, BorderLayout.CENTER);\r\n\u00a0\u00a0\u00a0 JLabel valueLabel = new JLabel(\"Last Selection:\");\r\n\u00a0\u00a0\u00a0 valueLabel.setFont(displayFont);\r\n\u00a0\u00a0\u00a0 valueField = new JTextField(\"None\", 7);\r\n\u00a0\u00a0\u00a0 valueField.setFont(displayFont);\r\n\u00a0\u00a0\u00a0 valueField.setEditable(false);\r\n\u00a0\u00a0\u00a0 JPanel valuePanel = new JPanel();\r\n\u00a0\u00a0\u00a0 valuePanel.setBackground(Color.white);\r\n\u00a0\u00a0\u00a0 Border valuePanelBorder =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 BorderFactory.createTitledBorder(\"JList Selection\");\r\n\u00a0\u00a0\u00a0 valuePanel.setBorder(valuePanelBorder);\r\n\u00a0\u00a0\u00a0 valuePanel.add(valueLabel);\r\n\u00a0\u00a0\u00a0 valuePanel.add(valueField);\r\n\u00a0\u00a0\u00a0 content.add(valuePanel, BorderLayout.SOUTH);\r\n\u00a0\u00a0\u00a0 pack();\r\n\u00a0\u00a0\u00a0 setVisible(true);\r\n\u00a0 }\r\n\r\n\u00a0 private class ValueReporter implements ListSelectionListener {\r\n\r\n\u00a0\u00a0\u00a0 \/** You get three events in many cases -- one for the \r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0 deselection of the originally selected entry, one \r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0 indicating the selection is moving, and one for the \r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0 selection of the new entry. In the first two cases, \r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0 getValueIsAdjusting returns true; thus, the test below\r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0 when only the third case is of interest.\r\n\u00a0\u00a0\u00a0\u00a0 *\/\r\n\r\n\u00a0\u00a0\u00a0 public void valueChanged(ListSelectionEvent event) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 if (!event.getValueIsAdjusting()) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Object value = sampleJList.getSelectedValue();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (value != null) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 valueField.setText(value.toString());\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0 }\r\n}\r\n**\/\/<\/pre>\n<p style=\"text-align: justify;\">\nDefaultListModelExample.java Creates a list using a DefaultListModel. By default, a JList doesn&#8217;t permit you to directly add new entries; however, with the DefaultListModel you can add or delete entries to the model (which are reflected in the list).<\/p>\n<p style=\"text-align: justify;\">\n<pre>import java.awt.*;\r\nimport java.awt.event.*;\r\nimport javax.swing.*;\r\nimport javax.swing.border.*;\r\n\r\n\/** JList example illustrating\r\n\u00a0* \u00a0\r\n\r\n\r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0 The creation of a JList by creating a DefaultListModel,\r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 adding the values there, then passing that to the\r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 JList constructor.\r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0 Adding new values at runtime, the key thing that \r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DefaultListModel lets you do that you can't do with\r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 a JList where you supply values directly.\r\n\u00a0\u00a0\u00a0\u00a0 * \u00a0\r\n\r\n\r\n\u00a0*\r\n\u00a0*\/\r\n\r\npublic class DefaultListModelExample extends JFrame {\r\n\u00a0 public static void main(String[] args) {\r\n\u00a0\u00a0\u00a0 new DefaultListModelExample();\r\n\u00a0 }\r\n\r\n\u00a0 JList sampleJList;\r\n\u00a0 private DefaultListModel sampleModel;\r\n\u00a0 \r\n\u00a0 public DefaultListModelExample() {\r\n\u00a0\u00a0\u00a0 super(\"Creating a Simple JList\");\r\n\u00a0\u00a0\u00a0 WindowUtilities.setNativeLookAndFeel();\r\n\u00a0\u00a0\u00a0 addWindowListener(new ExitListener());\r\n\u00a0\u00a0\u00a0 Container content = getContentPane();\r\n\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0 String[] entries = { \"Entry 1\", \"Entry 2\", \"Entry 3\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"Entry 4\", \"Entry 5\", \"Entry 6\" };\r\n\u00a0\u00a0\u00a0 sampleModel = new DefaultListModel();\r\n\u00a0\u00a0\u00a0 for(int i=0; ibefore trying to scroll\r\n\u00a0\u00a0\u00a0\u00a0 *\u00a0 to make the index visible.\r\n\u00a0\u00a0\u00a0\u00a0 *\/\r\n\r\n\u00a0\u00a0\u00a0 public void actionPerformed(ActionEvent event) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 int index = sampleModel.getSize();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 sampleModel.addElement(\"Entry \" + (index+1));\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 ((JComponent)getContentPane()).revalidate();\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 sampleJList.setSelectedIndex(index);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 sampleJList.ensureIndexIsVisible(index);\r\n\u00a0\u00a0\u00a0 }\r\n\u00a0 }\r\n}\r\n**\/\/<\/pre>\n<p># JListCustomModel.java\u00a0 Example illustrating that you can use your own custom data model (data structure) to hold the entries in a list. Uses the following classes:<\/p>\n<p>* JavaLocationListModel.java A custom list model (implements ListModel interface which provides support for custom data structures) to store data for the list.<br \/>\n* JavaLocationCollection.java A simple collection of JavaLocation (below) objects.<br \/>\n* JavaLocation.java An object representing a city named Java. Defines the country where the Java city is located, along with a comment and country flag (gif image).<\/p>\n<pre>JListCustomModel.java:\r\nimport java.awt.*;\r\nimport javax.swing.*;\r\n\r\n\/** Simple JList example illustrating the use of a custom\r\n\u00a0*\u00a0 ListModel (JavaLocationListModel).\r\n\u00a0*\r\n\u00a0 *\/\r\n\r\npublic class JListCustomModel extends JFrame {\r\n\u00a0 public static void main(String[] args) {\r\n\u00a0\u00a0\u00a0 new JListCustomModel();\r\n\u00a0 }\r\n\r\n\u00a0 public JListCustomModel() {\r\n\u00a0\u00a0\u00a0 super(\"JList with a Custom Data Model\");\r\n\u00a0\u00a0\u00a0 WindowUtilities.setNativeLookAndFeel();\r\n\u00a0\u00a0\u00a0 addWindowListener(new ExitListener());\r\n\u00a0\u00a0\u00a0 Container content = getContentPane();\r\n\r\n\u00a0\u00a0\u00a0 JavaLocationCollection collection =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocationCollection();\r\n\u00a0\u00a0\u00a0 JavaLocationListModel listModel =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocationListModel(collection);\r\n\u00a0\u00a0\u00a0 JList sampleJList = new JList(listModel);\r\n\u00a0\u00a0\u00a0 Font displayFont = new Font(\"Serif\", Font.BOLD, 18);\r\n\u00a0\u00a0\u00a0 sampleJList.setFont(displayFont);\r\n\u00a0\u00a0\u00a0 content.add(sampleJList);\r\n\r\n\u00a0\u00a0\u00a0 pack();\r\n\u00a0\u00a0\u00a0 setVisible(true);\r\n\u00a0 }\r\n}\r\n**\/\/\r\n# JavaLocationListModel.java:\r\n\r\nimport javax.swing.*;\r\nimport javax.swing.event.*;\r\n\r\n\/** A simple illustration of writing your own ListModel.\r\n\u00a0*\u00a0 Note that if you wanted the user to be able to add and\r\n\u00a0*\u00a0 remove data elements at runtime, you should start with\r\n\u00a0*\u00a0 AbstractListModel and handle the event reporting part.\r\n\u00a0*\r\n\u00a0*\/\r\n\r\npublic class JavaLocationListModel implements ListModel {\r\n\u00a0 private JavaLocationCollection collection;\r\n\u00a0 \r\n\u00a0 public JavaLocationListModel(JavaLocationCollection collection) {\r\n\u00a0\u00a0\u00a0 this.collection = collection;\r\n\u00a0 }\r\n\r\n\u00a0 public Object getElementAt(int index) {\r\n\u00a0\u00a0\u00a0 return(collection.getLocations()[index]);\r\n\u00a0 }\r\n\r\n\u00a0 public int getSize() {\r\n\u00a0\u00a0\u00a0 return(collection.getLocations().length);\r\n\u00a0 }\r\n\r\n\u00a0 public void addListDataListener(ListDataListener l) {}\r\n\r\n\u00a0 public void removeListDataListener(ListDataListener l) {}\r\n}\r\n\r\n**\/\/\r\n\r\nJavaLocationCollection.java:\r\n\/** A simple collection that stores multiple JavaLocation\r\n\u00a0*\u00a0 objects in an array and determines the number of\r\n\u00a0*\u00a0 unique countries represented in the data.\r\n\u00a0*\r\n\u00a0*\/\r\n\r\npublic class JavaLocationCollection {\r\n\u00a0 private static JavaLocation[] defaultLocations =\r\n\u00a0\u00a0\u00a0 { new JavaLocation(\"Belgium\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"near Liege\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"flags\/belgium.gif\"),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocation(\"Brazil\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"near Salvador\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"flags\/brazil.gif\"),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocation(\"Colombia\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"near Bogota\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"flags\/colombia.gif\"),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocation(\"Indonesia\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"main island\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"flags\/indonesia.gif\"),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocation(\"Jamaica\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"near Spanish Town\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"flags\/jamaica.gif\"),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocation(\"Mozambique\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"near Sofala\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"flags\/mozambique.gif\"),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocation(\"Philippines\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"near Quezon City\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"flags\/philippines.gif\"),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocation(\"Sao Tome\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"near Santa Cruz\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"flags\/saotome.gif\"),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocation(\"Spain\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"near Viana de Bolo\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"flags\/spain.gif\"),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocation(\"Suriname\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"near Paramibo\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"flags\/suriname.gif\"),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocation(\"United States\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"near Montgomery, Alabama\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"flags\/usa.gif\"),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocation(\"United States\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"near Needles, California\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"flags\/usa.gif\"),\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 new JavaLocation(\"United States\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"near Dallas, Texas\",\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"flags\/usa.gif\")\r\n\u00a0\u00a0\u00a0 };\r\n\r\n\u00a0 private JavaLocation[] locations;\r\n\u00a0 private int numCountries;\r\n\r\n\u00a0 public JavaLocationCollection(JavaLocation[] locations) {\r\n\u00a0\u00a0\u00a0 this.locations = locations;\r\n\u00a0\u00a0\u00a0 this.numCountries = countCountries(locations);\r\n\u00a0 }\r\n\u00a0 \r\n\u00a0 public JavaLocationCollection() {\r\n\u00a0\u00a0\u00a0 this(defaultLocations);\r\n\u00a0 }\r\n\r\n\u00a0 public JavaLocation[] getLocations() {\r\n\u00a0\u00a0\u00a0 return(locations);\r\n\u00a0 }\r\n\r\n\u00a0 public int getNumCountries() {\r\n\u00a0\u00a0\u00a0 return(numCountries);\r\n\u00a0 }\r\n\r\n\u00a0 \/\/ Count the number of unique countries in the data.\r\n\u00a0 \/\/ Assumes the list is sorted by country name\r\n\u00a0 private int countCountries(JavaLocation[] locations) {\r\n\u00a0\u00a0\u00a0 int n = 0;\r\n\u00a0\u00a0\u00a0 String currentCountry, previousCountry = \"None\";\r\n\u00a0\u00a0\u00a0 for(int i=0;i\r\n\u00a0*\u00a0 Note that this method can get called lots and lots of times\r\n\u00a0*\u00a0 as you click on entries. We don't want to keep generating \r\n\u00a0*\u00a0 new ImageIcon objects, so we make a Hashtable that associates \r\n\u00a0*\u00a0 previously displayed values with icons, reusing icons for \r\n\u00a0*\u00a0 entries that have been displayed already.\r\n\u00a0* \u00a0\r\n\r\n\r\n\u00a0*\u00a0 Note that in the first release of JDK 1.2, the default \r\n\u00a0*\u00a0 renderer\u00a0 has a bug: the renderer doesn't clear out icons for \r\n\u00a0*\u00a0 later entries. So if you mix plain strings and ImageIcons in \r\n\u00a0*\u00a0 your JList, the plain strings still get an icon. The \r\n\u00a0*\u00a0 call below clears the old icon when the value is not a \r\n\u00a0*\u00a0 JavaLocation.\r\n\u00a0*\r\n\u00a0\r\n\u00a0*\/\r\n\r\npublic class JavaLocationRenderer extends \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DefaultListCellRenderer {\r\n\u00a0 private Hashtable iconTable = new Hashtable();\r\n\u00a0 \r\n\u00a0 public Component getListCellRendererComponent(JList list,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Object value,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int index,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 boolean isSelected,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 boolean hasFocus) {\r\n\u00a0\u00a0\u00a0 \/\/ First build the label containing the text, then \r\n\u00a0\u00a0\u00a0 \/\/ later add the image.\r\n\u00a0\u00a0\u00a0 JLabel label =\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 (JLabel)super.getListCellRendererComponent(list,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 value,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 index,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 isSelected,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 hasFocus);\r\n\u00a0\u00a0\u00a0 if (value instanceof JavaLocation) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 JavaLocation location = (JavaLocation)value;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 ImageIcon icon = (ImageIcon)iconTable.get(value);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 if (icon == null) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 icon = new ImageIcon(location.getFlagFile());\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 iconTable.put(value, icon);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 label.setIcon(icon);\r\n\u00a0\u00a0\u00a0 } else {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ Clear old icon; needed in 1st release of JDK 1.2.\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 label.setIcon(null); \r\n\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0 return(label);\r\n\u00a0 }\r\n}\r\n**\/\/\r\n# JavaLocationListModel.java A custom list model (implements ListModel interface) to store data for a list.\r\n# JavaLocationCollection.java A simple collection of JavaLocation (below) objects.\r\n# JavaLocation.java An object representing a city named Java. Defines the country where the Java \r\ncity is located, along with a comment and country flag<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>All examples, except for FileTransfer use WindowUtilities.java and ExitListener.java. WindowUtilities.java: import javax.swing.*; import java.awt.*;\u00a0\u00a0 \/\/ For Color and Container classes. \/** A few utilities that simplify using windows in Swing. \u00a0* \u00a0 *\/ public class WindowUtilities { \u00a0 \/** Tell system to use native look and feel, as in previous \u00a0\u00a0 *\u00a0 releases. Metal (Java) &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=10265\">Continue reading<\/a><\/p>\n","protected":false},"author":130,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1417,1424],"tags":[706,308,285],"class_list":["post-10265","post","type-post","status-publish","format-standard","hentry","category-code-programming-samples--","category-javaj2eej2me","tag-code","tag-java","tag-285","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":26791,"url":"http:\/\/bangla.sitestree.com\/?p=26791","url_meta":{"origin":10265,"position":0},"title":"Simplifies the setting of native look and feel #Programming Code Examples #Java\/J2EE\/J2ME #Layout Managers","author":"Author-Check- Article-or-Video","date":"May 1, 2021","format":false,"excerpt":"WindowUtilities.java Simplifies the setting of native look and feel. #################### import javax.swing.*; import java.awt.*; \/\/ For Color and Container classes. \/** A few utilities that simplify using windows in Swing. * ################### public class WindowUtilities { \/** Tell system to use native look and feel, as in previous * releases.\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10323,"url":"http:\/\/bangla.sitestree.com\/?p=10323","url_meta":{"origin":10265,"position":1},"title":"Simplifies the setting of native look and feel","author":"","date":"August 26, 2015","format":false,"excerpt":"WindowUtilities.java Simplifies the setting of native look and feel. #################### import javax.swing.*; import java.awt.*;\u00a0\u00a0 \/\/ For Color and Container classes. \/** A few utilities that simplify using windows in Swing. \u00a0* ################### public class WindowUtilities { \u00a0 \/** Tell system to use native look and feel, as in previous \u00a0\u00a0\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26818,"url":"http:\/\/bangla.sitestree.com\/?p=26818","url_meta":{"origin":10265,"position":2},"title":"PluginApplet.jsp  Page that demonstrates the use of jsp:plugin. #Programming Code Examples #Java\/J2EE\/J2ME #JSP","author":"Author-Check- Article-or-Video","date":"May 2, 2021","format":false,"excerpt":"PluginApplet.jsp Page that demonstrates the use of jsp:plugin. Requires you to compile and install PluginApplet.java, TextPanel.java, DrawingPanel.java, and WindowUtilities.java Since these are classes sent to the client to used by applets, the .class files should be in the same directory as the JSP page, not in the WEB-INF\/classes directory where\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10146,"url":"http:\/\/bangla.sitestree.com\/?p=10146","url_meta":{"origin":10265,"position":3},"title":"PluginApplet.jsp Page that demonstrates the use of jsp:plugin.","author":"","date":"August 12, 2015","format":false,"excerpt":"PluginApplet.jsp\u00a0 Page that demonstrates the use of jsp:plugin. Requires you to compile and install PluginApplet.java, TextPanel.java, DrawingPanel.java, and WindowUtilities.java\u00a0 Since these are classes sent to the client to used by applets, the .class files should be in the same directory as the JSP page, not in the WEB-INF\/classes directory where\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10245,"url":"http:\/\/bangla.sitestree.com\/?p=10245","url_meta":{"origin":10265,"position":4},"title":"DOM example that represents the basic structure of an XML document as a JTree","author":"","date":"August 25, 2015","format":false,"excerpt":"\/\/XMLTree.java \/\/Uses the following files Uses the following files: \u00a0\u00a0\u00a0 * XMLFrame.java:Swing application to select an XML document and display in a JTree. ExtensionFileFilter.java Allows you to specify which file extensions will be displayed in a JFileChooser. test.xml Default file loaded if none selected by user. perennials.xml and perennials.dtd Data\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26856,"url":"http:\/\/bangla.sitestree.com\/?p=26856","url_meta":{"origin":10265,"position":5},"title":"DOM example that represents the basic structure of an XML document as a JTree #Programming Code Examples #Java\/J2EE\/J2ME #JavaScript","author":"Author-Check- Article-or-Video","date":"May 3, 2021","format":false,"excerpt":"\/\/XMLTree.java \/\/Uses the following files Uses the following files: * XMLFrame.java:Swing application to select an XML document and display in a JTree. ExtensionFileFilter.java Allows you to specify which file extensions will be displayed in a JFileChooser. test.xml Default file loaded if none selected by user. perennials.xml and perennials.dtd Data on\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10265","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/130"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10265"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10265\/revisions"}],"predecessor-version":[{"id":10266,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10265\/revisions\/10266"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10265"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10265"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10265"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}