Size of the frame to be set a little bit larger than content

Assignment Help JAVA Programming
Reference no: EM13941683

I need the size of the frame to be set a little bit larger than its content, which is a label. Also, the location could be set so that it could be appeared not at the upper left corner of the screen. And we can set the foreground and background color of the label.

import javax.swing.*;
import java.util.*;

public class helloWorldSwing {

private static void createAndShowGUI() {

//Make sure we have nice window decorations.

JFrame.setDefaultLookAndFeelDecorated(true);

//Create and set up the window.

JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Add the ubiquitous "Hello World" label.

JLabel label = new JLabel("Hello World");
frame.getContentPane().add(label);

//Display the window.
frame.pack();
frame.setVisible(true);
}

public static void main(String[] args) {

//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}

Reference no: EM13941683

Questions Cloud

What does a merchant wholesaler do : What does a merchant wholesaler do?
Project planning process pyramid : Project Planning Process Pyramid Why do many people like to start at the bottom of the pyramid for the project planning process instead of at the top?
What ensure to there no instances of reverse discrimination : Is it more important for criminal-justice leaders to be ethical than leaders in business because monetary ambition and a cutthroat mentality can have benefits in business while they can only lead to corruption in criminal justice? Explain.
Four steps in market research process : 1. List the four steps in market research process? 2. Describe in some detail the three types of research that are typically used in business environment and any specific areas of research interest to business?
Size of the frame to be set a little bit larger than content : I need the size of the frame to be set a little bit larger than its content, which is a label. Also, the location could be set so that it could be appeared not at the upper left corner of the screen. And we can set the foreground and background co..
How much do you need to invest : If you are 35, want to retire in 30 years and be able to withdraw $50,000.00 for each year in retirement, and expect to live to age 85, how much do you need to invest at 9.5% each year(to the nearest dollar)(5 points)?
Discuss the possible causes of the accident : Discuss the possible causes of the accident. What are the steps one should have followed in order to avoid the disaster? Should international corporations be engaged in the production of such toxic materials for profit
Communication channel for urgent messages : How effective is email as a communication channel for urgent messages? How do the strengths and weaknesses of the email channel impact the internal communication of urgent messages? How do employees perceive urgent email information?
What is the difference between a felony and a misdemeanor : What is the difference between a felony and a misdemeanor - What is the State's burden of proof in a criminal case?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Draw all tree patterns corresponding to the instruction

Draw all tree patterns corresponding to this instruction (and its special cases). Pick one of the bigger patterns and show how to write a Java if-statement to match it, with the Tree representation used for the MiniJava compiler.

  Create a book class which stores the information

You run a small library. Ask the user to provide information for several books. The information must include the author, title and publisher of each book.

  What is the output of the following program

How can you tell whether an exception is checked or unchecked? What is required of checked exceptions that is not required of those that are unchecked? What is the output of the following program

  Improve the efficiency of their operations

To help improve the efficiency of their operations, the Maitre De has hired you to write a program that simulates people waiting for tables. The goal is to determine the average amount of time people spend waiting for tables.

  A java program that reads the records

A java program that reads the records from the golf.dat file and displays them. It also displays the name of the player with the best (lowest) golf score.

  What is an advantage of executing a process in background

What is an advantage of executing a process in background? How do you execute one program from within another?

  Create a java program

UserApp and PrettyPrintUtility multiple times (supplying different TransData test file names), the AutoTesterUtility PROGRAM will be the driver program.

  Write a method to save a linked list to a text file

Write a method to save a Linked List to a text file called file.txt. It must save the Linked List to the file with each node on a different line.

  Note the line number in the statement

Note the line number in the statement

  Role of inheritance in object-oriented programming

role of inheritance in object-oriented programming

  Design a java application using the list data structure

You are to design a Java application using the list data structure to manage your contact information. Each contact may have the subsequent data:

  Write a program that plays the memory matching game

Create a class HugeInteger which uses a 40-element array of digits to store integers as large as 40 digits each - output a large number of newlines to force the old board.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd