Displaying a .jpg on a panel

Whats the easiest way to display a .jpg on a panel? I haven't done this for so long the implementation seems to have changed... when I tried looking it up I got all kinds of confusing junk like prepare image etc.. I don't need to render or do any b.s. Just display it.
Thank you for your time and assistance.

import java.awt.*;
import java.io.*;
import java.net.*;
import javax.imageio.*;
import javax.swing.*;
public class JPGDisplay {
  public static void main(String[] args) {
    String url = "file:images/cougar.jpg";
    Image image = null;
    try {
      image = ImageIO.read(new URL(url));
    catch(MalformedURLException mue) {
      System.out.println(mue.getMessage());
    catch(IOException ioe) {
      System.out.println(ioe.getMessage());
    JLabel imageLabel = new JLabel(new ImageIcon(image));
    JPanel panel = new JPanel();
    panel.add(imageLabel);
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(panel);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setVisible(true);
}

Similar Messages

  • Hi i am new to labview. i want to extract data from a text file and display it on the front panel. how do i proceed??

    Hi i am new to labview
    I want to extract data from a text file and display it on the front panel.
    How do i proceed??
    I have attached a file for your brief idea...
    Attachments:
    extract.jpg ‏3797 KB

    RoopeshV wrote:
    Hi,
    The below code shows how to read from txt file and display in the perticular fields.
    Why have you used waveform?
    Regards,
    Roopesh
    There are so many things wrong with this VI, I'm not even sure where to start.
    Hard-coding paths that point to your user folder on the block diagram. What if somebody else tries to run it? They'll get an error. What if somebody tries to run this on Windows 7? They'll get an error. What if somebody tries to run this on a Mac or Linux? They'll get an error.
    Not using Read From Spreadsheet File.
    Use of local variables to populate an array.
    Cannot insert values into an empty array.
    What if there's a line missing from the text file? Now your data will not line up. Your case structure does handle this.
    Also, how does this answer the poster's question?

  • Displaying a jpg on the browser using a simple http server.....

    Hi
    I've written a simple server which responds by sending a jpg file .
    BROWSER ---request---> SERVER ( reads a jpg file, converts to byte[] and writes to browser )
    ^
    |
    |
    <----response ----------
    So I connect from the browser and the server sends a jpg and I'd to display that. Everything is thru sockets. There is no webserver as such.
    The problem is, I'm getting the text fine, but instead of the picture, I get lots of characters...probably the browser is unable to interpret the jpg . How to I display the jpg ? Do I have to convert the characters in the server code before sending it ?
    Anything to do with Base64 encoding ??
    Thanks !!

    All answers to this question including mine disappeared ??????
    In order to serve an image or any other type of data over the HTTP protocol you have to supply the correct HTTP response header with the data.
    The stream of bytes written to the client should be structured like this:
    A status code followed by several lines of key/value pairs with header information, a blank line and finally the bytes of the image.
    All lines in the header should end with \r\n no matter what OS the server is running.
    HTTP/1.1 200 OK
    Date: Wed, 07 Nov 2001 18:37:47 GMT
    Server: MyServer/0.1
    Content-Type: image/jpeg
    Content-Length: 4321The Content-Length field must have the length of the image data in bytes. The Content-Type field must be the correct mime type for the image data.
    Read RFC 2068 if you want or need more information.

  • Can I obtain the date of the exe and display it on the fropnt panel?

    Hello,
        Is there a way that a Labview program can display the date of the exe and display it on the front panel? I am aware of the version info on the application builder, but I did not see a way to get the date when the exe was created.
    Regards,
    Kaspar

    Hi
    You could use File/Directory Info function in your code like this
    cheers
    David
    Message Edited by David Crawford on 02-24-2010 11:11 PM
    Message Edited by David Crawford on 02-24-2010 11:12 PM
    Attachments:
    App Last Mod.png ‏17 KB

  • PSE11 and 12 will NOT display a JPG i open..... this just occured- have no idea why - please help??

    PSE11 and 12 will NOT display a JPG i open..... this just occured- have no idea why - please help??

    All JPEGs or a particular one?

  • Display of JPG in binary format

    Hi,
    I'd like to diplay a jpg in ABAP WD. This jpg ist stored as binary in a table (several table lines of type raw).
    Could anyone tell me how to display this jpg in ABAP WD.
    Thank you and best regards, Edgar

    Edgar,
    check this link
    https://forums.sdn.sap.com/click.jspa?searchID=26028955&messageID=7306968
    Thanks
    Bala Duvvuri

  • How can i display a JPG image in a JFrame ?

    sample code would be appreciated
    marvinrouge

    Thanks both : it helped
    here is the code given to all jana-net-guys
    it displays from 1.jpg to 12.jpg
    how can i improve it to displays all .jpg and .gif even if their names ARE NOT like <number>.jpg ???
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class PhotoDisplayer extends JFrame implements ActionListener {
         JPanel cp = new JPanel();
         public PhotoDisplayer() {
              getContentPane().setLayout(new BorderLayout());
              setImage(1);
                   cp.add(first);
                   first.addActionListener(this);
                   cp.add(prev);
                   prev.addActionListener(this);
                   cp.add(next);
                   next.addActionListener(this);
                   cp.add(last);
                   last.addActionListener(this);
                   cp.add(exit);
                   exit.addActionListener(this);
              getContentPane().add(cp, BorderLayout.SOUTH);
              pack();
              show();
         public void setImage(String image) {
              ImageIcon ii = new ImageIcon(image);
              if (ii.getIconHeight()>height)
                   height = ii.getIconHeight();
              if (ii.getIconWidth()>width)
                   width = ii.getIconWidth();
              JLabel img = new JLabel(ii);
              JScrollPane sp = new JScrollPane(img);
              getContentPane().removeAll();
              getContentPane().add(sp, BorderLayout.CENTER);
              getContentPane().add(cp, BorderLayout.SOUTH);
              setTitle(image);
              pack();
         public void setImage(int img) {
              setImage("" + img + ".jpg");
         public int image = 1;
         public void moveImage(int dec) {
              if (image+dec>=1 && image+dec<=12) {
                   image += dec;
                   setImage(image);
         public void actionPerformed(ActionEvent event) {
              if (event.getSource()==first)
                   setImage(1);
              if (event.getSource()==prev)
                   moveImage(-1);
              if (event.getSource()==next)
                   moveImage(1);
              if (event.getSource()==last)
                   setImage(12);
              if (event.getSource()==exit)
                   System.exit(0);
         int width = 320;
         int height = 200;
         JButton first = new JButton("First");
         JButton prev = new JButton("Prev");
         JButton next = new JButton("Next");
         JButton last = new JButton("Last");
         JButton exit = new JButton("Exit");
         public static void main(String[] args) {
              new PhotoDisplayer();
         public Dimension getPreferredSize() {
              return new Dimension(width, height);
    }

  • I save two copies of an image, one jpg, one tiff.  LR will not display the jpg or let it be available, only the tiff.   When I try to put another copy of the jpg into the folder LR says the jpg is already there.e

    I converted an rgb image into a grayscale image and saved two copies, one jpg, one tiff, into my chosen folder.
    I tried to import both into LR, which only showed the tiff in the import dialogue.  After import LR only shows the tiff in the folder but when I try to insert the jpg into the folder using Explorer LR reports that the jpg is already in folder.
    How can I get LR to display this jpg image?

    Hi,
    I have an example here that is intended to demonstrate the difference between Positioned and Flowed subforms: http://assure.ly/i8pSdy.
    This shows how you can use a slider to change the dimensions of the image object.
    I have extended this to an example with buttons to scale the image: http://assure.ly/i8ZI5Y
    This may not be fine enough for your purposes, but it may give you some ideas.
    Good luck,
    Niall
    Assure Dynamics

  • Displaying multiple jpgs in applet

    Hello hello
    I'd like a little advice on the best way to display a number of jpegs in an applet - it could be any number of jpg's. My main idea so far is to have a scrollable JPanel (if that's possible) - within the panel, for every jpeg that is received (they will arrive from a socket, one by one) a new button will be created to display the jpeg. So ultimately you have a JPanel with many jpegs inside, and which can be scrolled so that a potentially large number of jpegs may be viewed.
    Is this a realistic idea? And more to the point, are there better ways to do this?
    Cheers
    Steve

    Hi Steve,
    Yes and Yes:
    Yes: I like JTables as the appareance is nice.
    Yes: To change your Table during runtime, you simply change the TableModel.
    That means:
    A JTable constructs itsself with a TableModel. Subclassing AbstractTableModel, you will find the most important methods declared 'abstract'.
    Use getValueAt( int row, int column ), getRowCount() and getColumnCount() as your 'dynamic' methods.
    I assume that you will get your Data over Streams. I assume You will have your images stored in your program as Vector of Images.
    This is just pseudo code. It may not work properly, but I hope that makes it easier to follow my thoughts:
    getColumnCount()
    // four looks fine
    return 4;
    getRowCount()
    return vector.length/4;
    getValueAt( int row, int col )
    int pos = row*4 + col;
    if( pos < vector.length() )
    return vector.getElementAt( pos );
    else
    return ""; // in the case that vector.length is not dividable by 4
    With the TableCellRenderer, you will be able to define the appearence of your image ( like putting it on a Button ).
    Then, you can add an Image to the vector and call tableModel.revalidate() and the JTable should adjust itsself.
    Any questions? ;-)
    Just play around a little bit.
    Good luck!
    Kaethchen

  • How to compare two images and display the difference on Front Panel

    HI..
    I have attached two images.
    I want to compare these two images and subtract the differenc from these two images and display the difference(the mouse) on the front panel
    Anyone can help me?
    Really thanks
    Attachments:
    IMG_2117.JPG ‏1677 KB
    IMG_2118.JPG ‏1650 KB

    The missing thing. You have to keep in mind that what you see is not the same as the camera sees.
    So when using IMAQ Substract it gives you the difference of the value of every single pixel!
    In order to find the mouse as only difference you have to manage that every other pixel value stays the same, e.g. with a proper lightening.
    At the other hand you can combine different filters or alogorithms to get the object, e.g. if the object is darker or brighter then everything else in the image you could use a threshold and then use morphologic operations to get the objects size and position.
    Christian

  • How can I display a JPG Date Taken stamp on images?

    I have several digital JPG images taken that I would like to pull EXIF data from to display a timestamp on the photo.  I know many old cameras used to do this natively, but my iPhone does not imprint the date and time on the images.  I want to pull the data from the JPG so it will display the correct info on the image for when the picture was taken.  Any help is appreciated.  I own Adobe Web Premium CS5.
    Thanks, Bryan

    If the EXIF metadata is in the jpeg you can do what you want using a photoshop script retrieve the date and time in matadata and add a text layer containing a timestamp. Here is an example where more then just the timestamp was stamped onto an image. http://www.mouseprints.net/old/dpr/StampExif.jsx

  • Error displaying a jpg file loaded into a table with blob field

    This may not be the correct forum for this question, but if it isn't could someone direct me to the correct one.
    I have created a table with a blob field in which I have loaded a jpg image. This appeared to work correctly, but when I try to display the image in internet explorer it comes back and tells me that it doesn't recognize the file type. Enclosed is the table create, load, and display pl/sql code. Can anyone tell me what I am doing wrong. Thanks. For the mime/header I used owa_util.mime_header('images/jpg') because my image is a jpg file.
    The database is 10g
    -- Create table
    create table PHOTOS
    IMAGEID NUMBER(10),
    IMAGE BLOB,
    IMAGE_NAME VARCHAR2(50)
    load image
    CREATE OR REPLACE PROCEDURE load_file ( p_id number, p_photo_name in varchar2) IS
    src_file BFILE;
    dst_file BLOB;
    lgh_file BINARY_INTEGER;
    BEGIN
    src_file := bfilename('SNAPUNCH', p_photo_name);
    -- insert a NULL record to lock
    INSERT INTO photos (imageid, image_name, image)
    VALUES (p_id , p_photo_name, EMPTY_BLOB())
    RETURNING image INTO dst_file;
    -- lock record
    SELECT image
    INTO dst_file
    FROM photos
    WHERE imageid = p_id AND image_name = p_photo_name
    FOR UPDATE;
    -- open the file
    dbms_lob.fileopen(src_file, dbms_lob.file_readonly);
    -- determine length
    lgh_file := dbms_lob.getlength(src_file);
    -- read the file
    dbms_lob.loadfromfile(dst_file, src_file, lgh_file);
    -- update the blob field
    UPDATE photos
    SET image = dst_file
    WHERE imageid = p_id
    AND image_name = p_photo_name;
    -- close file
    dbms_lob.fileclose(src_file);
    END load_file;
    display image
    PROCEDURE display_image(p_id NUMBER) IS
    Photo BLOB;
    v_amt NUMBER DEFAULT 4096;
    v_off NUMBER DEFAULT 1;
    v_raw RAW(4096);
    BEGIN
    -- Get the blob image
    SELECT image
    INTO Photo
    FROM PHOTOS
    WHERE IMAGEID = p_id;
    owa_util.mime_header('images/jpg');
    BEGIN
    LOOP
    -- Read the BLOB
    dbms_lob.READ(Photo, v_amt, v_off, v_raw);
    -- Display image
    htp.prn(utl_raw.cast_to_varchar2(v_raw));
    v_off := v_off + v_amt;
    v_amt := 4096;
    END LOOP;
    dbms_lob.CLOSE(Photo);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    END;
    END;
    The url I enter is: http://webdev:7777/tisinfo/tis.tiss0011.Display_Image?p_id=1

    Just a little more information. When I enter owa_util.mime_header('image/jpeg') I can't display the file. It just shows up with a red x for the file.
    When I enter owa_util.mime_header('image/jpg') it displays the file, but in the format
    ¿¿¿¿JFIF¿¿-Intel(R) JPEG Library, version [2.0.16.48]¿¿C
    This is the way I would expect it to look if I opened it with Notepad, or an application that doesn't recognize jpg files. Can anyone tell me what I am doing wrong?? Thanks.

  • Displaying a timeline on a panel

    Hi everyone!!
    I am trying to develop a project management tool, so I need to know the best way of implementing a timeline (in months) to display on a JPanel. Basically, when the user selects a start date and duration of the project, I need a timeline to appear depending on what the user has selected from the combo box. The timeline needs to start from the start date and continue for x amount of months (where x is the duration). At the moment I have used loads of switch statements, but there must be a much better and efficient way of implementing this. If anyone can help me with this then it will be most appreciated. My code is provided below which can be complied and run from the "NewChartTest" class file. Thanks.
    * NewChartTest.java
    * 23/11/02 (Date start)
    * This class is for test purposes for
    * the "New Chart" wizard
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class NewChartTest extends JPanel
    private JButton newButton;
    public JFrame wizardFrame;
    static NewChartTest instance;     
    public NewChartTest()
         instance = this;
    // create new button
    newButton = new JButton("New Chart");
    // create tooltip for every button
    newButton.setToolTipText("New Chart");
    // add our button to the JPanel
    add(newButton);
    // construct button action
    NewButtonListener listener1 = new NewButtonListener();
    // Add action listener to button
    newButton.addActionListener(listener1);
    private class NewButtonListener implements ActionListener
    public void actionPerformed(ActionEvent evt)
    wizardFrame = new JFrame("New Chart Wizard*");
    NewWizardPanel wizardPanel = new NewWizardPanel();
    wizardFrame.getContentPane().add(wizardPanel);
    wizardFrame.setSize(410, 280);
    wizardFrame.setVisible(true);
    // Main entry point into the ToolBarPanel class
    public static void main(String[] args)
    // Create a frame to hold us and set its title
    JFrame frame = new JFrame("New Chart Test");
    // Set frame to close after user request
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // Add our tab panel to the frame
    NewChartTest nct = new NewChartTest();
    frame.getContentPane().add(nct, BorderLayout.CENTER);
    // Resize the frame
    frame.setSize(680, 480);
    // Make the windows visible
    frame.setVisible(true);
    * NewWizardPanel.java
    * 23/11/02 (Date start)
    * This class is for test purposes for
    * the "New Chart" wizard
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class NewWizardPanel extends JPanel
    private JLabel projectNameLabel;
    private JLabel maxCharacterLabel;
    private JLabel durationLabel;
    private JLabel monthLabel;
    private JLabel startDate;
    private JLabel forwardDash;
    private JLabel forwardDash1;
    private JLabel dateFormatLabel;
    public JTextField projectName;
    private JComboBox projectDay;
    private JComboBox projectMonth;
    private JComboBox projectYear;
    private JComboBox projectDuration;
    public String daySelect;
    public String monthSelect;
    public String yearSelect;
    public String durationSelect;
    private JButton okButton;
    private JButton cancelButton;
    private JFrame wizardFrame;
    private JFrame drawChart;
    static NewWizardPanel instance1;
    public NewWizardPanel()
    instance1 = this;
    // create additional panels to hold objects
    JPanel topPanel = new JPanel();
    JPanel middlePanel = new JPanel();
    JPanel lowerPanel = new JPanel();
    JPanel buttonPanel = new JPanel();
    // Create a border around the "toppanel"
    Border etched = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.black, Color.blue);
    Border titled = BorderFactory.createTitledBorder(etched, "Please provide a title to your project");
    topPanel.setBorder(titled);
    // Create a border around the "middlepanel"
    Border etched1 = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.black, Color.blue);
    Border titled1 = BorderFactory.createTitledBorder(etched1, "Please enter the start date of your project");
    middlePanel.setBorder(titled1);
    // Create a border around the "lowerpanel"
    Border etched2 = BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.black, Color.blue);
    Border titled2 = BorderFactory.createTitledBorder(etched2, "Please select the duration of your project");
    lowerPanel.setBorder(titled2);
    // initialise label objects
    projectNameLabel = new JLabel("Project Name", JLabel.LEFT);
    maxCharacterLabel = new JLabel("(Max 20 Chars)");
    durationLabel = new JLabel("Duration (in months)", JLabel.LEFT);
    monthLabel = new JLabel("(1 - 12 months)");
    startDate = new JLabel("Project Start Date", JLabel.LEFT);
    forwardDash = new JLabel("/");
    forwardDash1 = new JLabel("/ 20");
    dateFormatLabel = new JLabel("(e.g. 31/12/02)");
    projectName = new JTextField(20);
    projectName.setColumns(15);
    topPanel.validate();
    String[] theDay = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16",
    "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"};
    projectDay = new JComboBox(theDay);
    projectDay.setEditable(false);
    String[] theMonth = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};
    projectMonth = new JComboBox(theMonth);
    projectMonth.setEditable(false);
    String[] theYear = {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"};
    projectYear= new JComboBox(theYear);
    projectYear.setEditable(false);
    String[] theDuration = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"};
    projectDuration = new JComboBox(theDuration);
    projectDuration.setEditable(false);
    // initialise buttons
    okButton = new JButton("Ok", new ImageIcon("D:/My Uni Work/Final Year Project/Test/ok.gif"));
    cancelButton = new JButton("Cancel", new ImageIcon("D:/My Uni Work/Final Year Project/Test/cancel.gif"));
    // set tooltips for buttons
    okButton.setToolTipText("Ok");
    cancelButton.setToolTipText("Cancel");
    // add objects to panels
    topPanel.add(projectNameLabel);
    topPanel.add(projectName);
    topPanel.add(maxCharacterLabel);
    middlePanel.add(startDate);
    middlePanel.add(projectDay);
    middlePanel.add(forwardDash);
    middlePanel.add(projectMonth);
    middlePanel.add(forwardDash1);
    middlePanel.add(projectYear);
    middlePanel.add(dateFormatLabel);
    lowerPanel.add(durationLabel);
    lowerPanel.add(projectDuration);
    lowerPanel.add(monthLabel);
    buttonPanel.add(okButton);
    buttonPanel.add(cancelButton);
    // create instance of cancelButtonListener
    CancelButtonListener cancelListen = new CancelButtonListener();
    // create instance of okButtonListner
    OkButtonListener okListen = new OkButtonListener();
    // add actionListener for the cancel/ok button
    cancelButton.addActionListener(cancelListen);
    okButton.addActionListener(okListen);
    // use Box layout to arrange panels
    Box hbox2 = Box.createHorizontalBox();
    hbox2.add(topPanel);
    Box hbox3 = Box.createHorizontalBox();
    hbox3.add(middlePanel);
    Box hbox4 = Box.createHorizontalBox();
    hbox4.add(lowerPanel);
    Box hbox5 = Box.createHorizontalBox();
    hbox5.add(buttonPanel);
    Box vbox = Box.createVerticalBox();
    vbox.add(hbox2);
    vbox.add(Box.createGlue());
    vbox.add(hbox3);
    vbox.add(Box.createGlue());
    vbox.add(hbox4);
    vbox.add(Box.createGlue());
    vbox.add(hbox5);
    this.add(vbox, BorderLayout.NORTH);
    private class CancelButtonListener implements ActionListener
    public void actionPerformed(ActionEvent event)
    Object source = event.getSource();
    if(source == cancelButton)
    NewChartTest.instance.wizardFrame.setVisible(false);
    private class OkButtonListener implements ActionListener
    public void actionPerformed(ActionEvent event)
    String nameText = projectName.getText().trim();
    int textSize = nameText.length();
    daySelect = (String)projectDay.getSelectedItem();
    monthSelect = (String)projectMonth.getSelectedItem();
    yearSelect = (String)projectYear.getSelectedItem();
    durationSelect = (String)projectDuration.getSelectedItem();
    if(textSize > 20)
    //display a JOptionPane
    JOptionPane.showMessageDialog(NewWizardPanel.instance1, "You have entered a title that is greater than 20 characters. Please change this.",
    "Text too Long", JOptionPane.ERROR_MESSAGE);
    else if(textSize == 0)
    //display a JOptionPane
    JOptionPane.showMessageDialog(NewWizardPanel.instance1, "You have not entered a project name. Please do so (Maximum 20 Characters).",
    "No Project Name Entered", JOptionPane.ERROR_MESSAGE);
    else if(daySelect == "30" && monthSelect == "02" || daySelect == "31" && monthSelect == "02" || daySelect == "31" && monthSelect == "04" ||
    daySelect == "31" && monthSelect == "06" || daySelect == "31" && monthSelect == "09" || daySelect == "31" && monthSelect == "11")
    JOptionPane.showMessageDialog(NewWizardPanel.instance1, "You have selected an invalid date. Please re-check that the date is valid.",
    "Invalid Date Selected", JOptionPane.ERROR_MESSAGE);
    else
    NewChartTest.instance.wizardFrame.setVisible(false);
    drawChart = new JFrame("Milestone Chart Panel");
    DrawPanel drawingChart = new DrawPanel();
    drawChart.getContentPane().add(drawingChart);
    drawChart.setSize(1000, 510);
    drawChart.setVisible(true);
    * DrawPanel.java
    * 27/11/02 (Date start)
    * This class is for test purposes for
    * the "New Chart" wizard
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.io.*;
    public class DrawPanel extends JPanel
    private JLabel aName;
    private JLabel date;
    private JLabel day;
    private JLabel forwardSlash1;
    private JLabel month;
    private JLabel forwardSlash2;
    private JLabel year;
    private JLabel empty;
    private JLabel startingMonth;
    private JPanel nameHolder;
    private JPanel dateHolder;
    private JPanel emptyPanel;
    private JPanel calendarPanel;
    private JPanel timelinePanel;
    private JPanel zoomInButtonPanel;
    private JPanel zoomOutButtonPanel;
    private JTextField projectName;
    private String daySelect;
    private JButton zoomIn;
    private JButton zoomOut;
    private JScrollPane timeLineScroll;
    private String theDuration;
    private String startMonth;
    private String monthStart;
    private String[] theMonths = {"January", "February", "March", "April", "May", "June", "July", "August",
    "September", "October", "November", "December"};
    //private String requiredMonths;
    public DrawPanel()
    nameHolder = new JPanel();
    dateHolder = new JPanel();
    emptyPanel = new JPanel();
    calendarPanel = new JPanel();
    calendarPanel.setBackground(Color.white);
    timelinePanel = new timeLinePanel();
    timelinePanel.setBackground(Color.white);
    zoomInButtonPanel = new JPanel();
    zoomInButtonPanel.setBackground(Color.black);
    zoomOutButtonPanel = new JPanel();
    zoomOutButtonPanel.setBackground(Color.black);
    String name = NewWizardPanel.instance1.projectName.getText().trim();
    aName = new JLabel(name, JLabel.CENTER);
    date = new JLabel("Date Start:");
    String dayStart = NewWizardPanel.instance1.daySelect;
    day = new JLabel(dayStart);
    forwardSlash1 = new JLabel("/");
    monthStart = NewWizardPanel.instance1.monthSelect;
    month = new JLabel(monthStart);
    forwardSlash2 = new JLabel("/");
    String yearStart = NewWizardPanel.instance1.yearSelect;
    year = new JLabel(yearStart);
    empty = new JLabel(" ");
    // initialise buttons required for panel
    zoomIn = new JButton(new ImageIcon("D:/My Uni Work/Final Year Project/Test/zoomIn.gif"));
    zoomOut = new JButton(new ImageIcon("D:/My Uni Work/Final Year Project/Test/zoomOut.gif"));
    // set the tool tips for the buttons
    zoomIn.setToolTipText("Zoom In");
    zoomOut.setToolTipText("Zoom Out");
    theDuration = NewWizardPanel.instance1.durationSelect;
    drawTimeLine(monthStart, theDuration);
    nameHolder.add(aName);
    dateHolder.add(date);
    dateHolder.add(day);
    dateHolder.add(forwardSlash1);
    dateHolder.add(month);
    dateHolder.add(forwardSlash2);
    dateHolder.add(year);
    emptyPanel.add(empty);
    zoomInButtonPanel.add(zoomIn);
    zoomOutButtonPanel.add(zoomOut);
    dateHolder.setPreferredSize(new Dimension(200, 30));
    emptyPanel.setPreferredSize(new Dimension(750, 30));
    calendarPanel.setPreferredSize(new Dimension(950, 30));
    timelinePanel.setPreferredSize(new Dimension(950, 300));
    zoomInButtonPanel.setPreferredSize(new Dimension(100, 50));
    zoomOutButtonPanel.setPreferredSize(new Dimension(100, 50));
    // use Box layout to arrange panels
    Box hbox1 = Box.createHorizontalBox();
    hbox1.add(nameHolder);
    Box hbox2 = Box.createHorizontalBox();
    hbox2.add(dateHolder);
    hbox2.add(emptyPanel);
    Box hbox3 = Box.createHorizontalBox();
    hbox3.add(calendarPanel);
    Box hbox4 = Box.createHorizontalBox();
    hbox4.add(timelinePanel);
    Box hbox5 = Box.createHorizontalBox();
    hbox5.add(zoomOutButtonPanel);
    hbox5.add(zoomInButtonPanel);
    Box vbox = Box.createVerticalBox();
    vbox.add(hbox1);
    vbox.add(Box.createGlue());
    vbox.add(hbox2);
    vbox.add(Box.createGlue());
    vbox.add(hbox3);
    vbox.add(Box.createGlue());
    vbox.add(hbox4);
    vbox.add(Box.createGlue());
    vbox.add(hbox5);
    this.add(vbox, BorderLayout.NORTH);
    public void drawTimeLine(String aStartMonth, String aDuration)
    if(monthStart == "01")
    startMonth = theMonths[0];
    System.out.println(theDuration);
    int duration = Integer.parseInt(theDuration);
    switch(duration)
    case 1:
    JLabel months = new JLabel(startMonth);
    calendarPanel.add(months);
    break;
    case 2:
    JLabel months1 = new JLabel(startMonth + " " + theMonths[1]);
    calendarPanel.add(months1);
    break;
    case 3:
    JLabel months2 = new JLabel(startMonth + " " + theMonths[1] + " " + theMonths[2]);
    calendarPanel.add(months2);
    break;
    case 4:
    JLabel months3 = new JLabel(startMonth + " " + theMonths[1] + " " + theMonths[2] + " " + theMonths[3]);
    calendarPanel.add(months3);
    break;
    case 5:
    JLabel months4 = new JLabel(startMonth + " " + theMonths[1] + " " + theMonths[2] + " " + theMonths[3] + " " + theMonths[4]);
    calendarPanel.add(months4);
    break;
    case 6:
    JLabel months5 = new JLabel(startMonth + " " + theMonths[1] + " " + theMonths[2] + " " + theMonths[3] + " " + theMonths[4]
    + " " + theMonths[5]);
    calendarPanel.add(months5);
    break;
    case 7:
    JLabel months6 = new JLabel(startMonth + " " + theMonths[1] + " " + theMonths[2] + " " + theMonths[3] + " " + theMonths[4]
    + " " + theMonths[5] + " " + theMonths[6]);
    calendarPanel.add(months6);
    break;
    case 8:
    JLabel months7 = new JLabel(startMonth + " " + theMonths[1] + " " + theMonths[2] + " " + theMonths[3] + " " + theMonths[4]
    + " " + theMonths[5] + " " + theMonths[6] + " " + theMonths[7]);
    calendarPanel.add(months7);
    break;
    case 9:
    JLabel months8 = new JLabel(startMonth + " " + theMonths[1] + " " + theMonths[2] + " " + theMonths[3] + " " + theMonths[4]
    + " " + theMonths[5] + " " + theMonths[6] + " " + theMonths[7] + " " + theMonths[8]);
    calendarPanel.add(months8);
    break;
    case 10:
    JLabel months9 = new JLabel(startMonth + " " + theMonths[1] + " " + theMonths[2] + " " + theMonths[3] + " " + theMonths[4]
    + " " + theMonths[5] + " " + theMonths[6] + " " + theMonths[7] + " " + theMonths[8] + " " + theMonths[9]);
    calendarPanel.add(months9);
    break;
    case 11:
    JLabel months10 = new JLabel(startMonth + " " + theMonths[1] + " " + theMonths[2] + " " + theMonths[3] + " " + theMonths[4]
    + " " + theMonths[5] + " " + theMonths[6] + " " + theMonths[7] + " " + theMonths[8] + " " + theMonths[9] + " " + theMonths[10]);
    calendarPanel.add(months10);
    break;
    case 12:
    JLabel months11 = new JLabel(startMonth + " " + theMonths[1] + " " + theMonths[2] + " " + theMonths[3] + " " + theMonths[4]
    + " " + theMonths[5] + " " + theMonths[6] + " " + theMonths[7] + " " + theMonths[8] + " " + theMonths[9] + " " + theMonths[10] + " " + theMonths[11]);
    calendarPanel.add(months11);
    break;
    } // + loads more "if else" and "switch" statements - there must be an easier and more effiecient way!!!!
    class timeLinePanel extends JPanel
    private int x1 = 50;
    private int x2 = 50;
    private int y1 = 7;
    private int y2 = 13;
    public void paintComponent(Graphics g)
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
    Line2D timeLine = new Line2D.Double(50, 10, 900, 10);
    g2.draw(timeLine);
    g2.setColor(Color.blue);
    Line2D separatorStart = new Line2D.Double(50, 7, 50, 13);
    g2.draw(separatorStart);
    Line2D separatorEnd = new Line2D.Double(900, 7, 900, 13);
    g2.draw(separatorEnd);
    Line2D Separator1 = new Line2D.Double(x1 + 100 , y1, x2 + 100, y2);
    g2.draw(Separator1);
    Line2D separator2 = new Line2D.Double(x1 + 200, y1, x2 + 200, y2);
    g2.draw(separator2);
    Line2D separator3 = new Line2D.Double(x1 + 300, y1, x2 + 300, y2);
    g2.draw(separator3);
    Line2D separator4 = new Line2D.Double(x1 + 400, y1, x2 + 400, y2);
    g2.draw(separator4);
    Line2D separator5 = new Line2D.Double(x1 + 500, y1, x2 + 500, y2);
    g2.draw(separator5);
    Line2D separator6 = new Line2D.Double(x1 + 600, y1, x2 + 600, y2);
    g2.draw(separator6);
    Line2D separator7 = new Line2D.Double(x1 + 700, y1, x2 + 700, y2);
    g2.draw(separator7);
    Line2D separator8 = new Line2D.Double(x1 + 800, y1, x2 + 800, y2);
    g2.draw(separator8);
    //Line2D separator9 = new Line2D.Double(x1 + 900, y1, x2 + 900, y2);
    //g2.draw(separator9);
    g2.setColor(Color.lightGray);
    Line2D dividerLine = new Line2D.Double(150, 14, 150, 300);
    g2.draw(dividerLine);
    Line2D dividerLine1 = new Line2D.Double(250, 14, 250, 300);
    g2.draw(dividerLine1);
    Line2D dividerLine2 = new Line2D.Double(350, 14, 350, 300);
    g2.draw(dividerLine2);
    Line2D dividerLine3 = new Line2D.Double(450, 14, 450, 300);
    g2.draw(dividerLine3);
    Line2D dividerLine4 = new Line2D.Double(550, 14, 550, 300);
    g2.draw(dividerLine4);
    Line2D dividerLine5 = new Line2D.Double(650, 14, 650, 300);
    g2.draw(dividerLine5);
    Line2D dividerLine6 = new Line2D.Double(750, 14, 750, 300);
    g2.draw(dividerLine6);
    Line2D dividerLine7 = new Line2D.Double(850, 14, 850, 300);
    g2.draw(dividerLine7);

    Haven't looked at all your code by can't you use a loop?
    int index = comboBox.getSelectedIndex();
    StringBuffer buf = new StringBuffer("Start Month ");
    JLabel label = new JLabel();
    for (int counter = 0; counter < index; ++ counter)
    buf.append(theMonths[counter] + " ");
    label.setText(buf.toString());

  • Display documents (jpg,doc,tff,ppt,pps,xls,pdf etc) in web dynpro

    Hi experts,
                    I have a requirement to upload the document of any type (jpg,doc,tff,ppt,pps,xls,pdf etc)  to a Z table (may be in a binary format) in a web dynpro application.
    I think this can be achieved through Fileupload view element.
    In another  window, I need to display the document based on what is selected in the table row. Which control or method can display any type of document?  As far as I know, the office control view element can only display documents of type (.doc and .xls).
    Please provide pointers on this or any example will help me.
    Thanks,
    AmitJain

    Abhimanyu,
                  Thanks for the reply. Wonderful it worked like a miracle.
    Awarded full points.
    Thanks
    Code I used in the action:  onactionclick
    METHOD onactionclick .
      DATA: content TYPE xstring.
      DATA:  lr_context_view_node          TYPE REF TO if_wd_context_node.
      wd_context->get_attribute(
          EXPORTING
            name =  `PDF`
          IMPORTING
            value = content ).
      CALL METHOD cl_wd_runtime_services=>attach_file_to_response
        EXPORTING
          i_filename      = 'Default_pdf.pdf'
          i_content       =   content
          i_mime_type     =   'pdf'
         i_in_new_window = ABAP_FALSE
         i_inplace       = ABAP_FALSE
    ENDMETHOD.
    Edited by: Amit Jain on Apr 2, 2009 5:46 PM

  • Problem displaying the JPG in Netscape ?!!

    I have a another problem,
    I have a jpg and i'm trying to display using servlet(out.println).
    The picture doesn't show in the Netscape but it does in the IE.
    Any clue ?
    Code is here...
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    String imagepath = "C:/Ora9idev/jdev/images/head.jpg";
    // String imagepath = "dphhead.jpg";
    response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();
    out.println("<html>\n" +
    "<head><title>Servlet2</title></head>" +
    "<body> \n" +
    "<div> \n" +
    "<img src=\"" + imagepath + "\" > \n " +
    "</div> \n" +
    "</body> \n" +
    "</html>");
    out.close();
    Thanks in advance

    James, what your IMG tag is referring to is a hard-coded local path. If your client (browser) happens to run on the same system as the server (servlet), it may or may not resolve the local reference. But anyway that's not how web apps work, and you should return a URL and have some server or container capable of serving that static content.
    I hope it makes sense, cheers,
    B.

Maybe you are looking for

  • Error-can't view photos in photo library using this version of iphoto .

    Hi, I recently bought a macbook air and wanted to transfer pictures to it from my old mac (macbook 10.4.11). I viewed the pictures through file sharing, but was unable to finish saving most of the pictures that day. When I try and view my iphoto phot

  • Use iMac monitor for PS2?

    Not sure if this is possible... Might be a stupid question. Any way I can plug my playstation 2 into my iMac to use it as a monitor?

  • Whoa! If specify custom Policy Provider, then JVM has no ProtectionDomain!!

    What is going on here? I copied the sun.security.provider.PolicyFile class into another folder and then used -Xbootclasspath to specify that folder, and then in java.security I said to use that one as the provider. When I do that, then AccessControll

  • How do I end a task before opening?

    I'm trying to create a pdf and a window comes up telling me there is an error. I need to end the task before opening this file? How do I do this?!?!?!

  • FORM within a FORM

    Trying to display listings of a search for a bookstore, and then either display a review of the book OR select the item and put it in the shopping cart. I have a large FORM which puts the selected items into the shopping cart and I would like to post