Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 815883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:45:00+00:00 2026-05-15T01:45:00+00:00

i’m working on GUI in java and got stuck with move the object. Please

  • 0

i’m working on GUI in java and got stuck with move the object.

Please visit this youtube video i made a short demo for you guys to see what i was trying to do. I’m so new to the GUI thing as i’ve never been taught of doing GUI.

Here is the link: http://www.youtube.com/watch?v=up1LV5r-NSg

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:45:01+00:00Added an answer on May 15, 2026 at 1:45 am

    I see you’re using a GUI designer. I highly recommend building your GUI “by hand” instead in which case your code is IMO much clearer (I’m not saying all GUI designers produce bad code, but it is almost always harder to read, and editing it will be hard without using the exact same GUI designer). Once you’re comfortable with GUI designing by hand, then try a GUI designer and see what makes you more comfortable.

    See: http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html

    In your case, you might create a BorderLayout, and in the “south” of your panel/frame you can place a panel with a FlowLayout aligning it’s components to the left. Then add your button to the panel with the FlowLayout.

    A little demo:

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Date;
    
    public class LayoutDemo extends JFrame {
    
        LayoutDemo() {
            super("LayoutDemo");
            super.setSize(400, 200);
            super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            createGUI();
            super.setVisible(true);
        }
    
        private void createGUI() {
            // set the layout of this frame
            super.setLayout(new BorderLayout());
    
            // create a panel to put the button on
            final JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    
            // create a text area to put in the center
            final JTextArea textArea = new JTextArea();
    
            // create the search button
            final JButton searchButton = new JButton("search");
    
            // add a listener to the button that add some text to the text area
            searchButton.addActionListener(new ActionListener(){
                @Override
                public void actionPerformed(ActionEvent e) {
                    textArea.setText(textArea.getText() + "pressed search on " + (new Date()) + "\n");
                }
            });
    
            // add the button to the bottom panel
            bottomPanel.add(searchButton);
    
            // wrap a scroll-pane around the text area and place it on the center of this frame
            super.add(new JScrollPane(textArea), BorderLayout.CENTER);
    
            // put the bottom panel (containing the button) on the 'south' of this frame
            super.add(bottomPanel, BorderLayout.SOUTH);
        }
    
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    new LayoutDemo();
                }
            });
        }
    }
    

    produces:

    alt text http://img689.imageshack.us/img689/5874/guiq.png


    EDIT

    And to move the button a bit more up, use the constructor new FlowLayout(FlowLayout.LEFT, int hgap, int vgap)

    where hgap is the gap (in pixels) between the left and right components and vgap is the gap (in pixels) between the upper and lower components.

    Try:

    final JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 10));
    

    Note that the space between the button and text area also increases slightly!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 418k
  • Answers 418k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try also including this line in your code: curl_setopt($ch, CURLOPT_HTTPHEADER,… May 15, 2026 at 10:03 am
  • Editorial Team
    Editorial Team added an answer From MSDN: An event in C# is a way for… May 15, 2026 at 10:03 am
  • Editorial Team
    Editorial Team added an answer Repeated addition would be a very inefficient way to multiply… May 15, 2026 at 10:03 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.