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

  Generate an amortization schedule

The applet input will be the loan amount, annual percentage rate (APR), and the number of years to pay out the loan. The output will be the loan amount, interest rate per pay period number of pay periods and the monthly payment

  What is the full path the to location of the web application

suppose that you are creating a java web application named "cset-test" consisting of a JSP file named "main.jsp" , and a java Servlet in a file named "InfoServlet.java". The user's home directory is /home/jdoe.

  Write a graphical user interface class

Write a graphical user interface class called SentenceCounterGUI. It should be able to manipulate the sentence of words and have the behaviour label.

  Guess the number game

The user interface is displayed and the user clicks the "Start Game" button to begin the game - Your application then gets a random number in the range 1-1000 inclusive

  Displays the calendar for the current month

Prepare a program that displays the calendar for the current month. You will use the Prior and next buttons to show the calendar of the previous or next month.

  How do you figure out how to declare a variable

How do you figure out how to declare a variable? How do you know what type of variable to use? What is the best way to name a variable and why? What are the differences between an integer variable and a floating point variable? When and why do dat..

  Write a program that simulate n rolls of six-sided die

Write a program that simulate n rolls of six-sided die and displays the frequency of occurrence of each side and What is the most likely method signature of the "parseInt() - TNE60003

  Write a class encapsulating a pc-based game

Write a class encapsulating a PC-based game, which inherits from Game. A PC-bases game has the following additional attributes: the minimum megabytes of RAM needed to play the fame, the number of megabytes needed on the hard drive to install the fame..

  Edit a java program to generate a better code

I need your help with this java program (That is what I have so far its not displaying the medal count)

  Java threads

This is an introductory assignment on Java synchronization. You will use Java Threads while learning more about concurrency and achieving atomicity using Java’s inbuilt mechanisms.

  Prepare a java application will read the database file

Prepare a java application will read the database file. The path of the database file will be supplied by a run-time parameter. If the database file does not exist, the user will be told the database does not exist.

  Design a war game that you can play against the computer

Create a Card class to store a single playing card.  Create a class called DeckOfCards that stores 52 objects of the card class.  Create appropriate constructors and methods for each class that allow for the following requirements.

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