Class SwingReader

java.lang.Object
org.proto4j.swing.core.SwingReader
All Implemented Interfaces:
java.lang.AutoCloseable

public class SwingReader
extends java.lang.Object
implements java.lang.AutoCloseable
A basic class which is used by parent classes to delegate the creation process of the GUI object.

This class is designed to be used in a try-catch resource statement. It will close automatically after the statement is finished. For example,

     Entry<MyGUI> entry = ...
     try (SwingReader reader = new SwingReader()) {
         reader.read(entry, arguments);
         SwingLinker.readEntry(entry);
     }
     //...
 
Note the SwingLinker statement above - it is used to execute all defined 'init' methods from the Option annotation and tries to bind each component to their specified parent component
Since:
1.0
See Also:
AutoCloseable
  • Constructor Summary

    Constructors 
    Constructor Description
    SwingReader()  
  • Method Summary

    Modifier and Type Method Description
    void close()
    Closes this resource, relinquishing any underlying resources.
    boolean isClosed()  
    <T_GUI> void read​(Entry<T_GUI> entry, java.lang.Object[] args)
    Tries to fill the given Entry with a GUI instance and all possible FieldReference objects.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • read

      public <T_GUI> void read​(Entry<T_GUI> entry, java.lang.Object[] args) throws java.lang.Exception
      Tries to fill the given Entry with a GUI instance and all possible FieldReference objects.
      Type Parameters:
      T_GUI - the GUI type
      Parameters:
      entry - the entry to be filled
      args - constructor arguments for the GUI-class
      Throws:
      java.lang.Exception - if an error occurs
    • isClosed

      public boolean isClosed()
      Returns:
      Whether this reader is already closed or still can be used
    • close

      public void close() throws java.lang.Exception
      Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.
      Specified by:
      close in interface java.lang.AutoCloseable
      Throws:
      java.lang.Exception - if this resource cannot be closed