Swing/AWT/SWT :: How Controller Interacts With View

Sep 12, 2014

create an application following the MVC pattern. My frame is composed of a JTable with some JComboBox and classic next/previous buttons to page the table. The table shows data of current accounts of the members of a family. My problem is figuring out how the controller interacts with the view, for example to enable / disable buttons or reset and reload the data in the comboboxes. In the view class all the graphical components are private instance variables. What is the best approach to ensure that the controller can act on them?

I need to create in the view public methods to act on each component like getSelectedItemAccountCombo, getSelectedItemYearsCombo, getSelectedItemMonthCombo, populateAccountCombo (ArrayList <String> list), setNextButton (boolean b) ... and so on (I think that the methods would be many ...) This approach does not convince me because I think that the class is fouled by procedures that should be in the controller class.

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: GUI - Create User Interface That Interacts With Setters And Getters Of Some Classes

Apr 14, 2014

I am new a creating GUIs and am not quite sure how to correctly make one. I have done the inheritance parts, and created two extra appliances: a washer and dryer. Now Creating the GUI ....

Here are the instructions to my project.

Introduction to GUIs (+ some inheritance)

For this assignment, you are going to create a user interface that interacts with the setters and getters of some classes that you will create.

First, create an abstract class called Appliance. This abstract class should have two attributes (dealing with household appliances) and two abstract methods called turnOn() and turnOff(). These methods should return void.

Then, create two subclasses of Appliance that represent household appliances (like a Refrigerator or Stove ((don't use those!))). These subclasses should have two attributes that are specific to the various appliance. Each subclass should implement the turnOn() and turnOff() methods. These methods should print to the command line some information about the appliance as it turns on and off.

Now, the fun part! Create a GUI interface!

Your window should have two panels: one for each appliance subclass. Each panel should have 4 textboxes (with appropriate labels) to receive/display information that correspond to the 4 attributes (2 from Appliance and 2 from the subclass) for each subclass.You also need 2 buttons on each panel: A Get button and a Set button.

When the Get button is pressed, the text boxes should be filled with the information from the instantiated object of the appropriate subclass. When the Set button is pressed, the object should then contain the information contained that the user has altered.

In your main method, you should create an object of each subclass, and prefill it with information (either using the constructor or the setters), then display your GUI. You should now be able to get and set the information for your objects from the GUI.

At least one of your attributes for each subclass should be numeric

Note that you will need to handle incorrectly formatted input (You can use exception handling to do this if you want to. Wrapper classes also will work)

If there is text in the boxes when the "Get" button is pressed, it should be overwritten by what is in the object. Remember that these two panels should both be on screen at the same time.

You don't need 2 different windows, one window: 2 panels.

View Replies View Related

Swing/AWT/SWT :: Passing Value To Combobox Through Controller

Sep 11, 2014

I've got 2 view classes with their own viewcontroller. In view 1 i'v got a combo box with a observablelist wicht show me some values.

What i want is to put an new value to the combobox through the controller of view2.

When i make the observablelist static it works but i think that isn't a nice way.

View Replies View Related

Jasper Report Is Only Showing Code (source View) Instead Of Design View

Mar 23, 2014

I am building a room management system in Java (Netbeans) and Ms Access. The jasper report is only showing code (source view) instead of design view. The GUI JFrame and Login JFrame are not displaying records in the database and the buttons are not working. Also the labels and text fields are not neatly arranged. The connection to the database is not displaying records.

Connection to the database. COIRMS.java

package Login;
import java.sql.*;
public class COIRMS {
Connection con;
Statement st;
ResultSet rs;
public COIRMS ()

[Code] ....

View Replies View Related

Observer Controller Pattern (MVC)

Dec 10, 2014

Model View Controller design pattern I completely understand then I was told about the observer controller pattern. After reading and reading I and watching video clips on youtube explaining it I have a question:

Isn't the actionListener the observer so to speak. It is firing whatever action it is told to do and dynamically updates the program to.

Example, I have a JButtons and a JTextArea. I press the button and it gives the current stock price of some stock, I press it again it refreshes. Sounds like an observer to me... Am i on the right track here?

View Replies View Related

MySQL Connection From JavaFX Controller

Nov 16, 2014

I am unable to connect my javafx scene to mysql database. I get a java.lang.NullPointerException every time. I tried searching everywhere possible but no answers available. This is the Person class (super class for Teacher class):

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

[code].....

View Replies View Related

Servlets :: Passing Request To The Controller?

May 24, 2014

I have used jsp's to passing request to the servlet or controllers. but we can also pass request from javascript using ajax and sending data using json.

what is the good approach and why? or does it depends on the situations? is yes, what kind of situations?

View Replies View Related

JavaFX 2.0 :: How To Access Application From Controller

Sep 25, 2014

I do Java for decades, but am a FXML beginner. Currently I do FXMLLoader.load(fxmlFile) in Application.start(), which is working well. My Application instance is creating a background thread in Application.init() which feeds several custom application properties with incoming data taken from a remote model (wrapping a sensor hardware). Some of my windows shall later be able to access those properties. So the question is: How can I inject my Application instance into the FXMLLoader-created controller instances auto-bound to the FXML-created Scene instances?

View Replies View Related

JavaFX 2.0 :: How To Access FXML Controller

Jun 24, 2014

I used the SceneBuilder to create an applications and it works quite well. Now I got a problem to set the pref. size of a ScrollPane to the size of the app.

I want to install a binding between the scroll pane's pref. size and the stage's pref. size. Since the scroll pane field reside in the FXMLController class I need a way to access this field.

View Replies View Related

Implementation Of MVC With Several Viewers And Single Model / Controller?

May 6, 2014

I am working on an project in which some data needs to be received through socket , do some processing on it and then store on the database. After that it will display on GUI. GUI should be updated automatically.

I am able to implement basic model in which data is storing in the database and displayed then on the GUI. I tried to implement MVC design patter as well.

Now i need to create a GUI which can be used by several users at a time means several jvm session for the GUI. I got struck at this point.

Some detail: i have one jvm session in which i am receiving , processing and storing the data. Now i want to fire an alert whenever any new entry is made into the database. Also each time new GUI is opened it should be registered with the model so that model send updated data alert to all this users.

When i am trying to open several GUI and trying to register with the Model then it is not increasing count of registered user. For each time it is showing 1 count only and whenever a new entry is made count is showing 0. Is it because both are running in different jvm sessions ?

Some code for the model which is running in different package and jvm

GUI..

private void runApp() {
//some gui code
WindowListenerClass windowListener = new WindowListenerClass(this);
frame.addWindowListener(windowListener)
//registering viewer with the model
Model.setNewAlarmEvent(this);
tableModel = windowListener.getDefaultTableModel();

[Code] .....

View Replies View Related

How To Pass Java Object Into Spring Controller

Jan 7, 2014

When I hit the url at the first time my call goes to the spring controller and sets the userDetails objects in the modelAndView.addObject("userDetails", userDetails.getUserDetails()) and returns the userDetails.html page. if I click any link in the same page i want to pass same (userDetails) object thru javascript or jquery and calls the another(controller) method and returns the same (userDetails.html) page.

It means how can I pass the java object thru javascript or jquery and calls the controller. If I get the same object in my controller i can avoid calling the db again.

View Replies View Related

Passing Object From JSP Page Through JSTL Into Controller Method

May 12, 2015

I need to pass advanced object into controller from JSP page, but I always get null result.It's a controller method:

Java Code:

@RequestMapping(value="admin-user-edit", method=RequestMethod.POST)
public ModelAndView editUser(@ModelAttribute(value="user") UsersEntity user)
{
if (null == user)System.out.println("User is null");
else
System.out.println("User name = " + user.getName() + " | Users id = " + user.getId());
ModelAndView view = new ModelAndView();
return view;
} mh_sh_highlight_all('java');

And this is a JSP page snippet. I need to choose some user from user list and pass it to controller.

XML Code:

<c:forEach var="user" items="${user_list}">
<tr>
<td><c:out value="${user.id}" /></td>
<td><c:out value="${user.name}" /></td>
<td><c:out value="${user.login}" /></td>
<td><c:out value="${user.status}" /></td>

[code]...

I tried to pass it through HttpServletRequest argument but all the same.

View Replies View Related

Servlets :: How To Track Source Of Request Coming To Controller

Sep 29, 2014

I have a controller that on the basis of commands (formaction and subaction) dispatch requests to different jsp pages. But somehow when I am debugging my application, I can find duplicate request coming to the controller, so one jsp page does load twice. I am not sure from where the duplicate request is generating.

View Replies View Related

Bluetooth Client Program To Communicate With Micro Controller

Jan 30, 2014

I use a bluetooth module (dwengo) in combination with a microcontroller (PIC16F877A). I want write a bluetooth client program in java to communicate with the microcontoller. Examples of clients on internet do not work or give errors I cant'n resolve. There is one program ( SampleSPPClient ) that give no errors and shows the bluetooth devices present.

But when I choose my bluetooth module I got an error (Device does not support Simple SPP Service). I think that I have to use an other service of bluetooth but I don't know how to implement. Here is the program I tried to use ....
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Vector;
import javax.bluetooth.DataElement;

[Code] ......

View Replies View Related

JavaFX 2.0 :: Worker Threads - Created By Model Or By Controller?

Dec 8, 2014

Sometimes models needs to access blocking devices, like network cards, databases, files, and so on. This should be done by worker threads or services. But who is in charge of that? The controller or the model itself? I tend to say it is the model, as only the model knows about the fact that it accesses a blocking object. On the other hand, it is said that a model should be a POJO, so it would be the controller's job. Is there a best practice or general design rule?

View Replies View Related

JSF :: Updating View From AJAX

Sep 26, 2014

I have two images. I want to be able to click them and kick off a call to a listener in Java to change a value in the bean. I also want the view to update my dropdown (labeled "menuModel") to either be rendered or not, depending on which image I click. Alternatively, I would be fine with the dropdown simply being disabled and enabled for the same criteria.

So far, the listener kicks off fine, and the value gets updated correctly in the bean. However, the view never gets updated. I have tried this a hundred different ways, but nothing seems to work. If I hit refresh on my browser, the view updates. But I want it to do it automatically.

I am using standard JSF 2.1.

<div style="font-family: Verdana; font-size: 10pt; color: #FFFFFF">
<h2>Calibrations</h2>
<h:form id="tunerSelectionForm" style="color: #000000">
<h:commandLink>

[Code] .....

View Replies View Related

JSF :: Components Inside Tag View

Jun 8, 2014

In some examples I see jsf components inside the tag view, other times dont.

- Is it important to put all jsf components inside "the view" tag?
- What would be the difference not putting them inside this tag?

View Replies View Related

JSF :: Possible To Map URL With Independent View Dir Structure?

Feb 16, 2015

Is it possible to map URL's with independent view dir structure? If so how?

My goal is to simply point an url to a specific view file:

i.e.

[URL] ....

to
not/default/path/views/main/index.xhtml
and
www.myserver.com/application/admin/
to
not/default/path/views/admin/index.xhtml

A couple solutions I found so far where:

Solution 1

PrettyFaces

I just didn't wanted to use a third party solution. This is my best solution so far.

Solution 2(a JSF solution):

navigation rule entries in the faces-config.xml file.

A bean is required, not a bad thing in above example but not great in combination with static navigation like:<h:commandButton action="index"/>

Solution 3 (another JSF solution)

Resource Library Contracts
This forces me to work in the contracts file.

None of the solutions gave me a clear solution except prettyfaces.

Are there some elegant native JSF solutions ? Something flexible and reusable? Something like a mvc controller i used to use in php applications. In this controller I was able to add a template file in the constructor and an content file in specific function. Custom paths where no problem. I didn't want to use mvc nor the php language in this project.

View Replies View Related

Runtime Error On View Contacts

Feb 9, 2015

why get a runtime error when choosing option 2 after adding a contact?

Main:

package contactlist;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

[code]....

View Replies View Related

Button To Reset View Of JFrame

Jan 23, 2015

I have to write a program that will generate 20 random circles with random radius lengths. If any of these circles intersect with another, the circle must be blue, and if it does not intersect, the color is red. I must also place a button on the JFrame. If this button is pressed, it needs to clear out the JFrame, and generate a new set of 20 circles following the same color rules. I am extremely new to Java Swing and am really stuck. I have everything working except the button. I cannot get a new set of circles to generate.

import java.awt.Graphics;
import javax.swing.JPanel;
import java.util.Random;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

[Code] ....

View Replies View Related

JSF :: Create A Managed Bean Per View

Jun 11, 2014

About creating views,

1. When we have a view and this uses two or three managed beans and not only one, is this ok? is a good design?

2 If we have two views and both of them only share one functionality (they need to display datatable with clients) , for the second view and for the shared functionality, should I in the managed bean for the second view create the same method that gets the clients or reuse the method in the managed bean created for the first view?

View Replies View Related

Application Crashes When Moving From One View To Another

Jun 6, 2014

So I've been working on a music player in android studio and I've created two java classes. One for Main Start Screen(StartScreen.Java) and one for the main player (player.Java). I have an onClicl event associated with a button as shown below.

public void onclick(View view) {
Intent detailIntent = new Intent(this, main_player.class);
startActivity(detailIntent);
}

The code for the second Java Class is as below. There is nothing in the java class as for now.

package com.example.musicplayer.app;
import android.app.Activity;
import android.os.Bundle;
public class main_player extends Activity {
protected void onCreate(Bundle savedInstanceState) {

[Code] .....

Where is the actual mistake because the app works fine until i click the button that is suppose to take me to the main player screen?

View Replies View Related

How To View Binary Tree Using Eclipse

Aug 7, 2014

Is there a way that I can view my entire binary tree on Eclipse? I remember the old IDE that I used, jGrasp, had a feature in its debugging that would allow me to see exactly what was going on and I want to know if Eclipse has the same thing.

View Replies View Related

Break Counter - Txt View Start From 0 To 30

Apr 1, 2014

I have two txt view

I have a counter that it starts from 0

I want it keep on to 30 and then stop and next txt view start from 0 to 30...

View Replies View Related

How To View Contents Of ISO File In Java

Jul 15, 2014

Any method of viewing the contents of an .ISO in java. my searches so far have said to use the java api loopy but I cant find hardly any information on it and i have been unable to use it correctly so far. If there is no way to just view the .ISO file contents then extracting its contents and then viewing them would also be fine how to do that.

View Replies View Related

How To View Contents Of ISO File In Java

Jul 15, 2014

Any method of viewing the contents of an .ISO in java. my searches so far have said to use the java api loopy but I cant find hardly any information on it and i have been unable to use it correctly so far. If there is no way to just view the .ISO file contents then extracting its contents and then viewing them would also be fine ....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved