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

  • SEARCH
  • Home
  • 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 8704681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:10:10+00:00 2026-06-13T03:10:10+00:00

Recently I have written a pair of applications with JAVA/Swing with a simple GUI:

  • 0

Recently I have written a pair of applications with JAVA/Swing with a simple GUI:

  • A JScrollPane
  • In the first application, there is a JTextArea inside the JScrollPane, and in the second one there is a JTable.

They look OK, they work OK. Until I executed then on a Windows 7 tablet (HP Slate). They both look empty, with a tiny symbol in the middle. This picture shows how the first application (the JTextArea one) looks over the tablet:

enter image description here

What’s the problem here and how can I solve it?

I’m showing the code, but since it looks fine when using a computer, I guess this is not the problem:

import java.io.*;
import java.net.*;

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.text.DefaultCaret;

class EstacionBase extends JFrame{
    private static final long serialVersionUID = 1L;

private static final String logFile = "log.txt";

private DateFormat df;
private FileWriter logWriter;

private Socket sisnetSocket;
private ServerSocket serverSocket;
private Socket clientSocket;
private BufferedWriter outToPlane;
private BufferedWriter outToDataServer;
private BufferedReader inputFromDataServer;
private JTextArea console;

private boolean terminated;

public EstacionBase() {
    setTitle("Base station");
    createGUI();
    pack();
    setResizable(false);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLocationRelativeTo(null);
    setVisible(true);

    try{
        df = new SimpleDateFormat ("[hh:mm:ss]");
        logWriter = new FileWriter(System.getProperty("user.dir") + "\\" + logFile, true);
        serverSocket = new ServerSocket(PORT); // A socket I use for listening for connections
    } catch(IOException e){
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }

    //mainLoop(); // doing some stuff

    try{
        logWriter.close();
        serverSocket.close();
    } catch(IOException e){
        JOptionPane.showMessageDialog(this, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }
}

private void createGUI() {
    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.fill = GridBagConstraints.BOTH;

    console = new JTextArea(40, 80);
    JScrollPane scroll = new JScrollPane(console);
    DefaultCaret caret = (DefaultCaret) console.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); // Autoscroll
    console.setText("Welcome to base station");
    console.setEditable(false);
    console.setVisible(true);
    add(scroll, c);
}

private void writeToConsole(String msg) throws IOException{
    Date now = new Date();
    String timeStr = df.format(now);
    console.append("\n");
    console.append(timeStr + " " + msg);
    writeToLogFile(msg, timeStr);
}

private void writeToLogFile(String msg, String timeStr) throws IOException{
    logWriter.write(timeStr + " " + msg + CRLF);
        logWriter.flush();
    }

    public static void main(String[] arg) {
        EstacionBase frame = new EstacionBase();
    }

}
  • 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-06-13T03:10:11+00:00Added an answer on June 13, 2026 at 3:10 am

    This is a GridBagLayout problem; I’m not sure of the optimal fix, but it works fine with the default JFrame layout, BorderLayout.CENTER. Functionally, these three layouts have similar effects:

    • BorderLayout.CENTER: the default for JFrame#add().

    • GridLayout(): one column, one row, no gaps.

    • GridBagLayout(): the default GridBagConstraints() has all fields set to default values.

    As an aside, Swing GUI objects should be constructed and manipulated only on the event dispatch thread.

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

Sidebar

Related Questions

Ok, recently i have written a paint application in Java. Small program similar to
I have recently written my first simple jQuery plugin. Proud I am. http://jsfiddle.net/johnhoffman/wSeLY/1/ (function($)
I have recently written a survey application that has done it's job and all
I have recently written an application(vb.net) that stores and allows searching for old council
I have recently written an application on per-contract base for a company. The deal
I have recently written a macro for visual studio 2010 in the macro IDE,
I'm working on a Windows Mobile 6.1 app written in C#. I have recently
I recently have a problem that my java code works perfectly ok on my
I have written various C# console based applications, some of them long running some
I have written a DLL-Injector in C++ recently, for which the requirements were the

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.