How do i use objects from one class in anohter?
Hey
I have two GUI classes ShowWhiteGUI and BasketGUI and then a control class ShowWhite. The control class calls all the method from anohter class's which the GUI classes are gonna use.
The basis idea with this script is it shall be a very very simpel Shop. Where you can add items to a basket and then show the items in a new window(BasketGUI).
So here is the problem. I cant create an object in both GUI classes, because then im working with two sets of data, right? So how do i do this?
Here is my code:
ShowWhiteGUI
* ShowWhiteGUI.java
* Created on 5. februar 2008, 10:43
package userclasses;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
* @author Lille mus
public class ShowWhiteGUI extends javax.swing.JFrame {
private BasketGUI basketGUI;
private ShowWhite control;
/** Creates new form ShowWhiteGUI */
public ShowWhiteGUI() {
basketGUI = new BasketGUI();
control = new ShowWhite();
initComponents();
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
aboutDialog = new javax.swing.JDialog();
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
itemIdField = new javax.swing.JTextField();
productIdLabel = new javax.swing.JLabel();
numberOfItems = new javax.swing.JLabel();
productId = new javax.swing.JTextField();
basketButton = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
showBasketButton = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
menu = new javax.swing.JMenu();
jMenu1 = new javax.swing.JMenu();
open = new javax.swing.JMenuItem();
quit = new javax.swing.JMenuItem();
jMenuItem1 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
help = new javax.swing.JMenuItem();
about = new javax.swing.JMenuItem();
javax.swing.GroupLayout aboutDialogLayout = new javax.swing.GroupLayout(aboutDialog.getContentPane());
aboutDialog.getContentPane().setLayout(aboutDialogLayout);
aboutDialogLayout.setHorizontalGroup(
aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
aboutDialogLayout.setVerticalGroup(
aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Show White's Shop");
setBackground(new java.awt.Color(0, 102, 255));
jLabel1.setFont(new java.awt.Font("Baby Kruffy", 0, 36));
jLabel1.setText("Snow White?s Shop");
jTextArea1.setColumns(20);
jTextArea1.setEditable(false);
jTextArea1.setRows(5);
jTextArea1.setText(control.getPrintAllStockItems());
jScrollPane1.setViewportView(jTextArea1);
productIdLabel.setText("Varenummer:");
numberOfItems.setText("Antal:");
basketButton.setText("L?g i kurv");
basketButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
putInBasket(evt);
showBasketButton.setText("Vis indk?bskurv");
showBasketButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
showBasket(evt);
menu.setLabel("Fil");
jMenu1.setText("Menu");
menu.add(jMenu1);
open.setLabel("?bn");
open.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
open(evt);
menu.add(open);
quit.setLabel("Luk");
quit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
quit(evt);
menu.add(quit);
jMenuItem1.setLabel("Gem");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
save(evt);
menu.add(jMenuItem1);
jMenuBar1.add(menu);
jMenu2.setLabel("Hj?lp");
help.setLabel("Hj?lp");
help.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
help(evt);
jMenu2.add(help);
about.setLabel("Om Show White Shop");
jMenu2.add(about);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(productIdLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(numberOfItems))
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(productId, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 65, Short.MAX_VALUE)
.addComponent(basketButton))
.addGroup(layout.createSequentialGroup()
.addGap(31, 31, 31)
.addComponent(jLabel2)))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(showBasketButton)))))
.addContainerGap())
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(productIdLabel)
.addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(numberOfItems)
.addComponent(productId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(showBasketButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 202, Short.MAX_VALUE)
.addComponent(basketButton)))
.addContainerGap())
pack();
}// </editor-fold>
public void createBasketWindow(){
basketGUI.setVisible(true);
private void showBasket(java.awt.event.ActionEvent evt) {
createBasketWindow();
private void putInBasket(java.awt.event.ActionEvent evt) {
Integer itemId = Integer.parseInt(itemIdField.getText());
String petToAdd = control.getFindItem(itemId);
System.out.println(petToAdd);
control.setAddItemToBasket(itemId);
basketGUI.addPetToBasket(petToAdd);
private void help(java.awt.event.ActionEvent evt) {
private void save(java.awt.event.ActionEvent evt) {
System.out.println("Gemmer fil");
private void open(java.awt.event.ActionEvent evt) {
System.out.println("?bn fil");
private void quit(java.awt.event.ActionEvent evt) {
System.exit(0);
public ShowWhite getControl(){
return control;
* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ShowWhiteGUI().setVisible(true);
// Variables declaration - do not modify
private javax.swing.JMenuItem about;
private javax.swing.JDialog aboutDialog;
private javax.swing.JButton basketButton;
private javax.swing.JMenuItem help;
private javax.swing.JTextField itemIdField;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JMenu menu;
private javax.swing.JLabel numberOfItems;
private javax.swing.JMenuItem open;
private javax.swing.JTextField productId;
private javax.swing.JLabel productIdLabel;
private javax.swing.JMenuItem quit;
private javax.swing.JButton showBasketButton;
// End of variables declaration
}BasketGUI:
* Basket.java
* Created on 5. februar 2008, 15:29
package userclasses;
import javax.swing.JTextArea;
* @author Lille mus
public class BasketGUI extends javax.swing.JFrame {
private String newline = "\n";
private InvoiceGUI invoiceGUI;
/** Creates new form Basket */
public BasketGUI() {
initComponents();
//invoiceGUI = new InvoiceGUI();
public void addPetToBasket(String pet){
jTextArea1.append(pet+newline);
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jButton1 = new javax.swing.JButton();
itemIdField = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
removeItemButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Indk?bskurv");
jLabel1.setText("Indk?bskurv");
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
jButton1.setText("K?b og print kvittering");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
printInvoice(evt);
jLabel2.setText("Slet varenr");
removeItemButton.setText("Slet");
removeItemButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
removeItemFromBasket(evt);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 141, Short.MAX_VALUE)
.addComponent(jButton1))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(removeItemButton)))))
.addContainerGap())
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton1)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 125, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(removeItemButton))
.addContainerGap())
pack();
}// </editor-fold>
private void removeItemFromBasket(java.awt.event.ActionEvent evt) {
Integer itemId = Integer.parseInt(itemIdField.getText());
private void printInvoice(java.awt.event.ActionEvent evt) {
//invoiceGUI.setVisible(true);
public JTextArea getTextArea(){
return jTextArea1;
* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new BasketGUI().setVisible(true);
// Variables declaration - do not modify
private javax.swing.JTextField itemIdField;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JButton removeItemButton;
// End of variables declaration
}ShowWhite:
* ShowWhite.java
* Created on 13. februar 2008, 18:15
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package userclasses;
* @author Lille mus
public class ShowWhite {
public Basket basket;
public Stock stock;
/** Creates a new instance of ShowWhite */
public ShowWhite() {
stock = new Stock();
basket = new Basket();
public String getFindItem(int itemId){
String returnItem = stock.findItem(itemId);
return returnItem;
public void setAddItemToBasket(int itemId){
basket.addItemToBasket(itemId);
public String getPrintAllStockItems(){
return stock.printAllStockItems();
public String getShowBasket(){
return basket.showBasket();
public void setRemoveItemFromBasket(int itemId){
basket.removeItemFromBasket(itemId);
}
okay i tried this, but it give me a nullpointerexeption:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at userclasses.ShowWhiteGUI.initComponents(ShowWhiteGUI.java:75)
at userclasses.ShowWhiteGUI.<init>(ShowWhiteGUI.java:21)
at userclasses.ShowWhite.<init>(ShowWhite.java:26)
at userclasses.Main.<init>(Main.java:16)
at userclasses.Main$1.run(Main.java:31)
ShowWhite
public class ShowWhite {
public Basket basket;
public Stock stock;
private ShowWhiteGUI mainGUI;
private BasketGUI basketGUI;
/** Creates a new instance of ShowWhite */
public ShowWhite() {
stock = new Stock();
basket = new Basket();
mainGUI = new ShowWhiteGUI(this);
basketGUI = new BasketGUI();
public String getFindItem(int itemId){
String returnItem = stock.findItem(itemId);
return returnItem;
public void setAddItemToBasket(int itemId){
basket.addItemToBasket(itemId);
public String getPrintAllStockItems(){
return stock.printAllStockItems();
public String getShowBasket(){
return basket.showBasket();
public void setRemoveItemFromBasket(int itemId){
basket.removeItemFromBasket(itemId);
public void createMainGUI(){
mainGUI.setVisible(true);
public BasketGUI getBasketGUI(){
return basketGUI;
public void setAddPetToBasket(String pet){
basketGUI.addPetToBasket(pet);
}ShowWhiteGUI:
public class ShowWhiteGUI extends javax.swing.JFrame {
private ShowWhite control;
/** Creates new form ShowWhiteGUI */
public ShowWhiteGUI(ShowWhite control) {
initComponents();
this.control = control;
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
aboutDialog = new javax.swing.JDialog();
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
itemIdField = new javax.swing.JTextField();
productIdLabel = new javax.swing.JLabel();
numberOfItems = new javax.swing.JLabel();
productId = new javax.swing.JTextField();
basketButton = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
showBasketButton = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
menu = new javax.swing.JMenu();
jMenu1 = new javax.swing.JMenu();
open = new javax.swing.JMenuItem();
quit = new javax.swing.JMenuItem();
jMenuItem1 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
help = new javax.swing.JMenuItem();
about = new javax.swing.JMenuItem();
javax.swing.GroupLayout aboutDialogLayout = new javax.swing.GroupLayout(aboutDialog.getContentPane());
aboutDialog.getContentPane().setLayout(aboutDialogLayout);
aboutDialogLayout.setHorizontalGroup(
aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
aboutDialogLayout.setVerticalGroup(
aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Show White's Shop");
setBackground(new java.awt.Color(0, 102, 255));
jLabel1.setFont(new java.awt.Font("Baby Kruffy", 0, 36));
jLabel1.setText("Snow White?s Shop");
jTextArea1.setColumns(20);
jTextArea1.setEditable(false);
jTextArea1.setRows(5);
jTextArea1.setText(control.getPrintAllStockItems());
jScrollPane1.setViewportView(jTextArea1);
productIdLabel.setText("Varenummer:");
numberOfItems.setText("Antal:");
basketButton.setText("L?g i kurv");
basketButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
putInBasket(evt);
showBasketButton.setText("Vis indk?bskurv");
showBasketButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
showBasket(evt);
menu.setLabel("Fil");
jMenu1.setText("Menu");
menu.add(jMenu1);
open.setLabel("?bn");
open.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
open(evt);
menu.add(open);
quit.setLabel("Luk");
quit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
quit(evt);
menu.add(quit);
jMenuItem1.setLabel("Gem");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
save(evt);
menu.add(jMenuItem1);
jMenuBar1.add(menu);
jMenu2.setLabel("Hj?lp");
help.setLabel("Hj?lp");
help.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
help(evt);
jMenu2.add(help);
about.setLabel("Om Show White Shop");
jMenu2.add(about);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jLabel1))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(productIdLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(numberOfItems))
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(productId, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 65, Short.MAX_VALUE)
.addComponent(basketButton))
.addGroup(layout.createSequentialGroup()
.addGap(31, 31, 31)
.addComponent(jLabel2)))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(showBasketButton)))))
.addContainerGap())
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(productIdLabel)
.addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(numberOfItems)
.addComponent(productId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(showBasketButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 202, Short.MAX_VALUE)
.addComponent(basketButton)))
.addContainerGap())
pack();
}// </editor-fold>
public void createBasketWindow(){
control.getBasketGUI().setVisible(true);
private void showBasket(java.awt.event.ActionEvent evt) {
createBasketWindow();
private void putInBasket(java.awt.event.ActionEvent evt) {
Integer itemId = Integer.parseInt(itemIdField.getText());
String petToAdd = control.getFindItem(itemId);
System.out.println(petToAdd);
control.setAddItemToBasket(itemId);
control.setAddPetToBasket(petToAdd);
private void help(java.awt.event.ActionEvent evt) {
private void save(java.awt.event.ActionEvent evt) {
System.out.println("Gemmer fil");
private void open(java.awt.event.ActionEvent evt) {
System.out.println("?bn fil");
private void quit(java.awt.event.ActionEvent evt) {
System.exit(0);
public ShowWhite getControl(){
return control;
// Variables declaration - do not modify
private javax.swing.JMenuItem about;
private javax.swing.JDialog aboutDialog;
private javax.swing.JButton basketButton;
private javax.swing.JMenuItem help;
private javax.swing.JTextField itemIdField;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JMenu menu;
private javax.swing.JLabel numberOfItems;
private javax.swing.JMenuItem open;
private javax.swing.JTextField productId;
private javax.swing.JLabel productIdLabel;
private javax.swing.JMenuItem quit;
private javax.swing.JButton showBasketButton;
// End of variables declaration
}
Similar Messages
-
Hi,how can i transport objects from one server to other like (Dev To Qty)
Hi Sir/madam,
Can u explain how can i transport objects from one server to other like (Development To Quality To Production).
Regards,
Vishali.Hi Vishali,
Step 1: Collect all Transports(with Packages) in Transports Tab(RSA1)- CTO
Step 2: Release the subrequests first and then the main request by pressing Truck button
Step 3: STMS or Customized transactions
Object Collection In Transports:
The respective Transports should have the following objects:
1. Base Objects -
a. Info Area
b. Info object catalogs
c. Info Objects
2. Info Providers u2013
a. Info Cubes
b. Multi Providers
c. Info Sets
d. Data Store Objects
e. Info Cube Aggregates
3. Transfer Rules u2013
a. Application Components
b. Communication Structure
c. Data Source replica
d. Info Packages
e. Transfer Rules
f. Transformations
g. Info Source Transaction data
h. Transfer Structure
i. Data sources (Active version)
j. Routines & BW Formulas used in the Transfer routines
k. Extract Structures
l. (Note) If the transfer structures and related objects are being transferred without preceding
Base Objects transport (e.g. while fixing an error) it is safer to transport the related Info
Objects as well.
4. Update Rules u2013
a. Update rules
b. Routines and formulas used in Update rules
c. DTPs
5. Process Chains u2013
a. Process Chains
b. Process Chain Starter
c. Process Variants
d. Event u2013 Administration Chains
6. Report Objects u2013
a. Reports
b. Report Objects
c. Web Templates
Regards,
Suman -
How to move database objects from one user to another user
Could someone help how to move database objects from one user to another user
Thanks in advanceThanks a lot for the reply.
Actually I wanted to know whether there is any command to change the owner ship of the table.
For ex table1 belongs to user1. can the owner of table1 to be changed to owner2.
directly using an oracle command. I knew that it can be done using import and export, since the table was 200 million thought the rename command would be faster instead of import and export.
Thanks Billy for letting me know that it is not possible using oracle query. -
How to transport CU02 objects from one system to another?
Hi,
How to transport CU02 objects from one system (Development) to another (Quality)?You need to set up the object dependency IDOC in the partner profile.Message type is KNOMAS. The transaction to send is CLD2.
-
How to send an object from one application to another?
Hi all,
I have two applications over the same server. The first application needs to send an object to the other application.
I try to put the object as a session attribute, but in the moment that the second application tries to get the attribute, the attribute doesn't exist.
Does anybody now how can pass an object from the one application to the other?You can also use JMS
-
How to carry an object from one JSP to another JSP?
How can I carry an object from one JSP to another JSP?
I have a servlet where I am setting an object in request as an attribute and then forwarding to PageA.jsp.
MyDTO myDTO = new MyDTO();
request.setAttribute("MyDTO", myDTO);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/PageA.jsp");
rd.forward(request, response);
I can get MyDTO object in PageA.jsp:
MyDTO myDTO = (MyDTO) request.getAttribute("MyDTO");
Now PageA.jsp has a form named form_pageA which submits to PageB.jsp. How can I make sure that myDTO object is available in PageB.jsp? I would like to not store it in session.
Edited by: srhcan on May 4, 2012 7:52 PMsrhcan wrote:
but its not a text I want to store; instead its a JavaBean object. Thats why I cannot use a hidden text type input field.No, but perhaps you could stick something in there which you can use to reconstruct your DTO object on the next request? -
How to pass a variable from one class to another class?
Hi,
Is it possible to pass a variable from one class to another? For e.g., I need the value of int a for calculation purpose in method doB() but I get an error <identifier> expected. What does the error mean? I know, it's a very, very simple question but once I learn this, I promise to remember it forever. Thank you.
class A {
int a;
int doA() {
a = a + 1;
return a;
class B {
int b;
A r = new A();
r.a; // error: <identifier> expected. What does that mean ?
int doB() {
int c = b/a; // error: operator / cannot be applied to a
}Thank you!elaine_g wrote:
I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
class B {
int b;
A r = new A();
r.a; //syntax error
}Why? Class definition restricts what you can define within a class to a few things:
class X {
Y y = new Y(); //defining a field -- okay
public X() { //defining a constructor -- okay
void f() { //defining a method -- okay
}... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
This is also illegal syntax:
int doB() {
A r = new A();
r.a; // error: not a statement
}Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that. -
How to pass the object of one class to the another class?
Hello All,
My problem is i am sending the object of serializable class from one class to another class but when i collection this class into another it is transfering null to that side even i filled that object into the class before transfer and the point is class is serializable
code is below like
one class contain the code where i collecting the object by calling this function of another class:-
class
lastindex and initIndex is starting and ending range
SentenceStatusImpl tempSS[] = new SentenceStatusImpl[lastIndex-initIndex ];
tempSS[i++] = engineLocal.CallParser(SS[initIndex],g_strUserName,g_strlanguage,g_strDomain);
another class containg code where we transfering the object:-
class
public SentenceStatusImpl CallParser(SentenceStatusImpl senStatus, String strUserName, String strLanguage, String strDomain)
*//here some code in try block*
finally
System.+out+.println("inside finally...........block......"+strfinaloutput.length);
senStatus.setOutputSen(strfinaloutput);//strfinaloutput is stringbuffer array containg sentence
fillSynonymMap(senStatus);
senStatus.setTranslateStatus(*true*);
return senStatus;
Class of which object is serialized name sentenceStatusimpl class:-
public class SentenceStatusImpl implements Serializable
///Added by pavan on 10/06/2008
int strSourceSenNo;
String strSourceSen = new String();
String strTargetSen = new String();
StringBuffer[] stroutputSen = null;
HashMap senHashMap = new HashMap();
HashMap dfaMarkedMap = new HashMap();
boolean bTargetStatus = false;
public SentenceStatusImpl(){
public void setOutputSen(StringBuffer[] outputSen){
stroutputSen = outputSen;
public StringBuffer[] getOutputSen(){
return stroutputSen;
public void setTranslateStatus(*boolean* TargetStatus){
bTargetStatus = TargetStatus;
}//classok,
in class one
we are calling one function (name callParser(object of sentenceStatusImpl class,.....argument.) it return object of sentenceStatusImple class containg some extra information ) and we collecting that object into same type of object.
and that sentenceStatusImple classs implements by Serializable
so it some cases it is returning null
if you think it is not proper serialization is please replay me and suggest proper serialization so that my work is to be done properly (without NULL)
hope you understand my problem -
How can I using tpcall from one service to another service in the same server
When I using tpforward between two services in one server, it's working ok. However,
when I using tpcall from one service to another service, it's failed?
anybody can tell me why?
thanks
george"george" <[email protected]> wrote:
>
When I using tpforward between two services in one server, it's working
ok. However,
when I using tpcall from one service to another service, it's failed?
anybody can tell me why?Basically, tpcall:ing another service in the same server is a no-no, unless you
a) are running a multi-threaded server (requires TUXEDO 7 or newer + compilation
options) or
b) use tpacall() instead of tpcall() and specify the flag TPNOREPLY. This is probably
not what you want to accomplish, though.
The reason is that TUXEDO servers by default (and always in versions before 7)
are single-threaded. If service A and B both reside in server X, server X will
be busy taking care of the call to A. If A makes a call to B, the call will be
put on the queue to X, but X will not look at the queue until it is done with
A, which won't happen until B returns... deadlock!
You can play tricks with starting multiple instances of X, but in the end you
will always face a risk (something lika a race-condition) for a dead-lock.
Solution: Move service B to another server (usually quite easy) OR switch to multi-threading,
if that's possible. Just make sure all code your service calls is MT-safe as well...
thanks
georgeHope this helps you,
/Per -
How to get array values from one class to another
Supposing i have:
- a class for the main()
- another for the superclass
And i want to create a subclass that does some function on an array object of the the superclass, how can i do so from this new subclass while keeping the original element values?
Note: The values in the array are randomly generated integers, and it is this which is causing my mind in failing to comprehend a solution.
Any ideas?If the array is declared as protected or public in the superclass you can directly access it using its identifier. If not, maybe the superclass can expose the array via some getter method.
If this functionality can be generified (or is generic enough) to apply to all subclasses of the superclass the method should be moved to the superclass to avoid having to reproduce it in all the subclasses. -
How to send a variable from one class to another?
hello,
i have "One.as", which is the document class for one.swf.
i also have "two.swf", with "Two.swf" entered as its document
class...
One loads two into it. two is basically a 10 frame movieClip
with a variable at the beginning called "var endFrame:Boolean =
false", then on the last frame it says endFrame = true.
my question: how in the world do I communicate this back to
One.as??? i've tried ENTER_FRAME listeners, declaring the variable
here and there... and many other embarrassingly usuccessful
strategies.
i would just like to load in "three.swf" after two.swf
finishes... but One needs to know that it has indeed finished.
your help would be greatly appreciated. thanksyarkehsiow,
> David,
> thank you for responding.
Sure thing! :)
> so does what you are saying mean that endFrame is a
property of
> two (the movieClip), or Two (the Class)?
If you've written a property named endFrame for your Two
class, then
yes, Two.endFrame is a property of that class.
Looking back at your original post, I see that you wrote
this:
> One loads two into it. two is basically a 10 frame
movieClip
> with a variable at the beginning called "var
endFrame:Boolean = false",
> then on the last frame it says endFrame = true.
So it sounds like your Two class extends MovieClip. (I'm not
sure
that's true, but that's what it sounds like.) That means your
Two class
supports all the features of the MovieClip class, including a
play() method,
a currentFrame property, and so on. In addition, you've added
new
functionality that amounts to -- by the sound of it -- a
property named
endFrame. If you made your property public (i.e., public var
endFrame),
then it should be accessible by way of an object reference to
your Two
instance.
myTwoInstance.endFrame;
> so can i invoke that method in One.as? do I call it
Two.endFrame (if
> (Two.endFrame == true) {?
Methods are things an object can *do,* such as
gotoAndPlay(). What
you're describing is a property (a characteristic ... in this
case, a
Boolean characteristic). You wouldn't use the expression
Two.endFrame
unless that property was static. Static classes are those
that cannot have
an instance made of them. Think of the Math class. It
contains numerous
static properties in the form of constants, such as Math.PI,
Math.E,
Math.SQRT2, and so on. You can't create an instance of the
Math class -- it
wouldn't make sense to -- so Math is a static class.
On the other hand, you definitely create instances of the
MovieClip
class. Every movie clip symbol is an instance of MovieClip
class, which
means that each instance carries its own unique values for
MovieClip class
members. The MovieClip class defines x and y properties, but
each movie
clip symbol (that is, each instance of the MovieClip class)
configures its
own values of those properties, depending on where each
instance is located
on the Stage.
Assuming your Two class is not static, then somewhere along
the line,
your One class will have to make an instance of it. Somethine
like ...
// inside your One class ...
var myTwo:Two = new Two();
... at which point that myTwo variable because a reference to
that
particular instance of Two. You can invoke Two methods on
that instance.
You can invoke Two properties and events on that instance.
You can invoke
whatever functionality is defined by the Two class on that
myTwo instance.
If Two extends MovieClip, that means you can also invoke any
MovieClip class
member on that myTwo instance.
At some point in your One class, you can refer to that myTwo
instance
later and check if the value of myTwo.endFrame is true or
false.
David Stiller
Adobe Community Expert
Dev blog,
http://www.quip.net/blog/
"Luck is the residue of good design." -
How do you move an object in one photo to another photo in Photoshop CC 2014
In the document with the object select the object and use copy (Crtl|CMD+C) then in the other image document use paste (Crtl|CMD+V).
However its not a move its a copy the object is still in the original image. (Crtl|CMD+X) instead of (Crtl|CMD+C) would cut the object out of the first image but leave a hole there that you would need to fill with a replacement to complete a move. -
How to access form objects from different class?
Hello, I am new to java and i started with netbeans 6 beta,
when i create java form application from template i get 2 classes one ends with APP and one with VIEW,
i put for example jTextField1 with the form designer to the form and i can manipulate it's contents easily from within it's class (let's say it is MyAppView).
Question>
How can i access jTextField1 value from different class that i created in the same project?
please help. and sorry for such newbie question.
Thanks Mikehmm now it says
non static variable jTree1 can not be referenced from static context
My code in ClasWithFormObjects is
public static void setTreeModel (DefaultMutableTreeNode treemodel){
jTree1.setModel(new DefaultTreeModel(treemodel));
and in Class2 it is
ClasWithFormObjects.setTreeModel(model); -
How can I use footage from one project in another?
The best format for saving your video from one project so that it can be used in another Premiere Elements project is DV-AVI. For hi-def video, the format is HDV.
To save your video as a standard-definition DV-AVI, go to Share, Personal Computer and select the AVI output option with the DV preset. When you're ready to mix together these segments open a new project using the DV settings and assemble them on that timeline.
To save your video as a high-definition M2T video, go to Share, Personal Computer and select the MPEG output option with the 1440x1080 MPEG preset. When you're ready to mix together these segments open a new project using the HDV settings and assemble them on that timeline.The best format for saving your video from one project so that it can be used in another Premiere Elements project is DV-AVI. For hi-def video, the format is HDV.
To save your video as a standard-definition DV-AVI, go to Share, Personal Computer and select the AVI output option with the DV preset. When you're ready to mix together these segments open a new project using the DV settings and assemble them on that timeline.
To save your video as a high-definition M2T video, go to Share, Personal Computer and select the MPEG output option with the 1440x1080 MPEG preset. When you're ready to mix together these segments open a new project using the HDV settings and assemble them on that timeline. -
How to move an object from one Transport Request to another TR
Hi,
I have created an object under one TR instead of Required TR.
Now i need to move that object to apropriate TR.
Please suggest me the way.
Thanks,
Sekhar.JGo to SE10 select the Request and press Include Objects button( a box with a arrow above it) and select freely selected objects and add your object to the request. Before doing this you may be required to delete the object entry from the source request.
Regards
Karthik D
Maybe you are looking for
-
Refreshing the data in a flat file
Hi I am working on data integration. I need to fetch data from Oracle data base and then write it to a flat file. It is working fine now,but for the next fetch I don't need the old data to remain there in the file.The data should get refreshed and on
-
I need to print a mirror image of a PDF on my iPad. Is this possible?
I need to print a mirror image of a PDF on my iPad for an iron on transfer. Is this possible? I have Pages and GoodReader but can't figure out how this would work on either app. Help!
-
Deadlock on Weblogic 8.1 SP4 (ELFLogger)
My Weblogic Server crashed due to a deadlock OS version : Red Hat Enterprise Linux AS release 3 u4 Proc : 2 bi-cpus Intel Xeon with hyperthreading app server : Weblogic 8.1 SP 4 jvm version : JRockit 1.4.2_05
-
Folks, I need to clone the DB software alone from production to development. production : EBS:R12 DB:11g RAC I need to clone only software ? Thanks, Edited by: JuniorDBA on Nov 2, 2011 10:57 AM
-
Macbook Pro (2010) vs Macbook Air (2011)
I have a Macbook Pro (2010 model, 15" screen, i7 2.66ghz, 500gb 7200rpm drive) which I currently use for work which includes some photoshop. I am a little tired of lugging it around as it is quite heavy especially when you include the power pack and