Tampilkan postingan dengan label Swing. Tampilkan semua postingan
Tampilkan postingan dengan label Swing. Tampilkan semua postingan

Jumat, 30 Juli 2021

Difference between repaint and revalidate method in Java Swing

Difference between repaint and revalidate method in Java Swing

What is the difference between revalidate() and repaint() in Java Swing is one of the popular Swing Interview Questions especially on Investment banks? Though both methods sound similar, there is a subtle difference between them. the revalidate() method instructs LayoutManager to recalculate layout and often called once new components are added or removed from Container. The revalidate() can also trigger to call the repaint() method to repaint components that have changed i.e. width, height, or any other visible property, which can affect layout. On the other hand repaint() method puts a paint request in AWT thread, for the repainting of a component on which it has called.
Is Swing Thread Safe in Java? Answer

Is Swing Thread Safe in Java? Answer

A couple of my readers ask questions, what does it mean by Swing is not thread-safe and How does it affect coding in Swing GUI application? This post is an effort to help those readers and several other programmers to understand Swing and thread safety in a bit more detailed way. To keep it simple, let's revise what does it mean by being thread-safe? We say an object is thread-safe if we can call its a method, which can change its states, from multiple threads at the same time. To give you an example, java.lang.String is a thread-safe class, which means you can call any method e.g. substring(), toUpperCase() or toLowerCase() from multiple threads.
How to Close Java Program or Swing Application with Example

How to Close Java Program or Swing Application with Example

In order to close the Java program, we need to consider which kind of Java application it is?, because termination of Java application varies between normal core java programs to swing GUI applications. In general, all Java program terminates automatically once all user threads created by program finishes its execution, including main thread. JVM doesn't wait for the daemon thread so as soon as the last user thread is finished, the Java program will terminate. If you want to close or terminate your java application before this your only option is to use System.exit(int status) or Runtime.getRuntime().exit().
InvokeLater and InvokeAndWait in Java Swing (an example tutorial)

InvokeLater and InvokeAndWait in Java Swing (an example tutorial)

Everyone who is doing programming in java swing has to come across invokeAndWait and invokeLater provided by SwingUtilites. In this java swing tutorial, we will learn about both invokeLater() and invokeAndwait() method. In the first part, we will mostly focus on invokeLater and will find answers to questions like What is invokeLater, how to use invokelater in java swing, an example of invokelater in swing, etc while in the second part of this invokeLater tutorial we will learn more about invokeAndWait method in java swing and will learn Why we need InvokeAndWait, how to use InvokeAndWait method in java Swing and differences between invokelater and invokeAndWait.

Kamis, 29 Juli 2021

Top 10 Java Swing Interview Questions Answers asked in Investment banks

Top 10 Java Swing Interview Questions Answers asked in Investment banks

The Swing  API and toolkit are heavily used in developing trading application front end in Java on both large Investment banks and small broker firms. Doesn’t matter whether it's a front office or middle office application, you will find Java Swing GUI everywhere. The Swing-based GUI is used to develop an Order entry system, Order monitoring GUI, and other tools that trader or operations can use on different trade life cycles in the front office. middle office and back-office space. Due to its heavy usage, there are a lot of requirements of Java Swing developers in investment banks like Barclays, Citibank, Deutsche Bank, Nomura, JP Morgan, Morgan Stanley, and Goldman Sachs, etc.