Swing class help needed

hi, i just need some help to create a bar kind of object (like a bar of battery shown in mobile phones).
the information i have is in percentage from 0-100%. and what i have planned is that:
the bar will be split into four:
from 0-25: one bar will be colored green.
26-49 "
50-74 "
75-100 "
the bar information will be from the battery left percentage as mentioned above.
also if the battery is below 25% the GUI should give an alert (possible red screen with big "alert"..)
I started doing the frame but got stuck on the bar. pls can you help.
im looking for nothing complex like make it very accurate to each value of infor. thanks

I am sorry if the Gradients were a bit confusing and they weren't exactly what you were asking for but that is what I did for my program.
What you will do is that your meter will have basically 4 Rectangle objects.
The logic to determine which Rectangles you will paint to the screen will intuitively go into the paint(Graphics g) method.
Pseudo-Code:
public void paint(Graphics g) {
  //set desired color on graphics context
  //switch percentage
  //case percentage = 100
  //fill Rectangle1
  //case percentage <= 75%
  //fill rectangle 2
  //case percentage <= 50%
  //fill rectangle 3
  //case percentage <= 25%
  //fill rectangle 4
  //end switch
Keep in mind not to put break statements in your switch so that all necessary blocks get colored.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • GUI swing class help needed

    hi, i just need some help to create a bar kind of object (like a bar of battery shown in mobile phones).
    the information i have is in percentage from 0-100%. and what i have planned is that:
    the bar will be split into four:
    from 0-25: one bar will be colored green.
    26-49 "
    50-74 "
    75-100
    the bar information will be from the battery left percentage as mentioned above.
    also if the battery is below 25% the GUI should give an alert (possible red screen with big "alert"..)
    I started doing the frame but got stuck on the bar. pls can you help.
    im looking for nothing complex like make it very accurate to each value of infor. thanks

    Hi,
    You can use a JProgressBar (min 0 max 4)...
    Or make a custom bar with some filled rectangles ...
    Olek
    Edited by: Olek on Oct 11, 2007 10:01 AM

  • Testing a class help needed

    Hi, I have to do the following :
    (1)Write a class called Student with the following private member variables:
    name [String]
    id [long]
    marks [float]
    (2)It must have the following methods:
    Methods to set name, set ID, and set marks
    Eg: public void setName(String newName) { … }
    Methods getName, getID, getMarks, eg:
    public long getID() {
    return id;
    (3)Note that the set and get methods do not normally display messages on screen. However, setMarks should display an error if the marks are not in the range 0 - 100, and set the member variable marks to 0.
    (4)To test the Student class, write a Test Class that creates a Student object and sets its name, ID and marks. The program should then display the student's name and marks in a message box.
    Its parts (3) and (4) Im having trouble with. Im not sure is part 3 correct and cant check it if I dont know what to do for part 4
    import javax.swing.JOptionPane;
    public class Student {
          * OBP
         private String name;  // Student's name.
         private long ID;  // Unique ID number for this student.
         private float marks;   // Grade
         private static int nextUniqueID = 0;
         // keep track of next available unique ID number
         Student(String newName)
              // Names Student, assigns the student a unique ID number
              name = newName;
              nextUniqueID++;
              ID = nextUniqueID;
         public String getName()
              return name;
         public long getID()
              return ID;
         public float getMarks()
              return marks;
         public void setName(String newName)
              name = newName;
         public void setID(long newID)
              ID = newID;
         public void setMarks(float newMarks)
              if (newMarks >=0 && newMarks <=100)
              marks = newMarks;
              else
                   JOptionPane.showMessageDialog(null, "Marks must be >=0 and <=100");
                   marks=0;
    }Im still new to this so be gentle :P
    Thanks

    pierrot_2 wrote:
    >
    No, not quite. It means, if you want to do this...
    Student mySt = new Student();... then your Student class has to have this...
    public class Student{
    public Student(){
    }... but it doesn't, so you can't.Just figured that one out.
    Huh? You're the one who said what the syntax should be with the private variables and public methods etc. So instead of doing this...
    mySt.setID;//wrong syntax... you have to follow the rules you wrote in the Student class definition...
    mySt.setID((long)34);//right syntax... but then on this particular method, your Student class has already assigned an ID value (in the constructor), so that undermines your own logic.Its an assignment, hence not technically my logic, just doing what it says and now trying to understand it.
    ... that's what I'd like to know.If you look at the first post its clearly an assignment I needed help with and it tells you what to do, which I (Yes, "I") did, so now trying to do the Test Class and understand it is the tricky bit.
    New Student class (so far):
    import javax.swing.JOptionPane;
    public class Student {
         private String name;  // Student's name.
         private long ID;  // ID number for this student.
         private float marks;   // Grade
         public Student()
         //Removed Unique ID part...Should this do something??
         public String getName()
              return name;
         public long getID()
              return ID;
         public float getMarks()
              return marks;
         public void setName(String newName)
              name = newName;
         public void setID(long newID)
              ID = newID;
         public void setMarks(float newMarks)
              if (newMarks >=0 && newMarks <=100)
                   marks = newMarks;
              else
                   JOptionPane.showMessageDialog(null, "Marks must be >=0 and <=100");
                   marks=0;
    }New Test class:
    import javax.swing.JOptionPane;
    public class Test{
         public static void main(String[] args)
              String newName = "Dave";
              long newID = 8731543;
              float newMarks = 1010;
              Student mySt = new Student();
              mySt.setName(newName);
              mySt.setID(newID);
              mySt.setMarks(newMarks);
              JOptionPane.showMessageDialog(null, "Name: " + newName + " Marks: " + newMarks );
    }The error message that mark is >100 comes up but then so does "Name: Dave Marks:1010.0" even though marks should be set to 0?
    Am I still far off? Its 2:45am here and I need to hand this in as soon as possible so am I in for an all nighter?

  • Launching Browser From Swing Application - Help Needed

    Hi,
    I am opening a HTML file in Internet Explorer from my swing application.
    I am using the code given below
    private final static String WIN_FLAG = "url.dll,FileProtocolHandler";
    private final static String WIN_PATH = "rundll32";
    String cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
    // url is HTML file Path
    Process p = Runtime.getRuntime().exec( cmd );
    The HTML file is opening up,but it always opens behind the swing application,that makes me every time to maximize the HTML file after it being opened up.
    I want to open it in front of the Swing Application.
    Any Help Please ?
    - Manikandan

    Browser Utility - Class to launch a URL in a web browser in
    a platform independent manner. Includes an optional swing
    GUI allowing user customization. [Open Source - GPL]
    http://ostermiller.org/utils/Browser.html
    BrowserLauncher - Open the system web browser with
    particular attention paid to various Macintosh systems.
    (Freeware)
    http://browserlauncher.sourceforge.net/
    Java World - With a little platform-specific Java code, you
    can easily use your system's default browser to display any
    URL in Windows or Unix.
    http://www.javaworld.com/javaworld/javatips/jw-javatip66.html
    JConfig - Class Libraries that allow a URL to be launched in
    a browser on Windows, Unix, or Macintosh. [Commercial]
    http://www.tolstoy.com/samizdat/jconfig.html
    Apple - MRJFileUtils.openURL() not implemented in Mac OS X.
    http://developer.apple.com/techpubs/macosx/ReleaseNotes/JavaGMWebReleaseNotes.html#MRJToolkit
    Apple - How one would open a URL in a web browser on a
    Macintosh.
    http://developer.apple.com/qa/java/java12.html

  • Swing browser help needed

    I am developing desktop application which has a functionality of web browser i have tried JEditorPanel which is used to load html pages.
    the problem with this is it doesnt load even google.com or yahoo.com , like Internet Explorer , Mozilla etc. Neither it loads the pages containing flash , please let me know how can i do this.
    I have a jpanel form on click of menu or button i want to call another jpanel form . i have tried with jFrameForm and it works but same doesnt work with jPanelform
    Please help . your help will be appreciated
    thanks

    Browser Utility - Class to launch a URL in a web browser in
    a platform independent manner. Includes an optional swing
    GUI allowing user customization. [Open Source - GPL]
    http://ostermiller.org/utils/Browser.html
    BrowserLauncher - Open the system web browser with
    particular attention paid to various Macintosh systems.
    (Freeware)
    http://browserlauncher.sourceforge.net/
    Java World - With a little platform-specific Java code, you
    can easily use your system's default browser to display any
    URL in Windows or Unix.
    http://www.javaworld.com/javaworld/javatips/jw-javatip66.html
    JConfig - Class Libraries that allow a URL to be launched in
    a browser on Windows, Unix, or Macintosh. [Commercial]
    http://www.tolstoy.com/samizdat/jconfig.html
    Apple - MRJFileUtils.openURL() not implemented in Mac OS X.
    http://developer.apple.com/techpubs/macosx/ReleaseNotes/JavaGMWebReleaseNotes.html#MRJToolkit
    Apple - How one would open a URL in a web browser on a
    Macintosh.
    http://developer.apple.com/qa/java/java12.html

  • Class help needed.

    i have declared 3 variables in a class, x and y are coordiantres
    public class Robot
    private double x;
    private double y;
    private double Orientation;
    public Robot()
         x = 0;
         y = 0;
         Orientation = 0;
    public (double px, double py, double pOrientation)
         x = px;
         y= py;
         Orientation = pOrientation;
    public double getX()
    return x;
    public double getY()
    return y;
    public double getOrientation()
    return Orientation;
    public void turnRight (double pDeg) //Degrees
    Orientation= Orientation + pDeg;
    public void moveForward (double pDis)
    how do i get the moveforward i have been given the code written below. in the method also been given dx = d*sin(A) and dy = d*cos(A)
    aprreciate the help thanks
    double d=0;
    double dx=0;
    double dy=0;
    double radians=0;
    radians = Math.toRadians(A); //A is converted to radians
    dx=d* Math.sin(radians); //distance travelled in x
    dy=d* Math.cos(radians);//distance travelled in y
    stuck on what to do there, thanks

    >
    how do i get the moveforward i have been given the
    code written below. in the method also been given dx
    = d*sin(A) and dy = d*cos(A)
    aprreciate the help thanks
    double d=0;
    double dx=0;
    double dy=0;
    double radians=0;
    radians = Math.toRadians(A); //A is converted to
    radians
    dx=d* Math.sin(radians); //distance travelled in x
    dy=d* Math.cos(radians);//distance travelled in y
    A seems to be angle from the x axis that your robot is facing. Therefore replace it with your member variable orientation
    To get your new x, do x = x + dx;
    To get your new y, do y = y + dy;

  • How do I reorder songs in a playlist in the new itunes??? I can no longer just click and drag. When I click, it doesn't move!!!! Need help ASAP- trying to prepare for an aerobics class and need songs in a specific order!

    How do I reorder songs in a playlist in the new itunes??? I can no longer just click and drag. When I click, it doesn't move!!!! Need help ASAP- trying to prepare for an aerobics class and need songs in a specific order!

    Vera,
    Use View > View Options, and set 'Sort By" to "Manual Order."
    Then you will be able to drag-n-drop songs up and down the list.

  • Help Needed in Creating Java Class and Java Stored Procedures

    Hi,
    Can anyone tell how can i create Java Class, Java Source and Java Resource in Oracle Database.
    I have seen the Documents. But i couldn't able to understand it correctly.
    I will be helpful when i get some Examples for creating a Java Class, Java Source and Stored Procedures with Java with details.
    Is that possible to Create a Java class in the oracle Database itself ?.
    Where are the files located for the existing Java Class ?..
    Help Needed Please.
    Thanks,
    Murali.v

    Hi Murali,
    Heres a thread which discussed uploading java source file instead of runnable code on to the database, which might be helpful :
    Configure deployment to a database to upload the java file instead of class
    The files for the java class you created in JDev project is located in the myworks folder in jdev, eg, <jdev_home>\jdev\mywork\Application1\Project1\src\project1
    Hope this helps,
    Sunil..

  • Trying to make a class to read in strings, help needed

    hello
    i have this class that reads in numbers here is the code
    import java.io.*;
    public class readNumber {
         public static int readlnt()
              throws java.io.IOException
              BufferedReader str= new BufferedReader(new InputStreamReader(System.in));
              String input;
              int res = 0;
              Integer num = new Integer(res);//create integer object
              input = str.readLine();//read input and return a string
              return num.parseInt(input);//convert String to an int and return
              }// end of read method
         }//end of class numberi was trying to makr one to read in words i have this so far
    import java.io.*;
    public class readWord {
         public static int readlnt()
              throws java.io.IOException
              BufferedReader str= new BufferedReader(new InputStreamReader(System.in));
              String input;
              String res = null;
              String word = new String(res);
              input = str.readLine();
              return word.parseword(input);
              }// end of read method
         }//end of class numberi need a little help with the readWord class, any advice you can give would be great
    thanks alot
    Anthony

    Your basic logic is probably going to be something like this:
    (a) read from the stream until you get a letter. (discard spaces at the beginning of a line, or between words)
    (b) create a string or a string buffer that contains the letter you just read.
    (c) read from the stream as long as you're getting letters, appending them to the end of the string or string buffer. When you get a character that isn't a letter, discard it, and return what you've built up.
    This assumes you want to discard punctuation marks, spaces, carriage returns, etc.

  • Help Needed on a similar but not same class loader problem

    Hi,
    Please help...
    There is a ClassLoader called MyLoader that overrides default findClass() method to decrypt already encrypted class files available in a separate jar file.
    MyClass also contains a public static method launchMe() method that starts off with a call similar to loadClass("ApplicationMainClass");
    The MyLoader class is also encrypted
    I modified the default launcher (c) code to:
    First find the encrypted MyLoader file then decrypt it and create a byte array.
    The byte array, along with the system class loader and other required arguments, is passed to DefineClass native method (defined in jvm.dll)
    Note: The system class loader class has been instantiated using static method ClassLoader.getSystemClassLoader() through Java's invocation API.
    The DefineClass succeeds and I'm able to instantiate MyLoader and later call launchMe() to start application.
    Now i come to the problem:
    I'm not able to use any class other that those in rt.jar (i.e.standard classes) in MyLoader class. I end up with a runtime error ClassDefNotFoundError while trying to load any third party jar.
    The classes i need are present in class path and also in the local jre's ext that i use to launch my app.
    Although i can avoid using third party jar in MyLoader but if there is any way...
    Piyush

    make sure that third party jar resides in your library.....
    or else put rt.jar and external jars under same folder
    this is matter of path.... no else than this.......
    cheers
    Rajesh42

  • Help needed with Java 1.4 and xml Runtime problem

    I am working on a java 1.3 and JAXP1.1 written code. Now I want to compile and run it using J2SE 1.4. Here are the import statements from the existing code.
    import org.xml.sax.*;
    import org.xml.sax.helpers.DefaultHandler;
    import org.xml.sax.Locator;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.Attributes;
    import org.xml.sax.XMLReader;
    import org.xml.sax.InputSource;
    import java.sql.*;
    import java.net.*;
    import java.io.*;
    When I run the existing(using java 1.3 and Jaxp1.1) code I have to include the files crimson.jar and jaxp.jar in the windows 2000 CLASSPATH and works fine.
    But when I compile and run it using J2SE 1.4 which has the built in support for the saxp, I thought that I don't have to specify any CLASSPATH for the new 1.4 so I don't specify any Classpath and it gives me the Microsoft "ClassFactory cannot find the requested class" error which means that even thought the new java 1.4 has the xml classes as libraries yet it still requies some .jar files to be listed in the CLASSPATH.
    If I am right then what path will work(i.e what jar class I need to add to the CLASSPATH).
    Thanks for your help.
    RA.

    Thanks for your reply,
    I think I didn't specify when the error occurs. The ClassFactory related error occurs when I run the program, it compiles without any error.
    From what I understood somewhere in the java 1.4 docs, that the new 1.4 has the xml libraries built in by default so one doesn't need to give the classpaths just like we don't give any CLASSPATH for using swing and many of the other java packages. That is one thing.
    Second thing is that I also tried to use the java_xml_pack-spring02 and java_xml_pack-summer02; but non of them include the crimson.jar and the jaxp.jar files in them which are the 2 .jar files that makes the program run fine when used under the java 1.3 with combination of the jaxp1.1(which was downloaded seperately and then the CLASSPATH for it was set.).
    Can you please help what .jar files do I need to use instead. I tried to use the ones that the new java_xml_pack-spring02 and java_xml_pack-summer02 has for the jaxp in them.
    Thanks again.
    RA

  • Swing ActionListener help?

    Hi there,
    I'm trying to get to grips with Swing and I'm reasonably comfortable with laying out the GUI now. However, I'm still trying to get to grips with ActionListeners. As I understand it, you can have any old class as an ActionListener as long as it implements the ActionListener interface.....then you can just add this ActionListener to a component using .addActionListener().
    Couple of questions though....
    1. Is it generally bad design to just have a component call <whatever>.addActionListener(this) and then just implement the actionPerformed() method within the same class?
    2. Do you have to define a seperate ActionListener class for each type of component, or can you use one ActionListener for, say, one whole GUI screen? How do you usually organise these things?
    3. Anyone point me towards some decent tutorials on Java Swing event-handling?....preferably not the Sun ones, although if they are regarded as the best, I'll take 'em. :)
    Thanks for your time.

    URgent help need.
    i need to link the page together : by clicking the button on the index page.
    it will show the revelant class file. I have try my ationPerformed method to the actionlistener, it cannot work.
    Thanks in advance.
    // class mtab
    // the tab menu where it display the gui
    import javax.swing.*;
    import java.awt.*;
    public class mtab {
    private static final int frame_height = 480;
    private static final int frame_width = 680;
    public static void main (String [] args){
    JFrame frame = new JFrame ("Mrt Timing System");
    frame.setDefaultCloseOperationJFrame.EXIT_ON_CLOSE);
    frame.setSize(frame_width,frame_height);
    JTabbedPane tp = new JTabbedPane ();
    tp.addTab("Mrt Timing System", new sample());
    frame.setResizable(false);
    frame.getContentPane().add(tp);
    frame.setSize(680,480);
    frame.show();
    // index page
    // class sample
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Image;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import java.text.*;
    import javax.swing.border.*;
    class sample extends JPanel implements ActionListener
    //button
    private JButton TimingButton;
    private JButton ViewButton;
    private JButton FrequencyButton;
    private JButton calculateButton;
    private CardLayout mycard;
    private JPanel SelectXPanel;
    private JPanel SelectYPanel;
    private JPanel SelectZPanel;
    private JPanel bigFrame, mainPane;
    // constructor
    public sample() {
    super(new BorderLayout());
    //create the object
    //create button and set it
    TimingButton = new JButton("MRT Timing Calculator");
    TimingButton.addActionListener(this);
    ViewButton = new JButton("View First and Last Train");
    ViewButton.addActionListener(this);
    FrequencyButton = new JButton("Show the Train Frequency");
    FrequencyButton.addActionListener(this);
    // Layout
    //Lay out the button in a panel.
    JPanel buttonPane = new JPanel(new GridLayout(3,0));
    buttonPane.add(TimingButton);
    buttonPane.add(ViewButton);
    buttonPane.add(FrequencyButton);
    // Layout the button panel into another panel.
    JPanel buttonPane2 = new JPanel(new GridLayout(0,1));
    buttonPane2.add(buttonPane);
    tfrequency x = new tfrequency();
    fviewl2 y = new fviewl2 ();
    timing z = new timing ();
    JPanel SelectXPanel = new JPanel(new GridLayout(0,1));
    SelectXPanel.add(x);
    JPanel SelectYPanel = new JPanel(new GridLayout(0,1));
    SelectYPanel.add(y);
    JPanel SelectZPanel = new JPanel(new GridLayout(0,1));
    SelectZPanel.add(z);
    // Layout the button by putting in between the rigid area
    JPanel mainPane = new JPanel(new GridLayout(3,0));
    mainPane.add(Box.createRigidArea(new Dimension(0,1)));
    mainPane.add(buttonPane2);
    mainPane.add(Box.createRigidArea(new Dimension(0,1)));
    mainPane.setBorder(new TitledBorder("MRT Timing System"));
    // x = new tfrequency();
    // The overall panel -- divide the frame into two parts: west and east.
    JPanel bigFrame = new JPanel(new GridLayout(0,2));
    bigFrame.add(mainPane, BorderLayout.WEST);
    //bigFrame.add(x,BorderLayout.EAST); // this is where i want to link the page
    // this page being the index page. there being nothing to display.
    add(bigFrame);
    //Create the GUI and show it. For thread safety,
    public void actionPerformed (ActionEvent e){
    if (e.getSource() == TimingButton ){
    JPanel bigFrame = new JPanel(new GridLayout(0,2));
    bigFrame.add(mainPane, BorderLayout.WEST);
    bigFrame.add(SelectZPanel,BorderLayout.EAST);
    add(bigFrame);
    else if (e.getSource() == ViewButton ){
    JPanel bigFrame = new JPanel(new GridLayout(0,2));
    bigFrame.add(mainPane, BorderLayout.WEST);
    bigFrame.add(SelectYPanel,BorderLayout.EAST);
    add(bigFrame);
    else if (e.getSource() == FrequencyButton ){
    JPanel bigFrame2 = new JPanel(new GridLayout(0,2));
    bigFrame.add(mainPane, BorderLayout.WEST);
    bigFrame.add(SelectXPanel,BorderLayout.EAST);
    add(bigFrame);
    // Train Frequency Page
    // class fviewl2
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.Image;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import java.text.*;
    import javax.swing.border.*;
    class fviewl2 extends JPanel implements ActionListener
    //Labels to identify the fields
    private JLabel stationLabel;
    private JLabel firstLabel;
    private JLabel lastLabel;
    //Strings for the labels
    private static String station = "MRT Station:";
    private static String first = "First Train Time:";
    private static String last = "Last Train Time:";
    //Fields for data entry
    private JFormattedTextField stationField;
    private JFormattedTextField firstField;
    private JFormattedTextField lastField;
    //button
    private JButton homeButton;
    private JButton cancelButton;
    private JButton calculateButton;
    public fviewl2()
    super(new BorderLayout());
    //create the object
    //Create the Labels
    stationLabel = new JLabel(station);
    firstLabel = new JLabel (first);
    lastLabel = new JLabel (last) ;
    //Create the text fields .// MRT Station:
    stationField = new JFormattedTextField();
    stationField.setColumns(10);
    stationField.setBounds(300,300,5,5);
    //Create the text fields // First Train Time:
    firstField = new JFormattedTextField();
    firstField.setColumns(10);
    firstField.setBounds(300,300,5,5);
    //Create the text fields //Last Train Time:
    lastField = new JFormattedTextField();
    lastField.setColumns(10);
    lastField.setBounds(300,300,5,5);
    //Tell accessibility tools about label/textfield pairs, matching label for the field
    stationLabel.setLabelFor(stationField);
    firstLabel.setLabelFor(firstField);
    lastLabel.setLabelFor(lastField);
    //create button and set it
    homeButton = new JButton("Home");
    //homeButton.addActionListener(this);
    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);
    calculateButton = new JButton("Get Time");
    // Layout
    //MRT Station Label // insert into the panel
    JPanel StationPane = new JPanel(new GridLayout(0,1));
    StationPane.add(stationLabel);
    //MRT Station input field // insert into the panel
    JPanel StationInput = new JPanel(new GridLayout(0,1));
    StationInput.add(stationField);
    //Get Time Button // insert into the panel
    JPanel GetTime = new JPanel(new GridLayout(0,1));
    GetTime.add(calculateButton);
    //Lay out the labels in a panel.
    JPanel FlabelL = new JPanel(new GridLayout(0,1));
    FlabelL.add(firstLabel);
    FlabelL.add(lastLabel);
    // Layout the fields in a panel
    JPanel FFieldL = new JPanel(new GridLayout(0,1));
    FFieldL.add(firstField);
    FFieldL.add(lastField);
    //Lay out the button in a panel.
    JPanel buttonPane = new JPanel(new GridLayout(1,0));
    buttonPane.add(homeButton);
    buttonPane.add(cancelButton);
    // Layout all components in the main panel
    JPanel mainPane = new JPanel(new GridLayout(4,2));
    mainPane.add(StationPane);
    mainPane.add(StationInput);
    mainPane.add(Box.createRigidArea(new Dimension(0,1)));
    mainPane.add(GetTime);
    mainPane.add(FlabelL);
    mainPane.add(FFieldL);
    mainPane.add(Box.createRigidArea(new Dimension(0,1)));
    mainPane.add(buttonPane);
    mainPane.setBorder(new TitledBorder("View First and Last Train"));
    JPanel leftPane = new JPanel(new GridLayout(1,0));
    leftPane.add(Box.createRigidArea(new Dimension(0,1)));
    leftPane.add(mainPane);
    leftPane.add(Box.createRigidArea(new Dimension(0,1)));
    JPanel hahaFrame = new JPanel(new GridLayout(0,1));
    hahaFrame.add(Box.createRigidArea(new Dimension(0,1)));
    hahaFrame.setBorder(BorderFactory.createEmptyBorder(30, 10, 80, 150));
    hahaFrame.add(Box.createRigidArea(new Dimension(0,1)));
    JPanel bigFrame = new JPanel();
    bigFrame.add(hahaFrame, BorderLayout.NORTH);
    bigFrame.add(leftPane, BorderLayout.CENTER);
    add(bigFrame, BorderLayout.CENTER);
    //Create the GUI and show it. For thread safety,
    private void cancelButtonClicked()
    stationField.setText("");
    firstField.setText("");
    lastField.setText("");
    public void actionPerformed (ActionEvent e){
    if (e.getSource() == cancelButton){
    cancelButtonClicked();
    }

  • JCmboBox setSelectedIndex help needed !!!!!!!!!!!!

    hi,
    I hope it's a trivial question but I am not able to solve it so need your help plz. I have a demo program if you run it you will see what I mean. Actually I am adding items to my JComboBox dynamically. My problem is that if I add the items with the same name and then explicitly set them selected my first item with same name is always highlighted and selected even though I say to select the last item which I add. But when I pull down the comboBox my first item with the same name is selected and highlighted not the last one. Please run the program and see. How can I solve this problem help needed.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ComboBoxDemo extends JPanel {
    JButton picture;
    public ComboBoxDemo() {
    String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };
    // Create the combo box, select the pig
    final JComboBox petList = new JComboBox(petStrings);
    picture = new JButton("ADD");
    picture.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    petList.addItem("TEST ");
                   int nodeTotal =     petList.getItemCount();
                   petList.setSelectedIndex(nodeTotal-1);
    setLayout(new BorderLayout());
    add(petList, BorderLayout.NORTH);
    add(picture, BorderLayout.SOUTH);
    setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
    public static void main(String s[]) {
    JFrame frame = new JFrame("ComboBoxDemo");
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {System.exit(0);}
    frame.setContentPane(new ComboBoxDemo());
    frame.pack();
    frame.setVisible(true);
    I want to select the last item I add even if there exists an item with same name.
    Any help is greatly appreciated.
    Thanks.

    never mind I got the answer.
    Tnaks

  • Help needed  while exporting crystal reports to HTML file format using java

    Help needed  while exporting crystal reports to HTML file format using java api(not using crystalviewer).i want to download the
    html file of the report
    thanks

    the ReportExportFormat class does not have HTML format, it has got to be XML. Export to HTML is available from CR Designer only.
    Edited by: Aasavari Bhave on Jan 24, 2012 11:37 AM

  • Help needed to loadjava apache poi jars into oracle database.

    Help needed to loadjava apache poi jars into oracle database. Many classes left unresolved. (Poi 3.7, database 11.1.0.7). Please share your experience!

    Hi,
    The first 3 steps are just perfect.
    But with
    loadjava.bat -user=user/pw@connstr -force -resolve geronimo-stax-api_1.0_spec-1.0.jar
    the results are rather unexpected. Here is a part of the log file:
    arguments: '-user' 'ccc/***@bisera7-db.dev.srv' '-fileout' 'c:\temp\load4.log' '-force' '-resolve' '-jarsasdbobjects' '-v' 'geronimo-stax-api_1.0_spec-1.0.jar'
    The following operations failed
    resource META-INF/MANIFEST.MF: creation (createFailed)
    class javax/xml/stream/EventFilter: resolution
    class javax/xml/stream/events/Attribute: resolution
    class javax/xml/stream/events/Characters: resolution
    class javax/xml/stream/events/Comment: resolution
    class javax/xml/stream/events/DTD: resolution
    class javax/xml/stream/events/EndDocument: resolution
    class javax/xml/stream/events/EndElement: resolution
    class javax/xml/stream/events/EntityDeclaration: resolution
    class javax/xml/stream/events/EntityReference: resolution
    class javax/xml/stream/events/Namespace: resolution
    class javax/xml/stream/events/NotationDeclaration: resolution
    class javax/xml/stream/events/ProcessingInstruction: resolution
    class javax/xml/stream/events/StartDocument: resolution
    class javax/xml/stream/events/StartElement: resolution
    class javax/xml/stream/events/XMLEvent: resolution
    class javax/xml/stream/StreamFilter: resolution
    class javax/xml/stream/util/EventReaderDelegate: resolution
    class javax/xml/stream/util/StreamReaderDelegate: resolution
    class javax/xml/stream/util/XMLEventAllocator: resolution
    class javax/xml/stream/util/XMLEventConsumer: resolution
    class javax/xml/stream/XMLEventFactory: resolution
    class javax/xml/stream/XMLEventReader: resolution
    class javax/xml/stream/XMLEventWriter: resolution
    class javax/xml/stream/XMLInputFactory: resolution
    class javax/xml/stream/XMLOutputFactory: resolution
    class javax/xml/stream/XMLStreamReader: resolution
    resource META-INF/LICENSE.txt: creation (createFailed)
    resource META-INF/NOTICE.txt: creation (createFailed)
    It seems to me that the root of the problem is the error:
    ORA-29521: referenced name javax/xml/namespace/QName could not be found
    This class exists in the SYS schema though and is valid. If SYS should be included as a resolver? How to solve this problem?

Maybe you are looking for

  • Custom Field in BSID - How do I populate value at time of JE?

    Hi all We have a custom append to the BSID table to have a custom field. I was hoping we could populate this custom field on BSID using the FI substitution rule in OBBH. However, it looks like we cannot access BSID from within the FI substitution exi

  • How to get back software I lost with Belle update?

    I had the following games installed on my N8 when there was this "Summer Game Gifts" campaign: - Tom Clancy's H.A.W.X. HD+ - Angry Birds Seasons - The Settlers - Angry Birds Rio - Monopoly Classic HD - Worms HD - GT Racing HD+ - Tetris HD - Guitar Ro

  • Problem with synchronisation

    i have created an applet with two buttons and have brought in concept of threads and when i click one button a thread starts and it starts printing the numbers and if i press another button another thread starts and it also start printing but my requ

  • Error in J2I8 -Transfer of capital goods credit

    Hi,   I want to transfer the capital goods credit,  In J2I8 ,  I have select the check box of vendor invoice numner then when i click on transfer credit, system is giving error message as Please check the amount,  how to solve problem.   regards,   

  • Where's the Band?

    Recently purchased an album from itunes. Loaded fine into my library but when I synced up to ipod I noticed the album did not appear in the ipod list of artists. Repeated attempts to load were futile; however, I imported album via playlist and is now