Java swing dynamic forms (in a loop)
Hi All,
Is it possible to dynamically create forms using java swing? What I mean to ask is that if I have the necessary information in a table, like the label and a corresponding text field, I can loop through and create the required number of fields. If I do it this way and when the users add text, will I not lose the ability to access each JTextField through its own variable? Is this possible? Basically, I need to be able to access each field through its own variable to do some additional validations on the text entered, etc. Please let me know, if it is possible through java swing.
Any help in this regard is greatly appreciated.
Thanks.
mrbean1975 wrote:
..Is it possible to dynamically create forms using java swing? If by java swing you mean Java Swing, then yes.
Similar Messages
-
Java Swing App hangs on socket loop
H}ello everyone i've run into a bit of a snag with my application, its a simple chat bot right now but will evolve into a chat client soon. I can't do that however since my app hangs when i look through the readLine() function to receive data and i dont know how to fix this error. The code is below.
The doSocket() function is where the while loop is if anyone can help me with this i'd be very greatful.
* GuiFrame.java
* Created on August 13, 2008, 9:36 PM
import java.net.*;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
* @author brian
public class GuiFrame extends javax.swing.JFrame {
/** Creates new form GuiFrame */
public GuiFrame() {
initComponents();
Socket client_sock = null;
PrintWriter out = null;
BufferedReader in = null;
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
convertButton = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Test Bot");
convertButton.setText("Connect");
convertButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
convertButtonActionPerformed(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()
.addGap(41, 41, 41)
.addComponent(convertButton)
.addContainerGap(42, Short.MAX_VALUE))
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(convertButton)
.addContainerGap(26, Short.MAX_VALUE))
pack();
}// </editor-fold>
private void convertButtonActionPerformed(java.awt.event.ActionEvent evt) {
if (convertButton.getText()=="Connect") {
String old;
try {
client_sock = new Socket("www.spinchat.com", 3001);
out = new PrintWriter(client_sock.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(client_sock.getInputStream()));
} catch (UnknownHostException e) {
} catch (IOException e) {
try {
doSocket();
} catch (IOException ex) {
Logger.getLogger(GuiFrame.class.getName()).log(Level.SEVERE, null, ex);
} else if (convertButton.getText()=="Disconnect") {
out.println("e");
out.close();
try {
client_sock.close();
in.close();
} catch (IOException ex) {
Logger.getLogger(GuiFrame.class.getName()).log(Level.SEVERE, null, ex);
private void doSocket() throws IOException {
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
String userInput;
String old;
while ((userInput = stdIn.readLine()) != null) {
old = userInput;
if (userInput != old) {
String proto = userInput.substring(0, 0);
if (proto == ":") {
out.println("{2");
out.println("BI'm a bot.");
out.println("aNICKHERE");
out.println("bPASSHERE");
} else if (proto == "a") {
convertButton.setText("Disconnect");
out.println("JoinCHannel");
* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new GuiFrame().setVisible(true);
// Variables declaration - do not modify
private javax.swing.JButton convertButton;
// End of variables declaration
}Edited by: briansykes on Aug 13, 2008 9:55 PM
Edited by: briansykes on Aug 13, 2008 9:56 PM>
..i've run into a bit of a snag with my application, its a simple chat bot right now but will evolve into a chat client soon. >Is this intended as a GUId app? If so, I would stick to using a GUI for input, rather than reading from the command line (which when I run it, is the DOS window that jumps up in the BG - quite counterintuitive). On the other hand, if it is intended as a non-GUId or headless app., it might be better to avoid any use of JComponents at all.
My edits stick to using a GUI.
Other notes:
- String comparison should be done as
s1.equals(s2)..rather than..
s1 == s2- Never [swallow exceptions|http://pscode.org/javafaq.html#stacktrace] in code that does not work.
- Some basic debugging skills are well called for here, to find where the program is getting stuck. When in doubt, print out!
- What made you think that
a) a test of equality on a member against which you had just set the value to the comparator, would logically lead to 'false'?
old = userInput;
if (userInput != old) ..b) A substring from indices '0 thru 0' would provide 1 character?
String proto = userInput.substring(0, 0);
if (proto == ":") ..
>
..if anyone can help me with this i'd be very greatful.>Gratitude is often best expressed through the offering of [Duke Stars|http://wikis.sun.com/display/SunForums/Duke+Stars+Program+Overview].
* GuiFrame.java
* Created on August 13, 2008, 9:36 PM
import java.net.*;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
* @author brian
public class GuiFrame extends JFrame {
/** Creates new form GuiFrame */
public GuiFrame() {
initComponents();
Socket client_sock = null;
PrintWriter out = null;
BufferedReader in = null;
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
convertButton = new JButton();
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setTitle("Test Bot");
convertButton.setText("Connect");
convertButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
convertButtonActionPerformed(evt);
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(41, 41, 41)
.addComponent(convertButton)
.addContainerGap(42, Short.MAX_VALUE))
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(22, 22, 22)
.addComponent(convertButton)
.addContainerGap(26, Short.MAX_VALUE))
pack();
setLocationByPlatform(true);
}// </editor-fold>
private void convertButtonActionPerformed(java.awt.event.ActionEvent evt) {
if (convertButton.getText()=="Connect") {
String old;
try {
System.out.println( "Connect start.." );
client_sock = new Socket("www.spinchat.com", 3001);
out = new PrintWriter(client_sock.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(client_sock.getInputStream()));
System.out.println( "Connect end.." );
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
try {
doSocket();
} catch (IOException ex) {
Logger.getLogger(GuiFrame.class.getName()).log(Level.SEVERE, null, ex);
} else if (convertButton.getText()=="Disconnect") {
out.println("e");
out.close();
try {
client_sock.close();
in.close();
} catch (IOException ex) {
Logger.getLogger(GuiFrame.class.getName()).log(Level.SEVERE, null, ex);
private void doSocket() throws IOException {
System.out.println( "doSocket start.." );
String userInput;
String old;
userInput = JOptionPane.showInputDialog(this, "Send..");
while(userInput!=null && userInput.trim().length()>0) {
System.out.println( "doSocket loop 1.." );
String proto = userInput.substring(0, 1);
System.out.println("proto: '" + proto + "'");
if (proto.equals(":")) {
System.out.println("Sending data..");
out.println("{2");
out.println("BI'm a bot.");
out.println("aNICKHERE");
out.println("bPASSHERE");
} else if (proto.equals("a")) {
convertButton.setText("Disconnect");
out.println("JoinCHannel");
userInput = JOptionPane.showInputDialog(this, "Send..");
System.out.println( "doSocket end.." );
* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new GuiFrame().setVisible(true);
// Variables declaration - do not modify
private JButton convertButton;
// End of variables declaration
} -
Problem with java swing button and loop
Problem with java swing button and loop
I�m using VAJ 4.0. and I�m doing normal GUI application. I have next problem.
I have in the same class two jswing buttons named start (ivjGStart) and stop (ivjGStop) and private static int field named Status where initial value is 0. This buttons should work something like this:
When I click on start button it must do next:
Start button must set disenabled and Stop button must set enabled and selected. Field status is set to 1, because this is a condition in next procedure in some loop. And then procedure named IzvajajNeprekinjeno() is invoked.
And when I click on stop button it must do next:
Start button must set enabled and selected and Stop button must set disenabled.
Field status is set to 0.
This works everything fine without loop �do .. while� inside the procedure IzvajajNeprekinjeno(). But when used this loop the start button all the time stay (like) pressed. And this means that a can�t stop my loop.
There is java code, so you can get better picture:
/** start button */
public void gStart_ActionEvents() {
try {
ivjGStart.setEnabled(false);
ivjGStop.setEnabled(true);
ivjGStop.setSelected(true);
getJTextPane1().setText("Program is running ...");
Status = 1;
} catch (Exception e) {}
/** stop button */
public void gStop_ActionEvents() {
try {
ivjGStart.setEnabled(true);
ivjGStart.setSelected(true);
ivjGStop.setEnabled(false);
getJTextPane1().setText("Program is NOT running ...");
Status = 0;
} catch (Exception e) {
/** procedure IzvajajNeprekinjeno() */
public void IzvajajNeprekinjeno() { //RunLoop
try {
int zamik = 2000; //delay
do {
Thread.sleep(zamik);
PreberiDat(); //procedure
} while (Status == 1);
} catch (Exception e) {
So, I'm asking what I have to do, that start button will not all the time stay pressed? Or some other aspect of solving this problem.
Any help will be appreciated.
Best regards,
TomiThis is a multi thread problem. When you start the gui, it is running in one thread. Lets call that GUI_Thread so we know what we are talking about.
Since java is task-based this will happen if you do like this:
1. Button "Start" is pressed. Thread running: GUI_Thread
2. Event gStart_ActionEvents() called. Thread running: GUI_Thread
3. Method IzvajajNeprekinjeno() called. Thread running: GUI_Thread
4. Sleep in method IzvajajNeprekinjeno() on thread GUI_Thread
5. Call PreberiDat(). Thread running: GUI_Thread
6. Check status. If == 1, go tho 4. Thread running: GUI_Thread.
Since the method IzvajajNeprekinjeno() (what does that mean?) and the GUI is running in the same thread and the event that the Start button has thrown isn't done yet, the program will go on in the IzvajajNeprekinjeno() method forever and never let you press the Stop-button.
What you have to do is do put either the GUI in a thread of its own or start a new thread that will do the task of the IzvajajNeprekinjeno() method.
http://java.sun.com/docs/books/tutorial/uiswing/index.html
This tutorial explains how to build a multi threaded gui.
/Lime -
Problem in printing a java swing form
Hi,
Could anyone help me on how to set the page margings while I print a java swing form since it is taking a lot of space as margins in the top right top and bottom how do i do that. or is it that java can only print in the printable area or is there any way i can increase the scope of the printable areaI used PrintRequestAttributeSet and set the margins to 0.5 on all four sides by creating an instance of MediaPrintableArea. By default, the margins on all sides comes up as 1.0 inch. Default paper size is LETTER (8.5 x 11).
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new MediaPrintableArea(0.5f,0.5f,7.5f,10.0f,MediaPrintableArea.INCH);
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(component);
if(printJob.printDialog(aset))
printJob.print(aset);
hope it helps. -
Java swing/visual components in an Oracle Form
Hello,
Has someone used visual javabeans embedded in Oracle Forms ?
is there a special api or componente to use?
I want to embed a jclass javabean in an Oracle Form (oracle forms client)
any help will be welcome, thanksThere are examples of white papers on OTN which show how you can integrate Java Beans into the Forms UI.
You may have some success with Swing but forms is based on AWT/EWT of which there was only and old (and not
very good) Swing version.
As I said - check out the white papers and you can try the demos which are on the Sample Code page.
Regards
Grant Ronald
Forms Product Management -
How to convert oracle form fmb file to java swing file using Jdeveloper
how to convert oracle form fmb file to java swing file using Jdeveloper.Please explain with detailes steps if possible or please give a link where it is available
thanks
Message was edited by:
user591884There is no automatic way to do this in JDeveloper. I know there are some Oracle Partners offering forms to java conversion, I don't know how much of their tools are automated and done with JDeveloper. With JDeveloper+ADF you basically rewriting the Forms application from scratch (and using ADF is helpful during this process).
-
How to embed/perform a Java Swing form into webased Swing form
How to embed/perform a Java Swing form into webased Swing form or any alternative.
Suppose i have 2 or more swing forms which are desktop applications but i want those forms to be now webbased..so how can i do this.Will i need to change the swing coding or will have to keep the swing design same.what can be the best Solution.You can launch your existing desktop app via the web using [Java Web Start|http://java.sun.com/javase/technologies/desktop/javawebstart/index.jsp]
-
PDF form into a Java Swing Panel
Hi All,
we have generated a form with LiveCycle Design, and now we are thinking to view and navigate this PDF form into a Java Swing Panel.
Anybody have try this? Do we need to specify some special thing during the generation of the form with LiveCycle Design?
I hope not to be OT here.
Thanks in advance for any reply.
P.I have not done this but I can assure you that there is nothing in Designer to do with this. At that point it is a PDF so how woudl you add any other PDF to your swing panel?
Paul -
PL/SQL and Java Swing interface
Everybody in this forum knows that Oracle is the best database around
with many functionalities, stability, performance, etc. We also know
that PL/SQL is a great language to manipulate information directly
in the database with many built in functions, OOP capability,
transaction control, among other features. Today an application that
manipulates information, which needs user interface, requires components
to be developed using different technologies and normally running in
different servers or machines. For example, the interface is done using
a dynamic HTML generator like JSP, PHP, PL/SQL Web Toolkit, etc.
This page is executed in an application server like Oracle iAS or
Tomcat, just to name two, which in turn access a database like Oracle to
build the HTML. Also rich clients like Java applets require an intermediate
server to access the database (through servlets for example) although
it is possible to access the database directly but with security issues.
Another problem with this is that complexity increases a lot, many
technologies, skills and places to maintain code which leads to a greater
failure probability. Also, an application is constantly evolving, new
calculations are added, new tables, changed columns. If you have an
application with product code for example and you need to increase its
size, you need to change it in the database, search for all occurrences
of it in the middle-tier code and perhaps adjust interfaces. Normally
there is no direct dependency among the tier components. On another
issue, many application interfaces today are based on HTML which doesn't
have interactive capabilities like rich-client interfaces. Although it
is possible to simulate many GUI widgets with JavaScript and DHTML, it is
far from the interactive level we can accomplish in rich clients like
Java Swing, Flash MX, Win32, etc. HTML is also a "tag-based" language
originally created to publish documents so even small pages require
many bytes to be transmitted, far beyond of what we see on the screen.
Even in fast networks you have a delay time to wait the page to be
loaded. Another issue, the database is in general the central location
for all kinds of data. Most applications relies on it for security,
transaction and availability. My proposal is to use Oracle as the
central location for interface, processing and data. With this approach
we can create not only the data manipulation procedures in the database,
but procedures that also control and manage user interfaces. Having
a Oracle database as the central location for all components has many
advantages:
- Unique point of maintenance, backup and restore
- Integrated database security
- One language for everything, PL/SQL or Java (even both if desired)
- Inherited database cache, transaction and processing optimizations
- Direct access to the database dictionary
- Application runs on Oracle which has support for many platforms.
- Transparent use of parallel processing, clusters and future
background technologies
Regarding the interface, I already created a Java applet renderer
which receives instructions from the database on how to create GUI
objects and how to respond to events. The applet is only 8kb and can
render any Swing or AWT object/event. The communication is done
through HTTP or HTTPS using Oracles's MOD_PLSQL included in the Apache
HTTP server which comes with the database or application server (iAS).
I am also creating a database framework and APIs in PL/SQL to
create and manipulate the client interface. The applet startup is
very fast because it is very small, you don't need to download large
classes with the client interface. Execution is done "on-demand"
according to instructions received from the database. The instructions
are very optimized in terms of network bandwidth and based on preliminary
tests it can be up to 1/10 of a similar HTML screen. Less network usage
means faster response and means that even low speed connections will
have a good performance (a future development can be to use this in
wireless devices like PDAs e even cell phones, just an idea for now).
The applet can also be executed standalone by using Java Web Start.
With this approach no business code, except the interface, is executed
on the client. This means that alterations in the application are
dynamically reflected in the client, no need to "re-download" the
application. Events are transmitted when required only so network
usage is minimized. It is also possible to establish triggering
events to further reduce network usage. Since the protocol used is
HTTP (which is stateless), the database framework I am creating will
be responsible to maintain the state of connections, variables, locks
and session information, so the developer don't need to worry about it.
The framework will have many layers, from communication up to
application so there will be pre-built functions to handle queries,
pagination, lock, mail, log, etc. The final objective is to have a
rich client application integrated into the database with minimum
programming and maintenance requirements, not forgetting customization
capabilities. Below is a very small example of what can de done. A
desktop with two windows, each window with two fields, a button with an
image to switch the values, and events to convert the typed text when
leaving the field or double-clicking it. The "leave" event also has an
optimization to only be triggered when the text changes. I am still
developing the framework and adjusting the renderer but I think that all
technical barriers were transposed by now. The framework is still in
the early stages, my guess is that only 5% is done so far. As a future
development even an IDE can be created so we have a graphical environment
do develop applications. I am willing to share this with the PL/SQL
community and listen to ideas and comments.
Example:
create or replace procedure demo1 (
jre_version in varchar2 := '1.4.2_01',
debug_info in varchar2 := 'false',
compress_buffer in varchar2 := 'false',
optimize_buffer in varchar2 := 'true'
) as
begin
interface.initialize('demo1_init','JGR Demo 1',jre_version,debug_info,compress_buffer,optimize_buffer);
end;
create or replace procedure demo1_init as
begin
toolkit.initialize;
toolkit.create_icon('icon',interface.global_root_url||'img/switch.gif');
toolkit.create_internal_frame('frame1','Frame 1',50,50,300,136);
toolkit.create_label('frame1label1','frame1',10,10,50,20,'Field 1');
toolkit.create_label('frame1label2','frame1',10,40,50,20,'Field 2');
toolkit.create_text_field('frame1field1','frame1',50,10,230,20,'Field 1','Field 1',focus_event=>true,mouse_event=>true);
toolkit.create_text_field('frame1field2','frame1',50,40,230,20,'Field 2','Field 2',focus_event=>true,mouse_event=>true);
toolkit.set_text_field_event('frame1field1',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 1','false');
toolkit.set_text_field_event('frame1field2',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 2','false');
toolkit.set_text_field_event('frame1field1',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 1','false');
toolkit.set_text_field_event('frame1field2',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 2','false');
toolkit.create_button('button1','frame1',10,70,100,25,'Switch','Switch the values of "Field 1" and "Field 2"','S','icon');
toolkit.set_button_event('button1',toolkit.action_performed_event,'demo1_switch_fields(''frame1field1'',''frame1field2'')','frame1field1:'||toolkit.get_text_method||',frame1field2:'||toolkit.get_text_method);
toolkit.create_internal_frame('frame2','Frame 2',100,100,300,136);
toolkit.create_label('frame2label1','frame2',10,10,50,20,'Field 1');
toolkit.create_label('frame2label2','frame2',10,40,50,20,'Field 2');
toolkit.create_text_field('frame2field1','frame2',50,10,230,20,'Field 1','Field 1',focus_event=>true,mouse_event=>true);
toolkit.create_text_field('frame2field2','frame2',50,40,230,20,'Field 2','Field 2',focus_event=>true,mouse_event=>true);
toolkit.set_text_field_event('frame2field1',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 1','false');
toolkit.set_text_field_event('frame2field2',toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,'FIELD 2','false');
toolkit.set_text_field_event('frame2field1',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 1','false');
toolkit.set_text_field_event('frame2field2',toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,'field 2','false');
toolkit.create_button('button2','frame2',10,70,100,25,'Switch','Switch the values of "Field 1" and "Field 2"','S','icon');
toolkit.set_button_event('button2',toolkit.action_performed_event,'demo1_switch_fields(''frame2field1'',''frame2field2'')','frame2field1:'||toolkit.get_text_method||',frame2field2:'||toolkit.get_text_method);
end;
create or replace procedure demo1_set_upper as
begin
toolkit.set_string_method(interface.global_object_name,toolkit.set_text_method,upper(interface.array_event_value(1)));
toolkit.set_text_field_event(interface.global_object_name,toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,upper(interface.array_event_value(1)),'false');
end;
create or replace procedure demo1_set_lower as
begin
toolkit.set_string_method(interface.global_object_name,toolkit.set_text_method,lower(interface.array_event_value(1)));
toolkit.set_text_field_event(interface.global_object_name,toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,lower(interface.array_event_value(1)),'false');
end;
create or replace procedure demo1_switch_fields (
field1 in varchar2,
field2 in varchar2
) as
begin
toolkit.set_string_method(field1,toolkit.set_text_method,interface.array_event_value(2));
toolkit.set_string_method(field2,toolkit.set_text_method,interface.array_event_value(1));
toolkit.set_text_field_event(field1,toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,upper(interface.array_event_value(2)),'false');
toolkit.set_text_field_event(field2,toolkit.focus_lost_event,'demo1_set_upper',toolkit.get_text_method,upper(interface.array_event_value(1)),'false');
toolkit.set_text_field_event(field1,toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,lower(interface.array_event_value(2)),'false');
toolkit.set_text_field_event(field2,toolkit.mouse_double_clicked_event,'demo1_set_lower',toolkit.get_text_method,lower(interface.array_event_value(1)),'false');
end;Is it sound like Oracle Portal?
But you want to save a layer 9iAS.
Basically, that was the WebDB.(Oracle changed the name to Portal when version 3.0)
Over all, I agree with you.
>>Having a Oracle database as the central location for all components has many
>>advantages:
>>
>>- Unique point of maintenance, backup and restore
>>- Integrated database security
>>- One language for everything, PL/SQL or Java (even both if desired)
>>- Inherited database cache, transaction and processing optimizations
>>- Direct access to the database dictionary
>>- Application runs on Oracle which has support for many platforms.
>>- Transparent use of parallel processing, clusters and future
>>background technologies
I would like to build 'ZOPE' inside Oracle DB as a back-end
Using Flash MX as front-end.
Thomas Ku. -
How to create a dynamic form with bind variables :schema & :table_name
My application has two LOV's, one to select a schema, and the next to select a table within that schema. I then have a button which passes me to a report which displays the data in that table.schema.
I now want to create a link to a form where I can edit the record based on the rowid of that table.schema, but it doesn't appear that I can create a dynamic form where I pass the schema.table_name and rowid. Is this possible? Can anyone advise how I can do this? The form builder only wants a fixed schema/table name.
Thanks in advance.
Stuart.Hi Stuart,
In this sort of situation, you will need to be a bit creative.
I would suggest a pipeline function called as if it was a report.
Then you can pipe out the required fields.
Since you will have a variable number of fields, you could use two of the multi row field names for your field names and values.
Then after submit, you can create your own procedure to loop through the fields (stored for you in the Apex package) and update the table as required.
Not very specific I'm afraid, but it should work.
Regards
Michael -
How to print a JTable in Java Swing ?
Hi,
I have an application written in java swing.Now I want to write a print module that prints some details.The details includes the JTextArea and JTable that changes in size dynamically.One solution i found is to put them in a panel and print that panel.But it is static.The size of JTable and JTextArea changes, according to the given input.Please give me a solution for this.Printing is a bit of a nightmare, actually. Most of the trouble is layout. Basically a Printable is passed a page number and a graphics context and has to work out what components go on that page and where. It can't depend on the pages being requested in sequence.
You can call getPrintable from a JTable, and you can call that through your own Printable in order to add extra pages. However you can't ask a Printable how many pages it's going to produce, you just have to invoke it and see if it returns a code to say that the page is out of range.
And the Printable JTable generates is very limited, the table has to occupy full pages, you can't tell it to start in a different place on the first page, or find out how much space it's used on the last page. The headers and footers generate JTable's own idea of a page number, not yours.
You can call print() on most Swing components, but you'll need to set their size and location first, and/or mess with the transformation in the graphics context. -
Loading large files in Java Swing GUI
Hello Everyone!
I am trying to load large files(more then 70 MB of xml text) in a Java Swing GUI. I tried several approaches,
1)Byte based loading whith a loop similar to
pane.setText("");
InputStream file_reader = new BufferedInputStream(new FileInputStream
(file));
int BUFFER_SIZE = 4096;
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead;
String line;
while ((bytesRead = file_reader.read(buffer, 0, BUFFER_SIZE)) != -1)
line = new String(buffer, 0, bytesRead);
pane.append(line);
}But this is gives me unacceptable response times for large files and runs out of Java Heap memory.
2) I read in several places that I could load only small chunks of the file at a time and when the user scrolls upwards or downwards the next/previous chunk is loaded , to achieve this I am guessing extensive manipulation for the ScrollBar in the JScrollPane will be needed or adding an external JScrollBar perhaps? Can anyone provide sample code for that approach? (Putting in mind that I am writting code for an editor so I will be needing to interact via clicks and mouse wheel roatation and keyboard buttons and so on...)
If anyone can help me, post sample code or point me to useful links that deal with this issue or with writting code for editors in general I would be very grateful.
Thank you in advance.Hi,
I'm replying to your question from another thread.
To handle large files I used the new IO libary. I'm trying to remember off the top of my head but the classes involved were the RandomAccessFile, FileChannel and MappedByteBuffer. The MappedByteBuffer was the best way for me to read and write to the file.
When opening the file I had to scan through the contents of the file using a swing worker thread and progress monitor. Whilst doing this I indexed the file into managable chunks. I also created a cache to further optimise file access.
In all it worked really well and I was suprised by the performance of the new IO libraries. I remember loading 1GB files and whilst having to wait a few seconds to perform the indexing you wouldn't know that the data for the JList was being retrieved from a file whilst the application was running.
Good Luck,
Martin. -
How to get the index of subform in dynamic Forms??
We are creating a Dynamic Form in which there is a field "PAN number" in a block. With the Script, we are replicating the blocks. Suppose there are 10 blocks (hence 10 PAN number fields will be there) and if the user wants to enter the PAN number in any of the blocks, how can we get the index of the block on which a value has been entered?
Are you sure you are using JTree? (I couldn't find a method named getIndex at all!)
As I couldn't quite understand what you are getting at, one thing that would be helpful is if you refer to "How to use Trees" in The Java Tutorial:
http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html -
Java Swing/AWT and FX is so old school! Give me HTML and CSS for GUI!
Dear Java,
I am a seasoned programmer and I feel it's time JAVA implements a GUI system where it uses HTML and CSS for the GUI. For the love of god just look at the interfaces you can make using HTML and CSS alone. I am a big fan of Java Swing and the recent GUI designer for FX is quite cool. But they are just not as simple as HTML and CSS. And JavaFX has some interesting requirements for the graphics.
I know it is possible to use JavaFX and implement the WebView/WebDriver and make it load a HTML page, etc... but why go through all the trouble?
Just imagine... if you make Java where it has powerful back-end to do what it does best and the HTML/CSS powered GUI on the front-end. It will make the lives of many developers much much easier.
I am not sure whether a Swing designed GUI will be faster than a HTML designed GUI... but if you look at a traditional browser and how fast it renders HTML/CSS, I am sure if Java had a native Form where it uses HTML and CSS to render the GUI, Java will make the dreams of many programmers a reality.
Make it happen!!!!Check this i solve problem just now using this
https://wiki.archlinux.org/index.php/Ja … ow_Manager -
Hi,
I have a pretty difficult problem that I don't know how to solve using struts. I need to generate dynamic surveys from a database. The structure of the survey can be different for every different user. I really want to use the struts Form classes but I'm not sure how to do this. The only way I can think of is messy...
For every new type of survey generated from the database...
1. Generate a new class definition for the struts Form object and compile that.
2. Every struts Action class that interacts with the new dynamic Form classes will need to use reflection on the dynamic Form object to be able to pull all of the data from that form.
I'm sure there are many web sites where forms are dynamically generated and I would think this problem has already been solved. Does anyone out there have any ideas?Try to follow this way:
1 provide actions chain in your configuration file like this:
<form-bean
name="addFlatForm"
type="app.owner.forms.AddFlatForm">
</form-bean>
<action
path="/InitAddFlatForm"
type="app.owner.actions.InitAddFlatFormAction"
attribute="addFlatForm"
validate="false"
parameter="owner.extendedplace;place;/pages/AddFlat.jsp">
</action>
<!-- "/pages/AddFlat.jsp" - jsp page with html:form on it-->
<action
path="/AddFlatForm"
type="app.owner.actions.AddFlatAction"
name="addFlatForm"
validate="true"
input="/pages/AddFlat.jsp">
<forward
name="success"
path="/shortinfo/Welcome.do"></forward>
</action>2 first action(InitAddFlatFormAction) will be "prepare" action, where you must create new instance of the ActionForm descendant with Map, List, array etc definition. where your dynamic fields will be located , and fill the keys value from your database.
public class InitAddFlatFormAction extends Action{
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
//obtain parameters
String[] params = ActionHelper.parseParameter(mapping, 3, Constants.PARAMETER_SEPARATOR);
//get extended place from session attribute
ExtendedPlace currPlace = (ExtendedPlace)ServletUtils.getAttribute(
request, params[0], ServletUtils.SESSION_SCOPE);
//create form if form == null
if (form == null) {
System.out.println("InitAddFlatFormAction::execute method: create new instance of action form.");
//create new form instance
form = new AddFlatForm(new HashMap<String, Object>());
//set form to selected scope attribute
if ("request".equals(mapping.getScope()))
ServletUtils.setAttribute(request,
form, mapping.getAttribute(), ServletUtils.REQUEST_SCOPE); //just set the value to selected scope
else
ServletUtils.setAttribute(request,
form, mapping.getAttribute(), ServletUtils.SESSION_SCOPE); //just set the value to selected scope
//fill the form
AddFlatForm flatForm = (AddFlatForm) form;
flatForm.setValue(params[1], currPlace);
return URIUtils.forwardAction(params[2]);
}3 second action(AddFlatAction) will be "process" action. This action can be used when your data are successful validated.
//any your actions4 form bean(ActionForm desctndant)
public class AddFlatForm extends ActionForm{
public AddFlatForm(Map<String, Object> map){
super();
//check input arguments
AssertHelper.notNullIllArg(map);
setMap(map);
private Map<String, Object> map = null;
public void setMap(Map<String, Object> map) {
this.map = map;
public Map<String, Object> getMap() {
return this.map;
public void setValue(String key, Object value){
getMap().put(key,value);
public Object getValue(String key){
return getMap().get(key);
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
return (null);
}And than in your jsp page you can use something like this:
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="placeId">
<bean:write name="extPlace" property="placeInfo.id"/>
</c:set>
<c:set var="groupId">
<bean:write name="groups" property="filterGroupInfo.id"/>
</c:set>
<c:set var="filterId">
<bean:write name="filters" property="filter.id"/>
</c:set>
<bean:message name="filters" property="filter.filterDescription"/>
<html:text property="value(${placeId};${groupId};${filterId})"/> Something like this are displayed in struts-example.war (example application for struts1.1)
pay attention for classes
EditRegistrationAction.java and SaveRegistrationAction.java
sorry for bad english... :)
Maybe you are looking for
-
Itunes 7 won't show songs when Ipod is plugged in.
I used to just plug in my ipod on the old Itunes, click on the "manage manually" button and be able to look at and play (through my computer) all of the songs on my IPOD (My home computer is a separate laptop) So I downloaded Itunes 7 and when I plug
-
For loop in validation not working
Hi, I am trying to put validation on a tabularform, such that column1 is not greaterthan column2 value. begin apex_application.debug('start check'); for i in 1..3 loop apex_application.debug('i='||i); if apex_application.g_f05(i) < apex_application.g
-
[SOLVED] Warning errors after installing Blender. Bad desktop entries?
Any idea what these errors mean exactly and how to fix them? update desktop mime database... Warning in file "/usr/share/applications/Thunar-folder-handler.desktop": usage of MIME type "x-directory/normal" is discouraged ("x-directory" is an old medi
-
PowerPivot - SP2013 - Cannot create the service instance because the parent Service does not exist
Unable to setup PowerPivot using PowerPivot configuration tool. I have One server which has SQL 2012 SP1 and SP2013. The farm is configured with all service applications. SQL has default instance with DB Engine and SSAS Tabular. Reporting Services ha
-
Prelude and coda with JSP documents
Hello. I have problems with adding prelude and coda templates to JSP documents (XML-format JSP). This is content of my web.xml: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" xmlns:xsi="htt