Results 1 to 9 of 9
  1. #1
    SPATTER is offline Member
    Join Date
    Nov 2008
    Posts
    2
    Rep Power
    0

    Default Im forgetting someting

    Hellow,


    Im thinking that im forgetting something, but i cant see what.
    Does somebody have the anser?

    Thanks

    SPATTER

    the code:
    Java Code:
    package voco;
    
    import javax.swing.*;
    import java.awt.*;
    
    
    
    public class Gui extends JApplet {
        
        //
        Container c = new Container();
       
    
        //buttons
        private JButton btnPost = new JButton();
    
        //labels
        private JLabel lblSpotter = new JLabel("Spotter: ");
        private JLabel lblDatum = new JLabel("Datum: ");
        private JLabel lblTijd = new JLabel("Tijd: ");
        private JLabel lblVogelsoort = new JLabel("Vogelsoort: ");
        private JLabel lblLocation = new JLabel("Location: ");
        private JLabel lblCommentaar = new JLabel("Commentaar: ");
        private JLabel lblFoto = new JLabel("Foto: ");
        private JLabel sl1 = new JLabel("/");
        private JLabel sl2 = new JLabel("/");
        private JLabel dp1 = new JLabel(":");
    		
        //textfields & areas & scrollpane
        private JTextField inputSpotter = new JTextField();
        private JTextField inputDag = new JTextField();
        private JTextField inputUur = new JTextField();
        private JTextField inputVogelsoort = new JTextField();
        private JTextField inputMaand = new JTextField();
        private JTextField inputJaar = new JTextField();
        private JTextField inputMin = new JTextField();
        private JTextField inputLocAB = new JTextField();
        private JTextField inputLoc1234 = new JTextField();
        private JTextField inputLoc5678 = new JTextField();
        private JTextArea inputCommentaar = new JTextArea();
        private JScrollPane scrollPane = new JScrollPane();
    
        //
    
       
       @Override
        public void init() {
           inputCommentaar.setColumns(20);
           inputCommentaar.setRows(5);
           scrollPane.setViewportView(inputCommentaar);
          
      
            GroupLayout layout = new GroupLayout(c);
    
            c.setLayout(layout);
            layout.setAutoCreateGaps(true);
            layout.setAutoCreateContainerGaps(true);
    
            layout.setHorizontalGroup(
                layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                        .addComponent(lblCommentaar)
                        .addGroup(layout.createSequentialGroup()
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                                .addComponent(lblVogelsoort)
                                .addComponent(lblLocation)
                                .addComponent(lblTijd)
                                .addComponent(lblDatum)
                                .addComponent(lblSpotter)))
                        .addComponent(lblFoto))
                    .addGap(7, 7, 7)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
                        .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                .addComponent(inputDag)
                                .addComponent(inputUur, GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                                .addComponent(sl1)
                                .addComponent(dp1))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                .addComponent(inputMin, GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)
                                .addComponent(inputMaand))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(sl2)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(inputJaar))
                        .addComponent(scrollPane, GroupLayout.Alignment.LEADING)
                        .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addComponent(inputLocAB, GroupLayout.PREFERRED_SIZE, 53, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(inputLoc1234, GroupLayout.PREFERRED_SIZE, 63, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(inputLoc5678))
                        .addComponent(inputSpotter, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE)
                        .addComponent(inputVogelsoort, GroupLayout.Alignment.LEADING)
                        .addComponent(btnPost))
                    .addContainerGap(31, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(26, 26, 26)
                            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                .addComponent(lblDatum)
                                .addComponent(inputDag, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(inputMaand, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(inputJaar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(inputLocAB)
                                .addComponent(inputLoc1234)))
                        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(lblSpotter)
                            .addComponent(inputSpotter, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(lblTijd)
                        .addComponent(inputUur, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addComponent(inputMin, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addComponent(dp1))
                    .addGap(7, 7, 7)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(lblVogelsoort)
                        .addComponent(inputVogelsoort, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                        .addComponent(lblLocation)
                        .addComponent(inputLocAB, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addComponent(inputLoc1234, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addComponent(inputLoc5678, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                        .addComponent(lblCommentaar)
                        .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 78, GroupLayout.PREFERRED_SIZE))
                    .addGap(6, 6, 6)
                    .addComponent(lblFoto)
                    .addGap(21, 21, 21)
                    .addComponent(btnPost)
                    .addContainerGap())
            );
        }
        //@Override
        //public void start(){
     
        //}
    
    
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Im thinking that im forgetting something, but i cant see what.
    Yes. You've forgotten to ask a question. Please let us know what problem you're having. Remember that the more effort you put into helping others help you, the more likely you'll get decent help. Good luck.
    Last edited by Fubarable; 11-01-2008 at 01:18 AM.

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,409
    Rep Power
    25

    Default

    im forgetting something
    For one thing, there are no comments in the code describing what its supposed to do.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by SPATTER View Post
    Hellow,


    Im thinking that im forgetting something, but i cant see what.
    Does somebody have the anser?

    Yes, as serjan says what's your question is? You must explain it clearly if you are looking some help from our members. You just copy-paste a code from the IDE you are working on. Who knows what you are trying to do?

  5. #5
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    As I only paid attention,that the code above,places the components on the JApplet surface,i am popped up where is the question,lol
    Last edited by serjant; 11-01-2008 at 10:42 AM.

  6. #6
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    As i understood your code doesn't display what you want,it doesn't display the components in Container of JApplet

  7. #7
    SPATTER is offline Member
    Join Date
    Nov 2008
    Posts
    2
    Rep Power
    0

    Default

    Sorry, i didn`t explain what the problem is/was.
    I don`t get any output on my screen. I know i`m forgetting soemthing but what. Does somebody see why the components aren`t dislpayed.

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Since you are using the GroupLayout you've obviously created your app using the NetBeans Swing-generation code. I myself find it very difficult to translate this code much less debug. I recommend that you do this using standard layouts and skip the netbeans code generation. It will give you a much better understanding of Swing and Java if you do this.

    By the way, can you link a picture what your app is supposed to look like?

    edit: no you can't as you've only posted twice. You can post a pseudo link using <dot> for "." in the link

  9. #9
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,409
    Rep Power
    25

    Default

    I made three source changes to your code and got it to display some components in appletviewer. I'll post the steps I took:

    I found another small, working program I'd copied earlier that used the GroupLayout class. In looking at it I saw that it used getContentPane()which the code here doesn't use. I added(1) the following to the posted code:
    c = getContentPane();
    and also added some html in a comment at the head of the program so I could use Appletviewer:
    <APPLET CODE=GuiApplet WIDTH=500 HEIGHT=300>
    </APPLET>

    I used Appletviewer to execute the JApplet. Nothing showed in the window.
    I resized the window and got the following error:
    Exception in thread "AWT-EventQueue-1" java.lang.IllegalStateException:
    javax.swing.JLabel[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,bor der=,flags=8388608,
    maximumSize=,minimumSize=,preferredSize=,defaultIc on=,disabledIcon=,horizontalAlignment=LEADING,
    horizontalTextPosition=TRAILING,iconTextGap=4,labe lFor=,text=/,verticalAlignment=CENTER,
    verticalTextPosition=CENTER] is not attached to a vertical group

    I commented out(2) the add of the component refered to in the above error message and did it again.
    Got the same error for a different component.
    I commented out(3) the add for that component and now AppletViewer displays the form.
    Last edited by Norm; 11-02-2008 at 10:18 PM. Reason: New answer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •