How To Get Object From Panel Back Across To GUI

Jul 6, 2014

I've been putting together an addressbook and try to work on some idea but I have hit a bit of a wal early on, and Im sure the problem is easy to resolve, I just can't get the old brain to do it.At present I have 5 classes

PersonDetailsAdressDetailsAddressBookAddressBookGUIEnterDetailsPanel

I have taken EnterDetailsPanel out of the main GUI code, as I plan, or had planned on using additional JPanels for the other options of the application until I got stuck. What I want the EnterDetails panel to do, which it does so far is to have the user enter all of their information and when the button is pressed it will then create a PersonDetails object and here is where my problem is. how to get the object from the panel back across to the GUI which initalises the AddressBook class in the constructor and add it to the List via an addDetails() method.

If I create a quick method in the AddressBookGUI class I can add the object to the List fine, I'm guessing this is because I have created a new instance of the AddressBook in here already via the constructor, however if I add an AddressBook reference in the EnterDetailsPanel I get a nullpointerexception for the opposite because it's not been created in there.These are what most of the classes do so far.

PersonDetails has a reference to the AddressDetails and holds all information for that person.AddressBook contains a List that accepts PersonDetails and has methods to add/remove the person.AddressBookGUI creates a new instance of the AddressBook class along with the general gui things. EnterDetailsPanel is added to JTabbedPane in the GUI class and allows the user to enter their details and submit those via a button which will then create a new PersonDetails object that I am trying to get added to the AddressBook class List

View Replies


ADVERTISEMENT

Type In A Name And It Will Search Through Each Object And Print Back Corresponding Object Info

Nov 19, 2014

I am trying to get this to where I can type in a name and it will search through each object and print back the corresponding object info.

Java Code:

import java.util.Scanner;
public class MyPeople {
public static void main(String[] args) {
Person[] p = new Person[] {
new Person("Chris", 26, "Male", "NJ", "Single"),
new Person("JoAnna", 23, "Female", "NJ", "Single"),
new Person("Dana", 24, "Female", "NJ", "Single"),
new Person("Dan", 25, "Male", "NJ", "Single"),
new Person("Mike", 31, "Male", "NJ", "Married") };

[code]....

View Replies View Related

How To Set Size For Panel With Graphics2D Object

Oct 1, 2014

I am writing a program to solve Sudoku puzzles. I create the user interface using AWT/Swing.One panel of the main window (JFrame object) contains a Graphics2D component only (a grid for the sudoku puzzle). The problem is that this panel is too small for its contents when it is created. I have tried many things to make it bigger (like the setSize method of the panel), but to no avail. Who can tell me how I can make the panel with a single Graphics2D object larger?

Below is the code for the main window, which is a JFrame object. I set its size to 400 x 400 to have ample room for all panels. I then create two panels: a sudoku panel that contains the sudoku grid and a button panel that contains two buttons. The button panel has a flow layout.

I then create the main panel. This has a vertical BoxLayout. Finally I add the sudoku panel and the button panel to the main panel and the main panel to the frame.

public class ViewController_Graphics extends JFrame {
JButton solveButton = new JButton("Solve");
JButton nakedSinglesButton = new JButton("Naked Singles");

public ViewController_Graphics(SudokuModel model) {
super("Sudoku");
setSize(400,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLookAndFeel();
// create sudoku panel

[code]....

When I run the program, the following Window shows up:the button panel is exactly in the middle (and it remains in the middle, no matter how I resize the window). And there is not enough room for the sudoku panel. How can I make enough room for the sudoku panel when the window is created?

View Replies View Related

Swing/AWT/SWT :: When Click On Button From Bottom Panel Top Panel Need To Be Redrawn

Apr 1, 2014

When i click on the button from bottom panel, top panel need to be redrawn. But redrawing is not happening. It happens only when resizing the applet.

public class Graphics_Chart(){
public init(){
JScrollPane topPane = new JScrollPane(new ImagePanel2());
topPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
topPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);

[code]...

View Replies View Related

How To Switch From One Panel To Another Panel

Apr 5, 2014

I have two(panel1 and panel2) panels in a jframe,all three of them are different classes .

In jframe there is a display panel on which the panel1 and panel2 are called and displayed.

now i have a button in panel1 .i want that when i will click on that button panel2 will be displayed or added to the dispalypanel of jframe.

View Replies View Related

How To Get Information Back From A Different Method

Nov 12, 2014

I am trying to figure out how to get information back from a different method.

Basically I want to write a program to create a car, but I want to be able to add features based on user our put (V6 versus V8, Color choice, etc), but I want each one to be broken out into their own method but I am unsure of how to call from the main method and return the variable (engineSize = V8, color = blue, etc).

View Replies View Related

JSP :: Disable Back Button When Logout

Apr 19, 2014

I have a website which requires login. After I enter username and password and click login button, a new page is loaded. In that page I have a username in the right up corner. When the user clicks logout button, Session.Clear() method is called and also Response.Redirect(" to login page "). It works OK, but the problem appears when I then click Back button in the browser. It gets me back to previous page with the username in the right up corner. Insted, I would like to show message asking user to enter password again so he can login properly.

What should i do at client side???

View Replies View Related

Swing/AWT/SWT :: Looping Back To JOptionPane

Apr 28, 2014

how to have an application restart if the user inputs an incorrect integer in a JOptionPane question? I know how to do it with the Scanner class but nothing I do seems to work. This is the beginning of my code:

import javax.swing.JOptionPane;
public class Pay {
public static void main(String[] args) {
String level = JOptionPane.showInputDialog("Please select your skill level: 1, 2, or 3");
int levelPick = Integer.parseInt(level);

[code]...

View Replies View Related

Converting A SecretKey To String And Back Again

Feb 13, 2014

I'm using the class below to encrypt and decrypt data in my program. It works rather well with the exception that I can't for the mind of me get the recreation of the key to work. When the program runs the first time, it creates a key and saves it to Data.txt. This part works fine, and there are no errors, the encryption and decryption works until I reload the program and it tries to recreate the key using the String in the .txt.

read = loadFile.readline();
byte[] data = read.getBytes("UTF-8");
key = new SecretKeySpec(data, 0, data.length, "PBEWithMD5AndDES");

I've looked at:
java - convert Byte Array to Secret Key - Stack Overflow
java - Converted secret key into bytes, how to convert it back to secrect key? - Stack Overflow

and a number of other sites which didn't work, both of these however suggested the key = new SecretKeySpec. The actual key became: "[B@79fe3f51". Whereas the recreated key became: "[B@3e1d1648".So they are close, but not the same.I create the original key like this:

key = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(keySpec);

Encryption.java:

public class Encryption { 
public Cipher dcipher, ecipher; 
// Responsible for setting, initializing this object's encrypter and
// decrypter Chipher instances
Encryption(String passPhrase) {
 
[code]....

View Replies View Related

JRE :: Date Shifting 1 Day Back On 1 Of Many Systems

Feb 24, 2014

This piece of java software I am responsible for is running throughout numerous locations in my country, there is only 1 location which has trouble with the dates being displayed incorrectly, birthdates of clients are displayed as a day earlier. It seems pretty safe to say it is a problem on their end... But still, they're asking me for an explanation as to why java would treat a date differently in this rare case.

The date (a birthdate) comes from an oracle database, it is a date without a time (trunced date). It enters the application as a member of the client-class, it is NOT being set or changed after that. It goes through several layers in the application, then ends up in a GUI class which unwraps it from the "client"-object and puts a SimpleDateFormat (new SimpleDateFormat("dd-MM-yyyy")) on it. My first and only hunch was the timezone settings, but that seems to be OK!

View Replies View Related

Converting Strings To XML And Back To String

Mar 3, 2014

I'm stuck with the following error message when i try to convert a String to XML and back to a String.
 
Exception in thread "main" org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than the one that created it.
    at com.sun.org.apache.xerces.internal.dom.ParentNode.internalInsertBefore(Unknown Source)
    at com.sun.org.apache.xerces.internal.dom.ParentNode.insertBefore(Unknown Source)
    at com.sun.org.apache.xerces.internal.dom.NodeImpl.appendChild(Unknown Source)
    at com.innovatrail.consulting.xml.XMLTEST2.main(XMLTEST2.java:66)
 
Below is  my Java code snippet: The code syntactically correct except line 66. If you comment out line 66 in the source code, everything works just fine. The XML representation of my input string is denoted by INPUT 1 and that of my output string is denoted by OUTPUT 2.
 
package com.Test.xml;
 
import java.io.ByteArrayInputStream;
import java.io.StringWriter;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;

[Code] ....
 
INPUT 1:

<Collection>
<BookList>
  <Book>
    <Title>Wonder Man
    </Title>
    <Author>John Smith
    </Author>
    <Category>Fiction

[Code] .....
 
OUTPUT 2:

<Collection>
  <Book>
    <Title>Wonder Man</Title>
    <Author>John Smith</Author>
    <Category>Fiction</Category>

[Code] ....

View Replies View Related

JSF :: Reset Values In Back Form Bean

Jun 3, 2014

When we have a jsf form to store clients in a ddbb for example and the backing bean is in session scope.... Lets think of a user that requests 3 times the xhtml view with the form to store 3 clients.

1) If we dont reset the backing bean each time the form is processed, he would see the values he sent beforea and it doesnt have much sense, right?

2) Here there is an example of clearing form after submitting : [URL] ...... Clearing the form after submititng is a common practice for the reason of the statement 1, right?

3 ) What is the best or normal approach to reset values in a form? when the user requests it or done automatically by the application after processing a form?

4) Are there known issues about resetting or not resetting the values in a form bean?

View Replies View Related

How To Stop Boolean Value Going Back To Original Value In While Loop

Oct 9, 2014

Inside a While Loop (While Loop begins if a condition is True) I have an If Statement, the else part of the statement assigns False to the condition I mentioned earlier.

But I've tried de-bugging and even when the code goes through the else part of the statement, firstly it returns False but then it returns to the beginning of the loop as True again.

View Replies View Related

Read String To List (Integer) And Back

Feb 14, 2014

I am looking for a good and reliable library to read a string to construct a list of Integers, Doubles, Booleans, etc. This library should be robust enough to handle faulty input from an inexperienced user.

Example:

input: "1, 2, 3, 4"
output List<Integer> [1, 2, 3, 4]

input: "1, 2, 3.6, 4"
output List<Double> [1.0, 2.0, 3.6, 4.0]

input: "true, true, false"
output List<Boolean> [true, true, false]

input: "[1, 2, 3]"
output List<Integer> [1, 2, 3]

input: "(1, 2, 3)"
output List<Integer> [1, 2, 3]

It would be really nice if such a library would already exist.

View Replies View Related

How To Go Back To Main Menu And Terminate A Program

Oct 15, 2014

How to go back to main menu and terminate a program?

I just want a Simple code.

View Replies View Related

Using Datagrams - X And Y Coordinates / Send Back And Forth In One String

Feb 15, 2014

Ok, so I am relatively new to datagrams etc. I have three projects set up right now: Client, Client2, and Server, which all interact with each other to send coordinates of player1 and player2 back and forth (X, Y, this is in 2D space not 3D). I have everything set up perfectly except for one problem: I can only send the X coordinate back and forth for each player. I am getting the weirdest error, a parsing error. The way I communicate is I have everything sent back and forth in one string. Then I use the .split() function to turn that string into an array that contains the x and y coordinates. I've done several tests and to no avail. Here's my code:

Server:

Java Code:

package theGame;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import javax.swing.JOptionPane;
public class Main {
static String p1X;
static String p1Y;

[Code] ....

Lines 177 on Client1 and 172 on client2 are where the debugger is saying that I parsed wrong.

Also, if your are going to test this you will need to have the LWJGL libraries in your build path.

View Replies View Related

EJB / EE :: Life Cycle Call Back Methods

Apr 17, 2014

Life Cycle Call back methods(init(), destroy(),...) are not transactional by default and expecting this in coming EJB releases (EJB 3.x / EJB 4.x). I was expecting next EJB release along with Java 8, but it stays at 3.2

View Replies View Related

Implementing Back End Code To Front In GUI - Java Swing

Jun 8, 2014

I am messing around with a Swing application and am a bit stuck as to how to join the front and back ends.This is the code for the DataManager class which is responsible for loading and saving objects and interfacing with rest of the system. The data I need displayed comes from a .txt file in the applications directory. I need to show certain aspects of the data in the JComboBoxes in the GUI class.

Java Code:

package programdataapplication;
import java.io.*;
import java.util.*;
public class DataManager {

[code]....

how I can join back-end and GUI classes.

View Replies View Related

How To Remove Item From ArrayList Then Add Back To Place Of Removal

Dec 2, 2014

How do you remove from an ArrayList at a particular index then add back to that same index without the removal causing the ArrayList to compensate for the loss of them item and moving the empty space to the end of the array list?I've tried:

public void dischargePatient(int bedNumber) {
if (bedNumber < beds.size()) {
beds.remove(bedNumber);
}
}

But this moves the bed at bedNumber to the end of the ArrayList after removing the patient from the bed. How do I keep it at bedNumber?

View Replies View Related

Return Array Data From A Method Back To Main

Mar 16, 2014

I'm trying to return an array back to main. The array returned to main should contain the reversed random numbers array. I believe I have the array correctly reversed within the 'reverseArray' method. I'm trying to send this array back to main, but it appears to contain empty data (a bunch of zeros).

Java Code:

class ArrToMain {
public static void main(String[] args) {
final int NUMBER_OF_ELEMENTS = 1000;
double[] numbers = new double [NUMBER_OF_ELEMENTS];
//Invoke initialize method
initialize(numbers);

[Code] ......

View Replies View Related

How Does Threads Come Back To Ready State After Executing The Task

Mar 21, 2014

When a thread completes its execution, it will be destroyed.In Java thread pool implemenation, how does threads come back to ready state after executing the task.?

View Replies View Related

JSF :: How To Get Back Bean Updated Property Value In Javascript Function

Oct 11, 2014

get updated bean property in javascript function. This function I am calling from <a4j: commandbutton> this button is having actionListner, which is updatin bean property based on some User selection. When this action is completed then I am calling javascript function in oncomplete. But that javascript function is not taking updated bean value, it is always taking first value.I can't use hidden text as there are some drop downs which User will selct and then hit commandbutton which will update bean property.

<div align="center">
<a4j:commandButton
value="#{msgs.notification_searchNotificationReportLbl}"
id="searchNotificationRptBtn" styleClass="controlButtonActive"
actionListener="#{dashboardCtrl.loadOTVsubmit}"
oncomplete="drawChart();"

[code]....

View Replies View Related

Java Timer - GUI Button Not Linking Back To Code

Jan 12, 2014

I have started coding recently and been working on a simple java timer. My problem is that the button does not show any response even though an action has been done via actionlistener.

Example: When I press the "Start Timing" button, it should start timing and output the counter to Static Timer but instead of doing that, it does nothing.

The important bits are under Timer code and Button Start Timing. Is their something that I'm missing?

//--- All imports have been handled ---
public class GUI {
double counter = 1;
double inputA = 1;
int delay = 1000;
Timer timer = new Timer(delay, null);
 
[Code] ....

View Replies View Related

JSP :: How To Get Rid Of Webpage Expired Error When Clicking Browser Back Button

Jul 1, 2014

I am getting Web Page Expired error while clicking the back button of the browser, after submitting a form. The form method is POST. ( I have to keep it that way). I tried this code

<%session.setHeader("Cache-Control", "no-cache");
response.setHeader("Cache-Control", "no-store");
response.setDateHeader("Expires", 0);
response.setHeader("Pragma", "no-cache");
%>

In my jsp. Still it is not working. I also tried

<script language="JavaScript" type="text/javascript">
window.history.forward(1);
</script>

View Replies View Related

Servlets :: HTML To Servlet And Come Back To Same Page With Field Values

Apr 11, 2014

i have one html page ,inside html radio button and 3 textboxes and one submit button ->action->SampleServlet.java-> from here again come back to html page with checked radio buttton value and text box value. I dont want to click back button in this case, html page to servlet->here i have to call back to my html page with checked radio button and text box value .

I tried response.redirect(original.html)-->i cant able to display checked radio button and textbox value also tried requestdispatcher forward/include,html page comes newly from starting but i dont want it,i want to view in html page with checked radio button and text box value.

View Replies View Related

JSP :: Generate Hashtable And Display Its Key Value Pairs Back To Browser - How To Prevent Timeout

Jun 24, 2004

I have a jsp page that generate a hashtable and display its key-value pairs back to the browser. The problem is that it takes on an average about 15 minutes to build this hashtable, and as a result, I always get a timeout error. What can I do to avoid getting the timeout error without changing the server configuration for timeout

View Replies View Related







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