How to implement a graphical interface

To implement my GUI, I did:
public class Gui extends MyClass{
Is this a good practice? MyClass is a controller that controls the machines. So I figure it makes sense to use inheritance because the GUI is also a controller for the same machines.

But in the word GUI, 'I' means Interface. This means that a GUI must be an interface that is implemented by MyClass?

What is the best practice or rule to follow?

SquareBox wrote:
To implement my GUI, I did:

public class Gui extends MyClass{

Is this a good practice? MyClass is a controller that controls the machines. So I figure it makes sense to use inheritance because the GUI is also a controller for the same machines.

If you talk about 'Controller' as in the 'C' in 'MVC', then no, the user interface is not that. It is point of view. The only case in which the user interface should extend antyhing is if she extends a (proabably summary) class that defines some of the options view, and this particular interface is just a way of presenting, while, for example, some CommandLineInterface could be an another subclass that implements these features in a textual manner.

You don't generally range from concrete classes, and if you do, it is only to provide behavior specialized on certain methods. As a general rule, [url http://www.google.com/search?q=prefer+composition+to+inheritance] prefer composition over inheritance.

You certainly not inherit just to share the code.

But in the word GUI, 'I' means Interface. This means that a GUI must be an interface that is implemented by MyClass?

Yes and no. The "Interface" in "GUI" has nothing to do with the interfaces of the Java language itself. It is a 'user interface' - in other words, how your application interacts with the user. The term predates Java. However, it would not be of the never seen to set an interface that specifies the operations that is responsible for the user interface of your application. Note, however, that implements an interface is no different from one that extends an abstract class. In both cases, you provide concrete implementations for a set operation.

Tags: Java

Similar Questions

  • How to implement the ScreenUiEngineAttachedListener Interface?

    How to implement the ScreenUiEngineAttachedListener Interface? It is somewhat a mystery reading through the API.

    I have a class that implements ScreenUiEngineAttachedListener:

    public class UiListener implements ScreenUiEngineAttachedListener {
      public void onScreenUiEngineAttached(Screen screen, boolean attached) {
      }
    }
    

    Then I have a class MyScreen which extends from screen and has two methods:

    public void addScreenUiEngineAttachedListener(ScreenUiEngineAttachedListener listener) {
      super.addScreenUiEngineAttachedListener(listener);
    }
    
    private void removeScreenUiEngineAttachedListener() {
    
    }
    
    • What is the correct positioning of everything?
    • Can I define an instance of UiListener and pass in the addScreenUiEngineAttachedListener?
    • How to remove UiListener in removeScreenUiEngineAttachedListener?

    You will need:

    • an instance of your UiListener - probably a static member inside your UiApplication;
    • a method that allows to retrieve the reference to this instance of UiListener;
    • a call in your constructor for the screen at addScreenUiEngineAttachedListener (yourApplication.getUiListener ()) or similar;
    • potentially a call within your onScreenUiEngineAttached (attached screen, boolean) routine, the branch (attachment is false) : screen.removeScreenUiEngineAttachedListener (this);

    However, all this is too much work for no gain. Just override protected void onUiEngineAttached (boolean attached) in your screen class and make your logic there - all members of your class are accessible and all the code is placed where it belongs.

  • How to design own graphic interface for text entry

    Hello world

    I use the black background in my application and I would like to create my own custom controls which looks nice on a black background.

    For text input, I managed to create an entry of text with white background and black fonts. But I couldn't make the field to be a little larger than the text nor I was able to focus the State field.

    Code:

    public class CSTextField extends BasicEditField {}

    public {CSTextField()}

    Super (Field.FOCUSABLE |) Field.EDITABLE);

    }

    protected void paint (Graphics g) {}

    g.setBackgroundColor (Color.WHITE);

    g.setColor (Color.WHITE);

    g.fillRoundRect (0, 0, super. getWidth(), super. getHeight(), 5, 5);

    g.setColor (Color.GRAY);

    g.drawRoundRect (0, 0, super. getWidth(), super. getHeight(), 5, 5);

    g.setColor (Color.BLACK);

    Super.paint (g);

    }

    }

    See here: http://liechti-fotografie.ch/share/textfield.png

    Do you have an idea how realize that the focus is visible and the text field seems good?

    Thank you

    Do not design your own text input field - build a Manager around it that meets your needs.

    Here's an example of how this can be done:

    A scrolling line text entry field

    Read the comments - there are a few examples here on adding borders. I don't think you need boundaries, but they can give you ideas on how to position the fields in order to create some padding between the text and the surrounding black background.  You seem to be advanced enough to be able to easily change the code corresponding to your needs.

    Good luck!

  • How to implement interfaces or inheritance in LabVIEW?

    Hi all

    I try to implement oriented OBJECT in my LabVIEW code and require heritage or just an interface (such as might be required in java).  I have a good knowledge of OOP is just how do me in LabVIEW, I'm curious.

    I'll try to stick with my own example for now, so that someone is able to tell me exactly how to implement this.

    in any case, I have two different DMM and each come with their own GPIB commands to get the measures and set the measurement configurations.  This seems to be a perfect example to learn how to use inheritance.  I figured out how to make a class for each DMM but was curious as to how I might be able to create a parent class for each of them because they both require the same fields in their configuration (AC/DC, Measurment Type, rank, address VISA).  I think that I could create a parent class with these fields, then the methods of use of these fields and have then child classes inherit fields and override the methods of the parent class so that depending on what the user selected DMM, it would be able to use the correct class to issue the right GPIB commands.

    If anyone can point me to a good example or explain how this could be implemented in labview that would be super.  I'm also browsing the forums LVOOP to LavaG trying to figure this out, thanks!

    Brent

    Brent,

    LabVIEW help contains a lot of detailed information on the use of classes.  I recommend reading through it, before we begin with OOP in LabVIEW.  In the content of the Help window tab, search for "Fundamentals > LabVIEW Object - Oriented Programming > How - to's»  There is an article entitled 'change the legacy of a LabVIEW class' that should be what you're looking for.

    Chris M

  • How to implement the reading of data from a matte file on a cRIO?

    Hi all!

    I'm still not sure, it is plausible, but I'll ask rather before you begin complicating. So far, I found no useful information on reading in the data to a device of RT from a file (type of a simulation test - data is simulated).

    I have the MatLab plugin that allows the storage of data read a MAT file, which has a number of columns that represent the different signals and lines representing the samples at a time (depending on the time of the sample - sample every time has its own line of signal data).

    I have no idea how to implement this at cRIO.

    The idea is:

    I have some algorithms running on the controller of RIO in a timed loop. As the entries of these algorithms I need to access each of the values of columns in the row, which is the time of the sample (sort of a time series - without written actual times).

    I am fairly new to RT and LV development, so any help would be appreciated.

    Thank you

    Luka

    Dear Luka!

    I think the reading of all the samples in a single channel is exactly what you need here, because reading the files may take some time and is not deterministic, so it is best to read all the data in memory (or if this is not feasible due to problems of size, fairly large pieces may be sufficient). The table read can be provided and then in the loop simulating outings, something like this:

    I used here separate channels so it's more graphic, but you can build all the channels in a 2D array and array index corresponding to the samples fom 1 who. You can also use for loops with indexing as tunnels are setup and then you won't need the index functions and the number of iterations is also set automatically, but you have to take care of synchronization settings.

    Best regards:

    Andrew Valko

    National Instruments

  • How to implement a time UI?

    I would like to implement a user interface as time blackberry widget - Options-> Date/time, and we select Formate of time 24 hours / 12 hours. In the hour or minute field we can only enter a legal data.

    How can I implement the function in my own application? Or I need to write the text filter myself? Any suggestion will be appreciated. Thanks in advance.

    Do you mean a DateField?

    This is the API: http://www.blackberry.com/developers/docs/4.5.0api/net/rim/device/api/ui/component/DateField.html

  • Found that the solution does not know how to implement

    Hello

    In my reports (using oracle obiee 11.1.1.7.0) I need to display the values in the chart in percentage and value at the same time, but I don't know how. (for example in a pie chart, I can only see one, either the actual value or percentage of the slice)

    I found this solution the percentage and value of pie , but I do not know how to implement it.

    The solution is to apply this:

    FormatString = '_VALUE %, _PERCENT_OF_CATEGORY % '.


    OK, but where? and how

    Anyone want to explain further? Thank you

    Thanks ofr version information.

    As I said, the solution of John was for 10g, which means a version where OBI has always used the engine Corda to render graphics, and so there was the *.pcxml files which you can hack.

    This solution is no longer applicable since 11g and I think that there is no work around at the moment. At least the last thread of 5-10 on the subject gave no tangible results IIRC.

  • How to enable 3D Graphics and HD audio on a virtual machine?

    How to enable 3D Graphics and HD audio on a virtual machine?

    The 3D support is supposed to allow the possibility for the graphical interface of Windows Aero, in order to test with a Windows 7 if possible.

  • Compliabiality of DOT NET graphical Interfaces (GUI) with Java

    Hello
    Right now, I'm about to start the GUI in Java learning.
    I have gained all the basic knowledge of Java enough to learn GUI.

    My Questions are:
    (1) in a first time learning Java GUI, is it really necessary to learn AWT before learning Java Swing framework?

    (2) I heard that VISUAL STUDIO of Dot Net Framework supports advanced of GUI facilities and rich watch that we use to build graphic interfaces that must operate in Java Applications, so that Java Gui done, can the .net GUI library classes?

    Also is this really true?

    Tejaswi.B wrote:
    .. is it really necessary to learn AWT before learning Java Swing framework?

    No, but noted there are many (no) components of AWT that could be used in Swing interfaces. Fonts, sizes, layouts...

    This being said, follow the link provided Darryl and you will find the tutorial covers these classes (or almost) as if they were Swing.

    (2) I heard that VISUAL STUDIO of Dot Net Framework supports advanced GUI facilities and rich look than that of Java Gui...

    Where did you hear that?

    As far as I understand, there are a few components provided in .NET that are not in the swing, such as (I don't know how it's called) a "list of switch" where there are two lists side by side with buttons to move items from one list to the other. These components are possible from other components in the swing. I guess that Swing developers felt that these components were rarely required to justify the addition of a specific component for them.

    You can also go on SwingX (https://swingx.dev.java.net/), which is based on the swing to provide additional components.

  • Implement the OdiOpenToolAbstractJava Interface

    Hello

    I read in the slides in presentation of Oracle, there is a possibility to implement your own tools ODI by implementing an interface in Java called OdiOpenToolAbstractJava.
    But I could not find detailed information on this interface and how to proceed with the classes implement.

    Is there information on how to implement your own ODI tools available?

    Thank you
    H.

    You will find the information contained in the [reference tools Guide | http://www.oracle.com/technology/products/oracle-data-integrator/10.1.3/htdocs/documentation/oracledi_tools_reference.pdf], and the details of the API is available in the documentation of your installation:
    \oracledi\doc\sdk\opentools\index.html

  • How can implement you not with Tim Capsule and AirPort their simulation on the iMac?

    Hello

    How can implement you not with Time Capsule and AirPort their simulation on the iMac?

    I don't know what you're asking.

    AirPort Extreme is a wireless router.

    A Time Capsule airport is an AirPort Extreme with a built-in hard drive for data storage.

    An iMac is a Mac computer.

    An iMac is not a wireless router, so he is unable to perform the functions of a wireless router.

  • How we implemented personal signatures in Thunderbird?

    How we implemented personal signatures in Thunderbird?

    http://KB.mozillazine.org/Signatures_%28Thunderbird%29

  • How to change the graphics rather than the windows screen resolution

    Hello

    Intel graphics card;
    In response to the question of size screen. How him alter the graphics rather than windows.

    Granniebiker

    Hello

    I m not very well what you want to do?  :|
    You want to change the resolution of your laptop screen?

    I assume you have an XP operating system.
    If you can make them using two different ways.

    (1) go to-> graphic display Manager Control Panel Intel-> in one available tabs, you can change the display settings

    (2) using a second way to make a right click on the desktop-> properties-> settings tab
    There is also a setting to change the display resolution.

    Good bye

  • Equium A210-1AS: how to upgrade the graphics card from 128 MB to 256 MB

    Hello

    can someone tell me how to upgrade the graphics card 128 MB to 256 MB on the Satellite A210-1as... thx

    Hello

    Update graphics card is not possible.
    The GPU chip is soldered on the Board and it of not possible to remove the sleeve.

    Good bye

  • How to implement point filters fixed for FPGA

    Hello!

    I am applying the bandpass filter Butterworth for FPGA.

    I managed to develop filters of fixed point that suits my needs, but I don't know how to implement on a table in a project after the FPGA code generation. I tried to understand it in the examples, but I was not very successful.

    My time to finish what runs, any help would be really appreciated...

    Any suggestions?... some examples?

    Thanks in advance

    I've already done that and solved the problem.

    In any case thank you and have a nice day

    Ljubica

Maybe you are looking for