Francesco Furfari | ec7e175 | 2006-10-02 13:37:04 +0000 | [diff] [blame] | 1 | /*
|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one
|
| 3 | * or more contributor license agreements. See the NOTICE file
|
| 4 | * distributed with this work for additional information
|
| 5 | * regarding copyright ownership. The ASF licenses this file
|
| 6 | * to you under the Apache License, Version 2.0 (the
|
| 7 | * "License"); you may not use this file except in compliance
|
| 8 | * with the License. You may obtain a copy of the License at
|
Francesco Furfari | 91af5da | 2006-04-04 23:44:23 +0000 | [diff] [blame] | 9 | *
|
Francesco Furfari | ec7e175 | 2006-10-02 13:37:04 +0000 | [diff] [blame] | 10 | * http://www.apache.org/licenses/LICENSE-2.0
|
Francesco Furfari | 91af5da | 2006-04-04 23:44:23 +0000 | [diff] [blame] | 11 | *
|
Francesco Furfari | ec7e175 | 2006-10-02 13:37:04 +0000 | [diff] [blame] | 12 | * Unless required by applicable law or agreed to in writing,
|
| 13 | * software distributed under the License is distributed on an
|
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
| 15 | * KIND, either express or implied. See the License for the
|
| 16 | * specific language governing permissions and limitations
|
| 17 | * under the License.
|
Francesco Furfari | 91af5da | 2006-04-04 23:44:23 +0000 | [diff] [blame] | 18 | */
|
| 19 |
|
| 20 | package org.apache.felix.upnp.tester;
|
| 21 |
|
| 22 | import java.awt.Image;
|
| 23 | import java.net.URL;
|
| 24 |
|
| 25 | import javax.swing.ImageIcon;
|
| 26 | import javax.swing.JFrame;
|
| 27 | import javax.swing.JLabel;
|
| 28 | import javax.swing.JPanel;
|
Francesco Furfari | f2a6791 | 2006-07-17 17:08:02 +0000 | [diff] [blame] | 29 | /*
|
Karl Pauls | d312acc | 2007-06-18 20:38:33 +0000 | [diff] [blame^] | 30 | * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
|
Francesco Furfari | f2a6791 | 2006-07-17 17:08:02 +0000 | [diff] [blame] | 31 | */
|
Francesco Furfari | 91af5da | 2006-04-04 23:44:23 +0000 | [diff] [blame] | 32 |
|
| 33 | public class test extends JFrame {
|
| 34 |
|
| 35 | Image image;
|
| 36 |
|
| 37 | public test(String filename) {
|
| 38 | super(filename);
|
| 39 | setDefaultCloseOperation(EXIT_ON_CLOSE);
|
| 40 | //image = getToolkit().getImage(filename);
|
| 41 | ImageIcon image =loadIcon("EventedStateVariable");
|
| 42 | //image.setImageObserver(this);
|
| 43 | JPanel panel = new JPanel();
|
| 44 |
|
| 45 | panel.add(new JLabel(image));
|
| 46 | JLabel lab = new JLabel();
|
| 47 | lab.setIcon(image);
|
| 48 | panel.add(lab);
|
| 49 | this.getContentPane().add(panel);
|
| 50 | }
|
| 51 |
|
| 52 | /*public void paint(Graphics g) {
|
| 53 | super.paint(g);
|
| 54 | g.drawImage(image, 25, 25, this);
|
| 55 | }*/
|
| 56 |
|
| 57 | public static void main(String args[]) {
|
| 58 | if (args.length > 0) {
|
| 59 | JFrame f = new test(args[0]);
|
| 60 | f.setSize(300, 300);
|
| 61 | f.show();
|
| 62 | } else {
|
| 63 | System.err.println(
|
| 64 | "You must specify an image filename to display");
|
| 65 | }
|
| 66 | }
|
| 67 |
|
| 68 |
|
| 69 | public static ImageIcon loadIcon(String name)
|
| 70 | {
|
| 71 | try {
|
| 72 | //System.out.println("loading image ..."+path);
|
| 73 | URL eventIconUrl = test.class.getResource("images/" + name + ".gif");
|
| 74 | return new ImageIcon(eventIconUrl,name);
|
| 75 | }
|
| 76 | catch (Exception ex){
|
| 77 | System.out.println("Resource:" + name + " not found : " + ex.toString());
|
| 78 | return null;
|
| 79 | }
|
| 80 | }
|
| 81 |
|
Karl Pauls | d312acc | 2007-06-18 20:38:33 +0000 | [diff] [blame^] | 82 | } |