Objects in a GUI

When I run my GUI which has buttons, textareas and textfield I have to adjust my frame to make the objects appear, this is not because of the size of the frame . It just makes them appear wen i slightly adjust the frame size.
Could this be to do with wrong code? or is it a graphical problem?

Could this be to do with wrong code? or is it a
graphical problem?hi,
This problem is faced by most of GUI developers. This is bcoz at times wen u only repaint the window the componets would appear properly. To solve this you can explicitly call the repaint on window load. Remeber you can also made a some mistake on ur code..!!

Similar Messages

  • Dynamic Variables and New-Object - in a GUI

    so, i have not found anything that i can parlay into a solution for what i am attempting to do.  
    Basically i am using powershell to build a GUI to manage websites on various servers.  
    in a nutshell:
    - i have an array with the servers i want to query
    - a foreach loop gets me the site names for each server (number of sites can vary on a server).
    - need put checkboxes on a GUI for every site to do something (25-30 sites across 8 servers).
    currently i am passing the $dir.name variable to a function that will create the new variable using this command:
    $pName = $dir.name New-variable -name $pName -value (New-Object System.Windows.Forms.CheckBox)
    $pName.Location -value (New-Object System.Drawing.Size(10,$i))
    $pName.Size -value (New-Object System.Drawing.Size(100,20))
    $Pname.Text -value $dir.name
    $groupBox.Controls.Add($pName) 
    Problem is i am not able to do anything with my newly created variable.  I am trying to use the following code to position the new checkbox but i get nothing (same for text, size, etc.)  I am not seeing any errors, so i don't know what i have going
    wrong.  
    is this even possible?
    I am able to create static checkboxes, and i can create dynamic variables.  But i can't mix the two...

    Here is how we normally use listboxes to handle form situations like this one.  The listboxes can automatically select subgroups.
    The hash of arrays can be loaded very easily with a script or the results of the first list can be used to lookup and set the contents of the second.
    Notice how little code is actually used.  This is all of the setup code needed aside from the from definition:
    $FormEvent_Load={
    $global:serversToSites=@{
    Server1=@('S1_SITE1','S1_SITE2','S1_SITE3')
    Server2=@('S2_SITE1','S2_SITE2','S2_SITE3')
    Server3=@('S3_SITE1','S3_SITE2','S3_SITE3')
    $listbox1.Items.AddRange($serversToSites.Keys)
    $listbox1_SelectedIndexChanged={
    $listbox2.Items.Clear()
    $listbox2.Items.AddRange($global:serversToSites[$listbox1.SelectedItem])
    $listbox2_SelectedIndexChanged={
    [void][System.Windows.Forms.MessageBox]::Show($listbox2.SelectedItem,'You Selected Site')
    Here is the complete demo form:
    [void][reflection.assembly]::Load("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")
    [void][reflection.assembly]::Load("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
    [System.Windows.Forms.Application]::EnableVisualStyles()
    $form1 = New-Object 'System.Windows.Forms.Form'
    $listbox2 = New-Object 'System.Windows.Forms.ListBox'
    $listbox1 = New-Object 'System.Windows.Forms.ListBox'
    $buttonOK = New-Object 'System.Windows.Forms.Button'
    $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
    $FormEvent_Load={
    $global:serversToSites=@{
    Server1=@('S1_SITE1','S1_SITE2','S1_SITE3')
    Server2=@('S2_SITE1','S2_SITE2','S2_SITE3')
    Server3=@('S3_SITE1','S3_SITE2','S3_SITE3')
    $listbox1.Items.AddRange($serversToSites.Keys)
    $listbox1_SelectedIndexChanged={
    $listbox2.Items.Clear()
    $listbox2.Items.AddRange($global:serversToSites[$listbox1.SelectedItem])
    $listbox2_SelectedIndexChanged={
    [void][System.Windows.Forms.MessageBox]::Show($listbox2.SelectedItem,'You Selected Site')
    $Form_StateCorrection_Load=
    #Correct the initial state of the form to prevent the .Net maximized form issue
    $form1.WindowState = $InitialFormWindowState
    $form1.Controls.Add($listbox2)
    $form1.Controls.Add($listbox1)
    $form1.Controls.Add($buttonOK)
    $form1.AcceptButton = $buttonOK
    $form1.ClientSize = '439, 262'
    $form1.FormBorderStyle = 'FixedDialog'
    $form1.MaximizeBox = $False
    $form1.MinimizeBox = $False
    $form1.Name = "form1"
    $form1.StartPosition = 'CenterScreen'
    $form1.Text = "Form"
    $form1.add_Load($FormEvent_Load)
    # listbox2
    $listbox2.FormattingEnabled = $True
    $listbox2.Location = '237, 26'
    $listbox2.Name = "listbox2"
    $listbox2.Size = '120, 134'
    $listbox2.TabIndex = 2
    $listbox2.add_SelectedIndexChanged($listbox2_SelectedIndexChanged)
    # listbox1
    $listbox1.FormattingEnabled = $True
    $listbox1.Location = '13, 26'
    $listbox1.Name = "listbox1"
    $listbox1.Size = '120, 134'
    $listbox1.TabIndex = 1
    $listbox1.Sorted = $true
    $listbox1.add_SelectedIndexChanged($listbox1_SelectedIndexChanged)
    # buttonOK
    $buttonOK.Anchor = 'Bottom, Right'
    $buttonOK.DialogResult = 'OK'
    $buttonOK.Location = '352, 227'
    $buttonOK.Name = "buttonOK"
    $buttonOK.Size = '75, 23'
    $buttonOK.TabIndex = 0
    $buttonOK.Text = "OK"
    $buttonOK.UseVisualStyleBackColor = $True
    #Save the initial state of the form
    $InitialFormWindowState = $form1.WindowState
    #Init the OnLoad event to correct the initial state of the form
    $form1.add_Load($Form_StateCorrection_Load)
    #Clean up the control events
    $form1.add_FormClosed($Form_Cleanup_FormClosed)
    #Show the Form
    $form1.ShowDialog()
    You can easily substitute  CheckedListbox if you like checkboxes.
    ¯\_(ツ)_/¯

  • Flash Object Display in GUI HTML VIEWER

    Is there a way to display html string in html viewer which contains the flash objects?
    Regards,
    Santhosh.

    Hi Santosh,
    Yes, create ABAP program in which use the HTML viewer (class:  cl_gui_html_viewer ) within a container.
    Please refer following links -
       About CL_GUI_HTML_VIEWER   -  http://wiki.sdn.sap.com/wiki/display/profile/2007/08/30/About+CL_GUI_HTML_VIEWER
       PDF for reference - http://help.sap.com/printdocu/core/print46c/en/data/pdf/BCCIHTML/BCCIHTML.pdf
    Thanks.
    Kumar Saurav.

  • Data From GUI to Objects?

    Ive been doing a lot of reading and asking a lot of questions about a program Im trying to tackle. Ive broken it down to its most basic form. I have a GUI with two text fields and a button. There is a main class that creates the GUI class and a Student class with a name and grade member. The user enters the name and grade into the fields and clicks the button to save the data to the student object. Im starting to clear up some, but Im still a little confused on where the student class goes in relation to the GUI. Im clear on the fact that student should not be a member object of the GUI (no GUI -> Student), but how then does the info get into the student class if its not a member of the GUI:
    My simple code so far has this snipet:
    private void jButton1_actionPerformed(ActionEvent e)
    student.setName(textField1.getText());
    student.setGrade(textField2.getText());
    But this only works if student is a member object of the GUI and thats a no no apparently, so how else can I get the info to student?

    I made this to demonstrate:
    1 - how the truck objects are separate from the gui,
    2 - how to pass the truck references (eg, truck1, truck2,...) into the gui, and
    3 - how these are used to query and change the truck objects.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ClassTalk
        public static void main(String[] args)
            ShineyNewGUI gui = new ShineyNewGUI();
            ShineyNewPickupTruck truck1 = new ShineyNewPickupTruck("red");
            ShineyNewPickupTruck truck2 = new ShineyNewPickupTruck("yellow");
            ShineyNewPickupTruck truck3 = new ShineyNewPickupTruck("blue");
            ShineyNewPickupTruck truck4 = new ShineyNewPickupTruck("pink");
            ShineyNewPickupTruck[] fleet = { truck1, truck2, truck3, truck4 };
            gui.addTrucks(fleet);
    class ShineyNewGUI
        ShineyNewPickupTruck[] trucks;
        ShineyNewPickupTruck selectedTruck;
        ShineyNewGUI()
            // north panel
            final JTextField colorField = new JTextField(12);
            colorField.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    selectedTruck.setColor(colorField.getText());
            JPanel northPanel = new JPanel();
            northPanel.add(new JLabel("truck color  "));
            northPanel.add(colorField);
            // center panel
            final JLabel outputLabel = new JLabel(" ");
            JPanel panel = new JPanel();
            panel.add(outputLabel);
            // south panel
            final JTextField indexField = new JTextField(4);
            final JButton showColorButton = new JButton("show color");
            showColorButton.addActionListener(new ActionListener()
                public void actionPerformed(ActionEvent e)
                    // must be a number from [0 - 3]
                    int index = Integer.parseInt(indexField.getText());
                    selectedTruck = trucks[index];
                    String truckColor = selectedTruck.color;
                    outputLabel.setText("truck # " + index + " color = " + truckColor);
            JPanel southPanel = new JPanel();
            southPanel.add(new JLabel("truck #  "));
            southPanel.add(indexField);
            southPanel.add(showColorButton);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(northPanel, "North");
            f.getContentPane().add(panel);
            f.getContentPane().add(southPanel, "South");
            f.setSize(400,300);
            f.setLocation(200,200);
            f.setVisible(true);
        public void addTrucks(ShineyNewPickupTruck[] trucks)
            this.trucks = trucks;
    class ShineyNewPickupTruck
        String color;
        public ShineyNewPickupTruck(String color)
            this.color = color;
        public void setColor(String color)
            this.color = color;
    }

  • How do i use objects from one class in anohter?

    Hey
    I have two GUI classes ShowWhiteGUI and BasketGUI and then a control class ShowWhite. The control class calls all the method from anohter class's which the GUI classes are gonna use.
    The basis idea with this script is it shall be a very very simpel Shop. Where you can add items to a basket and then show the items in a new window(BasketGUI).
    So here is the problem. I cant create an object in both GUI classes, because then im working with two sets of data, right? So how do i do this?
    Here is my code:
    ShowWhiteGUI
    * ShowWhiteGUI.java
    * Created on 5. februar 2008, 10:43
    package userclasses;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    * @author  Lille mus
    public class ShowWhiteGUI extends javax.swing.JFrame {
        private BasketGUI basketGUI;
        private ShowWhite control;
        /** Creates new form ShowWhiteGUI */
        public ShowWhiteGUI() {
            basketGUI = new BasketGUI();
            control = new ShowWhite();
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
        private void initComponents() {
            aboutDialog = new javax.swing.JDialog();
            jLabel1 = new javax.swing.JLabel();
            jScrollPane1 = new javax.swing.JScrollPane();
            jTextArea1 = new javax.swing.JTextArea();
            itemIdField = new javax.swing.JTextField();
            productIdLabel = new javax.swing.JLabel();
            numberOfItems = new javax.swing.JLabel();
            productId = new javax.swing.JTextField();
            basketButton = new javax.swing.JButton();
            jLabel2 = new javax.swing.JLabel();
            showBasketButton = new javax.swing.JButton();
            jMenuBar1 = new javax.swing.JMenuBar();
            menu = new javax.swing.JMenu();
            jMenu1 = new javax.swing.JMenu();
            open = new javax.swing.JMenuItem();
            quit = new javax.swing.JMenuItem();
            jMenuItem1 = new javax.swing.JMenuItem();
            jMenu2 = new javax.swing.JMenu();
            help = new javax.swing.JMenuItem();
            about = new javax.swing.JMenuItem();
            javax.swing.GroupLayout aboutDialogLayout = new javax.swing.GroupLayout(aboutDialog.getContentPane());
            aboutDialog.getContentPane().setLayout(aboutDialogLayout);
            aboutDialogLayout.setHorizontalGroup(
                aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 400, Short.MAX_VALUE)
            aboutDialogLayout.setVerticalGroup(
                aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 300, Short.MAX_VALUE)
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Show White's Shop");
            setBackground(new java.awt.Color(0, 102, 255));
            jLabel1.setFont(new java.awt.Font("Baby Kruffy", 0, 36));
            jLabel1.setText("Snow White?s Shop");
            jTextArea1.setColumns(20);
            jTextArea1.setEditable(false);
            jTextArea1.setRows(5);
            jTextArea1.setText(control.getPrintAllStockItems());
            jScrollPane1.setViewportView(jTextArea1);
            productIdLabel.setText("Varenummer:");
            numberOfItems.setText("Antal:");
            basketButton.setText("L?g i kurv");
            basketButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    putInBasket(evt);
            showBasketButton.setText("Vis indk?bskurv");
            showBasketButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    showBasket(evt);
            menu.setLabel("Fil");
            jMenu1.setText("Menu");
            menu.add(jMenu1);
            open.setLabel("?bn");
            open.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    open(evt);
            menu.add(open);
            quit.setLabel("Luk");
            quit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    quit(evt);
            menu.add(quit);
            jMenuItem1.setLabel("Gem");
            jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    save(evt);
            menu.add(jMenuItem1);
            jMenuBar1.add(menu);
            jMenu2.setLabel("Hj?lp");
            help.setLabel("Hj?lp");
            help.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    help(evt);
            jMenu2.add(help);
            about.setLabel("Om Show White Shop");
            jMenu2.add(about);
            jMenuBar1.add(jMenu2);
            setJMenuBar(jMenuBar1);
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(37, 37, 37)
                            .addComponent(jLabel1))
                        .addGroup(layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(productIdLabel)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(numberOfItems))
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(productId, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 65, Short.MAX_VALUE)
                                        .addComponent(basketButton))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(31, 31, 31)
                                        .addComponent(jLabel2)))
                                .addGroup(layout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(showBasketButton)))))
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel2))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(productIdLabel)
                                .addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(numberOfItems)
                                .addComponent(productId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(showBasketButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 202, Short.MAX_VALUE)
                            .addComponent(basketButton)))
                    .addContainerGap())
            pack();
        }// </editor-fold>                       
        public void createBasketWindow(){
            basketGUI.setVisible(true);
        private void showBasket(java.awt.event.ActionEvent evt) {                           
            createBasketWindow();
        private void putInBasket(java.awt.event.ActionEvent evt) {                            
            Integer itemId = Integer.parseInt(itemIdField.getText());
            String petToAdd = control.getFindItem(itemId);
            System.out.println(petToAdd);
            control.setAddItemToBasket(itemId);
            basketGUI.addPetToBasket(petToAdd);     
        private void help(java.awt.event.ActionEvent evt) {                     
        private void save(java.awt.event.ActionEvent evt) {                     
            System.out.println("Gemmer fil");
        private void open(java.awt.event.ActionEvent evt) {                     
            System.out.println("?bn fil");
        private void quit(java.awt.event.ActionEvent evt) {                     
            System.exit(0);
        public ShowWhite getControl(){
            return control;
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new ShowWhiteGUI().setVisible(true);
        // Variables declaration - do not modify                    
        private javax.swing.JMenuItem about;
        private javax.swing.JDialog aboutDialog;
        private javax.swing.JButton basketButton;
        private javax.swing.JMenuItem help;
        private javax.swing.JTextField itemIdField;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JMenu jMenu1;
        private javax.swing.JMenu jMenu2;
        private javax.swing.JMenuBar jMenuBar1;
        private javax.swing.JMenuItem jMenuItem1;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTextArea jTextArea1;
        private javax.swing.JMenu menu;
        private javax.swing.JLabel numberOfItems;
        private javax.swing.JMenuItem open;
        private javax.swing.JTextField productId;
        private javax.swing.JLabel productIdLabel;
        private javax.swing.JMenuItem quit;
        private javax.swing.JButton showBasketButton;
        // End of variables declaration                  
    }BasketGUI:
    * Basket.java
    * Created on 5. februar 2008, 15:29
    package userclasses;
    import javax.swing.JTextArea;
    * @author  Lille mus
    public class BasketGUI extends javax.swing.JFrame {
        private String newline = "\n";
        private InvoiceGUI invoiceGUI;
        /** Creates new form Basket */
        public BasketGUI() {       
            initComponents();
            //invoiceGUI = new InvoiceGUI();
        public void addPetToBasket(String pet){
            jTextArea1.append(pet+newline);
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
        private void initComponents() {
            jLabel1 = new javax.swing.JLabel();
            jScrollPane1 = new javax.swing.JScrollPane();
            jTextArea1 = new javax.swing.JTextArea();
            jButton1 = new javax.swing.JButton();
            itemIdField = new javax.swing.JTextField();
            jLabel2 = new javax.swing.JLabel();
            removeItemButton = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Indk?bskurv");
            jLabel1.setText("Indk?bskurv");
            jTextArea1.setColumns(20);
            jTextArea1.setRows(5);
            jScrollPane1.setViewportView(jTextArea1);
            jButton1.setText("K?b og print kvittering");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    printInvoice(evt);
            jLabel2.setText("Slet varenr");
            removeItemButton.setText("Slet");
            removeItemButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    removeItemFromBasket(evt);
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(21, 21, 21)
                            .addComponent(jLabel1))
                        .addGroup(layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 141, Short.MAX_VALUE)
                                    .addComponent(jButton1))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel2)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(removeItemButton)))))
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel1)
                    .addGap(20, 20, 20)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jButton1)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 125, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(removeItemButton))
                    .addContainerGap())
            pack();
        }// </editor-fold>                       
        private void removeItemFromBasket(java.awt.event.ActionEvent evt) {                                     
            Integer itemId = Integer.parseInt(itemIdField.getText());
        private void printInvoice(java.awt.event.ActionEvent evt) {                             
            //invoiceGUI.setVisible(true);
        public JTextArea getTextArea(){
            return jTextArea1;
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new BasketGUI().setVisible(true);
        // Variables declaration - do not modify                    
        private javax.swing.JTextField itemIdField;
        private javax.swing.JButton jButton1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTextArea jTextArea1;
        private javax.swing.JButton removeItemButton;
        // End of variables declaration                  
    }ShowWhite:
    * ShowWhite.java
    * Created on 13. februar 2008, 18:15
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package userclasses;
    * @author Lille mus
    public class ShowWhite {
        public Basket basket;
        public Stock stock;
        /** Creates a new instance of ShowWhite */
        public ShowWhite() {
            stock = new Stock();
            basket = new Basket();
        public String getFindItem(int itemId){
            String returnItem = stock.findItem(itemId);
            return returnItem;
        public void setAddItemToBasket(int itemId){
            basket.addItemToBasket(itemId);
        public String getPrintAllStockItems(){
            return stock.printAllStockItems();
        public String getShowBasket(){
             return basket.showBasket();
        public void setRemoveItemFromBasket(int itemId){
            basket.removeItemFromBasket(itemId);
    }

    okay i tried this, but it give me a nullpointerexeption:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at userclasses.ShowWhiteGUI.initComponents(ShowWhiteGUI.java:75)
    at userclasses.ShowWhiteGUI.<init>(ShowWhiteGUI.java:21)
    at userclasses.ShowWhite.<init>(ShowWhite.java:26)
    at userclasses.Main.<init>(Main.java:16)
    at userclasses.Main$1.run(Main.java:31)
    ShowWhite
    public class ShowWhite {
        public Basket basket;
        public Stock stock;
        private ShowWhiteGUI mainGUI;
        private BasketGUI basketGUI;
        /** Creates a new instance of ShowWhite */
        public ShowWhite() {
            stock = new Stock();
            basket = new Basket();
            mainGUI = new ShowWhiteGUI(this);
            basketGUI = new BasketGUI();
        public String getFindItem(int itemId){
            String returnItem = stock.findItem(itemId);
            return returnItem;
        public void setAddItemToBasket(int itemId){
            basket.addItemToBasket(itemId);
        public String getPrintAllStockItems(){
            return stock.printAllStockItems();
        public String getShowBasket(){
             return basket.showBasket();
        public void setRemoveItemFromBasket(int itemId){
            basket.removeItemFromBasket(itemId);
        public void createMainGUI(){
            mainGUI.setVisible(true);
        public BasketGUI getBasketGUI(){
            return basketGUI;
        public void setAddPetToBasket(String pet){
            basketGUI.addPetToBasket(pet);
    }ShowWhiteGUI:
    public class ShowWhiteGUI extends javax.swing.JFrame {
        private ShowWhite control;
        /** Creates new form ShowWhiteGUI */
        public ShowWhiteGUI(ShowWhite control) {
            initComponents();
            this.control = control;
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
        private void initComponents() {
            aboutDialog = new javax.swing.JDialog();
            jLabel1 = new javax.swing.JLabel();
            jScrollPane1 = new javax.swing.JScrollPane();
            jTextArea1 = new javax.swing.JTextArea();
            itemIdField = new javax.swing.JTextField();
            productIdLabel = new javax.swing.JLabel();
            numberOfItems = new javax.swing.JLabel();
            productId = new javax.swing.JTextField();
            basketButton = new javax.swing.JButton();
            jLabel2 = new javax.swing.JLabel();
            showBasketButton = new javax.swing.JButton();
            jMenuBar1 = new javax.swing.JMenuBar();
            menu = new javax.swing.JMenu();
            jMenu1 = new javax.swing.JMenu();
            open = new javax.swing.JMenuItem();
            quit = new javax.swing.JMenuItem();
            jMenuItem1 = new javax.swing.JMenuItem();
            jMenu2 = new javax.swing.JMenu();
            help = new javax.swing.JMenuItem();
            about = new javax.swing.JMenuItem();
            javax.swing.GroupLayout aboutDialogLayout = new javax.swing.GroupLayout(aboutDialog.getContentPane());
            aboutDialog.getContentPane().setLayout(aboutDialogLayout);
            aboutDialogLayout.setHorizontalGroup(
                aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 400, Short.MAX_VALUE)
            aboutDialogLayout.setVerticalGroup(
                aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 300, Short.MAX_VALUE)
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Show White's Shop");
            setBackground(new java.awt.Color(0, 102, 255));
            jLabel1.setFont(new java.awt.Font("Baby Kruffy", 0, 36));
            jLabel1.setText("Snow White?s Shop");
            jTextArea1.setColumns(20);
            jTextArea1.setEditable(false);
            jTextArea1.setRows(5);
            jTextArea1.setText(control.getPrintAllStockItems());
            jScrollPane1.setViewportView(jTextArea1);
            productIdLabel.setText("Varenummer:");
            numberOfItems.setText("Antal:");
            basketButton.setText("L?g i kurv");
            basketButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    putInBasket(evt);
            showBasketButton.setText("Vis indk?bskurv");
            showBasketButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    showBasket(evt);
            menu.setLabel("Fil");
            jMenu1.setText("Menu");
            menu.add(jMenu1);
            open.setLabel("?bn");
            open.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    open(evt);
            menu.add(open);
            quit.setLabel("Luk");
            quit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    quit(evt);
            menu.add(quit);
            jMenuItem1.setLabel("Gem");
            jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    save(evt);
            menu.add(jMenuItem1);
            jMenuBar1.add(menu);
            jMenu2.setLabel("Hj?lp");
            help.setLabel("Hj?lp");
            help.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    help(evt);
            jMenu2.add(help);
            about.setLabel("Om Show White Shop");
            jMenu2.add(about);
            jMenuBar1.add(jMenu2);
            setJMenuBar(jMenuBar1);
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(37, 37, 37)
                            .addComponent(jLabel1))
                        .addGroup(layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(productIdLabel)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(numberOfItems))
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(productId, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 65, Short.MAX_VALUE)
                                        .addComponent(basketButton))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(31, 31, 31)
                                        .addComponent(jLabel2)))
                                .addGroup(layout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(showBasketButton)))))
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel2))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(productIdLabel)
                                .addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(numberOfItems)
                                .addComponent(productId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(showBasketButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 202, Short.MAX_VALUE)
                            .addComponent(basketButton)))
                    .addContainerGap())
            pack();
        }// </editor-fold>                       
        public void createBasketWindow(){
            control.getBasketGUI().setVisible(true);
        private void showBasket(java.awt.event.ActionEvent evt) {                           
            createBasketWindow();
        private void putInBasket(java.awt.event.ActionEvent evt) {                            
            Integer itemId = Integer.parseInt(itemIdField.getText());
            String petToAdd = control.getFindItem(itemId);
            System.out.println(petToAdd);
            control.setAddItemToBasket(itemId);
            control.setAddPetToBasket(petToAdd);     
        private void help(java.awt.event.ActionEvent evt) {                     
        private void save(java.awt.event.ActionEvent evt) {                     
            System.out.println("Gemmer fil");
        private void open(java.awt.event.ActionEvent evt) {                     
            System.out.println("?bn fil");
        private void quit(java.awt.event.ActionEvent evt) {                     
            System.exit(0);
        public ShowWhite getControl(){
            return control;
        // Variables declaration - do not modify                    
        private javax.swing.JMenuItem about;
        private javax.swing.JDialog aboutDialog;
        private javax.swing.JButton basketButton;
        private javax.swing.JMenuItem help;
        private javax.swing.JTextField itemIdField;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JMenu jMenu1;
        private javax.swing.JMenu jMenu2;
        private javax.swing.JMenuBar jMenuBar1;
        private javax.swing.JMenuItem jMenuItem1;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTextArea jTextArea1;
        private javax.swing.JMenu menu;
        private javax.swing.JLabel numberOfItems;
        private javax.swing.JMenuItem open;
        private javax.swing.JTextField productId;
        private javax.swing.JLabel productIdLabel;
        private javax.swing.JMenuItem quit;
        private javax.swing.JButton showBasketButton;
        // End of variables declaration                  
    }

  • GUI building difficulties, nested Frames and other stuff

    I am currently working on a GUI and I am running into some difficulties. I have created a class which extends JFrame
    public class DelFace extends JFrame implements ActionListener, ItemListenerI am instantiating an object of this class from within another object of a different class as follows:
    DelFace DelGUI = new DelFace(this,MastFile);The creation of the object takes place within the listener methods of another object:
    public void actionPerformed(ActionEvent e)
      if(e.getActionCommand().equals("Delete"))
          DelFace DelGUI = new DelFace(this,MastFile);
      }The class that creates the object that makes this call does not contain the main method. Instead the afore mentioned object is created from a class that extends JFrame
    class GUI extends JFrame implements ActionListenerSo the code in it's order of activity is as follows:
    It breaks down hardcore at the beginning
    public class StartProgram {
      private static GUI LauncherGUI;
      private static FileOps MastFile;
      public static void main(String[] args)
      MastFile = new FileOps();
      MastFile.fileStatus();            //Create File object &/or file.
      MastFile.readFile();              //Read file contents if any.
      LauncherGUI = new GUI(StartProgram.MastFile);
    }A GUI object is created, - LauncherGUI = new GUI(StartProgram.MastFile);
    From here the code differentiates somewhat - FileOperations stem from here as do all code related to the complete construction of the General User Interface.
    Specifically my difficulties lie with the GUI, therefore I will present the next peice of code related to the GUI. The following code creates a JFrame and places a whole stack of buttons on it. Included with these buttons are menus. So basically the code creates a menu bar and adds menu items to that bar and so on until a menu similar to that found in any regular program is produced. Also contained on this part of the GUI are the five buttons that are fundemental to the programs operation.
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.EventObject; //Try removing this!!
    class GUI extends JFrame implements ActionListener
      private JButton button1;
      private JButton button2;
      private JButton button3;
      private JButton button4;
      private JButton button5;
      private String Path1;
      private String Path2;
      private String Path3;
      private String Path4;
      private String Path5;
      private FileOps MastFile;
      private DataEntryBox EntryBox;
      private HelpGUI Instruct;
      FrameListener GUIListener = new FrameListener();  //Listener object created.
      GUI(FileOps MastFile)
        this.MastFile = MastFile;          //Make MastFile objects methods available
                                           //to all of LauncherGUI object.
        Toolkit tk = Toolkit.getDefaultToolkit();       //intialize the toolkit.
        Dimension sSize = tk.getScreenSize();           //determine screen size.
        Container c = getContentPane();
        GridBagLayout gridbag2 = new GridBagLayout();    //GridBagLayout object
                                                        //instantiated.
        GridBagConstraints d = new GridBagConstraints();//GridBagConstraints object
                                                        //instantiated.
        c.setLayout(gridbag2);                          //Content pane's layout set
                                                        //to gridbag object.
        d.fill = GridBagConstraints.BOTH;               //Make all components fill
                                                        //their dispaly areas
                                                        //entirely.
        d.insets = new Insets(5,1,5,1);
        JMenuBar menuBar = new JMenuBar();  //Creates Menubar object called menuBar.
        setJMenuBar(menuBar);
        JMenu FMenu = new JMenu("File");    //File Menu object instantiated.
        FMenu.setMnemonic(KeyEvent.VK_F);   //Key that activates File menu...F.
        menuBar.add(FMenu);                 //File Menu added to menuBar object.
        JMenuItem NewItem = new JMenuItem("New");   //Creates New sub-menu object.
        NewItem.setMnemonic(KeyEvent.VK_N);         //Key that activates New sub-
                                                    //menu....N.
        FMenu.add(NewItem);
        NewItem.addActionListener(this);   //ActionListner for NewItem added.
        //Tutorial Note: Steps involved in creating a menu UI are as follows,
        //1). Create an instance of a JMenuBar.
        //2). Create an instance of a JMenu.
        //3). Add items to the JMenu (not to the JMenuBar).
        //Note: It is possible to include the Mnemonic activation key as part of
        //the JMenu or JMenuItem constructor. e.g.: JMenuItem NewItem = new JMenu
        //Item("New",KeyEvent.VK_N);
        JMenuItem DeleteItem = new JMenuItem("Delete");
        DeleteItem.setMnemonic(KeyEvent.VK_D);
        FMenu.add(DeleteItem);
        DeleteItem.addActionListener(this);
        JMenuItem ExitItem = new JMenuItem("Exit",KeyEvent.VK_E); //Mnemonic key
        //included with constructor method here and from now on.
        FMenu.add(ExitItem);
        ExitItem.addActionListener(this);
        JMenu HMenu = new JMenu("Help");
        HMenu.setMnemonic(KeyEvent.VK_H);
        menuBar.add(HMenu);
        JMenuItem InstructItem = new JMenuItem("Instructions",KeyEvent.VK_I);
        HMenu.add(InstructItem);
        InstructItem.addActionListener(this);
        JMenuItem AboutItem = new JMenuItem("About",KeyEvent.VK_A);
        HMenu.add(AboutItem);
        AboutItem.addActionListener(this);
        button1 = new JButton();
    /* The following if statments block first checks to see if the value held in the
    String array is equals to null (note: this only occurs when the program is first
    started and no data has been written to file). If the array is null then the
    buttons text is set to "". If the array value is not null (meaning that the file
    already holds data) then the value of the array is checked. If the value equals
    the String "null" then button text is set to "", otherwise button text is set to
    the relevant array value (a user defined shortcut name). Also the value of each
    buttons actionCommand is set to this string value. */
        if(MastFile.getFDArray(0) == null)
          button1.setText("");
          button1.setActionCommand("Link1");
        else
        if(MastFile.getFDArray(0) != null)
          if(MastFile.getFDArray(0).equals("null"))
            button1.setText("");
            button1.setActionCommand("Link1");
          else
            button1.setText(MastFile.getFDArray(0));
            button1.setActionCommand(MastFile.getFDArray(0));
        d.weightx = 0.2;  //Specifies horizontal sizing behaviour.
        d.weighty = 0.3;  //Specifies vertical resizing behaviour.
        d.gridx = 0;      //c.gridx and c.gridy specify the x,y starting position
        d.gridy = 0;      //of this label, in regard to column and row respectively.
        gridbag2.setConstraints(button1, d);
        c.add(button1);
        button1.addActionListener(this);
        button2 = new JButton();
        if(MastFile.getFDArray(2) == null) //If the file contains no contents then..
          button2.setText("");
          button2.setActionCommand("Link2");
        else
        if(MastFile.getFDArray(2) != null)
          if(MastFile.getFDArray(2).equals("null"))//If the file contains the string
          {                                        //"null" then do as above.
            button2.setText("");
            button2.setActionCommand("Link2");
          else  //Set both button text and actionCommand to relevant shortcut name.
            button2.setText(MastFile.getFDArray(2));
            button2.setActionCommand(MastFile.getFDArray(2));
        d.weightx = 0.2;  //Specifies horizontal sizing behaviour.
        d.weighty = 0.3;  //Specifies vertical resizing behaviour.
        d.gridx = 1;      //c.gridx and c.gridy specify the x,y starting position
        d.gridy = 0;      //of this label, in regard to column and row respectively.
        gridbag2.setConstraints(button2, d);
        c.add(button2);
        button2.addActionListener(this);
        button3 = new JButton();
        if(MastFile.getFDArray(4) == null)
          button3.setText("");
          button3.setActionCommand("Link3");
        else
        if(MastFile.getFDArray(4) != null)
          if(MastFile.getFDArray(4).equals("null"))
            button3.setText("");
            button3.setActionCommand("Link3");
          else
            button3.setText(MastFile.getFDArray(4));
            button3.setActionCommand(MastFile.getFDArray(4));
        d.weightx = 0.2;  //Specifies horizontal sizing behaviour.
        d.weighty = 0.3;  //Specifies vertical resizing behaviour.
        d.gridx = 2;      //c.gridx and c.gridy specify the x,y starting position
        d.gridy = 0;      //of this label, in regard to column and row respectively.
        gridbag2.setConstraints(button3, d);
        c.add(button3);
        button3.addActionListener(this);
        button4 = new JButton();
        if(MastFile.getFDArray(6) == null)
          button4.setText("");
          button4.setActionCommand("Link4");
        else
        if(MastFile.getFDArray(6) != null)
          if(MastFile.getFDArray(6).equals("null"))
            button4.setText("");
            button4.setActionCommand("Link4");
          else
            button4.setText(MastFile.getFDArray(6));
            button4.setActionCommand(MastFile.getFDArray(6));
        d.weightx = 0.2;  //Specifies horizontal sizing behaviour.
        d.weighty = 0.3;  //Specifies vertical resizing behaviour.
        d.gridx = 3;      //c.gridx and c.gridy specify the x,y starting position
        d.gridy = 0;      //of this label, in regard to column and row respectively.
        gridbag2.setConstraints(button4, d);
        c.add(button4);
        button4.addActionListener(this);
        button5 = new JButton();
        if(MastFile.getFDArray(8) == null)
          button5.setText("");
          button5.setActionCommand("Link5");
        else
        if(MastFile.getFDArray(8) != null)
          if(MastFile.getFDArray(8).equals("null"))
            button5.setText("");
            button5.setActionCommand("Link5");
          else
            button5.setText(MastFile.getFDArray(8));
            button5.setActionCommand(MastFile.getFDArray(8));
        d.weightx = 0.2;  //Specifies horizontal sizing behaviour.
        d.weighty = 0.3;  //Specifies vertical resizing behaviour.
        d.gridx = 4;      //c.gridx and c.gridy specify the x,y starting position
        d.gridy = 0;      //of this label, in regard to column and row respectively.
        gridbag2.setConstraints(button5, d);
        c.add(button5);
        button5.addActionListener(this);
        Path1 = MastFile.getFDArray(1);       //Load Path variables with path
        Path2 = MastFile.getFDArray(3);       //details from String Array in
        Path3 = MastFile.getFDArray(5);       //MastFile object of FileOps class.
        Path4 = MastFile.getFDArray(7);       //Effectively loading these variables
        Path5 = MastFile.getFDArray(9);       //with file data.
        this.addWindowListener(GUIListener);  //Listener registered with Frame.
        setLocation(sSize.width*1/2,sSize.height*1/20);
        setSize(sSize.width*1/2,sSize.height*1/7);
        setTitle("Java QuickLaunch Toolbar");
        setVisible(true);
      /* The following methods return the ActionCommand and Text Label
         String values of the buttons */
      public String getButton1Command()
        return button1.getActionCommand();
      public String getButton2Command()
        return button2.getActionCommand();
      public String getButton3Command()
        return button3.getActionCommand();
      public String getButton4Command()
        return button4.getActionCommand();
      public String getButton5Command()
        return button5.getActionCommand();
      public String getBt1Text()
        return button1.getText();
      public String getBt2Text()
        return button2.getText();
      public String getBt3Text()
        return button3.getText();
      public String getBt4Text()
        return button4.getText();
      public String getBt5Text()
        return button5.getText();
      /* The following methods set the Path, Button and ActionCommand String values. */
      public void setPath1(String setPath)
        Path1 = setPath;
      public void setPath2(String setPath)
        Path2 = setPath;
      public void setPath3(String setPath)
        Path3 = setPath;
      public void setPath4(String setPath)
        Path4 = setPath;
      public void setPath5(String setPath)
        Path5 = setPath;
      public void setButton1(String setButton)
        button1.setText(setButton);
      public void setButton2(String setButton)
        button2.setText(setButton);
      public void setButton3(String setButton)
        button3.setText(setButton);
      public void setButton4(String setButton)
        button4.setText(setButton);
      public void setButton5(String setButton)
        button5.setText(setButton);
      public void setBt1Action(String setAct)
        button1.setActionCommand(setAct);
      public void setBt2Action(String setAct)
        button2.setActionCommand(setAct);
      public void setBt3Action(String setAct)
        button3.setActionCommand(setAct);
      public void setBt4Action(String setAct)
        button4.setActionCommand(setAct);
      public void setBt5Action(String setAct)
        button5.setActionCommand(setAct);
      /* actionPerformed methods */
      public void actionPerformed(ActionEvent e)
        if(e.getActionCommand().equals("New"))
          //Create a data entry box.
          EntryBox = new DataEntryBox(this,MastFile);
        else
        if(e.getActionCommand().equals("Delete"))//Example part of interest
          DelFace DelGUI = new DelFace(this,MastFile);   /// -------- ////
        else
        if(e.getActionCommand().equals("Exit"))
          System.exit(0);
        else
        if(e.getActionCommand().equals("Instructions"))
          Instruct = new HelpGUI();
        else
        if(e.getActionCommand().equals("About"))
          JOptionPane.showMessageDialog(this,"Java QuickLaunch Toolbar created by David "+
                                        "Dartnell.","Programming Credits",1);
        else
          if(e.getActionCommand().equals(button1.getActionCommand())) //Determine source of event.
          if(Path1 == null)                        //If Path var is a null reference
            EntryBox = new DataEntryBox(this,MastFile);//create a data entry box.
          else
          if(Path1 != null)                        //If not a null reference then...
            if(Path1.equals("null"))               //Determine if string is "null".
              EntryBox = new DataEntryBox(this,MastFile);
            else        //If both the reference and the String are not null then run
            {           //the relevant command/program.
              try
                Runtime.getRuntime().exec(new String[]{Path1});
              catch(IOException run){}
        else
        if(e.getActionCommand().equals(button2.getActionCommand()))
          if(Path2 == null)
            EntryBox = new DataEntryBox(this,MastFile);
          else
          if(Path2 != null)
            if(Path2.equals("null"))
              EntryBox = new DataEntryBox(this,MastFile);
            else
              try
                Runtime.getRuntime().exec(new String[]{Path2});
              catch(IOException run){}
        else
        if(e.getActionCommand().equals(button3.getActionCommand()))
          if(Path3 == null)
            EntryBox = new DataEntryBox(this,MastFile);
          else
          if(Path3 != null)
            if(Path3.equals("null"))
              EntryBox = new DataEntryBox(this,MastFile);
            else
              try
                Runtime.getRuntime().exec(new String[]{Path3});
              catch(IOException run){}
        else
        if(e.getActionCommand().equals(button4.getActionCommand()))
          if(Path4 == null)
            EntryBox = new DataEntryBox(this,MastFile);
          else
          if(Path4 != null)
            if(Path4.equals("null"))
              EntryBox = new DataEntryBox(this,MastFile);
            else
              try
                Runtime.getRuntime().exec(new String[]{Path4});
              catch(IOException run){}
        else
        if(e.getActionCommand().equals(button5.getActionCommand()))
          if(Path5 == null)
            EntryBox = new DataEntryBox(this,MastFile);
          else
          if(Path5 != null)
            if(Path5.equals("null"))
              EntryBox = new DataEntryBox(this,MastFile);
            else
              try
                Runtime.getRuntime().exec(new String[]{Path5});
              catch(IOException run){}
    Something to consider concerning actionListeners:
    It must be remembered that String values are in fact objects and as such
    they require the equals() method unlike their cousins the primitive data
    types (int, float, boolean, byte, short, long and double) which require
    the == operator.
    */A comment is placed next to the line of code that is of interest to my problem (///-------////).
    When a button is pressed in the menu section that reads "Delete" then an actionCommand event is fired and the program responds by creating a second general user interface.
    When DelFace is instantiated in the form of the object called DelGUI I am once again creating an object which extends JFrame. I now have two objects of type JFrame on the screen at once, and I conveniently position one over the top of the other, so to the general user the programs appearance has changed in only very specified ways (i.e.: I have decided to increase the GUI's dimensions in the area of height only and not width). The code that constitutes class DelFace is as follows:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class DelFace extends JFrame implements ActionListener, ItemListener
      private GUI TkBar;        //GUI object.
      private FileOps Fops;     //File Operations object.
      private JCheckBox ckbox1; //Delete shortcut 1.
      private JCheckBox ckbox2; //Delete shortcut 2.
      private JCheckBox ckbox3; //Delete shortcut 3.
      private JCheckBox ckbox4; //Delete shortcut 4.
      private JCheckBox ckbox5; //Delete shortcut 5.
      private JButton OkBtn;    //OK button.
      private JButton CnBtn;    //Cancel button.
      private JOptionPane confirm;
      private boolean short1 = false;  //Boolean variables indicate whether to
      private boolean short2 = false;  //delete a shortcut entry. True = delete.
      private boolean short3 = false;
      private boolean short4 = false;
      private boolean short5 = false;
      DelFace(GUI TkBar, FileOps Fops)
        this.TkBar = TkBar;
        this.Fops = Fops;
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension sSize = tk.getScreenSize();
        Container dcon = getContentPane();
        GridBagLayout gb = new GridBagLayout();
        GridBagConstraints bagcon = new GridBagConstraints();
        dcon.setLayout(gb);
        bagcon.fill = GridBagConstraints.BOTH;
        bagcon.gridwidth = GridBagConstraints.REMAINDER;
        JLabel TLabel = new JLabel("Delete Wizard",JLabel.CENTER);
        TLabel.setFont(new Font("Tahoma",Font.BOLD+Font.ITALIC,32));
        bagcon.gridx = 0;
        bagcon.gridy = 0;
        bagcon.weightx = 1.0;      //Take up all the 'x room' in this row.
        bagcon.weighty = 0.5;      //Take up all the 'y room' in this column.
        /* The weightx and weighty values are required otherwise all components will
           gravitate toward the center of screen. */
        gb.setConstraints(TLabel,bagcon);
        dcon.add(TLabel);
        JTextArea TxArea = new JTextArea("Tick the box(s) of the shortcut(s)"+
                               " that you would like to delete and"+
                               " press the Delete button. Alternatively"+
                               " press the Cancel button to exit.");
        TxArea.setLineWrap(true);
        TxArea.setWrapStyleWord(true);
        TxArea.setEditable(false);
        TxArea.setFont(new Font("Times New Roman",Font.PLAIN,15));
        TxArea.setBackground(this.getBackground());
        bagcon.gridx = 0;
        bagcon.gridy = 1;
        gb.setConstraints(TxArea,bagcon);
        dcon.add(TxArea);
        bagcon.gridwidth = 1;
        JPanel Nopan1 = new JPanel();
        bagcon.gridx = 0;
        bagcon.gridy = 2;
        gb.setConstraints(Nopan1,bagcon);
        dcon.add(Nopan1);
        ckbox1 = new JCheckBox(TkBar.getBt1Text());
        bagcon.gridx = 1;
        bagcon.gridy = 2;
        gb.setConstraints(ckbox1,bagcon);
        dcon.add(ckbox1);
        ckbox1.addItemListener(this);
        ckbox2 = new JCheckBox(TkBar.getBt2Text());
        bagcon.gridy = 3;
        gb.setConstraints(ckbox2,bagcon);
        dcon.add(ckbox2);
        ckbox2.addItemListener(this);
        ckbox3 = new JCheckBox(TkBar.getBt3Text());
        bagcon.gridy = 4;
        gb.setConstraints(ckbox3,bagcon);
        dcon.add(ckbox3);
        ckbox3.addItemListener(this);
        ckbox4 = new JCheckBox(TkBar.getBt4Text());
        bagcon.gridy = 5;
        gb.setConstraints(ckbox4,bagcon);
        dcon.add(ckbox4);
        ckbox4.addItemListener(this);
        ckbox5 = new JCheckBox(TkBar.getBt5Text());
        bagcon.gridy = 6;
        gb.setConstraints(ckbox5,bagcon);
        dcon.add(ckbox5);
        ckbox5.addItemListener(this);
        JPanel Nopan2 = new JPanel();
        bagcon.gridx = 1;
        bagcon.gridy = 7;
        gb.setConstraints(Nopan2,bagcon);
        dcon.add(Nopan2);
        OkBtn = new JButton("OK");
        OkBtn.addActionListener(this);
        bagcon.gridx = 1;
        bagcon.gridy = 8;
        gb.setConstraints(OkBtn,bagcon);
        dcon.add(OkBtn);
        OkBtn.addActionListener(this);
        CnBtn = new JButton("Cancel");
        CnBtn.addActionListener(this);
        bagcon.gridx = 2;
        bagcon.gridy = 8;
        gb.setConstraints(CnBtn,bagcon);
        dcon.add(CnBtn);
        CnBtn.addActionListener(this);
        JPanel Nopan3 = new JPanel();
        bagcon.gridx = 3;
        bagcon.gridy = 8;
        gb.setConstraints(Nopan3,bagcon);
        dcon.add(Nopan3);
        JPanel Nopan4 = new JPanel();
        bagcon.gridx = 0;
        bagcon.gridy = 9;
        gb.setConstraints(Nopan4,bagcon);
        dcon.add(Nopan4);
        setLocation(sSize.width*1/2,sSize.height*1/20);
        setSize(sSize.width*1/2,sSize.height*4/5);
        setTitle("Java QuickLaunch Toolbar");
        setResizable(false);
        setVisible(true);
      public void actionPerformed(ActionEvent e)
      { /*--- Code of INTEREST begins here!!!!!! -------
        if(e.getActionCommand().equals("OK"))   
          if(short1 || short2 || short3 || short4 || short5)
            //confirm = new JOptionPane();
            int n = confirm.showConfirmDialog(this,
                 "Do you really want to delete?","Delete Confirmation",
                 JOptionPane.YES_NO_OPTION);
            if(n == confirm.YES_OPTION)  //Works Fine!
              while(short1 || short2 || short3 || short4 || short5)
                if(short1)
                  TkBar.setBt1Action("Link1");
                  TkBar.setButton1("");
                  TkBar.setPath1("null");
                  Fops.setFDArray(0,"null");
                  Fops.setFDArray(1,"null");
                  short1 = false;
                else
                if(short2)
                  TkBar.setBt2Action("Link2");
                  TkBar.setButton2("");
                  TkBar.setPath2("null");
                  Fops.setFDArray(2,"null");
                  Fops.setFDArray(3,"null");
                  short2 = false;
                else
                if(short3)
                  TkBar.setBt3Action("Link3");
                  TkBar.setButton3("");
                  TkBar.setPath3("null");
                  Fops.setFDArray(4,"null");
                  Fops.setFDArray(5,"null");
                  short3 = false;
                else
                if(short4)
                  TkBar.setBt4Action("Link4");
                  TkBar.setButton4("");
                  TkBar.setPath4("null");
                  Fops.setFDArray(6,"null");
                  Fops.setFDArray(7,"null");
                  short4 = false;
                else
                if(short5)
                  TkBar.setBt5Action("Link5");
                  TkBar.setButton5("");
                  TkBar.setPath5("null");
                  Fops.setFDArray(8,"null");
                  Fops.setFDArray(9,"null");
                  short5 = false;
              Fops.destroyFile();   //Destroy the old (outdated) file.
              Fops.fileStatus();    //Create a new file.
              Fops.writeFile();     //Write updated data to new file.
              setVisible(false);
            if(n == confirm.NO_OPTION)  //** Does not work ***
              System.out.println("No Option is being heard");
              //Listeners are working.
              //confirm.setVisible(false);
            if(n == confirm.CLOSED_OPTION) //** Does not work ***
              System.out.println("Closed Option is being heard");
              //Listeners are working.
              //confirm.setVisible(false);
        --- Code of interest ENDS here --- */
        else
        if(e.getActionCommand().equals("Cancel"))
          setVisible(false); 
      public void itemStateChanged(ItemEvent f)
        int state = f.getStateChange();
        if(state == ItemEvent.SELECTED)   //If a checkbox has been selected.
          if(f.getItem() == ckbox1)
            short1 = true;
          else
          if(f.getItem() == ckbox2)
            short2 = true;
          else
          if(f.getItem() == ckbox3)
            short3 = true;
          else
          if(f.getItem() == ckbox4)
            short4 = true;
          else
          if(f.getItem() == ckbox5)
            short5 = true;
        if(state == ItemEvent.DESELECTED)  //If a checkbox has been deselected.
          if(f.getItem() == ckbox1)
            short1 = false;
          else
          if(f.getItem() == ckbox2)
            short2 = false;
          else
          if(f.getItem() == ckbox3)
            short3 = false;
          else
          if(f.getItem() == ckbox4)
            short4 = false;
          else
          if(f.getItem() == ckbox5)
            short5 = false;
    }The code that is of interest to my current programming challenge is marked in the above code block like this:
    //*** Code of INTEREST begins here!!!!!! ********** //
    This is where my programming twilight behaviour begins to kick in. From the DelGUI object I now listen to a button event, this event when triggered causes a JOptionPane.showConfirmDialog(), as can be seen in the specified code block above. I make the JOptionPane centered over the DelGUI object ("JFrame No.: 2") which is also centered over the LauncherGUI object ("JFrame No.: 1").
    The program begins to behave quite strangely after the creation of the JOptionPane object called confirm. The JOptionPane is presented on screen without any visiual difficulty but it behaves quite strangely when it's buttons are pressed. The JOptionPane contains three event sources, the YES, NO and Close buttons.
    In my program the YES button causes a set of file operations to take place and then sets the "JFrame No.: 2"(DelGUI) invisible. It does this via the method setVisible(false). "JFrame No.: 2" is effectively the JOptionPane's parent component and as soon as it is setVisible(false) the JOptionPane is also cleared from the screen. I believe from my research that this is the JOptionPane's default behaviour, meaning that as soon as a button or event source is activated the JOptionPane will destroy itself.
    The end of the trail is near, thankyou for reading this if you have got this far, and please carry on....
    The Challenge:
    The program does not behave as desired at the two points in the code commented as such: ** Does not work ***
    if(n == confirm.NO_OPTION)
              System.out.println("No Option is being heard");
              //confirm.setVisible(false);
            if(n == confirm.CLOSED_OPTION)
              System.out.println("Closed Option is being heard");
              //confirm.setVisible(false);
            }If the NO_OPTION or the CLOSED_OPTION are pressed then the JOptionPane remains visible. After pressing the JoptionPane's button a second time it will disappear completely. I have tried a number of things in an attempt to work this out. Firstly I have inserted println messages to ensure that the events are being detected. These messages are always displayed whenever either the NO or Close buttons are pressed.
    As these messages are being passed to the Standard Output, twice by the time the JOptionPane has disappeared, I can only assume that the events are being detected.
    In addition to checking the event situation I have attempted to explicity set the JOptionPane invisible, in the form:
    confirm.setVisible(false); The above line of code did not change the situation. Still I need two button clicks for the JOptionPane to display it's default behaviour which is to set itself invisible (or possibly the object is alloted to garbage collection), either way it is no longer on screen. I have also tried this code with no if statements related to NO_OPTION and CLOSE_OPTION. This was done in an attempt to allow the default behaviour to take place. Unfortunately two presses were still required in this situation.
    A forum member mentioned the possibility that two JOptionPanes are being created. I have checked my code and am confident that I have not explicitly created the JOptionPane twice (the code throughout this question should support this).
    Is it possible that two JOptionPanes are being created because of the nature of my code, the fact that there are two JFrames on the screen at once when the JOptionPane is instantiated? I am using the this keyword to specify the parent of the JOptionPan

    Well, I've checked your code and I've seen where is the error.
    In Delface constructor (Delface.java, line 127), you've got this block of code :
    1. OkBtn = new JButton("OK");
    2. OkBtn.addActionListener(this);
    3. bagcon.gridx = 1;
    4. bagcon.gridy = 8;
    5. gb.setConstraints(OkBtn,bagcon);
    6. dcon.add(OkBtn);
    7. OkBtn.addActionListener(this);
    Have a deep look at lines 2 and 7 : you're registering twice an actionListener on this button. Then you're receiving twice the event and it shows two JOptionPanes. In fact, you've also the problem with the 'ok' option, but you don't see it, because the 'n' variable in your event handler is global to your class, then it's shared between the two calls to the event handlers.

  • Displaying Images in my GUI

    I have created a GUI that lets me display images that a user selects from a file. However is it possible to display an image that has not yet been written to a file?
    I have a class that takes an image object, perfoms operations on it then maps this to a new image object. Would it be possible to display this image before it has actually been written to file? If anyone out there has ideas i'll be very grateful.
    Here is an example of how I map one image to another:
         // Creates an image object.
         MyImage imageRight = new MyImage();
         // Now read in the image file
    // Create new object for reading image
         MyImage imageCenter = new MyImage(imageRight.getWidth(), imageRight.getHeight());
    /* Copy the pixel information from image that was read in to the
         new image */
         for (int y = 0; y < imageRight.getWidth(); y++) {
                   for (int x = 0; x < imageRight.getHeight(); x++) {
              /* Get the values from imageOne */
              int red = imageRight.getRed(x,y);
              int green = imageRight.getGreen(x,y);
              int blue = imageRight.getBlue(x,y);
              /* Put these values into imageTwo */
              imageCenter.setRGB(x, y, red, green, blue);
    At this point before I write the file, you can see that imageCenter holds all the attributes of an image. Now can I display this image object in my GUI?
    I hope someone can help me as this is really important.
    Thanks again.

    Look into the graphics's drawimage method.
    ;o)
    V.V.

  • How to create the Frame object with API in 6i?

    do i create an item using d2fitmcr_Create, and then set the type or style to frame? or is it a graphics item that i have to create using a different function? ive tried various combinations with no luck.
    ive looked at the frame object in the GUI, and cant figure out how to duplicate it using the API (the frame object is the thin line box with a label used to groups items visually on a form)
    thanks!
    [email protected]

    Frame is a type of graphic d2fgracr_Create() (d2fgra.h) then set the type as required using d2fgras_graphics_typ():
    Definition of Graphics types is in d2fdef.h
    ** Graphics Type (D2FP_GRAPHICS_TYP)
    ** [BPT]
    #define D2FC_GRTY_ARC              0                                 /* Arc */
    #define D2FC_GRTY_IMAGE            1                               /* Image */
    #define D2FC_GRTY_LINE             2                                /* Line */
    #define D2FC_GRTY_POLY             3                             /* Polygon */
    #define D2FC_GRTY_RECT             4                           /* Rectangle */
    #define D2FC_GRTY_RREC             5                   /* Rounded Rectangle */
    #define D2FC_GRTY_TEXT             6                                /* Text */
    #define D2FC_GRTY_GROUP            7                               /* Group */
    #define D2FC_GRTY_FRAME            8                               /* Frame */All the various properties for setting up the associated block etc (if required) can be set through macros in d2fgra.h

  • All objects property node and grouped objects

    Hi
    I am trying to position a the objects on my GUI in the centre of the screen using property nodes. However, I do not want to have to have a property node for every decoration, image and control. Is there a way that I can group all the objects and then use a property node to position them? I have tried using the all objects property node but none of the indexes seems to apply to my group of objects.
    Help please!
    Many thanks.
    John
    p.s. i have uploaded my test vi's. The chart, decoration and exit button have been grouped. use the control on check.vi to set the object to move. 
    Solved!
    Go to Solution.
    Attachments:
    check.vi ‏13 KB
    run.vi ‏13 KB

    Tab pages are a nice way to group GUI objects.
    Instead of using a decoration,
    use a tab control
    Remove all but the first tab
    Hide the tab
    Set the proprties of the tab control and the control on that page will move, hide, show along with the tab control.
    I hope that helps,
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Communicating with objects running in different JVM's

    Hi All
    I have a program which is running in multiple JVM.Each Jvm is using some special object.
    Now i need to monitor the state of that special object using a GUI sort of tool.ie i need to build a gui for seeing those special objects in all the running JVM.
    So whats the best way to do this
    Thanks
    Raj

    Please do not crosspost
    http://forum.java.sun.com/thread.jsp?forum=31&thread=400828&tstart=0&trange=100
    You have already been given a perfectly good answer more than once - try using RMI. Do you have a specific problem that is stopping you from using RMI? Have you read an RMI tutorial?

  • Maximizing communication between objects.

    Hi,
    I have a question concerning communication between objects. Particularly I want to learn to maximize communication between objects. Obviously there are several ways of increasing communication between objects, unfortunately I only really understand one methodology, which is as follows:
    For example:
    If I were to create an object called GUI of class UserInterFace, like so
    class UserInterface extends JFrame
      private variable1;
      private variable2;
      UserInterface()
        setBounds(x,y,width,height);
        setVisible(true);
    }I could then create an object called fileOps of class FileOperations and pass the entire GUI object into the constructor of the fileOps class, as follows:
    class FileOperations
      private FileReader input;
      private FileWriter output;
      private UserInterface GUI;
      FileOperations(UserInterface GUI)  //GUI object introduced.
        this.GUI = GUI;
    }By following the code fragments above it becomes obvious that I can establish communications between the fileOps object and the GUI object. With code similar to the above; fileOps will be able to access all of the accessor and mutator methods within object GUI. Using the above methodology always requires making all variables private and accompanying those variables with public methods (thus preserving encapsulation).
    If anybody can suggest any other methodologies for increasing communication between objects they will be greatly appreicated. Of interest to me is how one can go about ensuring complete two way communication between objects, my example above is rather one sided (fileOps can see GUI, but not vice versa). Obviously the instantiation of objects must occur in some procedural sequence, I want to know how to capitilize on this. Suggestions to read a particular book will be appreciated, however suggestions born from peoples experiences are most desired. Thanks.
    Regards
    David

    Rommie and Rajesh,
    Thank you both kindly for sharing your time and valuable knowledge. As I have only been programming with Java for a year part time (as one section of a Computer Systems Diploma) I consider myself to be a beginner in programming terms. I want to do really well with Java as quickly as possible and you have both helped me tremendously.
    Rommie the methodology that you have passed onto me is great, thankyou so much, I feel like a new section of Java has completely opened to me. I will be using the third "reference" class methodology from everyday now on.
    Rajesh your words are encouraging, and I will be reading up on Hierarchy and Aggregation immediately. When you said "Before using either, decide on the existence of the object, its intended functionalities e.t.c. ...", could you please explain with an example as to where Hierarchy is desirable and where Aggregation is desirable.
    Please feel free to e-mail me with further suggestions if you come up with something else that aids in the communication between objects.
    E-mail: [email protected]
    Thanks again.
    Regards
    David

  • Slow changing dimensions in application express GUI

    I need some kind of slow changing dimensions for application express GUI in order to be able
    1) simply allow users to edit 1 row for 1 object in APEX GUI
    2) widely use historical data in reporting.
    I.E.:
    Client's Last name (address, etc) was changed. I need to show in reports two points: before change and after:
    ID Name Order_date Amount
    12 Clark 1/1/10 500
    12 Johnson 5/1/10 200
    Are there common solutions?

    There are probably a few approaches you can take:
    1) Fine Grained Auditing (FGA) - very extensive and can be completely customized.
    http://download.oracle.com/docs/cd/B19306_01/network.102/b14266/cfgaudit.htm#sthref1766
    2) Triggers - if you have basic needs on a few tables/columns, it may be easier to just roll your own trigger. You can compare the :old to the :new value, and if they differ, write both to your own auditing table.

  • Storage area for GUI status Z_FI_UPLOAD_FIDOC 100 too small

    Hi,
    I have created a program for uploading and posting open items aso. I've gathered items in an internal tables and tried to display on ALV list with tree for correct and incorrect items. When table contains more than 1000 items ( not all in one document but 2 items for every single doc), ALV displays but after awhile I get the error message 'Storage area for GUI status Z_FI_UPLOAD_FIDOC 100 too small' and next step process leaves the program to initial SAP screen without dump. Error doesn't occur when item lines less than 1000. The detailed message is:
    +Storage area for GUI status Z_FI_UPLOAD_FIDOC 100 too small
    Message no. 00261
    Diagnosis
    The memory area of the basis software for the GUI status is too small for the requested status.  The following is stored in this area:
    Administration information in fixed length
    Menu structure, F keys and push buttons of a status
    The texts of the complete interface (not just of the status)
    The active and the requested Excluding list (SET PF-STATUS... EXCLUDING ...).
    System Response
    Termination as presumably the system is unable to continue processing.
    Procedure
    A short-term solution might consist of leaving off the EXCLUDING for the current SET PF-STATUS...
    Clear up the interface affected: in the Menu Painter (Transaction SE41), choose Utilities -> Unused objects.
    If it is an interface with a large number of statuses, it may be possible to take the interface apart.
    This is often possible for interfaces belonging to a function group that supplies GUI statuses for multiple programs (these programs call up function modules of the group that mainly contain a SET PF-STATUS command).
    If the above solutions will not work, your system administrator will have to enlarge the profile parameter "ztta/cua_area".
    Note that profile parameter "ztta/short_area" must be at least 6 times as large as "ztta/cua_area".+
    There is no unused object in my GUI. Is it connecting with number of items or should I ask system admin to enlarge mentioned parameters?
    Thanks for quick reply in advance,
    György
    Message was edited by:
            György Jakabovics

    Now I know what the problem was.
    Message was edited by:
            György Jakabovics
    Message was edited by:
            György Jakabovics

  • How to control iTV GUI from server

    I wanna develop iTV like DVB-MHP Ref-Impl at devicetop.com, but I want to control the GUI from server not build the GUI at client. it's like if we build web page database. at client side will request page to server and server send the UI+database to client. but the client side is iTV from devicetop. can I realize this???
    what web server that can make it realize??

    Well, MHP doesn't explicitly support it, but if you can implement it, then it's allowed. Implementing it is the hard part :)
    The rest of this answer assumes that you're not using DVB-HTML (fairly safe, since no available platform that I know of currently supports it). If this isn';t the case, please ignore the rest of this.
    Narakrishna, why do you want to build the GUI on the server and not the client? Given the way that MHP is designed to operate (e.g. like writing any other Java code, where the client running the app handles everything), then doing this will get extremely complex. You're assuming that a return channel exists and is always on, which will not be the case for most users. Since most of the existing MHP implementations use PSTN modems for the return channel if they have one, using an application like this could get very expensive for the user. This situation isn't likely to change in the short term.
    It could also be more computationally expensive to render a GUI built on the server than to just build the GUI on the client, since the GUI would eventually have to be converted to Java objects to be displayed. It's much easier to simply build the GUI on the client from Java objects int he first place.
    One way of doing someting similar (at the expense of object carousel size and application loading time) would be to hold the descriptions of pre-built GUI components in the oject carousel. You can then update these when you need to. There's a couple of downsides to this approach though:
    1) the GUI components are the same for every user
    2) depending on what you wanted, you'd still need to do some customisation on the client.
    3) you need some way of turning the description in to a real Java GUI component. Maybe you could serialise Java objects for your GUI and do it that way, but I'm not sure.
    On the whole, I don't think that this is the best approach to building a GUI for MHP apps due to the limitations of the platform.

  • Singleton Object With Anonymouse Methods

    I'm trying to create a singleton object using a GUI interface. The problem which I'm getting is that I can't find a way to create the object inside an .addActionListener() method while storing it for other .addActionListener() methods.
    CreditCard.java
       public class CreditCard {
           private static CreditCard uniqueInstance = null;
          final String creditCardNumber;
          String name;
          float creditLimit;
          float creditBalance;
           private CreditCard(String creditCardNumber,String name,float creditLimit) {
               this.creditCardNumber = creditCardNumber;
               this.name = name;
               this.creditLimit = creditLimit;
           public static CreditCard getInstance(String creditCardNumber,String name,float creditLimit)
               if (uniqueInstance == null)
                   uniqueInstance = new CreditCard (creditCardNumber, name, creditLimit);
               return uniqueInstance;
    Here's some code
    main class call
             CreditCard Student;
             JButton enterCardButton = new JButton("Edit Card");      
             enterCardButton.addActionListener(
                    new ActionListener() {
                       public void actionPerformed(ActionEvent ae) {
                         String cCNumber = creditCardNumberField.getText();
                         String cName = nameField.getText();
                         String cStringLimit = creditLimitField.getText();
                         float cLimit = Float.parseFloat(cStringLimit);
                         Student = CreditCard.getInstance(cCNumber, cName, cLimit);
             buttonPanel.add(enterCardButton);Of course the compiler error I get is that you must declare the CreditCard Student to be final. But if i make it final, I cannot create it in the method! I'm stuck :/

    You do need to call getInstance on a
    singleton. The compiler doesn't treat them specially.
    So, outside of the singleton itself you need
    something like
    String ccNumber =
    CreditCard.getInstance().getCreditCardNumber();(and it's probably best to define accessor methods
    for singleton fields).I actually do this for my other methods, thank you malcolmmc :). But the problem right now is the inablity to create the class using the ActionListener. I'm goign to Paste my whole code segment this time to try to provide a better picture.
    *          MAIN CLASS
    package Project2;
       import java.awt.BorderLayout;
       import java.awt.GridLayout;
       import java.awt.event.ActionEvent;
       import java.awt.event.ActionListener;
       import javax.swing.DefaultListModel;
       import javax.swing.JButton;
       import javax.swing.JFrame;
       import javax.swing.JLabel;
       import javax.swing.JList;
       import javax.swing.JPanel;
       import javax.swing.JScrollPane;
       import javax.swing.JTextField;
       import java.io.*;
       import java.lang.*;
       import java.util.*;
        public class Project2TestFrame {
          // public enum transactionType { LIMIT_CHANGE, CHARGE, PAYMENT}
           public static JFrame getTestFrame() {
             JFrame testFrame = new JFrame("Project 2 Tester");
          // Build the data portion of the frame
             final JTextField creditCardNumberField = new JTextField(15);
             final JTextField nameField = new JTextField(15);
             final JTextField creditLimitField = new JTextField(15);
             final JTextField chargeAmountField = new JTextField(15);
             JPanel dataPanel = new JPanel();
             dataPanel.setLayout(new GridLayout(4,2));
             dataPanel.add(new JLabel("Credit Card Number"));
             dataPanel.add(creditCardNumberField);
             dataPanel.add(new JLabel("Name"));
             dataPanel.add(nameField);
             dataPanel.add(new JLabel("Credit Limit"));
             dataPanel.add(creditLimitField);
             dataPanel.add(new JLabel("Charge Amount"));
             dataPanel.add(chargeAmountField);
             testFrame.add(dataPanel, BorderLayout.CENTER);
          // Add the buttons to the frame.  Note only the Exit button is
          // given here.  You should add other buttons.
             JPanel southPanel = new JPanel();
             southPanel.setLayout(new GridLayout(2,1));
             JPanel buttonPanel = new JPanel();
             southPanel.add(buttonPanel);
          // Add the messageField and
             String[] sarray = {"", "", "", "", ""};
             DefaultListModel dlm = new DefaultListModel();
             dlm.copyInto(sarray);
             final JList messageList = new JList(dlm);
             final JScrollPane jsp = new JScrollPane(messageList);
             southPanel.add(jsp);
             testFrame.add(southPanel, BorderLayout.SOUTH);
          // Add your buttons here.
             //Main Class Instance of CreditCard class.
             CreditCard Student;
             JButton enterCardButton = new JButton("Edit Card");
             enterCardButton.addActionListener(
                    new ActionListener() {
                       public void actionPerformed(ActionEvent ae) {
                         String cCNumber = creditCardNumberField.getText();
                         String cName = nameField.getText();
                         String cStringLimit = creditLimitField.getText();
                         float cLimit = Float.parseFloat(cStringLimit);
                         //***Compile Error** Needs to be final, but if final still complains
                         Student = CreditCard.getInstance(cCNumber, cName, cLimit);
             buttonPanel.add(enterCardButton);
             JButton chargeButton = new JButton("Charge Credit Card");
             chargeButton.addActionListener(
                    new ActionListener() {
                       public void actionPerformed(ActionEvent ae) {
                           String cStringCharge = chargeAmountField.getText();
                           float cAmount = Float.parseFloat(cStringCharge);
             buttonPanel.add(chargeButton);
             JButton paymentButton = new JButton("Payment");
             paymentButton.addActionListener(
                    new ActionListener() {
                       public void actionPerformed(ActionEvent ae) {
             buttonPanel.add(paymentButton);
             JButton dummyButton = new JButton("Transactions");
             buttonPanel.add(dummyButton);
             dummyButton.addActionListener(
                    new ActionListener() {
                       public void actionPerformed(ActionEvent ae) {
                         DefaultListModel messageData = (DefaultListModel)messageList.getModel();
                         messageData.clear();
                         messageData.addElement("String1");
                         messageData.addElement("String2");
                         messageData.addElement("String3");
             JButton exitButton = new JButton("Exit");
             buttonPanel.add(exitButton);
             exitButton.addActionListener(
                    new ActionListener() {
                       public void actionPerformed(ActionEvent ae) {
                         System.exit(0);
          // Finish and return data.
             return testFrame;
        * @param args
           public static void main(String[] args) {
             JFrame p2tf = getTestFrame();
             p2tf.pack();
             p2tf.setVisible(true);
        class Transaction {
          public enum transactionType { LIMIT_CHANGE, CHARGE, PAYMENT}
        //enum transactionType;
          int date;
          int amount;
           public Transaction(int date, int amount)
            //this.transactionType = transactionType;
             this.date = date;
             this.amount = amount;
    * CreditCard.java
    * Created on June 21, 2006, 9:27 AM
    * To change this template, choose Tools | Options and locate the template under
    * the Source Creation and Management node. Right-click the template and choose
    * Open. You can then make changes to the template in the Source Editor.
    package Project2;
       import java.io.*;
       import java.lang.*;
       import java.util.*;
       public class CreditCard {
           private static CreditCard uniqueInstance = null;
          final String creditCardNumber;
          String name;
          float creditLimit;
          float creditBalance;
          ArrayList<String> transactionHistory;
           private CreditCard(String creditCardNumber,String name,float creditLimit) {
               this.creditCardNumber = creditCardNumber;
               this.name = name;
               this.creditLimit = creditLimit;
           public static CreditCard getInstance(String creditCardNumber,String name,float creditLimit)
               if (uniqueInstance == null)
                   uniqueInstance = new CreditCard (creditCardNumber, name, creditLimit);
               return uniqueInstance;
           public void setName(String name)
             this.name = name;
           public String getName()
             return this.name;
           public String getCreditCardNumber()
             return this.creditCardNumber;
           public float getCreditLimit()
             return this.creditLimit;
           public void setCreditLimit(float creditLimit)
             this.creditLimit = creditLimit;
           public float getAvailableCredit()
             return this.creditBalance;
           public void addCharge(float chargeAmount)
            this.creditBalance -= chargeAmount;
           public void paymentReceived(float paymentAmount)
            this.creditBalance += paymentAmount;
        //public String[] getTransactions()
        //    return this.transactionHistory.toArray();
       class NumberOutOfBoundsException extends Exception {
        private int number;
        public NumberOutOfBoundsException() {
            number = 0;
        public NumberOutOfBoundsException(String Message) {
            super(Message);
        public NumberOutOfBoundsException(int number) {
            this.number = number;
        public NumberOutOfBoundsException(String Message, int number) {
            super(Message);
            this.number = number;
        public int getNumber() {
            return number;
    }

Maybe you are looking for

  • Bom for production order and subcontracting

    Dear guru , I have a finished material that can be use both produced in-house and procured externally with subcontracting. Now i use one only bom with usage 1 (production ) for the two process. I have a problem for one component. For subcontracting i

  • Reader 9.5 good. X and XI don't work--

    I can only use Reader 9.5. X and XI gives me an internal error everytime. Does anyone else have this problem? I use Windows 7.

  • Order by ignored if report has 2 groups in 1 query

    My report has order by &p_q1_order that allows the user to select the order of the report at runtime either by Business Name or by Applicator Name. The order by was working fine with only one group in the query. I have since had to add new fields(app

  • Multiple values for a Like condition

    How can I make a like condition for multiple value options, for example select b.segment1, b.segment2, b.description, c.cross_reference, c.cross_reference_type from inv.mtl_system_items_b b, inv.mtl_cross_references_b c where b.inventory_item_id = c.

  • Paper clip in Mavericks mail bitmapped and huge!

    Attachment icon in the viewer message window now bit mapped and huge under Mavericks. Rebooted, quit and reopened Mail. Problem always there. Looks ugly that's all. No problems so far anywhere else.