# After importing one icon i want to give functionality

**URL:** <https://discourse.processing.org/t/after-importing-one-icon-i-want-to-give-functionality/15859>\
**Category:** Libraries\
**Created:** [November 27, 2019, 9:15am UTC](https://discourse.processing.org/t/after-importing-one-icon-i-want-to-give-functionality/15859 "2019-11-27T09:15:09Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [December 3, 2019, 6:00am UTC](https://discourse.processing.org/t/after-importing-one-icon-i-want-to-give-functionality/15859/21 "2019-12-03T06:00:58Z")

</div>

sorry, but above i give you the link to a post from quark ( he makes G4P )

when you run that code you get 2 windows ( with 2 option groups )  
and see how that can be operated from both windows,

* * *

.p.s. i made for you a ready ( optional image ) button code  
( also with the idea you want learn processing )  
but you ignored and go for G4P buttons AND a 2 windows concept…  
is ok, but not expect using such a high-level library is easier…

ONLY A START:

```auto
// https://discourse.processing.org/t/after-importing-one-icon-i-want-to-give-functionality/15859/21

import g4p_controls.*;

GButton btnMakeWindow1,btnMakeWindow2,btnMakeWindow3;
GButton saveW1;
GWindow window1,window2,window3;

GTextField txf1, txf2, txf3; // input text fields for window1 : letter 
GLabel lbltxf1,lbltxf2,lbltxf3; // with labels

String W1_input_txf1, W1_input_txf2, W1_input_txf3; // global strings as result from window 1 / ON button click

void setup() {
  size(450, 230);
  make_main_buttons();
}

void draw() {
  background(202, 239, 127);
}

void make_main_buttons() {
  int x1=259, y1=40, dy=50, w1=170, h1=50;
  btnMakeWindow1 = new GButton(this, x1, y1, w1, h1);
  btnMakeWindow1.setIcon("Letter.png", 1, GAlign.EAST, GAlign.MIDDLE, GAlign.MIDDLE);
  btnMakeWindow2 = new GButton(this, x1, y1+dy, w1, h1);
  btnMakeWindow2.setIcon("Memo.png", 1, GAlign.EAST, GAlign.MIDDLE, GAlign.MIDDLE);
  btnMakeWindow3 = new GButton(this, x1, y1+2*dy, w1, h1);
  btnMakeWindow3.setIcon("Delete.png", 1, GAlign.EAST, GAlign.MIDDLE, GAlign.MIDDLE); 
}

void handleButtonEvents(GButton button, GEvent event) {
  if (button == btnMakeWindow1 && event == GEvent.CLICKED) {
    createWindow1();
    btnMakeWindow1.setEnabled(false);
  }
  if (button == btnMakeWindow2 && event == GEvent.CLICKED) {
    createWindow2();
    btnMakeWindow2.setEnabled(false);
  }
  if (button == btnMakeWindow3 && event == GEvent.CLICKED) {
    createWindow3();
    btnMakeWindow3.setEnabled(false);
  }
}

void createWindow1() {
  println("W1 letter ");
  window1 = GWindow.getWindow(this, "Window Letter", 70, 160, 500, 300, JAVA2D);
  window1.setActionOnClose(G4P.CLOSE_WINDOW);
  window1.addData(new MyWinData());
  window1.addDrawHandler(this, "windowDraw");
  window1.addMouseHandler(this, "windowMouse");
  window1.addKeyHandler(this, "windowKey");
  
  make_W1_widgets();
}

void createWindow2() {
  println("W2 memo ");
}

void createWindow3() {
  println("W3 delete ");
}

void make_W1_widgets() {
  int x1=30, dx=200, y1=40, dy=50, w1=170, h1=20;  

  lbltxf1 = new GLabel(window1, x1, y1, w1, h1);
  lbltxf1.setTextAlign(GAlign.LEFT, null);
  lbltxf1.setText("T1");

  lbltxf2 = new GLabel(window1, x1, y1+dy, w1, h1);
  lbltxf2.setTextAlign(GAlign.LEFT, null);
  lbltxf2.setText("T2");

  lbltxf3 = new GLabel(window1, x1, y1+2*dy, w1, h1);
  lbltxf3.setTextAlign(GAlign.LEFT, null);
  lbltxf3.setText("T3");

  
  txf1 = new GTextField(window1, x1+dx, y1, w1, h1);
  txf1.tag = "txf1";
  txf1.setPromptText("Text field 1");
  //txf1.setText("t1");

  txf2 = new GTextField(window1, x1+dx, y1+dy, w1, h1);
  txf2.tag = "txf2";
  txf2.setPromptText("Text field 2");
  //txf2.setText("t2");
  
  txf3 = new GTextField(window1, x1+dx, y1+2*dy, w1, h1);
  txf3.tag = "txf3";
  txf3.setPromptText("Text field 3");
  //txf3.setText("t3");

  saveW1 = new GButton(window1, x1+dx+10, height-h1, 80, 25);
  saveW1.setText(" BACK ");
  
  saveW1.addEventHandler(this,"backW1click"); //___ must be this, not window1 !!
}

public void backW1click(GButton button, GEvent event) {
  if ( button == saveW1 ) {
    println("W1 back button pressed "+event);
    W1_input_txf1 = txf1.getText();
    W1_input_txf2 = txf2.getText();
    W1_input_txf3 = txf3.getText();
    println(lbltxf1.getText(), W1_input_txf1,lbltxf2.getText(),W1_input_txf2,lbltxf3.getText(),W1_input_txf3 );    
  }
}

public void handleTextEvents(GEditableTextControl textcontrol, GEvent event) { /* code */ }

class MyWinData extends GWinData {
  int sx, sy, ex, ey;
  boolean done;
  int col;
}

public void windowMouse(PApplet appc, GWinData data, MouseEvent event) {
  MyWinData data2 = (MyWinData)data;
  switch(event.getAction()) {
  case MouseEvent.PRESS:

    break;
  case MouseEvent.RELEASE:

    break;
  case MouseEvent.DRAG:

    break;
  }
}

public void windowDraw(PApplet appc, GWinData data) {
  MyWinData data2 = (MyWinData)data;
  appc.background(200,200,0); // winX background
}  

public void windowKey(PApplet appc, GWinData data, KeyEvent keyevent ) {
  MyWinData data2 = (MyWinData)data;
}  

```

---

<div class="post-metadata">

**Author:** ![aronisha](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@aronisha](https://discourse.processing.org/u/aronisha)\
**Post date:** [December 6, 2019, 9:57am UTC](https://discourse.processing.org/t/after-importing-one-icon-i-want-to-give-functionality/15859/22 "2019-12-06T09:57:55Z")

</div>

- is there any suggestion that i can create the database to store the data i fill on the 3 rows
- and the way that can i see the text i fill in second window on the first window

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [December 6, 2019, 10:01am UTC](https://discourse.processing.org/t/after-importing-one-icon-i-want-to-give-functionality/15859/23 "2019-12-06T10:01:49Z")

</div>

yes, a good thing is using a file:  
`/data/mydata.csv`

with or without excel/csv headerline

and in processing use

> **[loadTable() / Reference](https://processing.org/reference/loadTable_.html)**
>
> Reads the contents of a file or URL and creates a Table object with its values. If a file is specified, it must be located in the sketch's "data" folder. The filename parameter can also be a URL to a …

> **[saveTable() / Reference](https://processing.org/reference/saveTable_.html)**
>
> Writes the contents of a Table object to a file. By default, this file is saved to the sketch's folder. This folder is opened by selecting "Show Sketch Folder" from the "Sketch" menu. Alter…

checkout how powerful that is

> **[Table / Reference](https://processing.org/reference/Table.html)**
>
> Table objects store data with multiple rows and columns, much like in a traditional spreadsheet. Tables can be generated from scratch, dynamically, or using data from an existing file. Tables c…

different syntax but functions like arrayList

but it might also depend on HOW the data  
( the result of your program is? stored user input ? )  
have to be used further?

* * *

> [@aronisha](#):
>
> that can i see the text i fill in second window on the first window

did you test my program?  
there i declared and set global variables  
you can use in any window

---

<div class="post-metadata">

**Author:** ![aronisha](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@aronisha](https://discourse.processing.org/u/aronisha)\
**Post date:** [December 6, 2019, 10:14am UTC](https://discourse.processing.org/t/after-importing-one-icon-i-want-to-give-functionality/15859/24 "2019-12-06T10:14:37Z")

</div>

thank you for your support !! if i create user account system for the application is that possible some users to access the database system  
also please recommend me about

- user account making codes
- getting time and date directly from internet
- when i go to second window to hide the first window & when i click back button to close the second window then return to the the first window
- like button making website please suggest me better icon making websites or icon websites
- is that good add some python codes on my coding?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [December 6, 2019, 10:29am UTC](https://discourse.processing.org/t/after-importing-one-icon-i-want-to-give-functionality/15859/25 "2019-12-06T10:29:35Z")

</div>

-a- database:  
[https://github.com/fjenett/sql-library-processing](https://github.com/fjenett/sql-library-processing) ,

-b- date time  
[https://processing.org/reference/day\_.html](https://processing.org/reference/day_.html)

-c- window select open close G4P  
[http://www.lagers.org.uk/g4p/ref/classg4p\_\_controls\_1\_1\_g\_window.html](http://www.lagers.org.uk/g4p/ref/classg4p__controls_1_1_g_window.html)

-d- why you not draw that buttons with draw or paint tools  
if you not find good ones online  
the buttons i make for you and show you i do online, sure, the link is inside the code  
[After importing one icon i want to give functionality](https://discourse.processing.org/t/after-importing-one-icon-i-want-to-give-functionality/15859/15),  
you have own button pictures in your post already.  
and not forget, anything you find in browser ( like with google )  
you can snap to a picture, snip out just the area you want use for a button  
and use that from file from processing as image button.

-e- mix with python difficult, but you might do the whole thing in python  
[https://py.processing.org/](https://py.processing.org/)  
— worst case can do 2 separate applications what talk via stored file…

[Previous page](https://discourse.processing.org/t/after-importing-one-icon-i-want-to-give-functionality/15859.md?page=1)
