Buttons in GUI

I have made two frames(mainframe and frame2) in a GUI, now what I want is that a button opens frame2 from the mainframe.
How do I do this?

How much do you know about Swing right now (I assume that this is Swing -- i.e., a JFrame not a Frame -- but I'm not sure. Can you let us know?)? Have you worked with creating and adding actionlisteners to JButtons?
If so, then you could just create an instance of frame2 from within the button's actionlistener, and then call it's setVisible(true) method.
If you want further details, we will need to know more about specifically what you're having trouble with.
A couple other recommendations:
1) Usually in this situation I'll have my JFrame create and show a JDialog not another JFrame. There are exceptions of course.
2) Most of what I've learned about Swing has been by studying the Sun Swing tutorials. I suggest you try this yourself. You won't be sorry.
3) Again if this is Swing, your next question should be asked in the Swing forum.
Good luck,
Pete

Similar Messages

  • Can I put abort execution button and Run button in GUI ?

    Dear All ,
    Can I put "abort execution button" and "Run button" in GUI with bigger buttons ?
    Thanks.....

    Hi wMw.
                 Aborting normally works fine for very small applications or architectures but not for anything after that. Aborting a VI can leave things in states that you don't want to be in or references open. Sometimes you do need to Abort the code though (other programming environments use Abort buttons) so I don't think we can get rid of it entirely.But try to avoid it maximum.
    EDIT:why you are trying to do such a strange thing??
    Thanks as kudos only

  • Java button or gui to sit on desktop to launch

    I am looking for a way to put a Java button or gui to sit on desktop and run/launch a program

    Your question is a little bit to open.
    If you want an icon then I sugest you pack your application into a jar file, create a short cut an running it from there.
    However iit is a complete different story is what you want is a button that sits on your desktop and when it is clicked it opens a new window (which I think it is your application).
    In that case you would have to create another application itself. Create a Jframe (remove the border) and then add a JButton to it. When user clicks on the button (use button action) open the new window (by createing a new instance)
    Hope I understood you well!

  • Add Button to GUI STATUS Application toolbar

    Hi,
    I have to add a button in the application toolbar of a gui status. I have done that many times before, but I never got into trouble like this time....
    When I open the Gui status and the tree for the application toolbar, I can see already set buttons. When I now click on change (a modification warning comes) and press the plus-icon, it is possible to enter a new item. But everything I´m typing, I get the message Function code XXXX has not been assigned to a function key. I have never got this before....
    When I now go to SE41 and enter a new function key, I can´t use it either afterwards as a button in the application toolbar.
    In the tree of the function keys, I can´t change anything...
    What can I do here? The program name is SAPMZLCG, so it has been modified sometimes. But how can I change the GUI STATUS now to add a new button?
    Thank you!

    You need to goto the application toolbar and the add your text to the items and click below the text you will get one popup which will ask for static text and dynamic text. select statictext and then add all the information like text name and if you want to add an icon you can do it aswell. the there will be another popup for fuction attributes where you will be able to find some options loke fuction types and reaction need to select all that and then click on the ok button and save check and activate the same and after that activate and check whether the button is visible or not. once the button is visible then you need to check for the ok_code and sy_ucomm and then insert the fuctionality of the button.
    I hope this might solve your problem.

  • Help with buttons in gui

    I need to create first, last, next, and previous buttons in my gui. I have them in there (in the code), but only one button shows up (instead of four), and it has "first" overlapped with the "previous" button. The "next" and "last" don't even show up at all.
    Can some one guide me please? Can someone tell me what I am doing wrong?? Thank you in advance
    Here is my maker.java which houses the navigation panel
    package inventorymain;
    import javax.swing.JFrame;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.io.*;
    import java.text.NumberFormat;
    import javax.swing.border.*;
    import java.net.*;
    import java.util.StringTokenizer;
    class Maker extends Inventory implements ActionListener
    {//begins Class Maker
        static String manufact[] = new String[10];
        static double restockingFee[] = new double[10];
        static int i;
        static double TotalVal;
        static int navItem;
        private Container cp = getContentPane();
        GridBagConstraints c;
        GridBagConstraints cconstraint;
        Border titledborder;
        JPanel pan;
        String labels[] = {"Product Name:", "Manufacturer:", "Product ID Number:", "Units in Stock:", 
                           "Price Per Unit: $", "Restocking Fee: $", "Value of Product in Stock Plus Restocking Fee: $",
                           "Value of All Merchandise Plus Restocking Fees: $"};
        int len1 = labels.length;
        JLabel lbl[] = new JLabel[len1];
        JTextField txtfield1[] = new JTextField[len1];
        String blabels[] = {"First", "Previous", "Next", "Last"};
        int blen = blabels.length;
        JButton navigate[] = new JButton[blen];
        JLabel lblImg;
        File file;
        public String FileName;
        public Maker(int Item_Number, String Item_Name, double Item_Price, int Items_in_Stock, String manufact, double restockingFee)// Constructor for varibles
            super(Item_Number, Item_Name, Item_Price, Items_in_Stock);
            this.manufact[i] = manufact;
            this.restockingFee[i] = restockingFee;
            i = i + 1;
        public static void setManufact(int k, String value)
            manufact[k] = value;
        public static double getRestockFee(int val)
            return restockingFee[val];
        public void ShowInventory()
            setLayout(new FlowLayout());
            GridBagLayout contlayout = new GridBagLayout();//layout for container
            GridBagConstraints cconstraint = new GridBagConstraints();//constraint for container
            GridBagLayout gblayout = new GridBagLayout();//layout for panel
            GridBagConstraints gbconstraint = new GridBagConstraints();
            try
                //first panel
                pan = new JPanel();
                gblayout = new GridBagLayout();
                gbconstraint = new GridBagConstraints();
                pan.setLayout(gblayout);
                for (int i = 0; i < 2; i++)
                    for (int j = 0; j < len1; j++)
                        int x = i;
                        int y = j;
                        if (x == 0)
                            lbl[j] = new JLabel(labels[j]);
                            lbl[j].setHorizontalAlignment(JLabel.LEFT);
                            lbl[j].setPreferredSize(new Dimension(250, 15));
                            gbconstraint.insets = new Insets(10, 0, 0, 0);
                            gbconstraint.gridx = x;
                            gbconstraint.gridy = y;
                            pan.add(lbl[j], gbconstraint);
                        }//end if
                        else
                            txtfield1[j] = new JTextField(15);
                            txtfield1[j].setPreferredSize(new Dimension(300, 15));
                            txtfield1[j].setHorizontalAlignment(JLabel.LEFT);
                            txtfield1[j].setEnabled(false);
                            lbl[j].setLabelFor(txtfield1[j]);
                            gbconstraint.gridx = x;
                            gbconstraint.gridy = y;
                            pan.add(txtfield1[j], gbconstraint);                       
                        }//end else
                    }//end for
                }//end for
                Border titledborder = BorderFactory.createTitledBorder("Current Inventory Data");
                pan.setBorder(titledborder);
                //adds panel to container
                cconstraint.gridwidth = 1;
                cconstraint.gridheight = 1;
                cconstraint.gridx = 0;
                cconstraint.gridy = 0;
                cp.add(pan, cconstraint);
                //add icon to display
                pan = new JPanel();
                gblayout = new GridBagLayout();
                gbconstraint = new GridBagConstraints();
                pan.setLayout(gblayout);
                gbconstraint.gridwidth = 1;
                gbconstraint.gridheight = 1;
                gbconstraint.gridy = 0;
                lblImg = new JLabel((new ImageIcon(getClass().getResource("logo111.jpg"))));
                lblImg.setPreferredSize(new Dimension(120, 60));
                pan.add(lblImg);
                cconstraint.gridwidth = 1;
                cconstraint.gridheight = 1;
                cconstraint.gridx = 0;
                cconstraint.gridy = 1;
                cp.add(pan, cconstraint);
                //navigation panel
                pan = new JPanel();
                gblayout = new GridBagLayout();
                gbconstraint = new GridBagConstraints();
                pan.setLayout(gblayout);
                gbconstraint.gridwidth = 1;
                gbconstraint.gridheight = 1;
                gbconstraint.gridx = 0;
                gbconstraint.gridy = 1;
                for (int i = 0; i < blen; i++)
                    navigate[i] = new JButton(blabels);
    gbconstraint.gridx = 1;
    pan.add(navigate[i], gbconstraint);
    navigate[i].addActionListener(this);
    }//end for
    titledborder = BorderFactory.createTitledBorder("Navigation");
    pan.setBorder(titledborder);
    //add panel to container
    cconstraint.gridwidth = 4;
    cconstraint.gridheight = 1;
    cconstraint.gridx = 1;
    cconstraint.gridy = 1;
    cp.add(pan, cconstraint);
    ShowInventory(0);
    }//end try
    catch (Exception e)
    e.printStackTrace();
    }//end catch
    }//end showInventory
    public void ShowInventory(int ItemNo)
    txtfield1[0].setText(Integer.toString(ItemNo));
    txtfield1[0].setText(Inventory.getItemName(ItemNo));
    txtfield1[1].setText(manufact[ItemNo]);
    txtfield1[2].setText(Integer.toString(Inventory.getItemNum(ItemNo)));
    txtfield1[3].setText(Integer.toString(Inventory.getItemUnits(ItemNo)));
    txtfield1[4].setText(Double.toString(Inventory.getItemPrice(ItemNo)));
    txtfield1[5].setText(String.format("%3.2f",
    Products.totalOfRestockFee(Inventory.getItemPrice(ItemNo),
    getRestockFee(ItemNo))));
    txtfield1[6].setText(String.format("%3.2f",
    Products.totalOfInventory(Inventory.getItemPrice(ItemNo),
    Inventory.getItemUnits(ItemNo), getRestockFee(ItemNo))));
    txtfield1[7].setText(String.format("%3.2f",
    GetTotalInvVal()));
    }//end ShowInventory(int ItemNo)
    public void EnableFields(boolean bflag)
    txtfield1[1].setEnabled(bflag);
    txtfield1[2].setEnabled(bflag);
    txtfield1[3].setEnabled(bflag);
    txtfield1[4].setEnabled(bflag);
    txtfield1[5].setEnabled(bflag);
    }//end EnableFields
    public double GetTotalInvVal()
    TotalVal = 0;
    for(int j = 0; j < Inventory.getCount(); j++)
    TotalVal += Products.totalOfInventory(Inventory.getItemPrice(j),
    Inventory.getItemUnits(j), getRestockFee(j));
    return TotalVal;
    }//end GetTotalInvVal
    public void actionPerformed(ActionEvent e)//button actions
    String btnClicked = ((JButton)e.getSource()).getText();
    if (btnClicked.equals("First"))
    EnableFields(false);
    navItem = 0;
    ShowInventory(navItem);
    }//end if
    if (btnClicked.equals("Next"))
    EnableFields(false);
    if (navItem == getCount() - 1)
    navItem = 0;
    }//end if
    else
    navItem += 1;
    }//end else
    ShowInventory(navItem);
    }//end if
    if (btnClicked.equals("Previous"))
    EnableFields(false);
    if (navItem == 0)
    navItem = getCount() - 1;
    }//end if
    else
    navItem = navItem - 1;
    }//end else
    ShowInventory(navItem);
    }//end if
    if (btnClicked.equals("Last"))
    EnableFields(false);
    navItem = getCount() - 1;
    ShowInventory(navItem);
    }//end if
    }//end ActionPerformed
    }// end of class Maker

    for (int i = 0; i < blen; i++)
             navigate[i] = new JButton(blabels);
    gbconstraint.gridx = 1; // ---- > You mean for this be = i, No?
         // Somehow you need to be resetting the grid x for each button added     
    pan.add(navigate[i], gbconstraint);
    navigate[i].addActionListener(this);
    }//end for
    Or check out gridx = GridBagConstraints.RELATIVE
    Message was edited by:
    nantucket

  • Help hiding button in GUI

    Hi,
    I need some help. I want to hide a button in my app's GUI if a related file is not present in the Documents. Here's the code that tries to hide the button:
    tmpStr = [currTxtPath stringByReplacingOccurrencesOfString:@"txt" withString:@"dt"];
    NSLog(tmpStr);
    BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:tmpStr];
    NSLog((fileExists) ? @"YES" : @"NO");
    [picInfoButton setHidden:NO];
    if (!fileExists) {
    [picInfoButton setHidden:YES];
    The here's the output on the console, indicating that the file is not present.
    2010-05-14 17:47:39.978 myApp[8169:207] */Users/me/Library/Application Support/iPhone Simulator/3.2/Applications/4A86E2E1-8F75-4DC0-9767-63AE1963AD2A/Documents/Text_ 0001.dt*
    2010-05-14 17:47:39.979 myApp[8169:207] NO
    Given the log info, can someone tell me why the button does not get hidden?
    Many thanks,
    Sam

    Hey Sam -
    Your code looks fine, so it's most likely the 'picInfoButton' ivar doesn't point to the button object you're observing. Add another log statement to check that:
    tmpStr = [currTxtPath stringByReplacingOccurrencesOfString:@"txt" withString:@"dt"];
    NSLog(tmpStr);
    BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:tmpStr];
    NSLog((fileExists) ? @"YES" : @"NO");
    NSLog(@"picInfoButton=%@", picInfoButton); // <-- does this print "(null)"?
    [picInfoButton setHidden:NO];
    if (!fileExists) {
    [picInfoButton setHidden:YES];
    If the ivar is nil and the button is defined in a xib, make sure the controller's 'picInfoButton' outlet is connected to the button. If the ivar isn't nil, verify that the address printed in the log is actually the address of the visible button. For example, make sure you didn't reset 'picInfoButton' to a newly created button that was never added to the superview. Also make sure there isn't a second button covering the button that's connected to the ivar.
    - Ray

  • Save button on GUI does work in ver. 5, IE_Tab not released for ver. 5

    I was recommended that I should be able to use FF - but the saving button on the GUI for the data portal does not respond and the IE_Tab is not released for the latest version FF
    :-) Ole

    IE Tab V2 (FF 3.5, 4, 5, 6, 7+) 3.5.9.1
    * https://addons.mozilla.org/en-US/firefox/addon/ie-tab-2-ff-36/
    IE Tab Support Forum
    * http://getsatisfaction.com/ietab/products/ietab_ie_tab_2_for_firefox
    * http://getsatisfaction.com/ietab/topics/ietab_on_firefox_5
    Check and tell if its working.

  • Desactivate standard buttons in GUI Status

    We are looking to desactivate these standard buttons in the gui status.
    Button 1: Creates new session
    Button 2: Generates a shortcut on the desktop
    Button 3: Help
    Button 4: Customizing of local layout
    We thing that these buttons are set automaticaly by SAP. Is there a way to desactivate them. (SAP version 4.6C)
    Help Required,
    Best regards.

    Hello Daniel,
    It is not possible to do that. The reason is that these buttons are a part of the SAPGUI. They don't come from the application server - i.e., they don't have any function codes as such. So you wouldn't be able to disable them.
    Regards,
    Anand Mandalika.

  • Overloaded radio buttons -- good GUI design?

    I don't know where else to ask this. What do you think about overloading radio buttons with multiple functions? I have made an update to my Interactive Color Wheel that uses this technique. I haven't released it yet, but it is available here:
    * http://r0k.us/rock/Junk/SIHwheel.html
    It offers eight different sorts of 1567 colors and their names. That seemed to me to be way too many radio buttons; there were originally just three sorts and three buttons. I made a second row that contains the five new sorts accessed via two buttons. The sorts on each button are closely related, riffs on a theme if you will. Consecutive clicks on one of these two buttons will rotate through its functions, with the button text and toolTip updated to match its current sort and state.
    I won't try describing more -- just use it, and let me know what you think. Intuitive? Ugly? Bad GUI design? Other comments?

    RichF wrote:
    Don't forget to take Spot, the Magic Color Dog for a walk! I recommend a different sort than the default [alphabetically], but you can change sorts on the fly. (Try [by hue], or one of the three Hilbert sorts.) In fact, Spot isn't stopping you from doing anything. Well, you'd have to have him go really slow to type in a hex color.
    I was really, really amazed how fast Spot can run. With the gauge fully to the right, the timer has a specified delay of 0, so he's running as fast as everything else in the program lets him. There's a LOT going on, yet Spot can traverse all 1567 colors in mere seconds.
    [add] It just occurred to me, maybe I should set a minimum update rate. I don't want it to cause someone to have an epileptic seizure. I'm thinking of setting 10 updates a second as the fastest it would go. What do you guys think?Actually it made me have to kill the JVM to stop the applet (closing the web page didn't work, apparently the new Java plugin sandboxing doesn't work). Only the JList was updating at full speed, not the color wheel.
    This one I did not do. There was a complication with intensity. It uses a quantized color space, with intensity almost ranging from 0..74. I say almost because this integral range also includes 0.5. I forced that in so the value after black on a 0.255 scale would not be 4, but 2. The third value is 4, and the rest of the time it jumps by 3 or 4 on the 255 scale.
    Once I decided to keep the intensity buttons as they were, it did not make sense to change the tile width buttons either. Their range is only 10..15, so IMO the [-] and [+] buttons work well.Just as a demo how to do that with JSpinner (JSlider is much harder to have non linear scales):
    import java.awt.EventQueue;
    import java.awt.FlowLayout;
    import javax.swing.JFrame;
    import javax.swing.JSpinner;
    import javax.swing.SpinnerNumberModel;
    public class TestJSpinner {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    SpinnerNumberModel rings = new SpinnerNumberModel(10, 10, 15, 1);
                    SpinnerNumberModel intensity = new SpinnerNumberModel(10.0, 0.0, 74.0, 1.0) {
                        @Override
                        public Object getPreviousValue() {
                            Double value = (Double) getValue();
                            if (value == 1.0) {
                                return 0.5;
                            else if (value == 0.5) {
                                return 0.0;
                            else {
                                return super.getPreviousValue();
                        @Override
                        public Object getNextValue() {
                            Double value = (Double) getValue();
                            if (value == 0.0) {
                                return 0.5;
                            else if (value == 0.5) {
                                return 1.0;
                            else {
                                return super.getNextValue();
                    JFrame frame = new JFrame("Test");
                    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    frame.getContentPane().setLayout(new FlowLayout());
                    frame.getContentPane().add(new JSpinner(intensity));
                    frame.getContentPane().add(new JSpinner(rings));
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
    }Edited by: Walter Laan on Nov 5, 2010 2:01 PM

  • OEM 12c: buttons in GUI page does not work

    Hi,
    I am using OEM12c, we just installed BI publisher last week and we have problem configure it to integrate with OEM12c. One day after the failed configuration, one of the target Authorization Policy Manager (oracle.security.apm) shows down, then we start seeing GUI problems on the console:
    1. Under My Oracle Support, all links except for the Community link show blank pages.
    2. Buttons in a lot of pages does not work. For example, view/edit/create on the administer page, nothing happen when click on these buttons. This is all overall the GUI, I think in general http post method is not working. Basically the GUI is un-workable.
    Any suggestion to how to fix these problem?
    Thanks for the help!

    Enterprise Manager Cloud Control Workbook for Applying Bundle Patch 1 (February 2012) and 12.1.0.2 Plugins [ID 1393173.1]

  • Exit button in GUI

    hi every pro, can teach me write a statement to implement my "EXIT" button by using ActionListener in GUI?
    thx so much ^^

    In that case, here is the answers to your next 12 Swing questions: [http://java.sun.com/docs/books/tutorial/uiswing/index.html]
    ;-)

  • OK Codes of GUI buttons while GUI recording.

    Hi all,
    I am facing a problem.. While BDC recording of any T-Code OK- Codes of the GUI (PF status) buttons like Cancel, Back and Up are not captured..
    Suppose after recording is done and we run that BDC recording and at any point of time we want to press 'CANCEL' and come out of screen it is not cancelled and goes further to the next screen..
    Please Help.
    Thanks and Regards,

    hi,
    No need to capture gui button function code..
    In SAP 'bend ' function code is used for come out the bdc recording at any step provided by .
    regards
    Gaurav

  • Please Help - Need Help with Buttons for GUI for assignment. URGENT!!

    Can someone please help me with the buttons on this program? I cannot figure out how to get them to work.
    Thanks!!!
    import java.awt.*;
    import java.awt.event.*;
    import java.text.NumberFormat;
    import javax.swing.*;
    import javax.swing.JButton;
    public class InventoryTAH implements ActionListener
        Maker[] proMaker;
        JTextField[] fields;
        NumberFormat nf;
        public void actionPerformed(ActionEvent e)
            int index = ((JComboBox)e.getSource()).getSelectedIndex();
            populateFields(index);
        public static void main(String[] args)
            try
                UIManager.setLookAndFeel(
                        "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            catch (Exception e)
                System.err.println(e.getClass().getName() + ": " + e.getMessage());
            InventoryTAH test = new InventoryTAH();
            test.initMakers();
            test.showGUI();
            test.populateFields(0);
        private void initMakers() {
            proMaker = new Maker[10];
            proMaker[0] = new Maker( 1, "Pens",1.59,100,"Bic");
            proMaker[1] = new Maker( 2, "Pencils", .65, 100,"Mead");
            proMaker[2] = new Maker( 3, "Markers", 1.29, 100,"Sharpie");
            proMaker[3] = new Maker( 4, "Paperclips", 1.19, 100,"Staples");
            proMaker[4] = new Maker( 5, "Glue", .85, 100,"Elmer's");
            proMaker[5] = new Maker( 6, "Tape", .50, 100,"3m");
            proMaker[6] = new Maker( 7, "Paper", 1.85, 100,"Mead");
            proMaker[7] = new Maker( 8, "Stapler", 2.21, 100,"Swingline");
            proMaker[8] = new Maker( 9, "Folders", .50, 100,"Mead");
            proMaker[9] = new Maker( 10, "Rulers", .27, 100,"Stanley");      
          int maxNum = 10;
          int currentNum = 0;
          int currentInv = 0;
             Action firstAction = new AbstractAction("First")
              public void actionPerformed(ActionEvent evt)
                   currentInv = 0;
                   int populateFields;
          JButton firstButton = new JButton(firstAction);
          Action previousAction = new AbstractAction("Previous")
              public void actionPerformed(ActionEvent evt)
                   currentInv--;
                   if (currentInv < 0)
                        currentInv = maxNum - 1;
                   int populateFields;
          JButton previousButton = new JButton(previousAction);
          Action nextAction  = new AbstractAction("Next")
              public void actionPerformed(ActionEvent evt)
                   currentInv++;
                   if (currentInv >= currentNum)
                        currentInv = 0;
                  int populateFields;
          JButton nextButton = new JButton(nextAction);
          Action lastAction = new AbstractAction("Last")
              public void actionPerformed(ActionEvent evt)
                   currentInv = currentNum - 1;
                   int populateFields;
          JButton lastButton = new JButton(lastAction);
              JPanel buttonPanel = new JPanel( );
        private void showGUI() {
            JLabel l;
            JButton button1;
                JButton button2;
            fields = new JTextField[8];
            JFrame f = new JFrame("Inventory");
            Container cp = f.getContentPane();
            cp.setLayout(new GridBagLayout());
            cp.setBackground(UIManager.getColor(Color.BLACK));
            GridBagConstraints c = new GridBagConstraints();
            c.gridx = 0;
            c.gridy = GridBagConstraints.RELATIVE;
            c.gridwidth = 1;
            c.gridheight = 1;
            c.insets = new Insets(2, 2, 2, 2);
            c.anchor = GridBagConstraints.EAST;
            cp.add(l = new JLabel("Item Number:", SwingConstants.CENTER), c);
            l.setDisplayedMnemonic('a');
            cp.add(l = new JLabel("Item Name:", SwingConstants.CENTER), c);
            l.setDisplayedMnemonic('b');
            cp.add(l = new JLabel("Number of Units in Stock:", SwingConstants.CENTER), c);
            l.setDisplayedMnemonic('c');
            cp.add(l = new JLabel("Price per Unit: $", SwingConstants.CENTER), c);
            l.setDisplayedMnemonic('d');
            cp.add(l = new JLabel("Total cost of Item: $", SwingConstants.CENTER), c);
            l.setDisplayedMnemonic('e');
            cp.add(l = new JLabel("Total Value of Merchandise in Inventory: $", SwingConstants.CENTER), c);
            l.setDisplayedMnemonic('f');
            cp.add(l = new JLabel("Manufacturer:", SwingConstants.CENTER), c);
            l.setDisplayedMnemonic('g');
            cp.add(l = new JLabel("Restocking Fee: $", SwingConstants.CENTER), c);
            l.setDisplayedMnemonic('h');
                c.gridx = 1;
            c.gridy = 0;
            c.weightx = 1.0;
            c.fill = GridBagConstraints.HORIZONTAL;
            c.anchor = GridBagConstraints.CENTER;
            cp.add(fields[0] = new JTextField(), c);
            fields[0].setFocusAccelerator('a');
            c.gridx = 1;
            c.gridy = GridBagConstraints.RELATIVE;
            cp.add(fields[1] = new JTextField(), c);
            fields[1].setFocusAccelerator('b');
            cp.add(fields[2] = new JTextField(), c);
            fields[2].setFocusAccelerator('c');
            cp.add(fields[3] = new JTextField(), c);
            fields[3].setFocusAccelerator('d');
            cp.add(fields[4] = new JTextField(), c);
            fields[4].setFocusAccelerator('e');
            cp.add(fields[5] = new JTextField(), c);
            fields[5].setFocusAccelerator('f');
            cp.add(fields[6] = new JTextField(), c);
            fields[6].setFocusAccelerator('g');
            cp.add(fields[7] = new JTextField(), c);
            fields[7].setFocusAccelerator('h');
            c.weightx = 0.0;
            c.fill = GridBagConstraints.NONE;
              cp.add(firstButton);
              cp.add(previousButton);
              cp.add(nextButton);
              cp.add(lastButton);
                          JComboBox combo = new JComboBox();
            for(int j = 0; j < proMaker.length; j++)
                combo.addItem(proMaker[j].getName());
            combo.addActionListener(this);
                cp.add(combo);
                cp.add(button1 = new JButton("   "), c);
            f.pack();
            f.addWindowListener(new WindowAdapter()
                public void windowClosing(WindowEvent evt)
                    System.exit(0);
            f.setVisible(true);
      private void populateFields(int index) {
            Maker maker = proMaker[index];
            fields[0].setText(Long.toString(maker.getNumberCode()));
            fields[1].setText(maker.getName());
            fields[2].setText(Long.toString(maker.getUnits()));
            fields[3].setText(Double.toString(maker.getPrice()));
            fields[4].setText(Double.toString(maker.getSum()));
            fields[5].setText(Double.toString(maker.totalAllInventory(proMaker)));
            fields[6].setText(maker.getManufact());
            fields[7].setText(Double.toString(maker.getSum()*.05));       
    class Maker {
        int itemNumber;
        String name;
        int units;
        double price;
        String manufacturer;
        public Maker(int n, String name, double price, int units, String manufac) {
            itemNumber = n;
            this.name = name;
            this.price = price;
            this.units = units;
            manufacturer = manufac;
        public int getNumberCode() { return itemNumber; }
        public String getName() { return name; }
        public int getUnits() { return units; }
        public double getPrice() { return price; }
        public double getSum() { return units*price; }
        public String getManufact() { return manufacturer; }
        public double totalAllInventory(Maker[] makers) {
            double total = 0;
            for(int j = 0; j < makers.length; j++)
                total += makers[j].getSum();
            return total;
    }}

    // I have made some modifications. Please try this.
    import java.awt.*;
    import java.awt.event.*;
    import java.text.NumberFormat;
    import javax.swing.*;
    import javax.swing.JButton;
    public class InventoryTAH implements ActionListener
    Maker[] proMaker;
    JTextField[] fields;
    NumberFormat nf;
    int currentInv = 0;
    public void actionPerformed(ActionEvent e)
    currentInv= ((JComboBox)e.getSource()).getSelectedIndex();
    populateFields(currentInv);
    public static void main(String[] args)
    try
    UIManager.setLookAndFeel(
    "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    catch (Exception e)
    System.err.println(e.getClass().getName() + ": " + e.getMessage());
    InventoryTAH test = new InventoryTAH();
    test.initMakers();
    test.showGUI();
    test.populateFields(0);
    private void initMakers() {
    proMaker = new Maker[10];
    proMaker[0] = new Maker( 1, "Pens",1.59,100,"Bic");
    proMaker[1] = new Maker( 2, "Pencils", .65, 100,"Mead");
    proMaker[2] = new Maker( 3, "Markers", 1.29, 100,"Sharpie");
    proMaker[3] = new Maker( 4, "Paperclips", 1.19, 100,"Staples");
    proMaker[4] = new Maker( 5, "Glue", .85, 100,"Elmer's");
    proMaker[5] = new Maker( 6, "Tape", .50, 100,"3m");
    proMaker[6] = new Maker( 7, "Paper", 1.85, 100,"Mead");
    proMaker[7] = new Maker( 8, "Stapler", 2.21, 100,"Swingline");
    proMaker[8] = new Maker( 9, "Folders", .50, 100,"Mead");
    proMaker[9] = new Maker( 10, "Rulers", .27, 100,"Stanley");
         int maxNum = 10;
         int currentNum = 0;
    Action firstAction = new AbstractAction("First")
              public void actionPerformed(ActionEvent evt)
                   currentInv = 0;
                   populateFields(currentInv);
         JButton firstButton = new JButton(firstAction);
         Action previousAction = new AbstractAction("Previous")
              public void actionPerformed(ActionEvent evt)
                   currentInv--;
                   if (currentInv < 0)
                        currentInv = maxNum - 1;
                   populateFields(currentInv);
         JButton previousButton = new JButton(previousAction);
         Action nextAction = new AbstractAction("Next")
              public void actionPerformed(ActionEvent evt)
                   currentInv++;
                   if (currentInv >= maxNum)
                        currentInv = 0;
              populateFields(currentInv);
         JButton nextButton = new JButton(nextAction);
         Action lastAction = new AbstractAction("Last")
              public void actionPerformed(ActionEvent evt)
                   currentInv = maxNum-1;
                   populateFields(currentInv);
         JButton lastButton = new JButton(lastAction);
              JPanel buttonPanel = new JPanel( );
    private void showGUI() {
    JLabel l;
    JButton button1;
              JButton button2;
    fields = new JTextField[8];
    JFrame f = new JFrame("Inventory");
    Container cp = f.getContentPane();
    cp.setLayout(new GridBagLayout());
    cp.setBackground(UIManager.getColor(Color.BLACK));
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(2, 2, 2, 2);
    c.anchor = GridBagConstraints.EAST;
    cp.add(l = new JLabel("Item Number:", SwingConstants.CENTER), c);
    l.setDisplayedMnemonic('a');
    cp.add(l = new JLabel("Item Name:", SwingConstants.CENTER), c);
    l.setDisplayedMnemonic('b');
    cp.add(l = new JLabel("Number of Units in Stock:", SwingConstants.CENTER), c);
    l.setDisplayedMnemonic('c');
    cp.add(l = new JLabel("Price per Unit: $", SwingConstants.CENTER), c);
    l.setDisplayedMnemonic('d');
    cp.add(l = new JLabel("Total cost of Item: $", SwingConstants.CENTER), c);
    l.setDisplayedMnemonic('e');
    cp.add(l = new JLabel("Total Value of Merchandise in Inventory: $", SwingConstants.CENTER), c);
    l.setDisplayedMnemonic('f');
    cp.add(l = new JLabel("Manufacturer:", SwingConstants.CENTER), c);
    l.setDisplayedMnemonic('g');
    cp.add(l = new JLabel("Restocking Fee: $", SwingConstants.CENTER), c);
    l.setDisplayedMnemonic('h');
              c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    cp.add(fields[0] = new JTextField(), c);
    fields[0].setFocusAccelerator('a');
    c.gridx = 1;
    c.gridy = GridBagConstraints.RELATIVE;
    cp.add(fields[1] = new JTextField(), c);
    fields[1].setFocusAccelerator('b');
    cp.add(fields[2] = new JTextField(), c);
    fields[2].setFocusAccelerator('c');
    cp.add(fields[3] = new JTextField(), c);
    fields[3].setFocusAccelerator('d');
    cp.add(fields[4] = new JTextField(), c);
    fields[4].setFocusAccelerator('e');
    cp.add(fields[5] = new JTextField(), c);
    fields[5].setFocusAccelerator('f');
    cp.add(fields[6] = new JTextField(), c);
    fields[6].setFocusAccelerator('g');
    cp.add(fields[7] = new JTextField(), c);
    fields[7].setFocusAccelerator('h');
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
              cp.add(firstButton);
              cp.add(previousButton);
              cp.add(nextButton);
              cp.add(lastButton);
                        JComboBox combo = new JComboBox();
    for(int j = 0; j < proMaker.length; j++)
    combo.addItem(proMaker[j].getName());
    combo.addActionListener(this);
              cp.add(combo);
              cp.add(button1 = new JButton(" "), c);
    f.pack();
    f.addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent evt)
    System.exit(0);
    f.setVisible(true);
    private void populateFields(int index) {
    Maker maker = proMaker[index];
    fields[0].setText(Long.toString(maker.getNumberCode()));
    fields[1].setText(maker.getName());
    fields[2].setText(Long.toString(maker.getUnits()));
    fields[3].setText(Double.toString(maker.getPrice()));
    fields[4].setText(Double.toString(maker.getSum()));
    fields[5].setText(Double.toString(maker.totalAllInventory(proMaker)));
    fields[6].setText(maker.getManufact());
    fields[7].setText(Double.toString(maker.getSum()*.05));
    class Maker {
    int itemNumber;
    String name;
    int units;
    double price;
    String manufacturer;
    public Maker(int n, String name, double price, int units, String manufac) {
    itemNumber = n;
    this.name = name;
    this.price = price;
    this.units = units;
    manufacturer = manufac;
    public int getNumberCode() { return itemNumber; }
    public String getName() { return name; }
    public int getUnits() { return units; }
    public double getPrice() { return price; }
    public double getSum() { return units*price; }
    public String getManufact() { return manufacturer; }
    public double totalAllInventory(Maker[] makers) {
    double total = 0;
    for(int j = 0; j < makers.length; j++)
    total += makers[j].getSum();
    return total;
    }}

  • Adding a button in Application toolbar of Transaction IW32

    Hi ,
    I need to add a button in the Application Toolbar of standard transaction IW32,I tried copying the pf-status and adding it in the user exit exit_saplocih_006 also,but its not working.
    Please Kindly help.
    Regards,
    Ismail.

    I think you must create a copy of IW32 ( I am not wrong in SAP lingo they say repair) for example ZIW32. And add a button relevant gui status. (I have been looking Gui status of IW32 it is have more status. you must find true status)
    If you want change original source don't forget this a patch can change your code.

  • Problem with calculate button in form

    hi all
    We have a problem when we try to calculate in a data form using the button of GUI. We receive a form syntax verification message "with impossible to verify the calculation:", scenario,year,entity.
    We don't have this error when we use the calculate funzione using the contextual menu (right button over the cell).
    it appears that only users with administrative authorization doon't have this problem, only normal users have the error with the button.
    Do you have any idea about what generate the error? THanks
    Davide
    Edited by: user8013028 on 12-Oct-2012 06:48

    The form may be set to clear the fields when opening. There are various reasons folks select this option, but it is likely the problem.

Maybe you are looking for

  • 11.1.2 bug with iteratorBinding?

    This worked in 11.1.1.5 but in 11.1.2 I get the following error: javax.el.PropertyNotFoundException: The class 'oracle.jbo.server.ViewRowImpl' does not have the property 'shortName'. <af:forEach items="#{bindings.DictionaryVO1.iteratorBinding.allRows

  • Won't display table correctly; shows OK in IE all versions

    Table won't display correctly in Firefox; deletes first <tr>...</tr> section, shifts 2nd <tr>...</tr> section to right. The table shows correctly in all IE versions.

  • External service management

    hello, i am working for construction industry. This is   regarding unplanned external service procured by client. They get external service from labour contactors for ex: colouring the wall, plastering the wall etc. which are purely unplanned.They ca

  • Error: java.lang.UnsatisfiedLinkError: t2cParseExecuteDescribe

    Connection to DB seems fine Opening the connection just sits there " loading... " Opening a SQL Worksheet produces the following error message: Can someone help? java.lang.UnsatisfiedLinkError: t2cParseExecuteDescribe      at oracle.jdbc.driver.T2CSt

  • Umlauts in e-mail-templates

    Hi everybody, my sun idm 8.0-setup usually has no issues with german umlauts like äöüß, it should be clean UTF-8. However, I face problems using such characters in my email-templates, they are always broken and messages like "welcome Mr. M?ller" just