Raja has Published 760 Articles

What are the differences between JTextField and JTextArea in Java?

raja

raja

Updated on 07-Feb-2020 06:48:30

3K+ Views

The main difference between JTextField and JTextArea in Java is that a JTextField allows entering a single line of text in a GUI application while the JTextArea allows entering multiple lines of text in a GUI application.JTextFieldA JTextFeld is one of the most important components that allow the user to an input text value in a single ... Read More

What is an Event Handling and describe the components in Event Handling in Java?

raja

raja

Updated on 07-Feb-2020 06:34:45

3K+ Views

The GUI in Java processes the interactions with users via mouse, keyboard and various user controls such as button, checkbox, text field, etc. as the events. These events are to be handled properly to implement Java as an Event-Driven Programming.Components in Event HandlingEventsEvent SourcesEvent Listeners/HandlersEventsThe events are defined as an object that ... Read More

How to create a custom unchecked exception in Java?

raja

raja

Updated on 07-Feb-2020 06:23:44

8K+ Views

We can create the custom unchecked exception by extending the RuntimeException in Java.Unchecked exceptions inherit from the Error class or the RuntimeException class. Many programmers feel that we cannot handle these exceptions in our programs because they represent the type of errors from which programs cannot be expected to recover while the program is running. When an ... Read More

When will be an IllegalStateException (unchecked) thrown in Java?

raja

raja

Updated on 07-Feb-2020 06:21:13

278 Views

An IllegalStateException is an unchecked exception in Java. This exception may arise in our java program mostly if we are dealing with the collection framework of java.util.package. There are many collections like List, Queue, Tree,  Map out of which List and Queues (Queue and Deque) to throw this IllegalStateException at particular conditions.When will be IllegalStateException is thrownAn ... Read More

How can we create a login form in Java?

raja

raja

Updated on 07-Feb-2020 06:20:10

23K+ Views

We can develop a login form in Java using Java Swing technology. In this example, we can create two labels username and password, two text fields for the user to enter valid credentials and finally one submit button. Once the user is able to enter the valid credentials in the two text fields, we can ... Read More

Is Swing thread-safe in Java?

raja

raja

Updated on 07-Feb-2020 06:16:23

1K+ Views

No, Java Swing components are not thread-safe in Java.Why Swing Components are not thread-safeOne of the main reason for Java Swing is not thread-safe is to simplify the task of extending its components.Another reason for the Java Swing is not thread-safe due to the overhead involved in obtaining and releasing locks ... Read More

What are the differences between GridLayout and GridBagLayout in Java?

raja

raja

Updated on 07-Feb-2020 06:09:22

5K+ Views

A GridLayout puts all the components in a rectangular grid and is divided into equal-sized rectangles and each component is placed inside a rectangle whereas GridBagLayout is a flexible layout manager that aligns the components vertically and horizontally without requiring that the components be of the same size. Each GridBagLayout object maintains a dynamic, rectangular grid ... Read More

Can we extend an enum in Java?

raja

raja

Updated on 07-Feb-2020 05:58:29

3K+ Views

No, we cannot extend an enum in Java. Java enums can extend java.lang.Enum class implicitly, so enum types cannot extend another class.Syntaxpublic abstract class Enum> implements Comparable, Serializable {    // some statements }EnumAn Enum type is a special data type which is added in Java 1.5 version.An Enum is used to define ... Read More

Can we change the order of public static void main() to static public void main() in Java?

raja

raja

Updated on 07-Feb-2020 05:47:14

3K+ Views

Yes, we can change the order of public static void main() to static public void main() in Java, the compiler doesn't throw any compile-time or runtime error. In Java, we can declare access modifiers in any order, the method name comes last, the return type comes second to last and then ... Read More

When can we use intern() method of String class in Java?

raja

raja

Updated on 07-Feb-2020 05:45:33

301 Views

The intern() method of String class can be used to deal with the string duplication problems in Java. Using intern() we can save a lot of memory consumed by duplicate string instances. A string is duplicate if it contains the same content as another string but it can be occupied different memory ... Read More

Advertisements