Fxml ComboBox created in scene builder how to fetch data from database
Hi Sir, How r u? Hope to be fine. Sir, I have a problem that i want to fetch data in fxml comboBox created in Scene Builder?
I have used this code in JavaFx 2.0 for comboBox and textField the code is
ComboBox studentRegId = new ComboBox();
try{
stm = db.con.createStatement();
rs = stm.executeQuery("select * from students order by s_reg_id asc");
while(rs.next()){
for(int i=1; i<=1; i++)
studentRegId.getItems().add(rs.getString("s_reg_id"));
}catch(SQLException sqlException){
final TextField sRegId = new TextField();
final String regId[] = new String[1000];
try{
stm = db.con.createStatement();
rs = stm.executeQuery("select * from students order by s_reg_id asc");
int a = 0;
while(rs.next()) {
regId[a] = rs.getString("s_reg_id");
a++; }
}catch(SQLException sqlException){
studentRegId.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>(){
public void changed(ObservableValue ov,Number value, Number new_value){
sRegId.setText(regId[new_value.intValue()]);
Now, the problem is that I want to use this code in Scene Builder fxml ComboBox .
Please Help Me!
I shall be very grate full to you for this kindness.
Regards
Hi,
Ok, so you create your FXML :
Add a controller property to your root control. (See Code tab in SceneBuilder or direcly in FXML : fx:controller tag)
Add a fx:id to your controls (your combobox) (First property in SceneBuilder or directly in FXML : fx:id)
Example :
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.collections.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<HBox prefHeight="-1.0" prefWidth="-1.0" xmlns:fx="http://javafx.com/fxml" fx:controller="org.lgringo.comboexample.Controler">
<children>
<TextField fx:id="text" prefWidth="100.0" />
<ComboBox fx:id="combo" prefWidth="200.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="Item 1" />
<String fx:value="Item 2" />
<String fx:value="Item 3" />
</FXCollections>
</items>
</ComboBox>
</children>
</HBox>Then, you create your Controler class using @FXML annotation (name of control should be the name of fx:id properties)
You can do some initialisation in the inherit method "initialize"
Example :
package org.lgringo.comboexample;
import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
public class Controler {
@FXML
// fx:id="combo"
private ComboBox<String> combo; // Value injected by FXMLLoader
@FXML
// fx:id="text"
private TextField text; // Value injected by FXMLLoader
@FXML // This method is called by the FXMLLoader when initialization is complete
void initialize() {
assert combo != null : "fx:id=\"combo\" was not injected: check your FXML file 'ComboboxExample.fxml'.";
assert text != null : "fx:id=\"text\" was not injected: check your FXML file 'ComboboxExample.fxml'.";
// Initialize your logic here: all @FXML variables will have been injected
combo.getItems().clear();
combo.getItems().addAll("John Lennon","Mick Jagger","David Bowie");
combo.getItems().add("Others...");
text.setText("List : ");
}Then you use the FXMLLoader class to load your FXML and Controler.
Example :
package org.lgringo.comboexample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class App extends Application {
* @param args
public static void main(String[] args) {
App.launch(args);
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("ComboboxExample.fxml"));
primaryStage.setTitle("Combo Example");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}More info : http://docs.oracle.com/javafx/2/get_started/fxml_tutorial.htm
Similar Messages
-
How to fetch data from database in javafx 2.2 table which is editable.
Dears!
I want to fetch data from database in javafx 2.2 tableformat with jdbc , which is also editable and i can add more records in this table also.
Can anybody help meI can vaguely recall some sort of JavaFX database connectivity feature, I'm not sure if it's valid anymore.The link is based on JavaFX Composer which only applied to NetBeans 6.9 and JavaFX 1.x (both of which are now dead techs).
There is a good chance you will have to write your own. There are several blogs describing other peoples' work. You could probably use them as a reference.Here is Narayan's basic [url http://blog.ngopal.com.np/2011/10/19/dyanmic-tableview-data-from-database/] tutorial for displaying data from a database in a TableView, you'll need to look elsewhere for the editing portion.
The [url http://docs.oracle.com/javafx/2/ui_controls/table-view.htm]JavaFX TableView tutorial gives info about how to handle edits in a TableView, but you will need to tie the updates back to the database yourself.
It is possible that [url http://www.javafxdata.org/]DataFX may provide some facilities to help support you. -
How to fetch data from DataBase using Servlet ?
Hi all,
Till now, i was just sending values from web page and receive the data in excel format using servlets.
But, now, i want to fetch data from data base. I will be giving inputs in the web page(for the query)....ON click of submit button,
Servlet should be called.
Depending on the input, query has to be executed, and response should be sent to the user.
How to do it?
Code
import java.text.*;
import java.sql.*;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.OutputStream;
/** Simple servlet that reads three parameters from the html
form
public class Fetchdata extends HttpServlet
String query=new String();
String uid="ashvini";
String pwd="******";
try
Connection con=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Testing";
con = DriverManager.getConnection(url, uid, pwd);
Statement s = con.createStatement();
query = "select * from gowri.msllst1";
ResultSet rs = s.executeQuery(query);
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException, IOException
response.setContentType("application/vnd.ms-excel");
ServletOutputStream out=response.getOutputStream();
out.println("<HTML>" +"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=CENTER>" + title + "</H1>\n" +
"<table>" +" <th>ITEM Code</th>");
while(rs.next())
out.println("<tr><td>" rs.getString(1).trim()"</tr></td>");
}//end of while
out.println("</table></BODY></HTML>");
}//end of doGet method
}catch(Exception e)
System.out.println(e);
It is giving error message as:
C:\Program Files\Apache Tomcat 4.0\webapps\general\srvlt>javac Fetchdata.java
Fetchdata.java:17: illegal start of type
try
^
Fetchdata.java:48: <identifier> expected
^
2 errors
Is this format is correct? am i placing this doGet method at the right place? is my program's logic is correct?
Please help me?
Regards
AShviniThere is some mistakes in ur code.....how can try catch exists outside a function???
make use of try catch isde ur doGet method and put
Connection con=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Testing";
con = DriverManager.getConnection(url, uid, pwd);
Statement s = con.createStatement();
query = "select * from gowri.msllst1";
ResultSet rs = s.executeQuery(query);
isdie doGet method, for the time being,
i think u get me..
regards
shanu -
How to fetch data from Database using SUP MBOs
I'm learning to develop blackberry apps using SUP.I am new to both blackberry api and SUP.
I need to make a login page for a Student and then validate the username and password entered using data from a database.
I need to check the database for the username and password entered. What should be my next step? How do i get this data from the database. Using findAll() method is not working . Do i need to connect to SCC or unwired server first. If yes , then someone please provide a sample code for it.Hi!, I see your code and I see that you have a fee errors, try to use this:
import java.text.*;
import java.sql.*;
import java.util.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.OutputStream;
* NOTE: You must put the try-catch and your sql code into the get method
/** Servlet program to take fetchdata from database and display that on the broswer*/
public class Fetchdata
extends HttpServlet {
String query = new String();
String uid = "ashvini";
String pwd = "******";
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, Exception {
try {
Connection con = null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Testing";
con = DriverManager.getConnection(url, uid, pwd);
Statement s = con.createStatement();
query = "select * from gowri.msllst1";
ResultSet rs = s.executeQuery(query);
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("<HTML>" + "<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1 ALIGN=CENTER>" + title + "</H1>\n" +
"<table>" + " <th>ITEM Code</th>");
while (rs.next()) {
out.println("<tr><td>" + rs.getString(1).trim() + "</td></tr>");//I change </tr></td> for </td></tr>
} //end of while
out.println("</table></BODY></HTML>");
catch (Exception e) {
System.out.println(e);
} //end of doGet method
}I hope this help you :) -
How to fetch data from Mysql with SSL.
I am using jdk1.5 and mysql 5.0.
How to fetch data from Mysql with SSL
I am using url = jdbc:mysql://localhost/database?useSSL=true&requireSSL=true.
It shows error. how to fetchI have created certificate in mysql and checked in mysql.
mysql>\s
SSL: Cipher in use is DHE-RSA-AES256-SHA
but through ssl how to fetch data in java. -
What is a cube? how we store data in that? how we fetch data from cube?
Hi,
What is a cube? how we store data in that? how we fetch data from cube?
Regards.
venkat>
venkey B wrote:
> Hi,
>
>
> What is a cube? how we store data in that? how we fetch data from cube?
>
>
> Regards.
>
> venkat
Hi Venkat,
I guess you mean an infocube from the SAP BI product. I propose to look at the forum for Business Intelligence to find your answers.
E.g. SAP POS DM writes the sales data in infocubes..... -
How to fetch data from PTREQ tables
I need to display data in the customised webdynpro application from PTREQ tables.
Can anyone help me out how to fetch data from these tables.use the standard modules like
PT_ARQ_REQUEST_CHECK
PT_ARQ_REQUEST_EXECUTE
PT_ARQ_REQUEST_PREPARE -
How to fetch data from cluster tables
hi
i need to know how to fetch data from cluster tables please update me if any
i know that we cannot use joins in cluster table we use view etc
but i need detailed inforation on methods for fetching data from cluster tables
regards
NishantHi,
Check the following links
http://fuller.mit.edu/hr/cluster_tables.html
The specified item was not found.
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a0f46157-e1c4-2910-27aa-e3f4a9c8df33 -
How to retrive data from database views or projection views
how to retrive data from database views or projection views
Hi chintam,
1. Very simple
2. Just like normal select statement.
3. Select * from VIEWNAME.
4. (Instead of the tablename, we just have to give the viewname)
regards,
amit m. -
How to get data from database to JComboBox
hi
i am trying to get data which is in database. here the problem is i am getting only one row in the JcomboBox
i want all data just like list. i dont know how to get that . below is the code plz any one help me....
import javax.swing.*;
import javax.swing.JList.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.String.*;
import java.lang.Integer.*;
import java.sql.*;
public class customer_code extends JFrame implements ActionListener
Container c=getContentPane();
JLabel customer_code=new JLabel("Customer Code and Name");
customer_code()
super("Customer Details");
setSize(300,250);
setVisible(true);
setLayout(null);
setLocation(430,310);
Font f=new Font("SansSerif",1,16);
Font f1=new Font("SansSerif",0,14);
customer_code.setBounds(10,20,250,30);
add(customer_code);
customer_code.setFont(f);
ResultSet rs=null;
String j=null,k=null;
try
System.out.println("MySQL Connect Example.");
Statement st=null;
Connection con=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:project","vikky","vishu");
System.out.println("Connected to the database");
st=con.createStatement();
rs=st.executeQuery(" select code as c,Customer_name as n from customer_details ");
while(rs.next())
j=rs.getString("c");
k=rs.getString("n");
System.out.println(j);
System.out.println(k);
String[] names = new String[] {j,k};
JComboBox comboBox = new JComboBox(names);
add(comboBox);
comboBox.setBounds(25,60,250,50);
comboBox.setFont(f);
comboBox.addActionListener(this);
comboBox.setMaximumRowCount(10);
con.close();
System.out.println("Disconnected from database");
catch (Exception e)
e.printStackTrace();
public void actionPerformed(ActionEvent event)
if ("comboBoxChanged".equals(event.getActionCommand()))
System.out.println("User has selected an item from the combo box.");
JComboBox comboBox = (JComboBox) event.getSource();
if(comboBox.getSelectedItem().equals("None"))
public static void main(String agr[])
customer_code cd=new customer_code();
}r035198x wrote:
Also separate that database code from interface display code.
You should never access the database on the EDT.
See [Doing Swing Right|http://bytes.com/topic/java/insights/853297-doing-swing-right] for more details.
Yes! By the time you are working with Swing and JDBC you should already know how to structure code. If not, then you are not ready for these topics and you've jumped the gun. -
Help , How to get data from database using recordset with UI API
I want to get a data from database
when I want to create recordset i notice that UI API didn't has record set
so I created recordset using DI API (SAPbobscom.recordset and SAPbobscom.company)
======================================================
Dim oCompanyUI As SAPbouiCOM.Company <<UI API
Dim oRecSet As New SAPbobsCOM.Recordset << DI API
Dim oCompanyDI As New SAPbobsCOM.Company << DI API
'=====================================================
oCompanyDI.Connect
Set oRecSet = oCompanyDI.GetBusinessObject(BoRecordset)
oRecSet.DoQuery ("SELECT T0.CardCode, T0.CardName FROM OCRD T0")
SBO_Application.MessageBox oRecSet.Fields.Item(1).Value
======================================================
but I got an error it said "you are not connected to company"
I'm really don't have an idea about how to get a data from using UI API (exp I want to get a date or costumer code)
can someone help me please, I really need it
Thanksyou need a single sign on
Dim oDICompany As SAPbobsCOM.Company
Dim sCookie As String
Dim sConnStr As String
Dim ret As Integer
oDICompany = New SAPbobsCOM.Company
sCookie = oDICompany.GetContextCookie
sConnStr = SBO_Application.Company.GetConnectionContext(sCookie)
If oDICompany.Connected Then
oDICompany.Disconnect()
End If
ret = oDICompany.SetSboLoginContext(sConnStr)
If Not ret = 0 Then
SBO_Application.MessageBox("set Login Context failed!")
Exit Sub
End If
ret = oDICompany.Connect()
If Not ret = 0 Then
SBO_Application.MessageBox("Company Connect failed!")
End If -
How to fetch data from a SAP BW Cube via Perl/PHP on a Linux machine?
Hi all,
here's the scenario:
I need to fetch data from a cube of a remote SAP NetWeaver 7. The data will later be used in a web application based on Linux and Perl/PHP. (I'd prefer using perl for the backend and doing the business logic of the web application.)
I have:
A Linux system with all its on-board tools and scripting languages.
A user for the SAP BW which allows me to logon (very,very limited user rights, no se37,no se80,no rsaX and so on)
Access to http://<SAP BW Server>:<Port>/sap/bw/xml/soap/xmla with the above mentioned user.
My questions:
- Could you please push me into the right direction how I can realize this? E.g. by pointing to tutorials / HowTos / sample code / CPAN modules etc.. (Most information I found so far referred to software based on a different operating system and on remote function calls using custom functions.)
- I'm aware of the SAPNW::RFC CPAN module, but do I necessarily have to perform a remote function call? ( If so, is there a "standard" function I could call for accessing a cube?)
Thanks a lot in advance!You can take through the RFCS .check for some system function modules...but why do you need to route it through XI?How huge z the files?
-
How to display data from Database individually??? Anyone can help ?
HI,
i i had select a row of data from database using ,
/* Query * From Table RESOURCEORDER where po = selected no and project = selected project */
public ResultSet getAllData() throws SQLException
getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM RESOURCEORDER WHERE PROJECT = '" + getSelProject() + "' and PURCHASEORDERNO = '" + getPo() + "'" );
return rs;
After that , how do i display the data individually ?
Eg select data is ('projectA','7891203-1', '10-4-2005','lcd',2000,'121-45217-8','electrical','pending','donwong')
i want to display them individually, like this in a page
Projectname: /* should display the Project A*/
P.O no:
Date:
Order:
Cost:
Acc no:
Type:
status:
Orderedby:
Can anyone help ? cos i'm new to JSP ......Thanks alot!!!!!
Regards,
khimI assume PO being a unique key, will always return 1 row from db.
public String[] getAllData() throws Exception
getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM RESOURCEORDER WHERE PROJECT = '" + getSelProject() + "' and PURCHASEORDERNO = '" + getPo() + "'" );
String [] returnValue = new String[9];
while(rs.next())
returnValue[1] = rs.getString("colname");
returnValue[2] = rs.getString("colname");
///and so on
return returnValue;
}Once you get that you could individually view it by setting a loop to run through the returned array.
Hope it helps -
How to fetch data from single database table using 2 internal tables.
Hi friends,
i am a new user of ABAP and also SDN.
i need a help.
i want to fetch data from one database table based on primary keys of 2 internal tables. how to put in where clause.
Thanks in advance.hii
refer to following code ..i hope it will help you
SELECT matnr " Material Number
FROM mara
INTO TABLE i_mara
WHERE matnr IN s_matnr.
IF i_mara[] IS NOT INITIAL.
SELECT matnr " Material Number
werks " Plants
prctr " Profit Center
FROM marc
INTO TABLE i_marc
FOR ALL ENTRIES IN i_mara
WHERE matnr = i_mara-matnr
AND werks IN s_werks.
ENDIF. " IF i_mara[] IS NOT INITIAL
i_output = i_marc.
IF i_marc[] IS NOT INITIAL.
SELECT matnr " Material Number
werks " Plants
lgort " Storage Location
FROM mard
INTO TABLE i_mard
FOR ALL ENTRIES IN i_marc
WHERE matnr EQ i_marc-matnr
AND werks EQ i_marc-werks
AND lgort IN s_lgort.
ENDIF. " IF i_mara[] IS NOT INITIAL
regards
twinkal -
How to Fetch Data From Standard Table MARA and Display using BOPF ?
Hello All,
In BOPF creation of Quey to a node fetches data from the Data Base Table attached to that Node,
But in my requirement I have to fetch data Present in a Standard table and Display it in the FPM List Using FBI.
** Can we Fetch the data From Standard Table and fill the Node in BOPF, Is this possible as the standard Table do not contain KEY field which BOPF uses for Data Fetching ?
Kindly share your Idea's .
Thanks in Adv.Hi Dhivya,
Thanks For your Response.
In my Requirement I want to make ROOT Node as Transient Node.
When I create a Sub Node to a Root Node, I am able to get this option to make this sub node as a Transient Node .
By selecting 'Standard<-->Extended' option in the Menu item 'GoTo' I am able to get this Transient Node check box field for the Sub Nodes.
I want to make a ROOT Node as a Transient Node.
(Which Version you are using, and which transaction you are using to create BO . we are using BOBX Transaction, Version Ehp 6 )
Kindly Guide me .
Thanks,
Kranthi Kumar.
Maybe you are looking for
-
The PivotTable Field List shows up fine when using Excel Web Apps normally. It doesn't appear to be accesible via the javascript API and the main Excel Web App cannot be embeded in a frame. Any ideas?
-
Why can't I have more than one iTunes linked t my iPod
I have Macs for years, all sorts, I currently actively use, iMac g417,iMac g5 20, iMac intel 24. G4 Mac Mini,Intel Mac Mini, G5 tower, G4 Tower, powerbook g4 and mac book. Yes I know but I work from home with Mac all day... I have thousands of songs,
-
Help: matrix report grid lines missing for null values only on server side
Hi, I created a matrix report in pdf format. The output in great when run through report builder locally, it renders all necessary details. However, after the report being moved into AS server, the report does not show grid lines for null values. It
-
Create item copy other item (not template)
Hi experts, I have a question related to PPM 5.0, is it possible create an item with copy other item? ( no copy for a template)? I have no the way to do it. Thanks a lot, Sara
-
Hi, Is anyone else having network problems,i have an iPhone 5 and its searching more times than i have a signal,never had this problem before i have had the phone for over a year,its becoming a major problem,is it something to do with i.O.S 7.1.1 Man