Creating GUI window. Newbie help needed

Hey all this is the first time i am building a GUI box for school. Can you kind of help me out here. I think i am doing this all wrong. Can you point me in the direction of setting up a Blank box just so i can then play with it from there trying to add JButtons, JLabels and all that other stuff. This is what i was trying and i know its way wrong.. haha thanks
import java.io.*;
import javax.swing.*;
public class LetterProgram
public LetterProgram
setTitle("Letter Conversion Program");
setSize(100,50);
setVisible(True);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}

import javax.swing.*;
public class MyJFrame extends JFrame {
  private int returnCode = 0;
  public MyJFrame () {
  public MyJFrame (String title) {
    super (title);
  protected void frameInit() {
    super.frameInit();
    setDefaultCloseOperation(EXIT_ON_CLOSE);
}You should start from here.
put every thing u want into ExitableJFrame's constructor.
You will need a main method to creat a JFrame.
and then setVisiable(true); some sort of stuff there.
GOOD LUCK

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

  • Pdf showed in new window. Help needed!

    Hi all,
    This is my first post (but a thousand read), and i want first to thank you all for all the information i have read in this forums for years.
    I have a problem which is giving me more problems that i expected. In my webapp, i want to show a pdf document in a new page of the navigator when a button is pressed. I have discarded the target blank option in the container form because i have others buttons and dont want them to be opened in new windows, just the one that open the pdf.
    So, I used another navigation rule to open a new window. This page have to make de pdf in code an send it to the client. I dont know how to execute that code on the load of the page.
    The solution i am trying is using a poll that only will be called once and in the pollListener execute that code. The problem is that does not work to send the response to the client in the client. Here is the code of the pollListener:
    byte[] file; //Don't worry about it. Contains the file pdf i want to show.
    FacesContext fctx = FacesContext.getCurrentInstance();
    HttpServletResponse response =
    (HttpServletResponse) fctx.getExternalContext().getResponse();
    response.setContentType("application/pdf");
    response.setHeader("Content-Disposition",
    "inline; filename=\"file.pdf\"");
    response.setHeader("Cache-Control", "no-cache");
    response.setContentLength(file.length);
    ServletOutputStream sos = response.getOutputStream();
    sos.write(fichero);
    sos.flush();
    sos.close();
    fctx.responseComplete();
    The curious thing is that if i change the content-disposition to atachemement instead inline, it works asking me to download the file, however, i want it to open directly in the new window and is because of that i use content-disposition inline.
    I am almost killing myself because of this problem. Anyone can help me?
    Thanks in advance!

    First of all, you don't need to do this with a workaround using a Poll listener. I assume that one page has a commandButton or commandLink that is used to show the PDF, right?
    Set the useWindow property of the button or link to "true".
    Set the actionListener property of the button or link to a method in a backing bean that looks something like this:
        public void showPDF(ActionEvent actionEvent) throws IOException {
            //Setup the output
            String contentType = "application/pdf";
            FacesContext fc = FacesContext.getCurrentInstance();
            HttpServletResponse response =
                (HttpServletResponse)fc.getExternalContext().getResponse();
            /* Notice that I don't set the Content-Disposition header - inline is default. */
            response.setContentType(contentType);
            ServletOuputStream out = response.getOutputStream();
            /*  Do whatever you need to do to write the pdf to "out" here. */       
            out.flush();
            out.close();
            fc.responseComplete();
        }

  • Newbie help needed.  Looking to circle options on a form.

    Hey Guys,
    I'm a total beginner at this, but we've been mapping out forms and I need to know how to be able to "circle" different options on a form.
    I think the best way to do this is to have a button which makes a circle object visible or hidden.  Currently I've figured out how to set an object as hidden and make it appear on button click, but not make it go back to hidden if the button is clicked again.  Many times its just a yes/no type case, but sometimes there are cases where I have multiple options where only one can be selected and I would like to be able to click and circle the appropriate type.
    An example:
    How many cylinders does your vehicle have:
         4     6     8
    and I would like to make it so if you click the 4 it will circle the 4 and make sure the 6 and 8 are not circled.
    Any help would be appreciated.

    How about this case:
    There are three different cases that could be true, 4 cylinders, 6 cylinders and 8 cylinders.  I have created the 4, 6 and 8 as buttons, and created three circle objects as cyl4, cyl6 and cyl8.  I want it so that when 4 is clicked it displays the circle object cyl4 and makes the others hidden, unless cyl4 is already visible then it will just make all three objects hidden.  So far I have this code on each button click, modified for which objects should be set to visible on each one:
    topmostSubform.Page1.Span[41].Fourcyl::click - (JavaScript, client)
    if (cylinder == 4){
        xfa.form.topmostSubform.Page1.cyl4.presence="hidden"
        xfa.form.topmostSubform.Page1.cyl6.presence="hidden"
        xfa.form.topmostSubform.Page1.cyl8.presence="hidden"
        cylinder.value = 0
    else{
        xfa.form.topmostSubform.Page1.cyl4.presence="visible"
        xfa.form.topmostSubform.Page1.cyl6.presence="hidden"
        xfa.form.topmostSubform.Page1.cyl8.presence="hidden"
        cylinder.value = 4
    Where cylinder is just a control variable.  It's probably something simple that I'm missing, any help would be appreciated.
    Thanks

  • Newbie - help needed with array and dictionary objects

    Hi all
    Please see the code below. I've posted this code in another thread however the original issue was resolved and this is now a new issue I'm having although centered around the same code.
    The issue is that I'm populating an array with dictionary objects. each dictionary object has a key and it's value is another array of custom objects.
    I've found that the code runs without error and I end up with my array as I'm expecting however all of the dictionary objects are the same.
    I assume it's something to do with pointers and/or re-using the same objects but i'm new to obj-c and pointers so i am a bit lost.
    Any help again is very much appreciated.
    // Open the database connection and retrieve minimal information for all objects.
    - (void)initializeDatabase {
    NSMutableArray *authorArray = [[NSMutableArray alloc] init];
    self.authors = authorArray;
    [authorArray release];
    // The database is stored in the application bundle.
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"books.sql"];
    // Open the database. The database was prepared outside the application.
    if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
    // Get the primary key for all books.
    const char *sql = "SELECT id, author FROM author";
    sqlite3_stmt *statement;
    // Preparing a statement compiles the SQL query into a byte-code program in the SQLite library.
    // The third parameter is either the length of the SQL string or -1 to read up to the first null terminator.
    if (sqlite3preparev2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
    // We "step" through the results - once for each row.
    // We start with Letter A...we're building an A - Z grouping
    NSString *letter = @"A";
    NSMutableArray *tempauthors = [[NSMutableArray alloc] init];
    while (sqlite3_step(statement) == SQLITE_ROW) {
    author *author = [[author alloc] init];
    author.primaryKey = sqlite3columnint(statement, 0);
    author.title = [NSString stringWithUTF8String:(char *)sqlite3columntext(statement, 0)];
    // FOLLOWING WAS LEFT OVER FROM ORIGINAL COMMENTS IN SQLBooks example....
    // We avoid the alloc-init-autorelease pattern here because we are in a tight loop and
    // autorelease is slightly more expensive than release. This design choice has nothing to do with
    // actual memory management - at the end of this block of code, all the book objects allocated
    // here will be in memory regardless of whether we use autorelease or release, because they are
    // retained by the books array.
    // if the author starts with the Letter we currently have, add it to the temp array
    if ([[author.title substringToIndex:1] compare:letter] == NSOrderedSame){
    [tempauthors addObject:author];
    } // if this is different letter, then we need to deal with that too...
    else {
    // create a dictionary to store the current tempauthors array in...
    NSDictionary *tempDictionary = [NSDictionary dictionaryWithObject:tempauthors forKey:@"authors"];
    // add the dictionary to our appDelegate-level array
    [authors addObject:tempDictionary];
    // now prepare for the next loop...
    // set the new letter...
    letter = [author.title substringToIndex:1];
    // remove all of the previous authors so we don't duplicate...
    [tempauthors removeAllObjects];
    // add the current author as this was the one that didn't match the Letter and so
    // never went into the previous array...
    [tempauthors addObject:author];
    // release ready for the next loop...
    [author release];
    // clear up the remaining authors that weren't picked up and saved in the "else" statement above...
    if (tempauthors.count > 0){
    NSDictionary *tempDictionary = [NSDictionary dictionaryWithObject:tempauthors forKey:@"authors"];
    [authors addObject:tempDictionary];
    else {
    printf("Failed preparing statement %s
    ", sqlite3_errmsg(database));
    // "Finalize" the statement - releases the resources associated with the statement.
    sqlite3_finalize(statement);
    } else {
    // Even though the open failed, call close to properly clean up resources.
    sqlite3_close(database);
    NSAssert1(0, @"Failed to open database with message '%s'.", sqlite3_errmsg(database));
    // Additional error handling, as appropriate...
    Message was edited by: dotnetter

    Ok, so I know what the issue is now...I just don't know enough to be able to resolve it!
    it's the tempAuthors objects.
    It's an NSMutableArray which is create on the line before the start of the WHILE loop.
    Having looked through the debugger, I can see that each dictionary object is created (with different codes which I assume are memory addresses) so all is well there. However, on each iteration of the loop in the middle there is an IF...ELSE... statement which in the ELSE section is clearing all objects from the tempAuthors array and beginning to repopulate it again.
    Looking at the containing dictionary objects in the debugger I can see that the tempAuthors object that each contains has the same code (again, I'm assuming this is a memory address) - so if I understand correctly, it's the same object...I assumed that when I created the dictionary using the dictionWithObject call that I would be passing in a copy of the object, but it's referencing back to the object which I then go on to change.
    Assuming the above is correct, I've tried several "stabs in the dark" at fixing it.
    I've tried relasing the tempAuthors object within the ELSE and initialising it again via an alloc...init - but this didn't work and again looking through the debugger it looks as though it was confused as to which object it was supposed to be using on the following iteration of the WHILE loop (it tried to access the released object).
    Having read a little more about memory management can someone tell me if I'm correct in saying that the above is because the tempAuthors object is declare outside the scope of the WHILE loop yet I then try to re-instantiate it within the loop (does that make sense???).
    Sorry for the long post...the more I can understand the process the less I can hopefully stop relying on others for help so much.
    I am continuing to read up on memory management etc but just not there yet.
    Regards
    Wayne

  • NEWBIE - Help Needed Please!

    Hi - I am new to iMovie and have iMovie '08. I need to create a project as follows. I am trying to recreate some movies that when played will look like a Trade Test Transmission with music. Viz:
    The movie needs to be a static caption that lasts for about 1 hour
    That caption exists as as a .jpg file.
    I need to play an hour's worth of music with that caption
    I can import the picture and add music but I cannot work out how to make the picture stay on screen for 1 hour - is there a simple way of doing this?
    Sorry for such an easy question - iMovie is about the only Apple Software I have never used!
    Christian

    .. The maximum length it will allow me to enter seems to be 60 seconds. ...
    oops, you're right!
    I'm an old iM user, vers. ≤6 allowed longer durations than 60secs..
    the '4 sec increment' is defined in iM's prefs, you'll find there a slider, but it offers 10sec max. ...-
    soooo, 60x paste/copy, OR using iMHD6 ...
    Plan B)
    import your pic into iPhoto; create a slideshow containing just that single pic... set duration to 3600secs.. add music .. export 'movie' ...

  • Java newbie help: Need to change a graphic on screen

    Hello everyone. I'm a long time C/C++ programmer, and I've been thrust into the Java world when I inherited an incomplete project. If something I mention later on sounds stupid, it's probably because it came that way, or I'm trying to force it into what I know from old experience.
    FWIW, the project is being developed with Netbeans.
    What I'm after is how to change a graphic object onscreen from within the code, vs. with a device such as a mouse. I'm trying to emulate an LED indicator.
    What I've done so far is to try using the enable state, and defining GIFs to display. That didn't work.
    I've switched gears a bit, and tried something similar with the selected property, but that will only work if I hit the item with my mouse and click. Also, the item is defined as a jToggleButton.
    In general terms, what do I need to do to set this up for the displayed item to change without device input? I've been reading stuff about Buttons, ToggleButtons, Graphics, Images, and Icons, and I'm waaaaaay lost right now.
    To add to the frustration is that I've done something similar with Visual C++, and that worked as intended. Harumph.
    Help?!?

    FWIW, the project is being developed with Netbeans.
    In case you don't know, you can use any editor to develop java code.
    What I'm after is how to change a graphic object onscreen from within the code, vs. with a device such as a mouse. I'm trying to emulate an LED indicator.
    What I've done so far is to try using the enable state, and defining GIFs to display. That didn't work.
    What happend?
    I've switched gears a bit, and tried something similar with the selected property, but that will only work if I hit the item with my mouse and click. Also, the item is defined as a jToggleButton.
    Is this not what you wanted?

  • Creating Inbound IDoc - IDOC_INBOUND_SINGLE Help needed

    Hi all,
    I am using IDOC_INBOUND_SINGLE to create inbound IDoc. Its creating the IDoc and processing successfully.
    But this FM only returns IDoc number and not the processing errors if there are any. Any way to get processing errors also?
    Your help would be highly appreciated.
    Thanks,
    Sagar

    Hi
    I am not sure
    Pls check this function module 'IDOC_READ_COMPLETELY'
    Regards
    Madhan

  • Newbie help needed w/Graphics class!

    Hi everyone,
    I'm stuck on something I know is very simple to do, but I can't seem to find the right combination. I have a derived class that draws a circle using the graphics class. I'm getting compilation errors when I try to set the color and draw the circle. I have looked thru these forums as well as the API. Below is my code. Any pointers would be highly appreciated!
    import java.awt.Graphics;
    public class SmartCircle extends SmartShape
    SmartCircle(int first, int second, int third, Color c)
    super(first, second, third, c);
    public void draw(Graphics g)
    setColor(Color c);
    fillOval(first, second, size, size);
    }

    Here is SmartShape. It is located in the same directory as SmartCircle, so therefore doesn't need to be imported, correct?
    public abstract class SmartShape
    //define instance variables
    protected int positionX, positionY, size;
    protected Color theColor;
    public SmartShape()
         //initialize variables
         positionX = 20;
         positionY = 20;
         theColor = Color.white;
    public SmartShape(int first, int second, int third, Color c)
         if (first >= 0)
         positionX = first;
         else
         positionX = 0;
         if (second >= 0)
         positionY = second;
         else
         positionY = 0;
         if (third >= 0)
         size = third;
         else
         size = 0;
         theColor = c;
    public abstract void draw(Graphics g);
    Hope that helps!
    Melissa

  • Newbie help needed. Cant save to a WD Elements Hard Drive!!!Going Crazy!

    We got our imac yesterday! Love it but.....only real issue that is driving me crazy and ruining the experience is that I can't save a pages doc to my WD Elements External Hard Drive. It is installed I can move stuff from it but nothing to it! When I select save as and pick "Elements" a message appears saying <the document "Test" could not be saved as "test". Read-only file system. Can any one explain
    Message was edited by: wyleybruce

    OSX can read but not write to NTFS formatted disks. If you want to keep the disk as NTFS, there are utilities (like NTFS3G ) you can get that will allow you to save to the disk as it is currently formatted.
    IMHO it would be better for you to reformat the disk as Mac OS Extended if you intend to use it on an ongoing basis with your new Mac. But remember to back up anything you want or need to keep, because reformatting will erase everything that is on the drive.
    (Notes: If you reformat the disk to Mac OS Extended and then you want to use it with a Windows system, you will need Macdrive on the Windows machine. The only format that is natively compatible on both platforms is FAT32.)

  • Newbie help needed on apparent lockout

    Hi all, I am pretty much Mac illiterate but can stumble around. I was helping a friend who is even worse off install Retrospect (6.1) on her iMac (OS X 10.4.11). Install went fine, a backup ran fine and then today her machine appears to have locked up. After holding the power button to get it to shutdown and then reboot the mouse moves, dashboard comes up when I mouse to bottom of screen and a Retrospect window comes up and a window asking if wireless should attach to open network (machine is hardwired also). Clicking on anything doesn't appear to get any response nor does pressing any keyboard keys (I'm unfamiliar with the apple key combinations so I haven't tried any). At any rate machine appears stuck. It has ran fine for a long while only changes have been install Retrospect yesterday and plugged in Maxtor OneTouch 4 Plus (and formatted it to Mac). The desktop and windows appear normal, mousing over things like the close, minimze, etc... buttons highlights them but it just appears to refuse to accept any input. The keyboard and mouse are connected via bluetooth but since mouse moves I assume its not a problem there. Can anyone point me in some direction?
    TIA
    Ron

    Problem solved, not sure what it was but in desperation I turned of the wireless keyboard and mouse and plugged in my USB keyboard/mouse and everything worked, shutdown turned on the wireless keyboard/mouse and removed my USB and started up and everything worked just fine. Very strange

  • Newbie - Help needed starting with Threads

    Hi Friends,
    I have a class which extends thread and all it does is displays its name and then goes to sleep. So, I have this in my run method:
    public void run() {
            System.out.println("Name: "+name);
            try{
                 Thread.sleep(1000);
            }catch(Exception e){
              e.printStackTrace();
        }Now I have a tester class which created objects of these class and they should keep running until the user explicitly stops the program. So, I have this in my tester class:
    Thread one = new MyClass("one");
    Thread one = new MyClass("two");
    one.start();
    two.start();They run fine for one time but how can i make them run continously?? Any help will be appreciated.
    Thanks

    Micks80 wrote:
    I tried to add that while loop but it throws IllegalStateException because I guess you cannot call the start method more then once...
    So any other ways to accomplish this???As suggested in reply #1 put the while loop inside the run method of the Runnable.
    Also it is better for MyClass to implement Runnable rather than extending Thread. It is always better to implement Runnable than extend Thread.

  • NEWBIE: Help needed - Eclipse freeze after starting WLS 9.2

    Hi All,
    I'm very new in development with wls 9.2 and eclipse.
    I'm trying to create a simple application (an EAR with a Session Bean).
    When I start the WLS inside Eclipse (debug or run mode), this one, after a few seconds or clicks, freeze with 99%CPU usage.
    Thanks in advance for help.... it's urgent....
    Eclipse 3.3.0
    WLST 1.1.0
    WLS 9.2
    Edited by mtode at 10/07/2007 2:04 AM
    Edited by mtode at 10/07/2007 2:05 AM

    If I understand you correctly, Eclipse stops responding after a while.
    This may not be actually related to starting WLS. It sounds a bit like
    you might be having a memory problem. Could you specify your operating
    system, the amount of physical memory and the contents of your
    eclipse.ini file?
    Thanks,
    - Konstantin

  • Creating a web service help needed....

    i am using netbeans 6.0 on xp and hav jdk 1.5 update 17 installed. tomcat 5.5 is also running. when i start developing a web service according to [this tutorial|http://wiki.netbeans.org/SOAPNetBeans6] when i try to create a new web service from wsdl it says "to create web service in this project the java source code level must be atleast jdk 1.5" and i can't continue from there. waht must i do...?

    again, u need to visit to netbeans or jws (java web service) forum within forums.sun.com url

  • Trying to update Project scheduled finish date - newbie help needed!

    Guys, I am super new to Oracle Projects, I have never used it before.  I've just learned a few things in the UI and read through the docs documenting the stored procs.  My question is simple (hopefully)   In the UI I choose a responsibility, then under "Projects : Delivery" I choose "Search Projects", I enter the Project ID in the field and click Go, I am able to see all the project details and the Tasks.  No problem there!  What I would like to do through the Update_Project API is to change the "Scheduled Finish Date" of the Project.
    I have the following information that I have managed to scrape up:
    Project_id, Responsibility_id, User_id, Resp_Appl_Id
    I retrieved the project id using:
             Select project_id,name from pa_projects_all
              where name = 'My Project';
    So first I call set_global_info with the appropriate parameters, then this:
        -- SET GLOBAL VALUES
         pa_interface_utils_pub.set_global_info(
         p_api_version_number => 1.0,
         p_responsibility_id => fnd_profile.value('57203'),
         p_user_id => fnd_profile.value('1013415'),
         p_msg_count => l_msg_count,
         p_msg_data => l_msg_data,
         p_return_status => l_return_status);
         l_project_in.pa_project_id := 4608;
         l_project_in.scheduled_finish_date := to_date('2008-02-27', 'YYYY-MM-DD');
      --UPDATE_PROJECT
              pa_project_pub.UPDATE_project(
                        l_api_version_number,
                        p_commit => l_commit,
                        p_init_msg_list => l_init_msg_list,
                        p_msg_count => l_msg_count,
                        p_msg_data => l_msg_data,
                        p_return_status => l_return_status,
                        p_workflow_started => l_workflow_started,
                        p_pm_product_code => null,
                        p_project_in => l_project_in,
                        p_project_out => l_project_out,
                        p_key_members => l_key_members,
                        p_class_categories => l_class_categories,
                        p_tasks_in => l_tasks_in,
                        p_tasks_out => l_tasks_out);
    What I am getting is the message "error :Project ID is invalid" and the status is "E"
    I'm not sure why it is invalid as it is the exact Project ID from the projects table.  The only thing I can think of is that the p_pm_product_code is set to null but I am not sure where this value comes from and why it even matters.  I checked the documents and it says it refers to some external system.  Why does the external system code matter if I am changing data within Oracle Projects?

    Hello,
    Looks like you are not setting the Initialization values correctly. Oracle Project APIs are Org specific and require proper initialization before being called for them to work.
    Few things i noticed from the code is :
    1.  The following is being used to set the User ID and Responsibility ID  :
         p_responsibility_id => fnd_profile.value('57203'),
         p_user_id => fnd_profile.value('1013415'),
    I think the call should be like this. This should be used only if you are going to call the API through a concurrent program from the submit request window (Oracle Apps environment). fnd_profile.value will get the responsibility id and the used id of the user running the program and assign it to the variables.
         p_responsibility_id => fnd_profile.value('RESP_ID'),
         p_user_id => fnd_profile.value('USER_ID'),
    Or If you are directly passing the IDs hardcoded then, This can be used if you are running the script from a Non-Oracle Applications environment, for example from SQL*Plus.
         p_responsibility_id => 57203
         p_user_id => 1013415
    2. I notice that you are not passing P_OPERATING_UNIT_ID parameter in the call to pa_interface_utils_pub.set_global_info. This is fine if you are not using MOAC  and you have set MO: Operating Unit profile for the responsibility being passed.  If you are using MOAC or are not sure, then it is always a good practice to explicitly  pass the P_OPERATING_UNIT_ID parameter in the call to pa_interface_utils_pub.set_global_info.
    Note :  DO NOT use fnd_profile.value('ORG_ID') to set the P_OPERATING_UNIT_ID parameter. In a MOAC environment this may not work.
    3. Always ensure you check the return status of the pa_interface_utils_pub.set_global_info for success before calling the Project APIs. This will save you a lot of frustration when testing.
    4. You might find the following note useful
    Project API Overview and Reference (Doc ID 1424156.1)
    Regards,
    Raghavan Gopalakrishnan

Maybe you are looking for