What is the purpose of the @Component annotation in Spring?
@Component registers a class as a Spring-managed bean through component scanning. See how it relates to @Service, @Repository, @Controller and @Bean.
2,889 posts about Java: questions with answers, tutorials and articles, newest first.
@Component registers a class as a Spring-managed bean through component scanning. See how it relates to @Service, @Repository, @Controller and @Bean.
A step-by-step Spring Boot walkthrough of dependency injection: stereotype beans, constructor injection, @Bean configuration and fixing ambiguous or missing beans.
Dependency Injection reduces coupling and makes code easier to test and configure. See the main advantages with Java and Spring examples.
Learn what Dependency Injection is, why constructor injection is preferred, and how to wire Java classes by hand or with a container like Spring.
Define a JavaFX layout in FXML, connect it to a controller with fx:controller and @FXML, and load it with FXMLLoader. Includes OpenJFX and module setup.
FXML describes a JavaFX UI declaratively and keeps layout apart from Java logic. See how FXMLLoader, controllers and Scene Builder fit together.
Compare JavaFX and Swing with side-by-side code, key features, interoperability and guidance on which Java UI toolkit to choose.
Make a JavaFX interface adapt to any window size with nested panes, grow rules, breakpoint listeners and background tasks that never block the UI thread.
Node is the base class of every JavaFX scene graph element, and Group is a container that applies transforms and effects to children together without laying them out.
Extend JComponent, draw in paintComponent, report a preferred size and handle input safely on the Event Dispatch Thread. Includes a runnable example.
Swing offers lightweight components, a pluggable look and feel and many more widgets than AWT. See a full example and today's alternatives.
Swing is single-threaded, so slow work must leave the Event Dispatch Thread. Learn SwingWorker, invokeLater, executors and javax.swing.Timer with runnable examples.
The EDT is the one thread that creates and updates Swing components. Learn how to start your UI on it and keep slow work off it with SwingWorker.
Swing components must only change on the Event Dispatch Thread. See when to use invokeLater, invokeAndWait, Timer and SwingWorker, with complete runnable examples.
SwingUtilities moves work onto the Event Dispatch Thread so Swing UIs stay thread-safe. See invokeLater, invokeAndWait and SwingWorker in practice.
Build a Swing menu bar with JMenuBar, JMenu and JMenuItem, then add separators, mnemonics, accelerators, submenus, popup menus and shared Actions.
JPanel is the core container of Java Swing for grouping components, hosting layouts and custom drawing. See practical examples and tips.
FlowLayout wraps components in a row, BorderLayout uses five regions and GridLayout makes equal cells. See examples and when to combine them.
A layout manager decides how Swing components are sized and placed in a container. See the built-in managers and when to use each, with code.
Attach listeners to Swing components, use lambdas and adapters, prefer key bindings over KeyListener and keep the UI responsive with SwingWorker.