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 6569817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:40:44+00:00 2026-05-25T14:40:44+00:00

I just created an applet public class HomeApplet extends JApplet { private static final

  • 0

I just created an applet

public class HomeApplet extends JApplet {

    private static final long serialVersionUID = -7650916407386219367L;

    //Called when this applet is loaded into the browser.
    public void init() {
        //Execute a job on the event-dispatching thread; creating this applet's GUI.
//      setSize(400, 400);
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    createGUI();
                }
            });
        } catch (Exception e) { 
            System.err.println("createGUI didn't complete successfully");
        }
    }

    private void createGUI() {
        RconSection rconSection = new RconSection();
        rconSection.setOpaque(true); 

//      CommandArea commandArea = new CommandArea();
//      commandArea.setOpaque(true); 

        JTabbedPane tabbedPane = new JTabbedPane();
//      tabbedPane.setSize(400, 400);
        tabbedPane.addTab("Rcon Details", rconSection);
//      tabbedPane.addTab("Commad Area", commandArea); 


        setContentPane(tabbedPane);       
    }
}

where the fisrt tab is:

package com.rcon;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.Bean.RconBean;
import com.util.Utility;

public class RconSection extends JPanel implements ActionListener{
    /**
     * 
     */
    private static final long serialVersionUID = -9021500288377975786L;
    private static String TEST_COMMAND = "test";
    private static String CLEAR_COMMAND = "clear";
    private static JTextField ipText = new JTextField();
    private static JTextField portText = new JTextField();
    private static JTextField rPassText = new JTextField();
    //      private DynamicTree treePanel;

    public RconSection() {
//      super(new BorderLayout());
        JLabel ip = new JLabel("IP");
        JLabel port = new JLabel("Port");
        JLabel rPass = new JLabel("Rcon Password");

        JButton testButton = new JButton("Test");
        testButton.setActionCommand(TEST_COMMAND);
        testButton.addActionListener(this);

        JButton clearButton = new JButton("Clear");
        clearButton.setActionCommand(CLEAR_COMMAND);
        clearButton.addActionListener(this);

        JPanel panel = new JPanel(new GridLayout(3,2));
        panel.add(ip);
        panel.add(ipText);
        panel.add(port);
        panel.add(portText);
        panel.add(rPass);
        panel.add(rPassText);

        JPanel panel1 = new JPanel(new GridLayout(1,3));
        panel1.add(testButton);
        panel1.add(clearButton);

        add(panel);
        add(panel1);
//      add(panel, BorderLayout.NORTH);
//      add(panel1, BorderLayout.SOUTH);
    }

    @Override
    public void actionPerformed(ActionEvent arg0) {
        if(arg0.getActionCommand().equals(TEST_COMMAND)){
            String ip = ipText.getText().trim();
            if(!Utility.checkIp(ip)){
                ipText.requestFocusInWindow();
                ipText.selectAll();
                JOptionPane.showMessageDialog(this,"Invalid Ip!!!");
                return;
            }
            String port = portText.getText().trim();
            if(port.equals("") ||  !Utility.isIntNumber(port)){
                portText.requestFocusInWindow();
                portText.selectAll();
                JOptionPane.showMessageDialog(this,"Invalid Port!!!");
                return;
            }
            String pass = rPassText.getText().trim();
            if(pass.equals("")){
                rPassText.requestFocusInWindow();
                rPassText.selectAll();
                JOptionPane.showMessageDialog(this,"Enter Rcon Password!!!");
                return;
            }
            RconBean rBean = RconBean.getBean();
            rBean.setIp(ip);
            rBean.setPassword(pass);
            rBean.setPort(Integer.parseInt(port));
            if(!Utility.testConnection()){
                rPassText.requestFocusInWindow();
                rPassText.selectAll();
                JOptionPane.showMessageDialog(this,"Invalid Rcon!!!");
                return;
            }else{
                JOptionPane.showMessageDialog(this,"Correct Rcon!!!");
                return;
            }
        }
        else if(arg0.getActionCommand().equals(CLEAR_COMMAND)){
            ipText.setText("");
            portText.setText("");
            rPassText.setText("");
        }
    }
}

it appears as

applet screenshot

is has cropped some data how to display it full and make the applet non resizable as well. i tried setSize(400, 400); but it didnt helped the inner area remains the same and outer boundaries increases

  • 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-25T14:40:44+00:00Added an answer on May 25, 2026 at 2:40 pm

    As I mentioned in a comment, this question is really about how to layout components in a container. This example presumes you wish to add the extra space to the text fields and labels. The size of the applet is set in the HTML.

    200×130 FixedSizeLayout fixed at 200x130 200×150 FixedSizeLayout fixed at 200x150

    /*
    <applet
      code='FixedSizeLayout'
      width='200'
      height='150'>
    </applet>
    */
    import java.awt.*;
    import javax.swing.*;
    
    public class FixedSizeLayout extends JApplet {
        public void init() {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    initGui();
                }
            });
        }
    
        private void initGui() {
            JTabbedPane tb = new JTabbedPane();
            tb.addTab("Rcon Details", new RconSection());
    
            setContentPane(tb);
            validate();
        }
    }
    
    class RconSection extends JPanel {
        private static String TEST_COMMAND = "test";
        private static String CLEAR_COMMAND = "clear";
        private static JTextField ipText = new JTextField();
        private static JTextField portText = new JTextField();
        private static JTextField rPassText = new JTextField();
    
        public RconSection() {
            super(new BorderLayout(3,3));
            JLabel ip = new JLabel("IP");
            JLabel port = new JLabel("Port");
            JLabel rPass = new JLabel("Rcon Password");
    
            JButton testButton = new JButton("Test");
            testButton.setActionCommand(TEST_COMMAND);
    
            JButton clearButton = new JButton("Clear");
            clearButton.setActionCommand(CLEAR_COMMAND);
    
            JPanel panel = new JPanel(new GridLayout(3,2));
            panel.add(ip);
            panel.add(ipText);
            panel.add(port);
            panel.add(portText);
            panel.add(rPass);
            panel.add(rPassText);
    
            JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.CENTER,5,5));
            panel1.add(testButton);
            panel1.add(clearButton);
    
            add(panel, BorderLayout.CENTER);
            add(panel1, BorderLayout.SOUTH);
        }
    
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    Container c = new RconSection();
                    JOptionPane.showMessageDialog(null, c);
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just created a user control. This control also makes use of my static
Just created a WSS site with a some custom web-parts. But I get an
Just created an acc on SO to ask this :) Assuming this simplified example:
I just created a project so my Solution Explorer looks like this: (source: kalleload.net
I just created a ASP.NET MVC project in VS2008. When I press F5 to
I just created a ASP.NET MVC project and was able to build and browse
I just created a new table and filled it with data. When I run
I just created a PHP page that spits outs some data from my database
I just created an iPhone app and am having friends try it out, but
I just created my first MVC2 project using the standard template. I need to

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.