Swing/AWT/SWT :: Can't Change Visibility Of Two JPanels When Calling Method From Button Event In Another Class

Dec 30, 2014

I have two classes involved in this portion. CheckIn_Search

(class #1) is my main UI and I am collecting search information from the user in a jPanel form. When they click "Search" it passes the search criteria to a method that contacts a web service and gets the results. These results are passed to coSearchResults

(class #2) that opens a jFrame and jTable (in modal format, over the main window created by CheckIn_Search.

The user selects a row in the table and that selection data is passed back to coSearchResults to populate a new jPanel form. When the data is passed from coSearchResults, I want to close its window, hide the first jPanel in CheckIn_Search and make the second jPanel visible. To accomplish this, I created a method in CheckIn_Search that simply hides/shows the panels (it will do more later).

I instantiate and call the method in CoSearchResults as part of the button click event. The problem is, it doesn't work. The panels are unaffected and there are no errors. I've put in break-points and it goes into the method.. Here is the coSearch_Results code.

Here is am retrieving the jtable row id and using the first value in the row to get the data from the table model as there is more data than what is displayed in the table. I'm sending that whole row of data to the method that changes visibility.

private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
// TODO add your handling code here:
int rowNum = jTable1.getSelectedRow();
String coNum = jTable1.getValueAt(rowNum,0).toString();
String[] text;

[code]....

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: Event To Detect Jframe Change

Aug 13, 2014

I would like to detect when the user change de JFrame. I make:

public class UI implements ActionListener, ComponentListener, DocumentListener, MouseListener{

private JFrame ventana;
private JTable table;
private JPanel panel;
private JScrollPane tableScrollPane;

[Code] ....

I put componentResized but when I change JFrame I cant see the string that I put in the method.

View Replies View Related

Swing/AWT/SWT :: Right Button Event Mouse In Jtable

Feb 18, 2014

I'm trying to can make right button event to show a popup of copy/paste in a jtable but I put these code and doesn't works:

public class UI implements ActionListener, DocumentListener, MouseListener{
private JFrame ventana;
private JTable table;
private JPanel panel;
private JScrollPane tableScrollPane;

[Code] .....

View Replies View Related

Calling Private Method To Another Method Located In Same Class

Oct 23, 2014

I am trying to call a private method to another method that are located in the same class.

I am trying to call prepareString to the encode method below.

Java Code:

public class ShiftEncoderDecoder
private String prepareString(String plainText)
{
String preparedString = "";
for(int i = 0 ; i < plainText.length();i++)
if(Character.isAlphabetic(plainText.charAt(i)))

[Code] .....

View Replies View Related

Swing/AWT/SWT :: How To Change Button Text And Actions In Input Dialog Box

Oct 20, 2014

I'd like to change the text on the two buttons which I have in my Dialog Box, how should I do this?

Also, when I click the X Button in the top right of the Dialog Box, nothing happens, and the program only stops when I end it in jGrasp. How do I make this button close the program when clicked on?

import javax.swing.*;
import java.util.Random;
public class SwingInputExample {
public static void main(String args[]) {

[Code] .....

View Replies View Related

Calling Method Of Another Class Which Is Implemented By Runnable Class

Aug 11, 2014

i am having a problem while calling a method..i am having a class

Java Code:

public class MySer implements Runnable {
public void getMessage(String msg)
{
...,
}..,
} mh_sh_highlight_all('java');
i use the above class in another class

[code]....

View Replies View Related

Creating Object Of Class And Calling Its Method In Different Class

May 20, 2015

In the process of creating a new class, I need to move my main method from the class SaveDate to the class DynamicTest. Below I have listed the code of both classes.The objective is to be able to run my program from the DynamicTest Class. I need understanding the process of moving my main method to a different class and creating an Object of a class and calling its method.
 
public class SaveData { 
  private static final Map<String, Object> myCachedTreeMap = new TreeMap<String, Object>();
   public static final List<String> getLines(final String resourceParam, final Charset charset) throws IOException{
  System.out.println("Please get: "+resourceParam);
  if (myCachedTreeMap.containsKey(resourceParam) ) {
  // Use the cached file, to prevent an additional read.

[Code] ......

View Replies View Related

Calling Method From Within A Class

Sep 15, 2014

I am calling a method from within a class like so:

xmlWriter.updateFile(environment, doc);

The class is xmlWriter & the method is updateFile

updateFile passes Environment environment (another class) and Document doc (document builder)

but I am unsure about it passing these through the parameters in the method call..is it correct?

Also underneath that method call for the update could I then do another method call for the export method of the file?

View Replies View Related

Calling A Method From Another Class

Mar 24, 2014

I am having problem to call a method from another class using arrays. I already know how to call a method without using arrays but I am not sure how to pass parameters to the main method using arrays. I'd really appreciate any feedback or comments!This is what I have so far.

public class Customer123 {
public static void main(String [] args){
Scanner input = new Scanner(System.in);
int x;
System.out.print("Total number of customers: ");
x = input.nextInt();

[code]....

View Replies View Related

Calling A Method From One Class To Another

Mar 6, 2015

calling a method from one class to another.I have two classes. One called Vacation and another called VacationDriver.I am trying to input an int for addVac and have the value update to the numSold within the updateSales() method in Vacation. From there it should update and display in the v1.toString in the VacationDriver.

Vacation
import java.text.NumberFormat;
public class Vacation {
private String vacationName;
private int numSold;
private double priceEach;

[code]...

View Replies View Related

Calling Method Of A Class From Main Class?

Aug 31, 2014

// Add range to Vehicle.
class Vehicle {
int passengers; // number of passengers
int fuelcap; // fuel capacity in gallons
int mpg; // fuel consumption in miles per gallon

// Display the range.
void range() {
System.out.println("Range is " + fuelcap * mpg);

[Code] ....

I'm compiling it in Eclipse and this continues to show in the console display

Minivan can carry 7. Exception in thread "main" java.lang.NoSuchMethodError: Vehicle.range()V
at AddMeth.main(AddMeth.java:34)

View Replies View Related

Calling A Method On Object From Another Class?

Oct 27, 2014

I have a class for employees. This class has basic information for the employee but no real pay information. And 2 subclasses, one for employee's paid for hourly rates and one for those paid a yearly salary. Each subclass has their own pay() method, that calculates and returns their pay and extra fields relative to calculate that.

I'm just curious, if I do this and create an object for an hourly paid employee like so:

Object hourly1 = new HourlyEmployeeWilson("John Doe", "123 Tech Street",361961,"Human Resources", 0,12.50,50);

How can I utilize that classes public method of pay() to gather this instance (or hourly paid employee)'s pay? I've tried doing so via:

System.out.println(hourly1.pay());

But I get

DriverPayWilson.java:9: error: cannot find symbol
System.out.println(hourly1.pay());
^
symbol: method pay()
location: variable hourly1 of type Object
1 error

View Replies View Related

Calling Encode Method To Driver Class

Oct 30, 2014

I have a driver and a main program. How would I go along with calling the encode method to the driver class that I made so I can have the user inputs affected by the encode method?

Java Code:

public class ShiftEncoderDecoder
{
private int shift;
public ShiftEncoderDecoder(int shift)
{
setShift(shift);
}
public int getShift()

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Calling Method Does Not Work From JMenuBar

Nov 6, 2014

I have a paint program in Java where I can draw objects. The objects are stored in an arrayList. In the menubar the user can chooce "Back", which means the last item in the arrayList is removed. After that I want the program to loop through the arrayList and draw the remaining items.

My problem is that when I try to do that it will not work from the menu (menuItem2). If I instead add the code to one of the colorpanels (yellowPanel), from where the user can pick colors, it works fine.

menuItem2 uses ActionListener and yellowPanel uses MouseListener.
public class PaintProgram extends JFrame implements ActionListener {

public ArrayList<Draw> shapeList = new ArrayList<>();
int startX, startY, endX, endY, w, h;
private JPanel topPanel;
private JPanel bottomPanel;
private JPanel magentaPanel;
private JPanel greenPanel;
private JPanel bluePanel;
private JPanel blackPanel;

[code]....

View Replies View Related

Binary Search Tree - Calling FindSmallest Method In Main Class

Nov 3, 2014

How should I call my findSmallest method in the main class.. Here is the code:

public class Tester {
public static void main(String[] args){
try {
BinaryTree<Integer> myTree2 = new BinaryTree<Integer>();
 
myTree2.insert(5);
myTree2.insert(2);
myTree2.insert(7);

[Code] ....

So the question is what kind of parameter I should pass in myTree2.findSmallest()??? Here is my findSmallest method..

public E findSmallest(Node<E> parent){
if(parent.left.left == null){
E returnValue = parent.left.data;
parent.left = parent.left.right;
return returnValue;
} else {
return findSmallest(parent.left);
}
}

View Replies View Related

Swing/AWT/SWT :: Creating Several JPanels - Main Menu

Aug 17, 2014

I am tasked with creating several JPanels each of which has a title centered at the top. As such I have created parent panel that each panel extends. However, I am uncertain as to whether drawing the string on the panel or using a JLabel is the best solution. The panels might allow dynamic resizing...

View Replies View Related

Swing/AWT/SWT :: Construct A Vertical List Of JPanels

Feb 11, 2014

I am working on writing a desktop based email client using swing. First some specifics: I need to show emails in a (dynamically updatable) vertical list. Each item in this vertical list would represent an email showing: (a) the subject, (b) a photo of the sender that I have locally available & a couple of buttons. So, I plan to create a JPanel containing a JLabel to show the Subject, The photo inside a JLabel & JButtons. I have the layout of this panel done and is not a problem.

My problem is with stacking all these JPanels (each representing an email) and showing them on the UI as a list. I am not sure of any way to do this. Moreover, when a new email is received, it has to be displayed at the top of the list (not at the bottom).

Specifically, I need a good way of displaying a vertical list of JPanels & be able to add new JPanels at the top of the list.

View Replies View Related

Swing/AWT/SWT :: Endless Loop While Calling Dialog Box Via Separate JFrame Class In NetBeans IDE

May 2, 2014

I've used Netbeans IDE to create a simple Swing JFrame container, class NewJFrame.

NewJFrame calls another JFrame with dialog in it. Problem is there is an endless call made to it. Here's the issue relevant piece of code:

//Code for calling class
package p;
public class NewJFrame extends javax.swing.JFrame implements ActionListener {
.........
public NewJFrame() {
initComponents(); //IDE auto generated code for binding

[Code] ....

I searched but i cannot understand why run class is getting called multiple times. I have attached the screen prints for both the screens. 2nd screen print(of called class) is very shallow since screen was blinking unstopped due to multiple calls, but i have attached a faint image of it.

View Replies View Related

JavaFX 2.0 :: Only One Change Event On ObservableList?

Apr 9, 2015

I have a list of Row objects and want to listen to changes in the name property of a Row object.
 
public class Row implements Serializable {
    private final SimpleStringProperty name = new SimpleStringProperty(this, "name", "");
    public Row() {
        this("");
    }
    public Row(String name) {
        this.name.set(name);

[Code] ....
 
I would expect to be notified 4 times. Line 23: Added, Line25, 26, 27: Update

But there are only 2 change events. For Line 26 and 27 there is no change event.

View Replies View Related

Swing/AWT/SWT :: Method To Draw Triangle When Click On Specific Button

Mar 8, 2015

I'm trying to do a method which will draw a triangle and then the method will be called when we click on a specific button. How I must proceed.

View Replies View Related

Action Event - How To Implement Button And Text Field

May 9, 2015

I want to use this class and method with all of my buttons and text fields. My program contains 1 push button that adds questions and answers to a test, 2nd button that starts a test, a 3rd button that scores the test, and a text field that enters the user information. How would this work? I know how to create questions and answers, start a test, and score a test it's just a matter of how to implement the button and text fields. I'll post the code that I have done so far.

See:

private class ButtonListener implements ActionListener{
public void actionPerformed (ActionEvent event)

with all of my buttons and text fields.

import javax.swing.JFrame;
public class TestingDriver
{
//-----------------------------------------------------------------
// Creates and displays the main program frame.
//-----------------------------------------------------------------
public static void main (String[] args) {
JFrame frame = new JFrame ("Testing Program");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

[Code] ....

View Replies View Related

How To Make A Button That Change The Label

Jan 29, 2014

How can i code this differently so that when i click one of the button it changes the image to the red.jpg or green.jpg?

Java Code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class GUI{
public static void main(String[] args){
JFrame window = new JFrame("Test");

[Code]...

View Replies View Related

Change Text In JLabel When Button Pressed

Dec 4, 2014

Ok, so I am trying to learn about JFrames and JPanels. I have figured out buttons, layouts, etc. What im having trouble with is accessing the label object from the ButtonHandler class since it is static and I need my JLabel to be non-static so that it can change. Basically, I want JLabel to change to a pre-determined text string once a button is pressed. Here's what I have so far

package makewindow;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

[code]....

View Replies View Related

Servlets :: Calling DoGet Of Child Class From Service Of Parent Class

May 28, 2014

Regarding the lifecycle of servlet , in headfirst servlet i can find :

You normally will NOT override the service() method, so the one from HttpServlet will run. The service() method figures out which HTTP method (GET, POST, etc.) is in the request, and invokes the matching doGet() or doPost() method. The doGet() and doPost() inside HttpServlet don’t do anything, so you have to override one or both. This thread dies (or is put back in a Container-managed pool) when service() completes.

How can I call the doGet method of the subclass from the superclass. i am not getting this .

View Replies View Related

Not Able To Call Java Method From Event

Mar 4, 2014

I used java and jsf. I created dynamic datatable in java file. Can i call java method from setOnchange() event?

I am able to call java script function from setOnchange() event. See the below code which is working fine for java script.

HtmlSelectOneMenu selectOneMenu = new HtmlSelectOneMenu();
selectOneMenu.setStyleClass("dropdownStyleTwo");
selectOneMenu.setOnchange("openWin(this);IGNORE_UN LOAD=false");

I wrote openwin() function in java script. But i am not able to call java method change().

Code which is not working.

HtmlSelectOneMenu selectOneMenu = new HtmlSelectOneMenu();
selectOneMenu.setStyleClass("dropdownStyleTwo");
selectOneMenu.setOnchange("myclass.change();IGNORE _UNLOAD=false");

myclass is the bean of class Test. If user select any value from dropdown i want to call change java method. This function will apply the same selected dropdown value to the other record also.

View Replies View Related

Event Driven Programming / No Main Method

Jan 29, 2015

I'm reading a book titled 'Intro to Java Programming'. I understand all the Main Method stuff. I'm now reading a chapter that talks about event driven programming. I know how to do this in VBA and in C#, ut I can't figure out how this works in Java. Here's the sample code that I'm trying to run.

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;

[code]....

I'm using Net Beans IDE. When I paste that code into the IDE, I get all kinds of errors. Also, since there is no Main, I don't know how this is supposed to run. Java needs a Main Method for everything, I think. Does the Main call some kind of class?

View Replies View Related







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