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

Similar Messages

  • 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

  • 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;
    }}

  • Help: Link buttons to each row in JTable

    Here is the story: a JTable contains many entries/rows. I want to have a small "edit" button next to each row, once user click the "edit" button, another GUI will be loaded, and the new GUI is filled with the row of data where that clicked button is corresponding to.
    Question:
    1.How to link a button to a specific row in the JTable?
    2.Can I put the buttons inside the JTable? How?(eg. button at the end of each row).
    3.If it's not possible to put the button inside the JTable, then I want to make 5 buttons next to the JTable area(only 5 rows are visible in JTable at any given time). Now, assume we have 20 rows, 1-5 are visible, if I scroll down to 10-15, what can I do to make that once user click the top button of the five, row 10 is loaded with the GUI?
    plz help, thx.

    Ok, what i want to do is:
    user search the database, I display the search result on to the screen(use JTable).
    The search result will contain many rows of data, I want to allow user to choose a row, and edit that row with an editor. The editor is another GUI, that GUI will first be filled with data from the row that user chose, then user can edit those data with that editor.
    So my problem is: I dont know how to make the program know which row user chose from the JTable before it load the editor.

  • Buttons hiding buttons on indesign

    Hi hope you can help. I'm using indesign CS5 and have a problem with pop up buttons being hidden by other buttons. The page design is a 7 column grid with around 10 buttons underneath each column that act as hyperlinks and trigger other show/hide buttons that give a brief summary of the info at the destination of the hyperlink. So in total there is about 140 buttons - 70 shown all the time and 70 pop ups. To help me manage the design I set up the pop up buttons in 7 separate layers as they overlay the buttons in the 7 column grid. When I export to PDF the pop up buttons appear but are partially hidden by the other buttons. Strangely this is only happening for a proportion with some appearing as they should and in the button tool bar review option they all appear fine. It also worked fine on initial exports and the problem only started when I rearranged the tab order.
    Any any help would be much appreciated!
    James

    Hello,
    I do not think that the BASIS can help you in deleting/hiding buttons from the UI. Generally, the buttons are stored in the GT_BUTTON/GT_BUTTONS attribute of the overview view/viewset controller. In some cases it may be hard coded inside the htm page as well in the form of HTML tags.
    We'd definitely need to do some programming to achieve the functionality you are looking for, Also remember it is different for different views. You need to find out the view that has the buttons.
    Do a F2 on your UI screen to find out the details of the screen.
    Regards
    Prasenjit

  • Hiding buttons based up on business role; Is possible by the BASIS?

    Hi Experts,
    I have done one enhancement for hiding the buttons according to Business role using coding but it was not possible for all the desired buttons since I couldnu2019t find out relevant internal tables for the buttons.
    Now we are planning to do the same activity by the BASIS help.
    Are Hiding buttons based up on user or business role can be possible by the BASIS activity like authorization object to handle the drop downs based up on roles .
    If possible please suggest me the way out to resolve the issue using any kind of BASIS activity.
    Thanks
    Chand

    Hello,
    I do not think that the BASIS can help you in deleting/hiding buttons from the UI. Generally, the buttons are stored in the GT_BUTTON/GT_BUTTONS attribute of the overview view/viewset controller. In some cases it may be hard coded inside the htm page as well in the form of HTML tags.
    We'd definitely need to do some programming to achieve the functionality you are looking for, Also remember it is different for different views. You need to find out the view that has the buttons.
    Do a F2 on your UI screen to find out the details of the screen.
    Regards
    Prasenjit

  • Need help wit socketserver and GUI

    Hi, I've been searching a web all day how to do that my socketserver do not freeze my GUI. And no luck :( Maybe someone could help me in this case? I would like to see working example of two classes: GUI and server. The server's listening process should be launched after button in GUI class is clicked.
    PLEASE someone help me!

    Lixas wrote:
    i'm creating server that measures temperature (in my case it simulates it) and controls some other external hardware (in my case all goes in simulation way). In short- its a remote control ventilation/heating system... and i'm going to do interface for that server, where admin can use server's GUI to control server. Also later i will do web interface, standalone control system, mobile app, and java applet for my server (remote control systems). But first i want to build a server that listens for the connections and also has GUIYour server shouldn't have a GUI. Your server should be a seperate program. Which you talk to through an adminstrator client.
    Do as you like though.
    You should start either way with that tutorial. If you don't know how to use multithreading in Java then you're a long, long, long way from anything I fear.

  • How to call elem. Search help on Button click event in WD appilcation

    Hello All,
    i have requirement to call elem. search help on button click event in WD application. currently i am calling FM  F4IF_START_VALUE_REQUEST but getting the short dump as below,
    The following error text was processed in the system X31 : Screen output without connection to user.
    The error occurred on the application server saps_X31_31 and in the work process 0 .
    The termination type was: RABAX_STATE
    The ABAP call stack was:
    SYSTEM-EXIT of program SAPLSDH4
    Function: F4_PRESEL_WITH_TABSTRIP of program SAPLSDH4
    Form: F4PROZ_STEP_PRESEL of program SAPLSDSD
    Function: DD_SHLP_SINGLE_STEP of program SAPLSDSD
    Form: F4PROZ_LOOP of program SAPLSDSD
    Form: F4PROZ of program SAPLSDSD
    Function: F4IF_START_VALUE_REQUEST of program SAPLSDHI
    Method: ONACTIONSEARCH_CUSTOMER of program /1BCWDY/50TU5ZEXF3K0IWCWE153==CP
    Method: IF_WDR_VIEW_DELEGATE~WD_INVOKE_EVENT_HANDLER of program /1BCWDY/50TU5ZEXF3K0IWCWE153==CP
    Method: INVOKE_EVENTHANDLER of program CL_WDR_DELEGATING_VIEW========CP
    is there any way to achieve the required behaviour.
    please let me know.
    Regards,
    Chandra

    Hi Friends,
    I have the similar kind of requirement. Upon click on a Button on screen i need to call a search help, and collect one or more selected material numbers.
    The search help is working fine and i am getting the entries with the following code.
    The problem is i am finding extra popup on screen.
    CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
    EXPORTING
    tabname         =  space
    fieldname       =  space
    SEARCHHELP      =  'MAT1'
    MULTIPLE_CHOICE =  'X'
    STEPL           =  0
    value           = 'MATNR'
    *dynpprog        =  progname
    *dynpnr          =  dynnum
    *dynprofield     = 'CARRIER'
    CALLBACK_PROGRAM          = 'ZTEST_1_PRA'
    CALLBACK_FORM             = 'F4CALLBACK'
    TABLES
    RETURN_TAB                = RETURN_TAB
    EXCEPTIONS
    FIELD_NOT_FOUND           = 1
    NO_HELP_FOR_FIELD         = 2
    INCONSISTENT_HELP         = 3
    NO_VALUES_FOUND           = 4
    OTHERS                    = 5.

  • Help with buttons :S

    hi all,
    i'm new to flash but i have an idea whats going on with webpages. I need some help with buttons! i have a website and its has a stage and 9 different flv's (screens). I've been trying to read online and i can't find out how to navigate to different screens, example below
    home          |            |
    about us     |  stage   |
    contact       |            |
    you click one one button it updates the stage. also i'm using actionscript 2.0.
    thanks for any help ahead of time
    Thank you,

    Is it a wi-fi or cellular connection that isn't working?  If its wi-fi and other people/computers/phones can connect check your settings.  If its cellular, are other people's phones (on the same carrier) working in the same location? If other people can't connect then it is likely a network problem.  If others can you may need to reset/restore you iPhone.

  • 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

  • Need help about button

    Hi everybody!
    I'm from Italy, so I need help regarding button
    I create an animation, I put a button to replay the movie by this code:
    on (release) {
    gotoAndPlay(1);
    but in AS3 doesn't work. Can you help me pls?
    Another problem...I need a very simple preloader that display only percentage, stop.
    Anybody knows a template or tutorial about this?
    Thx in advance!

    What do you mean by scene2?. You can only preload external content like a picture, another swf, etc...a much simpler example:
    var myLoader:Loader = new Loader();
    addChildAt(myLoader,0)
    myLoader.load(new URLRequest("http://www.snowman-jim.org/science/images/north-pole-sun-moon.jpg"))
    myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loading)
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading)
    function loading(e:ProgressEvent):void{
        info_txt.text="Loading.."Math.floor(e.currentTarget.bytesLoaded/1024)" Kb";//e.currentTarget is referring to myLoader.contentLoaderInfo
    function finalizado(e:Event):void{
        info_txt.text="I'm done!";
    Just change myLoader.load(new URLRequest("http://www.snowman-jim.org/science/images/north-pole-sun-moon.jpg")) path for the relevant path to the file you want to preload.

  • 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!

  • Desperate need of HELP for a Java GUI !

    Hy people,
    I am working on a project trying to display a GUI where its output is dependant on the user's input.
    Here is a brief example of what Im trying to do:
    You have a GUI that contains 2 panels. buttonPanel and DisplayPanel.
    buttonPanel contains:
    a dropdown list: includes choices of colors,
    2 textfields: the length: (can enter from 1 to 100),
    the width: (can enter from 1 to 100),
    a checkbox: random
    and a start button.
    Now when I enter ALL the information needed in the components and then press start button, it should display its result in the DisplayPanel.
    In my case, I want to display just one rectangle to start off. That will have its color changed by the dropdown choice made. Now Im forgetting about the length and width textfield for now cause that will be incorporated for something else later on.
    I created a buttonLitener for the start button and an ItemListener for the dropDown List.
    I declared and drew a rectangle specific to the color chosen by the user in a class I created called DrawingCanvas that extends Canvas and that overrides the paint method.
    BUT My problem is that it does not display the rectangle I created in my DisplayPanel when I press on the Start button.
    I provided a screenshot of the GUI interface, and my 2 java files. Is someone brave enough to fix my problem or even tell me what Im doing wrong ?!
    ScreenShot:
    http://www.hybrid.concordia.ca/~boumbo/GUIProblem.jpg
    Java Files:
    http://www.hybrid.concordia.ca/~boumbo/GUI.zip]Java Files
    PLEASE I am not Amazing with Java, and pulling my hair out in figuring out my problem.
    Thank you.

    Seriously, look at the first reply in the following thread. It gives a pretty good idea of generally accepted good practices in the forum.
    http://forum.java.sun.com/thread.jspa?threadID=603683
    It is probably better to post code directly on the forum than to try to get people to take the extra steps to download, unzip, and compile your code. That way, they can just cut and paste to try to compile. Be sure to use [code][/code] tags to make your code easier to use. And, try to provide a small example of your problem if the code is very long or complex.
    Another piece of advice. Don't try to challenge the regulars in this forum to prove that they are smart enough, brave enough, whatever enough to tackle YOUR problem. The regulars here include software engineers, authors, and generally very smart and experienced people They don't need to prove themselves to anyone.
    What they want to see is that you have genuinely tried to understand your problem, rather than just running to the forum the first time you get a compiler error.
    You seem to have been working on this problem. Go ahead and create a test case that shows what the problem is. Quite frequently, just doing that will help you solve the problem yourself.
    Good luck.
    RD-R
    � {�
    Mon Mar 07 00:57:45 EST 2005
    Pseudo-random saying number 257 of 635
    For every complex problem, there is a solution that is simple, neat,
    and wrong.
                    -- Henry Louis Mencken

  • Help with a better GUI??

    hi everyone!!
    i am thinking for a better GUI i have already made..earlier my GUI was not reflecting any changes but with the help and suggestions by many of you i have tried to change it..but i still find it is not reflecting to be a good interface.i really need some help..i am hereby posting the code ..hope to get a good GUI than i have..
    Thanks a lot
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    public class front3 extends JFrame
         JRadioButton split,zip,rename,unzip;
             ButtonGroup radioGroup;
          public front3()
          Container c = getContentPane();
             c.setLayout(new  GridLayout(0,1)); 
          c.setBackground(Color. cyan);
           setSize(530,120);
          setResizable(false); // to disable  the maximize  button
            ImageIcon ip= new ImageIcon("title.jpg");
            JLabel j1=new JLabel("Choose the operation to be done :",ip,JLabel.CENTER);
    j1.setBackground(Color.red);
    c.add(j1);
             ImageIcon ii= new ImageIcon("split.jpg");
             split=new JRadioButton("Splitter",ii,false);
             split.setBackground(Color.cyan);
          ImageIcon ij= new ImageIcon("zip.jpg");
             zip=new JRadioButton("Zipper",ij,false);
             zip.setBackground(Color.cyan);
          ImageIcon ik= new ImageIcon("rename.jpg");
             rename=new JRadioButton("Rename all",ik,false);
          rename.setBackground(Color.cyan);
          ImageIcon il= new ImageIcon("unzip.jpg");
             unzip=new JRadioButton("unzip",il,false);
             unzip.setBackground(Color.cyan);
             c.add (split);
             c.add(zip);
             c.add(unzip);
             c.add(rename);
      // create logical relationship between JRadioButtons
          radioGroup = new ButtonGroup();
             radioGroup.add(split );
             radioGroup.add( zip);
             radioGroup.add(rename );
             radioGroup.add( unzip);
          //  setPosition(250,250);
    setTitle("FILE UTILITY SOFTWARE");
    setSize(300,500);
             setVisible(true);
    split.addItemListener(new ItemListener()
    public void itemStateChanged(ItemEvent event)
    if(split.isSelected())
    Gui file = new Gui();
    zip.addItemListener(new ItemListener()
    public void itemStateChanged(ItemEvent event)
    if(zip.isSelected())
    zipping file = new zipping();
    unzip.addItemListener(new ItemListener()
    public void itemStateChanged(ItemEvent event)
    if(unzip.isSelected())
    decompress file = new decompress();
    rename.addItemListener(new ItemListener()
    public void itemStateChanged(ItemEvent event)
    if(rename.isSelected())
    rename file = new rename();
       public static void main(String args[])
                  front3 f=new front3();
                  f.addWindowListener(
                       new WindowAdapter() {
                            public void windowClosing(WindowEvent e)
                                 System.exit(0);
      }

    simply run this code to see the GUI-
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.filechooser.*;
    public class front33 extends JFrame
         JRadioButton split,zip,rename,unzip;
             ButtonGroup radioGroup;
          public front33()
          Container c = getContentPane();
             c.setLayout(new  GridLayout(0,1)); 
          c.setBackground(Color. cyan);
           setSize(530,120);
          setResizable(false); // to disable  the maximize  button
            ImageIcon ip= new ImageIcon("title.jpg");
            JLabel j1=new JLabel("Choose the operation to be done :",ip,JLabel.CENTER);
    j1.setBackground(Color.red);
    c.add(j1);
             ImageIcon ii= new ImageIcon("split.jpg");
             split=new JRadioButton("Splitter",ii,false);
             split.setBackground(Color.cyan);
          ImageIcon ij= new ImageIcon("zip.jpg");
             zip=new JRadioButton("Zipper",ij,false);
             zip.setBackground(Color.cyan);
          ImageIcon ik= new ImageIcon("rename.jpg");
             rename=new JRadioButton("Rename all",ik,false);
          rename.setBackground(Color.cyan);
          ImageIcon il= new ImageIcon("unzip.jpg");
             unzip=new JRadioButton("unzip",il,false);
             unzip.setBackground(Color.cyan);
             c.add (split);
             c.add(zip);
             c.add(unzip);
             c.add(rename);
      // create logical relationship between JRadioButtons
          radioGroup = new ButtonGroup();
             radioGroup.add(split );
             radioGroup.add( zip);
             radioGroup.add(rename );
             radioGroup.add( unzip);
          //  setPosition(250,250);
    setTitle("FILE UTILITY SOFTWARE");
    setSize(300,500);
             setVisible(true);
    public static void main(String args[])
                  front33 f=new front33();
                  f.addWindowListener(
                       new WindowAdapter() {
                            public void windowClosing(WindowEvent e)
                                 System.exit(0);
      }

  • I need help with buttons

    I am creating a GUI program, and I would like to know how to recognize a "mouseover" event on a button. Right now I am using "private JButton Button;" -- is it possible to have a mouseover for that?
    If not, please tell me the steps I need to take in order to be able to have a mouseover event on a button. It is relatively important to the program =P
    Thanks.
    Edit -- I am going to be AFK for a while, please respond with as much info as possible. Thanks again ;-)

    I went to the help section on setRolloverIcon, and I kind of understand it, but what is an "Icon"?
    What I want to happen when I move my mouse over the button is this: TextBox.setText("This button does this: bla bla bla");
    Then I want the text in TextBox to go away when my mouse leaves the button. I know this is possible in some programs, but is it in Java?

Maybe you are looking for

  • HT3529 Can someone help me understand why my iMessage no longer works on my iPad

    Can someone help me understand why my iMessage no longer works on my iPad

  • Folder Size Displayed in Name  How to???

    Hi, I was at a friends who had all the folders on his desk top and elsewhere I suppose, displaying the size of the folder under it's name. I asked and he said under view options but I can't find a selection that will do that. I have a bunch of folder

  • Copy data between productive and test system

    Hi everybody, I need to copy data from one cube in productive system into the same cube in the test system. How can I do it? Regards Erwin

  • Cannot use object "CLAS CX_ROOT CLAS "

    Hi guy I am developing a function in my namespace ********* and I use try catch with  CX_ROOT . When I passed my function in Slin (t-code) the check program display the erro below. Any ideas how to correct it ? Syntax check warning (E) Pakage "******

  • Smtp rejecting outgoing mail

    Just started getting smtp rejecting mail. Server response from mail client: Server Configuration error. I tried to edit postfix/main.cf as the root, but get permissions denied. At this point I cannot do anything, although terminal lets me log in as r