XYlayout
I am using XYlayout in my code.
I am importing it from
import com.borland.jbcl.layout.*;
But when I am executing my code I am getting this error.
"package com.borland.jbcl.layout does not exist"
SO what I have to do to overcome this problem....
JBCL has been deprecated by Borland.
It is still available for backwards compatibilitybut
has to be manually enabled inside JBuilder inorder
for it to be available to your project (and to be
included in your completed application).
How do I do this?read Teh Docs ™ - or don't do it. JBCL is a proprietary library, you're best off avoiding it. yet another reason people shouldn't use an IDE right away :-)
Similar Messages
-
hey guys, i have created an applet and it is unable to find oracle.jdeveloper.layout.XYLayout. How might I add this to my jar to be able to deploy it?
not.
Figure out what jar it's in, and add that jar to the classpath for the applet (and thus to the webserver in a location where the applet can load it from).
See the documentation to figure out how to set an applet classpath. -
Hi everyone,
i developed an application using XYLayout and deployed it to a jar file. But whenever i start to jar file i get an error message saying "java.lang.NoClassDefFoundError: oracle/jdeveloper/layout/XYLayout". Where can i find the xylayout classes or what can i do to include them in the jar file?
Thanks!Hi,
add jdev-rt.jar from jdev\lib to your deployment (at least for dependency checking)
Frank -
XYlayout don't work with Java web start
I have created a simple application that display a 2 form, the second form
use oracle XYLayout. so far it works fine, than I put the application as
a Java web start, however I got an error message saying
Java Web Start Console, started Sun Mar 09 22:40:41 GMT+04:00 2003
Java 2 Runtime Environment: Version 1.3.0_02 by Sun Microsystems Inc.
Exception occurred during event dispatching:
java.lang.NoClassDefFoundError: oracle/jdeveloper/layout/XYLayout
at
om.net.omantel.pass.ui.registration.FillInfermation.<init>(FillInfermation.java:
28)
at
om.net.omantel.pass.ui.registration.CreateNewAccount.jButton1_mouseClicked(Creat
eNewAccount.java:447)
I'm sure I added the jdev-rt.jar to the Java web start jar file.
my JNLP file is as follows
<?xml version = '1.0' encoding = 'utf-8'?>
<jnlp spec="1.0+" codebase="http://localhost:8888" href="/pas.jnlp">
<information>
<title>Pas Application Sever</title>
<vendor>omantel</vendor>
<homepage href="PAS.html"/>
<description>Test Pas Application Sever</description>
<icon kind="splash" href="/tespic.jpg"/>
</information>
<resources>
<j2se version="1.3" initial-heap-size="64m" />
<jar href="/pass.jar" download="lazy" />
<!-- main="true" download="eager" -->
<!-- <nativelib href="/pass.jar"/> -->
</resources>
<application-desc
main-class="om.net.omantel.pass.ui.registration.CreateNewAccount"/>
</jnlp>Hi,
I have been able to solve the problem
I have put my application on seperate tar and
jdev-rt.jar on another tar.
on the jnlp file I change to
<jar href="/om.jar" main="true" download="eager" />
<jar href="/jdev-rt.jar" main="false" download="eager" />
it's working fine now.
Ahmed -
Hi
I got a problem when I was using jbuilder2005.
I designed the user interface using XYLayout that comes with jbuilder2005. It can run within jbuilder2005 and everything looks good.
But once I run this program via command line, the error happens like this: java.lang.NoClassDefFoundError:com/borland/jbcl/layout/XYLayout
The jbcl.jar that is including the class above has been added into the classpath.
Can anyone help me solve this problem?
Thanks.Hi
the stuff is here:
07/19/2005 02:04p 1,244 test.java
1 File(s) 1,244 bytes
2 Dir(s) 24,927,993,856 bytes free
C:\test\src>javac test.java
test.java:4: package com.borland.jbcl.layout does not exist
import com.borland.jbcl.layout.XYLayout;
^
test.java:5: package com.borland.jbcl.layout does not exist
import com.borland.jbcl.layout.*;
^
test.java:22: cannot find symbol
symbol : class XYLayout
location: class test
XYLayout xYLayout1 = new XYLayout();
^
test.java:22: cannot find symbol
symbol : class XYLayout
location: class test
XYLayout xYLayout1 = new XYLayout();
^
test.java:40: cannot find symbol
symbol : class XYConstraints
location: class test
this.getContentPane().add(jButton1, new XYConstraints(11, 39, 154, 46));
^
test.java:42: cannot find symbol
symbol : class XYConstraints
location: class test
new XYConstraints(37, 118, 232, 45));
^
6 errors
And once I executed the .class file like this:
C:\test\classes>java -classpath . test
Exception in thread "main" java.lang.NoClassDefFoundError: com/borland/jbcl/layo
ut/XYLayout
at test.<init>(test.java:22)
at test.main(test.java:46)
I checked the jbcl package, and all the classes are in there.
Thanks for your help. -
File and FileInputStream problem
Hi all
I have downloaded from developpez.com a sample code to zip files. I modified it a bit to suit with my needs, and when I launched it, there was an exception. So I commented all the lines except for the first executable one; and when it succeeds then I uncomment the next executable line; and so on. When I arrived at the FileInputStream line , the exception raised. When I looked at the code, it seemed normal. So I want help how to solve it. Here is the code with the last executable line uncommented, and the exception stack :
// Copyright (c) 2001
package pack_zip;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import oracle.jdeveloper.layout.*;
import java.io.*;
import java.util.*;
import java.util.zip.*;
import java.text.*;
* A Swing-based top level window class.
* <P>
* @author a
public class fzip extends JFrame implements ActionListener{
JPanel jPanel1 = new JPanel();
XYLayout xYLayout1 = new XYLayout();
JTextField szdir = new JTextField();
JButton btn = new JButton();
JButton bzip = new JButton();
* Taille générique du tampon en lecture et écriture
static final int BUFFER = 2048;
* Constructs a new instance.
public fzip() {
super("Test zip");
try {
jbInit();
catch (Exception e) {
e.printStackTrace();
* Initializes the state of this instance.
private void jbInit() throws Exception {
this.getContentPane().setLayout(xYLayout1);
this.setSize(new Dimension(400, 300));
btn.setText("btn");
btn.setActionCommand("browse");
btn.setLabel("Browse ...");
btn.setFont(new Font("Dialog", 0, 14));
bzip.setText("bzip");
bzip.setActionCommand("zipper");
bzip.setLabel("Zipper");
bzip.setFont(new Font("Dialog", 0, 14));
btn.addActionListener(this);
bzip.addActionListener(this);
bzip.setEnabled(false);
this.getContentPane().add(jPanel1, new XYConstraints(0, 0, -1, -1));
this.getContentPane().add(szdir, new XYConstraints(23, 28, 252, 35));
this.getContentPane().add(btn, new XYConstraints(279, 28, 103, 38));
this.getContentPane().add(bzip, new XYConstraints(128, 71, 103, 38));
public void actionPerformed(ActionEvent e)
if(e.getActionCommand() == "browse")
FileDialog fd = new FileDialog(this);
fd.setVisible(true);
szdir.setText(fd.getDirectory());
bzip.setEnabled(true);
else
* Compression
try {
// création d'un flux d'écriture sur fichier
FileOutputStream dest = new FileOutputStream("Test_archive.zip");
// calcul du checksum : Adler32 (plus rapide) ou CRC32
CheckedOutputStream checksum = new CheckedOutputStream(dest, new Adler32());
// création d'un buffer d'écriture
BufferedOutputStream buff = new BufferedOutputStream(checksum);
// création d'un flux d'écriture Zip
ZipOutputStream out = new ZipOutputStream(buff);
// spécification de la méthode de compression
out.setMethod(ZipOutputStream.DEFLATED);
// spécifier la qualité de la compression 0..9
out.setLevel(Deflater.BEST_COMPRESSION);
// buffer temporaire des données à écriture dans le flux de sortie
byte data[] = new byte[BUFFER];
// extraction de la liste des fichiers du répertoire courant
File f = new File(szdir.getText());
String files[] = f.list();
// pour chacun des fichiers de la liste
for (int i=0; i<files.length; i++) {
// en afficher le nom
System.out.println("Adding: "+files);
// création d'un flux de lecture
FileInputStream fi = new FileInputStream(files[i]);
/* // création d'un tampon de lecture sur ce flux
BufferedInputStream buffi = new BufferedInputStream(fi, BUFFER);
// création d'en entrée Zip pour ce fichier
ZipEntry entry = new ZipEntry(files[i]);
// ajout de cette entrée dans le flux d'écriture de l'archive Zip
out.putNextEntry(entry);
// écriture du fichier par paquet de BUFFER octets
// dans le flux d'écriture
int count;
while((count = buffi.read(data, 0, BUFFER)) != -1) {
out.write(data, 0, count);
// Close the current entry
out.closeEntry();
// fermeture du flux de lecture
buffi.close();*/
/* // fermeture du flux d'écriture
out.close();
buff.close();
checksum.close();
dest.close();
System.out.println("checksum: " + checksum.getChecksum().getValue());*/
// traitement de toute exception
catch(Exception ex) {
ex.printStackTrace();
And here is the error stack :
"D:\jdev32\java1.2\jre\bin\javaw.exe" -mx50m -classpath "D:\jdev32\myclasses;D:\jdev32\lib\jdev-rt.zip;D:\jdev32\jdbc\lib\oracle8.1.7\classes12.zip;D:\jdev32\lib\connectionmanager.zip;D:\jdev32\lib\jbcl2.0.zip;D:\jdev32\lib\jgl3.1.0.jar;D:\jdev32\java1.2\jre\lib\rt.jar" pack_zip.czip
Adding: accueil188.cfm
java.io.FileNotFoundException: accueil188.cfm (Le fichier spécifié est introuvable.
void java.io.FileInputStream.open(java.lang.String)
void java.io.FileInputStream.<init>(java.lang.String)
void pack_zip.fzip.actionPerformed(java.awt.event.ActionEvent)
void javax.swing.AbstractButton.fireActionPerformed(java.awt.event.ActionEvent)
void javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(java.awt.event.ActionEvent)
void javax.swing.DefaultButtonModel.fireActionPerformed(java.awt.event.ActionEvent)
void javax.swing.DefaultButtonModel.setPressed(boolean)
void javax.swing.plaf.basic.BasicButtonListener.mouseReleased(java.awt.event.MouseEvent)
void java.awt.Component.processMouseEvent(java.awt.event.MouseEvent)
void java.awt.Component.processEvent(java.awt.AWTEvent)
void java.awt.Container.processEvent(java.awt.AWTEvent)
void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
void java.awt.LightweightDispatcher.retargetMouseEvent(java.awt.Component, int, java.awt.event.MouseEvent)
boolean java.awt.LightweightDispatcher.processMouseEvent(java.awt.event.MouseEvent)
boolean java.awt.LightweightDispatcher.dispatchEvent(java.awt.AWTEvent)
void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
void java.awt.Window.dispatchEventImpl(java.awt.AWTEvent)
void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
void java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
boolean java.awt.EventDispatchThread.pumpOneEvent()
void java.awt.EventDispatchThread.pumpEvents(java.awt.Conditional)
void java.awt.EventDispatchThread.run()
Thank you very muchOne easy way to send a file through RMI is to read all bytes of a file to a byte array and send this array as a parameter of a remote method. But of course you may have problems with memory when you send large files. The receive is simillary.
Other way is to split the file and getting slices of the file, sending slices and re-assemble at destination. This assume that the file isn't changed through the full transfering is concluded.
I hope these could help you. -
Need help Take out the null values from the ResultSet and Create a XML file
hi,
I wrote something which connects to Database and gets the ResultSet. From that ResultSet I am creating
a XML file. IN my program these are the main two classes Frame1 and ResultSetToXML. ResultSetToXML which
takes ResultSet & Boolean value in its constructor. I am passing the ResultSet and Boolean value
from Frame1 class. I am passing the boolean value to get the null values from the ResultSet and then add those
null values to XML File. When i run the program it works alright and adds the null and not null values to
the file. But when i pass the boolean value to take out the null values it would not take it out and adds
the null and not null values.
Please look at the code i am posing. I am showing step by step where its not adding the null values.
Any help is always appreciated.
Thanks in advance.
============================================================================
Frame1 Class
============
public class Frame1 extends JFrame{
private JPanel contentPane;
private XQuery xQuery1 = new XQuery();
private XYLayout xYLayout1 = new XYLayout();
public Document doc;
private JButton jButton2 = new JButton();
private Connection con;
private Statement stmt;
private ResultSetToXML rstx;
//Construct the frame
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
catch(Exception e) {
e.printStackTrace();
//Component initialization
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
xQuery1.setSql("");
xQuery1.setUrl("jdbc:odbc:SCANODBC");
xQuery1.setUserName("SYSDBA");
xQuery1.setPassword("masterkey");
xQuery1.setDriver("sun.jdbc.odbc.JdbcOdbcDriver");
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
xQuery1.setSql("Select * from Pinfo where pid=2 or pid=4");
jButton2.setText("Get XML from DB");
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
catch(java.lang.ClassNotFoundException ex) {
System.err.print("ClassNotFoundException: ");
System.err.println(ex.getMessage());
try {
con = DriverManager.getConnection("jdbc:odbc:SCANODBC","SYSDBA", "masterkey");
stmt = con.createStatement();
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton2_actionPerformed(e);
contentPane.add(jButton2, new XYConstraints(126, 113, -1, -1));
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
void jButton2_actionPerformed(ActionEvent e) {
try{
OutputStream out;
XMLOutputter outputter;
Element root;
org.jdom.Document doc;
root = new Element("PINFO");
String query = "SELECT * FROM PINFO WHERE PID=2 OR PID=4";
ResultSet rs = stmt.executeQuery(query);
/*===========This is where i am passing the ResultSet and boolean=======
===========value to either add the null or not null values in the file======*/
rstx = new ResultSetToXML(rs,true);
} //end of try
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
======================================================================================
ResultSetToXML class
====================
public class ResultSetToXML {
private OutputStream out;
private Element root;
private XMLOutputter outputter;
private Document doc;
// Constructor
public ResultSetToXML(ResultSet rs, boolean checkifnull){
try{
String tagname="";
String tagvalue="";
root = new Element("pinfo");
while (rs.next()){
Element users = new Element("Record");
for(int i=1;i<=rs.getMetaData().getColumnCount(); ++i){
tagname= rs.getMetaData().getColumnName(i);
tagvalue=rs.getString(i);
System.out.println(tagname);
System.out.println(tagvalue);
/*============if the boolean value is false it adds the null and not
null value to the file =====================*/
/*============else it checks if the value is null or the length is
less than 0 and does the else clause in the if(checkifnull)===*/
if(checkifnull){
if((tagvalue == null) || tagvalue.length() < 0 ){
users.addContent((new Element(tagname).setText(tagvalue)));
else{
users.addContent((new Element(tagname).setText(tagvalue)));
else{
users.addContent((new Element(tagname).setText(tagvalue)));
root.addContent(users);
out=new FileOutputStream("c:/XMLFile.xml");
doc = new Document(root);
outputter = new XMLOutputter();
outputter.output(doc,out);
catch(IOException ioe){
System.out.println(ioe);
catch(SQLException sqle){Can someone please help me with this problem
Thanks. -
"AWT-EventQueue-0" java.lang.NullPointerException and JInternalFrame
I have two classes one with main method second with GUI methods (JFrame, JInternalFrame). When I call method to start second JInternalFrame from main everything is working but if i call it form any other method i get:
Exception in thread "main" java.lang.NullPointerException
at pkg1.GUI.createFrame(GUI.java:123)
at pkg1.GUI.startFrame2(GUI.java:66)
at pkg1.Top.cos(Top.java:25)
at pkg1.Top.main(Top.java:20) My code:
GUI class
package pkg1;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.event.MouseMotionListener;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import oracle.jdeveloper.layout.XYLayout;
public class GUI
public JDesktopPane desktop;
private XYLayout xYLayout1 = new XYLayout();
public int openFrameCount = 0;
JFrame f = new JFrame();
public void GUII() // Prepare JFrame
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(500, 600);
f.setVisible(true);
public void startFrame()
desktop = new JDesktopPane();
createFrame(); //create first "window"
f.setContentPane(desktop);
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
public void startFrame2()
createFrame(); //create second "window"
f.setContentPane(desktop);
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
public void createFrame()
MyInternalFrame frame = new MyInternalFrame();
frame.setVisible(true); //necessary as of 1.3
desktop.add(frame);
frame.add(new GUI2());
} Top class
public class Top
public static void main(String[] args)
GUI g = new GUI();
g.GUII(); //Create JFrame
g.startFrame(); //Create JInternalFrame
Top t = new Top();
t.sth();
public void sth()
GUI gui = new GUI();
gui.startFrame2();
} MyIntternalFrame class
import javax.swing.JInternalFrame;
import java.awt.event.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import oracle.jdeveloper.layout.XYConstraints;
import oracle.jdeveloper.layout.XYLayout;
/* Used by InternalFrameDemo.java. */
public class MyInternalFrame extends JInternalFrame {
static int openFrameCount = 0;
static final int xOffset = 30, yOffset = 30;
private XYLayout xYLayout1 = new XYLayout();
private JButton jButton1 = new JButton();
private JLabel jLabel1 = new JLabel();
private JFrame c = new JFrame();
private JPanel d = new JPanel();
private XYLayout xYLayout2 = new XYLayout();
public MyInternalFrame() {
super("Document #" + (++openFrameCount),true /*resizable*/,true /*closable*/,true /*maximizable*/,true);//iconifiable*/
//...Create the GUI and put it in the window...
//...Then set the window size or call pack...
int width = new GUI2().width + 10;
int height = new GUI2().height + 40;
setSize(width,height);
setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
} Please tel me where is my mistake or maybe you knew another way to open JInternalFrame with public method form another classSome possibly helpful suggestions:
1) Create one JDesktopPane, and do it in the constructor of GUI. You should call this constructor only once.
2) Get rid of GUII. The GUI constructor will do all this and more.
3) Get rid of startFrame and startFrame2.
4) In GUI2, change your width and height to static variables if you are going to use them in outside classes. There is no reason to have to create a GUI2 object just to get those values. Get them from the class, not the instances.
5) You're doing something funky in your Top class with your mixing of static code and non-static code. My gut tells me that Top is just a static universe that exists to get your code up and running, and that the code within it should all be static, but that's just my personal opinion.
6) In MyInternalFrame, get the height and width from GUI2 (if that's what you want to do) again in a static fashion. Rather than new GUI2().width which makes no sense, use GUI2.width.
Why can't you put the button inside of the JInternalFrame object? I believe that the contentPane of this object which may hold your button (unless you embed a jpanel) uses BorderLayout, so you have to take care how you add jcomponents to the jinternalframe (or more precisely, it's contentPane). -
Questions about Using Vector To File And JTable
hi all
I want to write all data from Vector To File and read from file To Vector
And I want To show all data from vector to JTable
Note: I'm using the JBuilder Compiler
This is Class A that my datamember And Methods in it
import java.io.*;
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2008</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
public class A implements Serializable {
int no;
String name;
int age;
public void setA (int n,String na,int a)
no=n;
name=na;
age=a;
public void set_no(int n)
no = n;
public void set_age(int a)
age = a;
public int getage ()
return age;
public void setName(String a)
name = a;
public String getname ()
return name;
public int getno ()
return no;
This is The Frame That the JTextFeild And JButtons & JTable in it
import java.awt.*;
import java.io.*;
import java.util.*;
import com.borland.jbcl.layout.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.table.*;
import javax.swing.border.*;
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2008</p>
* <p>Company: </p>
* @author unascribed
* @version 1.0
public class Frame1 extends JFrame {
/* Vector v = new Vector ();
public int i=0;*/
A a = new A();
XYLayout xYLayout1 = new XYLayout();
JTextField txtno = new JTextField();
JTextField txtname = new JTextField();
JTextField txtage = new JTextField();
JButton add = new JButton();
JButton search = new JButton();
/*JTable jTable1 = new JTable();
TableModel tableModel1 = new MyTableModel(*/
TableModel dataModel = new AbstractTableModel() {
public int getColumnCount() { return 2; }
public int getRowCount() { return 2;}
public Object getValueAt(int row, int col) { return new A(); }
JTable table = new JTable(dataModel);
JScrollPane scrollpane = new JScrollPane(table);
TitledBorder titledBorder1;
TitledBorder titledBorder2;
ObjectInputStream in;
ObjectOutputStream out;
JButton read = new JButton();
public Frame1() {
try {
jbInit();
catch(Exception e) {
e.printStackTrace();
private void jbInit() throws Exception {
titledBorder1 = new TitledBorder(BorderFactory.createEmptyBorder(),"");
titledBorder2 = new TitledBorder("");
this.getContentPane().setLayout(xYLayout1);
add.setBorder(BorderFactory.createRaisedBevelBorder());
add.setNextFocusableComponent(txtno);
add.setMnemonic('0');
add.setText("Add");
add.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
add_actionPerformed(e);
add.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
add_actionPerformed(e);
search.setFocusPainted(false);
search.setText("Search");
search.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
search_actionPerformed(e);
xYLayout1.setWidth(411);
xYLayout1.setHeight(350);
read.setText("Read");
read.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
read_actionPerformed(e);
this.getContentPane().add(txtno, new XYConstraints(43, 35, 115, 23));
this.getContentPane().add(txtname, new XYConstraints(44, 67, 114, 22));
this.getContentPane().add(txtage, new XYConstraints(44, 97, 115, 23));
this.getContentPane().add(add, new XYConstraints(60, 184, 97, 26));
this.getContentPane().add(search, new XYConstraints(167, 185, 88, 24));
this.getContentPane().add(table, new XYConstraints(187, 24, 205, 119));
this.getContentPane().add(read, new XYConstraints(265, 185, 75, 24));
this.setSize(450,250);
table.setGridColor(new Color(0,0,255));
void add_actionPerformed(ActionEvent e)
a.set_no(Integer.parseInt(txtno.getText()));
a.setName(txtname.getText());
a.set_age(Integer.parseInt(txtage.getText()));
fileOutput();
txtno.setText(null);
txtname.setText(null);
txtage.setText(null);
try
out.writeObject(a);
out.close();
}catch (Exception excep){};
/* try
add.setDefaultCapable(true);
v.addElement(new A());
((A)v.elementAt(i)).setA(Integer.parseInt(txtno.getText()),txtname.getText(),Integer.parseInt(txtage.getText()));
JOptionPane.showMessageDialog(null,"The Record is Added");
txtno.setText(null);
txtname.setText(null);
txtage.setText(null);
i++;
}catch (Exception excep){};*/
void search_actionPerformed(ActionEvent e) {
int n = Integer.parseInt(JOptionPane.showInputDialog("Enter No:"));
for (int i=0;i<v.size();i++)
if (((A)v.elementAt(i)).getno()==n)
txtno.setText(Integer.toString(((A)v.elementAt(i)).getno()));
txtname.setText(((A)v.elementAt(i)).getname() );
txtage.setText(Integer.toString(((A)v.elementAt(i)).getage()));
public void fileOutput()
try
out = new ObjectOutputStream(new FileOutputStream("c:\\UserData.txt",true));
}catch(Exception excep){};
public void fileInput()
try
in = new ObjectInputStream(new FileInputStream("c:\\UserData.txt"));
}catch(Exception excep){};
void read_actionPerformed(ActionEvent e) {
fileInput();
try
a = (A)in.readObject();
txtno.setText(Integer.toString(a.getno()));
txtname.setText(a.getname());
txtage.setText(Integer.toString(a.getage()));
}catch (Exception excep){};
}//program which copies string data between vector and file
import java.util.*;
import java.io.*;
class Util
private Vector v;
private FileReader filereader;
private FileWriter filewriter;
Util(String data[])throws Exception
v=new Vector();
for(String o:data)
v.add(o);
public void listData()throws Exception
int size=v.size();
for(int i=0;i<size;i++)
System.out.println(v.get(i));
public void copyToFile(String data,String fname)throws Exception
filewriter =new FileWriter(fname);
filewriter.write(data);
filewriter.flush();
System.out.println("Vector content copied into file..."+fname);
public void copyFromFile(String fname)throws Exception
filereader=new FileReader(fname);
char fcont[]=new char[(int)new File(fname).length()];
filereader.read(fcont,0,fcont.length);
String temp=new String(fcont);
String fdata[]=temp.substring(1,temp.length()-1).split(",");
for(String s:fdata)
v.add(s.trim());
System.out.println("File content copied into Vector...");
public String getData()throws Exception
return(v.toString());
class TestUtil
public static void main(String a[])throws Exception
String arr[]={"siva","rama","krishna"};
Util util=new Util(arr);
System.out.println("before copy from file...");
util.listData();
String fname=System.getProperty("user.home")+"\\"+"vecdata";
util.copyToFile(util.getData(),fname);
util.copyFromFile(fname);
System.out.println("after copy from file...");
util.listData();
} -
Hi all, I am currently writing a program which should allow me to add, delete, search and edit database records. What i would like to do is to click one of the six buttons on the toolbar and it to lauch a form within an internal frame. I have had a go but a cannot make the frame viewable. If you could help me i would be very grateful. Cheers x
package worldfactfile;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
public class mainScreen extends JFrame implements ActionListener{
JPanel contentPane, panel;
private JDesktopPane theDesktop;
private JButton button1, button2, button3, button4, button5, button6;
BorderLayout borderLayout1 = new BorderLayout();
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
//Construct the frame
public mainScreen() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
catch(Exception e) {
e.printStackTrace();
//Component initialization
private void jbInit() throws Exception {
ImageIcon image1 = new ImageIcon("add.gif");
ImageIcon image2 = new ImageIcon("edit.gif");
ImageIcon image3 = new ImageIcon("delete.gif");
ImageIcon image4 = new ImageIcon("search.gif");
ImageIcon image5 = new ImageIcon("help.gif");
ImageIcon image6 = new ImageIcon("exit.gif");
button1 = new JButton(image1);
button2 = new JButton(image2);
button3 = new JButton(image3);
button4 = new JButton(image4);
button5 = new JButton(image5);
button6 = new JButton(image6);
button1.addActionListener(this);
button6.addActionListener(this);
JToolBar bar = new JToolBar();
bar.add(button1);
bar.add(button2);
bar.add(button3);
bar.add(button4);
bar.add(button5);
bar.add(button6);
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
theDesktop = new JDesktopPane();
contentPane.add("Center", theDesktop);
contentPane.add("South", bar);
this.getContentPane().setBackground(SystemColor.controlText);
this.setSize(new Dimension(950, 750));
this.setTitle("World Fact File");
panel = new JPanel() {
public void paintComponent(Graphics g) {
ImageIcon img = new ImageIcon("globe2.gif");
g.drawImage(img.getImage(), -20, -50, null);
super.paintComponent(g);
panel.setOpaque(false);
contentPane.add(panel);
public void actionPerformed(ActionEvent e){
if(e.getSource() == button6){
System.exit(0);
if(e.getSource() == button1){
JInternalFrame iFrame = new JInternalFrame("My Frame, mine i said", true, true, true, true);
JLabel lb1 = new JLabel("Hey ho...");
iFrame.getContentPane().add(lb1);
iFrame.setSize(new Dimension(200,50));
iFrame.setVisible(true);
theDesktop.add(iFrame);
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}here is ur code, i've modifyed some places. its working now.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class mainScreen extends JFrame implements ActionListener{
JPanel contentPane, panel;
JDesktopPane theDesktop;
JButton button1, button2, button3, button4, button5, button6;
BorderLayout borderLayout1 = new BorderLayout();
//XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
//Construct the frame
public mainScreen() {
button1 = new JButton("One");
button2 = new JButton("Two");
button3 = new JButton("Three");
button4 = new JButton("Four");
button5 = new JButton("Five");
button6 = new JButton("Six");
button1.addActionListener(this);
button6.addActionListener(this);
JToolBar bar = new JToolBar();
bar.add(button1);
bar.add(button2);
bar.add(button3);
bar.add(button4);
bar.add(button5);
bar.add(button6);
//contentPane = (JPanel) this.getContentPane();
panel = new JPanel();
panel.setLayout(borderLayout1);
theDesktop = new JDesktopPane();
panel.add("Center", theDesktop);
panel.add("South", bar);
getContentPane().add(panel);
setSize(new Dimension(950, 750));
setTitle("World Fact File");
setVisible(true);
public void actionPerformed(ActionEvent e){
if(e.getSource() == button6){
System.exit(0);
if(e.getSource() == button1){
JInternalFrame iFrame = new JInternalFrame("My Frame, mine i said", true, true, true, true);
JLabel lb1 = new JLabel("Hey ho...");
iFrame.getContentPane().add(lb1);
iFrame.setSize(new Dimension(200,50));
iFrame.setVisible(true);
theDesktop.add(iFrame);
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
public static void main(String a[]){
mainScreen ms = new mainScreen();
} -
HOW TO: Create a GUI "Hello World"
</p>
This document describes how to create and run a very simple "Hello World"
Java GUI app using JDeveloper. The application will have one button and one
text field. Clicking the button will populate the text field with the message,
"Hello World!"</p>
Creating The New Application
In this section, we will create an application with an empty frame.</p>
<ol>
[*]Choose File | New Workspace.
</li>
[*]Choose File | Save Workspace.
</li>
[*]Enter <TT>HelloGui.jws</tt> as the name for the workspace.
This creates a Workspace called HelloGui. A workspace organizes all the projects
you need to work on at one time.
</li>
[*]Choose File | New Project.
The Project Wizard opens. This wizard will help you create a new project called
HelloGui. A project contains all the files that go together in one "tier"--for
example, all the files belonging to a single Java Application client, or all
the files belonging to an Enterprise Java Bean. Because we are working on
a simple, one-tier application, we will only need one project in our workspace.
</li>
[*]If the Welcome page appears, click Next.
</li>
[*]On the Project Type page, in the What is the Project's Filename?
field, change the filename to <TT>HelloGui.jpr</tt>. Leave the rest of the
path the same.
</li>
[*]Select A Project containing a new... and choose Application
from the dropdown list.
</li>
[*]Click Next.
</li>
[*]On the Project Options page, in the What is the name of the project's
default package field, enter <TT>helloGui</tt>.
</li>
[*]Click Next.
</li>
[*]On the Project Information page, you can enter any information about your
project that you wish.
</li>
[*]Click Finish.
The Application Wizard opens.
</li>
[*]In the Class field, enter <TT>HelloApp</tt>.
</li>
[*]Select the New Empty Frame radio button.
</li>
[*]Click OK.
The Frame Wizard opens.
</li>
[*]In the Class field, enter <TT>HelloFrame</tt>.
</li>
[*]Click OK.
JDeveloper creates an application, <TT>HelloApp</tt>, containing an empty
frame, <TT>HelloFrame</tt>. The source code for these classes appears in the
Navigator, which is the upper left-hand pane in the JDeveloper IDE.
</li>
[*]Choose File | Save All.</li>
</ol>
Adding a Panel to the Frame
In this section, we will now add a panel to the frame. In the next section,
we will add all the other components to this panel.</p>
<ol>
[*]In the Navigator, double-click <TT>HelloFrame.java</tt>.
A viewer opens. This viewer has four tabs at the bottom:
<ul>
[*]Source, the currently active tab, which displays the source code
of the selected class</li>
[*]Design, which invokes a visual layout designer</li>
[*]Class, which invokes an editor for the class' attributes, and
can help you stay JavaBean complient</li>
[*]Doc, which displays the class' JavaDoc
</li>
</ul>
</li>
[*]Click the Design tab.
The viewer now displays a grey square, a graphical mock-up of your frame.
Also, on the right-hand side of your screen, the Property Inspector opens.
This allows you to quickly set attributes and define events for components.
</li>
[*]In the component palette (the tabbed toolbar near the top of your screen),
select the Swing Containers tab.
</li>
[*]Click the blue square (described in rollover text as <TT>JPanel</tt>) and
click on your frame to add the panel.
The Property Inspector now displays attributes of the JPanel.
</li>
[*]In the Property Inspector, click twice inside the box beside the name
field.
</li>
[*]Change the name to mainPanel.
</li>
[*]Click the box beside the layout field.
</li>
[*]Choose XYLayout.
XYLayout is an easy-to-use Layout for prototyping. Later, we will change the
layout to a more portable one.</li>
</ol>
Adding Components to the Panel
In this section, we finish laying out a prototype UI. We will add polish and
portability to the UI later.</p>
<ol>
[*]In the Component Palette, select the Swing tab.
</li>
[*]Select the <TT>JTextField</tt> component, which looks like a text field
with a cursor.
</li>
[*]In your panel, click and drag the cursor to outline the text field.
Don't worry if the text field doesn't have exactly the right size or position.
We will adjust these later.
The Property Inspector now displays attributes of the JTextField.
</li>
[*]In the Property Inspector, change the name (just as you did for the
JPanel) to <TT>displayField</tt>.
</li>
[*]Change the text to nothing (erase the value that is already there).
</li>
[*]In the Component Palette, select the <TT>JButton</tt> component, which looks
like a button being clicked.
</li>
[*]In your panel, click and drag the cursor to outline the button.
The Property Inspector now displays attributes of the JButton.
</li>
[*]In the Property Inspector, change the name and action command
to helloButton.
</li>
[*]Change the text to <TT>Say Hello!</tt>.
</li>
[*]Choose File | Save All.</li>
</ol>
Wiring Up the UI
In this section, we wire the UI so that clicking the button causes "Hello
World!" to display in the text field.</p>
<ol>
[*]In the Property Inspector, select the Events tab.
</li>
[*]Click the box next to the Action Performed field and press the Enter
key.
This creates a method, <TT>helloButton_actionPerformed()</tt>, which will
be invoked when the button is clicked, and displays the source code for the
method stub in the viewer.
</li>
[*]In the viewer, add the following command to the body of the method:
<TT>displayField.setText("Hello World!");</tt>
</li>
[*]Choose File | Save All.</li>
</ol>
Testing the Prototype Application
<ol>
[*]Choose Run | Run "HelloApp".
Your application appears, with a blank text field and a button labeled "Say
Hello!"
</li>
[*]Click the button.
The text "Hello World!" appears in the text field.
</li>
[*]Close your application.</li>
</ol>
Refining the UI
In this section, we polish the UI so that the components have the right size
and alignment, the text in the text field shows up red, and the panel uses the
portable GridBag layout instead of the JDeveloper-specific XYLayout.</p>
<ol>
[*]In the viewer, select the Design tab.
</li>
[*]Select your text field.
</li>
[*]Drag the edges of your text field until it is the size you want.
</li>
[*]Drag the center of the text field until it is the vertical position you
want.
</li>
[*]Right-click the text field and choose Align Center.
This centers your text field horizontally in the frame.
</li>
[*]In the property inspector, click the box next to the foreground field.
</li>
[*]Click the ellipses (...).
A color editor appears.
</li>
[*]Select Red from the dropdown list.
</li>
[*]Click OK.
</li>
[*]On your frame, select your button.
</li>
[*]Drag the right edge of your button until it is the horizontal size you want.
</li>
[*]Select your text field, and multi-select your button by control-clicking
it.
</li>
[*]Right-click your button or text field.
</li>
[*]Choose Same Size Vertical.
This sets the height of all selected components to that of the first selected
component (the text field).
</li>
[*]Right-click your button or text field.
</li>
[*]Choose Align Center.
This aligns the center of all selected components to that of the first selected
component (the text field).
</li>
[*]Select your panel by clicking anywhere on the grey background in the visual
designer.
</li>
[*]In the Property Inspector, click the box beside the layout field.
</li>
[*]Select GridBagLayout from the dropdown list.
</li>
[*]Choose File | Save All.</li>
</ol>
Running the Finished Application From Within JDeveloper
<ol>
[*]Choose Run | Run "HelloApp".
Your application appears, with a blank text field and a button labeled "Say
Hello!"
</li>
[*]Click the button.
The text "Hello World!" appears in the text field, in red.
</li>
[*]Close your application.</li>
</ol>
Deploying the Application to Your File System
<ol>
[*] In the Navigator, right-click <tt>HelloGui.jpr</tt> and choose New Deployment
Profile.
The Deployment Profile Wizard opens.
</li>
[*]If the Welcome page appears, click Next.
</li>
[*]On the Delivery page, select Web Application or Command-Line Application
from the dropdown list, and click Next.
</li>
[*]On the Staging Area page, in the Deployment Destination field, enter
<tt><JDeveloper>/HelloGui</tt>, where <tt><JDeveloper></tt>
is your JDeveloper root directory. Click Next.
</li>
[*]On the Project page, select all the <tt>.java</tt> files and click Next.
</li>
[*]Skip the Archive page and Applet Tags page by clicking Next on each.
</li>
[*]On the Libraries page, shuttle all libraries from the Project Libraries
list to the Deployed Libraries list, and click Next.
</li>
[*]On the Finish page, name the profile <tt>HelloGui.prf</tt>, and click Finish.
</li>
[*]When JDeveloper asks you if you want to deploy now, click Yes.</li>
</ol>
JDeveloper will archive your application files and copy this archive and all
other required libraries to <tt><JDeveloper>/HelloGui</tt>.</p>
Running the Application from the Command Line
<ol>
[*]Open a command-line prompt.
</li>
[*]Enter the following script.
Note: You may want to create a batch file containing this script. Be
sure to replace JDeveloper_Home with your JDeveloper home directory.
<pre>set __CLASSPATH_ROOT_DIR__=JDeveloper_Home\HelloGui
set CLASSPATH="%__CLASSPATH_ROOT_DIR__%\HelloGui.jar"
set CLASSPATH=%CLASSPATH%;"%__CLASSPATH_ROOT_DIR__%\xmlparserv2.jar"
set CLASSPATH=%CLASSPATH%;"%__CLASSPATH_ROOT_DIR__%\classes12.zip"
set CLASSPATH=%CLASSPATH%;"%__CLASSPATH_ROOT_DIR__%\jdev-rt.zip"
set CLASSPATH=%CLASSPATH%;"%__CLASSPATH_ROOT_DIR__%\swingall.jar"
cd JDeveloper_Home\HelloGui
jre -cp %CLASSPATH% helloGui.HelloApp</pre>
</li>
[*]Your application appears, with a blank text field and a button labeled "Say
Hello!"
</li>
[*]Click the button.
The text "Hello World!" appears in the text field, in red.
</li>
[*]Close your application.</li>
</ol>
</p>
</p>
nullHello,
I followed your instruction step by step to make this "Hello World", but when I run it, I got message "cannot find the runable node". What do I miss here? Thanks.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Avrom Faderman ([email protected]):
</p>
This document describes how to create and run a very simple "Hello World"
Java GUI app using JDeveloper. The application will have one button and one
text field. Clicking the button will populate the text field with the message,
"Hello World!"</p>
[b]Creating The New Application
In this section, we will create an application with an empty frame.</p>
<ol>
[*]Choose File | New Workspace.
</li>
[*]Choose File | Save Workspace.
</li>
[*]Enter <TT>HelloGui.jws</tt> as the name for the workspace.
This creates a Workspace called HelloGui. A workspace organizes all the projects
you need to work on at one time.
</li>
[*]Choose File | New Project.
The Project Wizard opens. This wizard will help you create a new project called
HelloGui. A project contains all the files that go together in one "tier"--for
example, all the files belonging to a single Java Application client, or all
the files belonging to an Enterprise Java Bean. Because we are working on
a simple, one-tier application, we will only need one project in our workspace.
</li>
[*]If the Welcome page appears, click Next.
</li>
[*]On the Project Type page, in the What is the Project's Filename?
field, change the filename to <TT>HelloGui.jpr</tt>. Leave the rest of the
path the same.
</li>
[*]Select A Project containing a new... and choose Application
from the dropdown list.
</li>
[*]Click Next.
</li>
[*]On the Project Options page, in the What is the name of the project's
default package field, enter <TT>helloGui</tt>.
</li>
[*]Click Next.
</li>
[*]On the Project Information page, you can enter any information about your
project that you wish.
</li>
[*]Click Finish.
The Application Wizard opens.
</li>
[*]In the Class field, enter <TT>HelloApp</tt>.
</li>
[*]Select the New Empty Frame radio button.
</li>
[*]Click OK.
The Frame Wizard opens.
</li>
[*]In the Class field, enter <TT>HelloFrame</tt>.
</li>
[*]Click OK.
JDeveloper creates an application, <TT>HelloApp</tt>, containing an empty
frame, <TT>HelloFrame</tt>. The source code for these classes appears in the
Navigator, which is the upper left-hand pane in the JDeveloper IDE.
</li>
[*]Choose File | Save All.</li>
</ol>
Adding a Panel to the Frame
In this section, we will now add a panel to the frame. In the next section,
we will add all the other components to this panel.</p>
<ol>
[*]In the Navigator, double-click <TT>HelloFrame.java</tt>.
A viewer opens. This viewer has four tabs at the bottom:
<ul>
[*]Source, the currently active tab, which displays the source code
of the selected class</li>
[*]Design, which invokes a visual layout designer</li>
[*]Class, which invokes an editor for the class' attributes, and
can help you stay JavaBean complient</li>
[*]Doc, which displays the class' JavaDoc
</li>
</ul>
</li>
[*]Click the Design tab.
The viewer now displays a grey square, a graphical mock-up of your frame.
Also, on the right-hand side of your screen, the Property Inspector opens.
This allows you to quickly set attributes and define events for components.
</li>
[*]In the component palette (the tabbed toolbar near the top of your screen),
select the Swing Containers tab.
</li>
[*]Click the blue square (described in rollover text as <TT>JPanel</tt>) and
click on your frame to add the panel.
The Property Inspector now displays attributes of the JPanel.
</li>
[*]In the Property Inspector, click twice inside the box beside the name
field.
</li>
[*]Change the name to mainPanel.
</li>
[*]Click the box beside the layout field.
</li>
[*]Choose XYLayout.
XYLayout is an easy-to-use Layout for prototyping. Later, we will change the
layout to a more portable one.</li>
</ol>
Adding Components to the Panel
In this section, we finish laying out a prototype UI. We will add polish and
portability to the UI later.</p>
<ol>
[*]In the Component Palette, select the Swing tab.
</li>
[*]Select the <TT>JTextField</tt> component, which looks like a text field
with a cursor.
</li>
[*]In your panel, click and drag the cursor to outline the text field.
Don't worry if the text field doesn't have exactly the right size or position.
We will adjust these later.
The Property Inspector now displays attributes of the JTextField.
</li>
[*]In the Property Inspector, change the name (just as you did for the
JPanel) to <TT>displayField</tt>.
</li>
[*]Change the text to nothing (erase the value that is already there).
</li>
[*]In the Component Palette, select the <TT>JButton</tt> component, which looks
like a button being clicked.
</li>
[*]In your panel, click and drag the cursor to outline the button.
The Property Inspector now displays attributes of the JButton.
</li>
[*]In the Property Inspector, change the name and action command
to helloButton.
</li>
[*]Change the text to <TT>Say Hello!</tt>.
</li>
[*]Choose File | Save All.</li>
</ol>
Wiring Up the UI
In this section, we wire the UI so that clicking the button causes "Hello
World!" to display in the text field.</p>
<ol>
[*]In the Property Inspector, select the Events tab.
</li>
[*]Click the box next to the Action Performed field and press the Enter
key.
This creates a method, <TT>helloButton_actionPerformed()</tt>, which will
be invoked when the button is clicked, and displays the source code for the
method stub in the viewer.
</li>
[*]In the viewer, add the following command to the body of the method:
<TT>displayField.setText("Hello World!");</tt>
</li>
[*]Choose File | Save All.</li>
</ol>
Testing the Prototype Application
<ol>
[*]Choose Run | Run "HelloApp".
Your application appears, with a blank text field and a button labeled "Say
Hello!"
</li>
[*]Click the button.
The text "Hello World!" appears in the text field.
</li>
[*]Close your application.</li>
</ol>
Refining the UI
In this section, we polish the UI so that the components have the right size
and alignment, the text in the text field shows up red, and the panel uses the
portable GridBag layout instead of the JDeveloper-specific XYLayout.</p>
<ol>
[*]In the viewer, select the Design tab.
</li>
[*]Select your text field.
</li>
[*]Drag the edges of your text field until it is the size you want.
</li>
[*]Drag the center of the text field until it is the vertical position you
want.
</li>
[*]Right-click the text field and choose Align Center.
This centers your text field horizontally in the frame.
</li>
[*]In the property inspector, click the box next to the foreground field.
</li>
[*]Click the ellipses (...).
A color editor appears.
</li>
[*]Select Red from the dropdown list.
</li>
[*]Click OK.
</li>
[*]On your frame, select your button.
</li>
[*]Drag the right edge of your button until it is the horizontal size you want.
</li>
[*]Select your text field, and multi-select your button by control-clicking
it.
</li>
[*]Right-click your button or text field.
</li>
[*]Choose Same Size Vertical.
This sets the height of all selected components to that of the first selected
component (the text field).
</li>
[*]Right-click your button or text field.
</li>
[*]Choose Align Center.
This aligns the center of all selected components to that of the first selected
component (the text field).
</li>
[*]Select your panel by clicking anywhere on the grey background in the visual
designer.
</li>
[*]In the Property Inspector, click the box beside the layout field.
</li>
[*]Select GridBagLayout from the dropdown list.
</li>
[*]Choose File | Save All.</li>
</ol>
Running the Finished Application From Within JDeveloper
<ol>
[*]Choose Run | Run "HelloApp".
Your application appears, with a blank text field and a button labeled "Say
Hello!"
</li>
[*]Click the button.
The text "Hello World!" appears in the text field, in red.
</li>
[*]Close your application.</li>
</ol>
Deploying the Application to Your File System
<ol>
[*] In the Navigator, right-click <tt>HelloGui.jpr</tt> and choose New Deployment
Profile.
The Deployment Profile Wizard opens.
</li>
[*]If the Welcome page appears, click Next.
</li>
[*]On the Delivery page, select Web Application or Command-Line Application
from the dropdown list, and click Next.
</li>
[*]On the Staging Area page, in the Deployment Destination field, enter
<tt><JDeveloper>/HelloGui</tt>, where <tt><JDeveloper></tt>
is your JDeveloper root directory. Click Next.
</li>
[*]On the Project page, select all the <tt>.java</tt> files and click Next.
</li>
[*]Skip the Archive page and Applet Tags page by clicking Next on each.
</li>
[*]On the Libraries page, shuttle all libraries from the Project Libraries
list to the Deployed Libraries list, and click Next.
</li>
[*]On the Finish page, name the profile <tt>HelloGui.prf</tt>, and click Finish.
</li>
[*]When JDeveloper asks you if you want to deploy now, click Yes.</li>
</ol>
JDeveloper will archive your application files and copy this archive and all
other required libraries to <tt><JDeveloper>/HelloGui</tt>.</p>
Running the Application from the Command Line
<ol>
[*]Open a command-line prompt.
</li>
[*]Enter the following script.
Note: You may want to create a batch file containing this script. Be
sure to replace JDeveloper_Home with your JDeveloper home directory.
<pre>set __CLASSPATH_ROOT_DIR__=JDeveloper_Home\HelloGui
set CLASSPATH="%__CLASSPATH_ROOT_DIR__%\HelloGui.jar"
set CLASSPATH=%CLASSPATH%;"%__CLASSPATH_ROOT_DIR__%\xmlparserv2.jar"
set CLASSPATH=%CLASSPATH%;"%__CLASSPATH_ROOT_DIR__%\classes12.zip"
set CLASSPATH=%CLASSPATH%;"%__CLASSPATH_ROOT_DIR__%\jdev-rt.zip"
set CLASSPATH=%CLASSPATH%;"%__CLASSPATH_ROOT_DIR__%\swingall.jar"
cd JDeveloper_Home\HelloGui
jre -cp %CLASSPATH% helloGui.HelloApp</pre>
</li>
[*]Your application appears, with a blank text field and a button labeled "Say
Hello!"
</li>
[*]Click the button.
The text "Hello World!" appears in the text field, in red.
</li>
[*]Close your application.</li>
</ol>
</p>
</p><HR></BLOCKQUOTE>
null -
How can I control the size of a cell in the GridBagLayout?
Hi,Swing Gurus
I am developing a swing-based program using JBulider5 enterprise.
It seems to me that the GridBagLayout is really a hard nut!
How can I control the size of a cell in the GridBagLayout?
It seems that I cann't control the size of a cell directly.
But how the size of a particular cell is determined when I switch the layout manager from XYLayout to GridBagLayout?
Thx in advance!
Regards,
Justinehi,i have not done what you are asking but there are fields like
COLUMNWIDTH, MINSIZE, MAXGRIDSIZE, PREFEREDSIZE to which you can set the appropriate values and test for your need.hope this helped.bye martian. -
Getting error while running jar file
Hi,
I am getting below error while running the jar file
"Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdeveloper/layout/XYLayout:"
I have created a simple ADF desktop app in which i am displaying the frame.I created the jar from Jdeveloper.
Please help..How do you run the jar file? Take a look at this thread for a possible a solution: Re: deploying a jdeveloper adf application to a desktop
Is the class XYLayout packaged or referenced? Take a look at this thread: XYlayout classes - can I distribute with my code? -
Writing Image in the clipboard to Oracle DB
Hi,
I want to write the image in the clipboard to the Blob am using JDeveloper. Can any1 help me please I am stuck on conversion and writing to Blob.
Very Urgent Please!!!!!!!
Comments: Applet is used to diplay an image present in the clipboard, convert this image into bytes write it to a blob and transfer the blob into Oracle DB
package mypackage1;
import java.applet.Applet;
import javax.swing.JLabel;
import oracle.jdeveloper.layout.XYLayout;
import oracle.jdeveloper.layout.XYConstraints;
import java.awt.datatransfer.*;
import java.awt.image.*;
import java.awt.datatransfer.DataFlavor;
import java.awt.event.*;
import java.io.*;
import java.awt.*;
import javax.swing.*;
import oracle.jdeveloper.layout.OverlayLayout2;
import java.awt.Button;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.Blob;
import java.sql.Statement;
import java.awt.Toolkit;
import java.awt.event.*; //Clipboard
import java.awt.datatransfer.*; //Clipboard
import java.awt.Image;// .image.*; //Clipboard
import java.sql.*;
import java.sql.*;
import java.net.*;
import java.lang.*;
import java.awt.TextField;
import java.awt.Font;
import oracle.sql.BLOB;
public class ClipboardImage extends Applet
Button displayButton = new Button();
Button exitButton = new Button();
JLabel photoLabel = new JLabel();
Panel panel1 = new Panel();
XYLayout xYLayout2 = new XYLayout();
XYLayout xYLayout1 = new XYLayout();
Button submitButton = new Button();
Connection connection = null;
static Image photo;
public byte[] data;
public Blob bl;
TextField Message = new TextField();
public ClipboardImage()
public void init()
try
jbInit();
catch(Exception e)
e.printStackTrace();
public static void main(String[] args)
ClipboardImage applet = new ClipboardImage();
Frame frame = new Frame();
frame.addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
frame.add(applet, BorderLayout.CENTER);
frame.setTitle("Applet Frame");
applet.init();
applet.start();
frame.setSize(300, 300);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
frame.setLocation((d.width - frameSize.width) / 2, (d.height -
frameSize.height) / 2);
frame.setVisible(true);
private void jbInit() throws Exception
this.setLayout(xYLayout2);
this.setBackground(new Color(136, 212, 122));
displayButton.setLabel("Display");
displayButton.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
scanButton_actionPerformed(e);
exitButton.setLabel("Exit");
exitButton.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
exitButton_actionPerformed(e);
photoLabel.setText("Photo");
panel1.setLayout(xYLayout1);
panel1.setBackground(new Color(255, 249, 240));
xYLayout2.setWidth(288);
xYLayout2.setHeight(300);
submitButton.setLabel("Submit");
submitButton.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
submitButton_actionPerformed(e);
Message.setFont(new Font("Abadi MT Condensed", 0, 9));
panel1.add(photoLabel, new XYConstraints(0, 0, 115, 155));
this.add(Message, new XYConstraints(20, 275, 250, 15));
this.add(submitButton, new XYConstraints(105, 220, 80, 30));
this.add(panel1, new XYConstraints(90, 25, 115, 155));
this.add(exitButton, new XYConstraints(195, 220, 85, 30));
this.add(displayButton, new XYConstraints(10, 220, 85, 30));
void exitButton_actionPerformed(ActionEvent e)
System.exit(0);
If an image is on the system clipboard, this method returns it
otherwise it returns null
public static Image getClipboard()
Transferable t =
Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
try
if (t != null && t.isDataFlavorSupported(DataFlavor.imageFlavor))
Image text = (Image)t.getTransferData(DataFlavor.imageFlavor);
photo = text;
return text;
catch (UnsupportedFlavorException e)
catch (IOException e)
return null;
Display an image in the system's clipboard
void scanButton_actionPerformed(ActionEvent e)
Image img = this.getClipboard();
photo = img;
photoLabel.setIcon(new ImageIcon(photo));
// Gives out int array
public int[] fetchPixels(Image image, int width, int height)
int pixMap[] = new int[width*height];
PixelGrabber pg = new PixelGrabber(image, 0,0,width,height, pixMap,
0, width);
try
pg.grabPixels();
catch (InterruptedException e)
return null;
if((pg.status() & ImageObserver.ABORT)!=0)
return null;
return pixMap;
// Here int array given by Pixel Grabber function is converted into
byte array
public byte[] extractData(int[] pixmap, int numbands) {
byte data[] = new byte[pixmap.length*numbands];
for(int i=0;i<pixmap.length;i++){
int pixel = pixmap;
byte a = (byte)((pixel >> 24) & 0xff);
byte r = (byte)((pixel >> 16) & 0xff);
byte g = (byte)((pixel >> 8) & 0xff);
byte b = (byte)((pixel ) & 0xff);
if(numbands == 4){
data[i*numbands+0] = r;
data[i*numbands+1] = g;
data[i*numbands+2]= b;
data[i*numbands+3] = a;
} else {
data[i*numbands+0] = r;
data[i*numbands+1] = g;
data[i*numbands+2]= b;
return data;
public void processData() {
Image awtImage = getClipboard();
int imageWidth = awtImage.getWidth(this);
int imageHeight = awtImage.getHeight(this);
int[] pix = fetchPixels(awtImage, imageWidth, imageHeight);
data = extractData(pix, 4);
photo = awtImage;
System.out.println(" Height = " + imageHeight + " Width = " +
imageWidth + " Pixel = " + pix + " Byte = " + data);
void submitButton_actionPerformed(ActionEvent e)
processData();
try {
System.out.println("Executing code");
// Load the JDBC driver
String driverName = "oracle.jdbc.driver.OracleDriver";
Class.forName(driverName);
// Create a connection to the database
String serverName = "10.20.90.101";
String portNumber = "1521";
String sid = "iasdb";
String url = "jdbc:oracle:thin:@" + serverName + ":" +
portNumber + ":" + sid;
String username = "birmingham";
String password = "in";
connection = DriverManager.getConnection(url, username,
password);
PreparedStatement ast = connection.prepareStatement("INSERT
INTO PASSPORT (PASSID, PHOTO) VALUES (1992, EMPTY_BLOB())");
ast.executeUpdate();
PreparedStatement pst = connection.prepareStatement("UPDATE
PASSPORT SET PHOTO = ? WHERE PASSID = 1992");
//pst.setObject(1, (Object)photo);
//Writing bytes to blob bl
bl.setBytes(0, data);
//Setting the blob to transfer to the blob column in oracle
db
pst.setBlob(1, bl);
pst.executeUpdate(); if(pst.EXECUTE_FAILED == 1)
Message.setText("Sql failed!");
}else{
Message.setText("Sql success!");
System.out.println ("Connected\n");
} catch (ClassNotFoundException ea) {
// Could not find the database driver
} catch (SQLException ea) {
System.out.println(ea.toString());Look at the ArrayListTransferHandler class in the following Drag List Demo example: http://www.java2s.com/Code/Java/Swing-JFC/DragListDemo.htm
-
Number of of lines in af row.
Hi Experts.
I need some help. I'm trying to display JTextAreas in a table using the TableCellRenderer interface. My problem is that I have to display more than one line in each row (I need linewrap). I think the tables cell size prevents the expansion of the JTextArea. I've posted my code and marked the important places:
package box;
import java.applet.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.util.ArrayList;
import javax.swing.table.TableCellRenderer;
public class GUI
extends Applet {
boolean isStandalone = false;
BorderLayout borderLayout1 = new BorderLayout();
JTextField tArea1 = new JTextField();
Label tArea2 = new Label();
JButton jButton1 = new JButton();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JPanel rightPanel = new JPanel();
JPanel leftPanel = new JPanel();
JPanel leftTopPanel = new JPanel();
JPanel leftBotPanel = new JPanel();
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
Thread graphFrame;
dbInterface db = new dbInterface();
Connection dbConn = null;
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
//Construct the applet
public void init() {
int lastValue;
jbInit();
lastValue = db.getLatest(dbConn);
String temp = Integer.toString(lastValue);
showText(temp);
//Component initialization
private void jbInit() {
dbConn = db.dbConnect();
this.setLayout(new XYLayout());
tArea1.setBackground(Color.lightGray);
tArea1.setBorder(null);
tArea1.setDisabledTextColor(Color.white);
tArea1.setText("56");
tArea1.setHorizontalAlignment(JLabel.CENTER);
tArea2.setAlignment(Label.CENTER);
tArea2.setBackground(Color.lightGray);
tArea2.setText("");
tArea2.addMouseListener(new GUI_tArea2_mouseAdapter(this));
jButton1.setText("Set temperature");
jButton1.addMouseListener(new GUI_jButton1_mouseAdapter(this));
jButton1.addActionListener(new GUI_jButton1_actionAdapter(this));
jLabel1.setText("From db");
jLabel2.setText("UI");
String[] columnNames = {"test"};
Object[][] data = {{new JTextArea("Max f sf sf sf a fas f dsf s fds f dsf ds")}, {new JTextArea("test")}};
JTable table = new JTable(data, columnNames);
table.setDefaultRenderer(Object.class, new TableRenderer());
leftPanel.setLayout(new XYLayout());
rightPanel.setLayout(new XYLayout());
leftTopPanel.setLayout(new XYLayout());
leftBotPanel.setLayout(new XYLayout());
rightPanel.add(tArea1, new XYConstraints(50, 50, 30, 20));
rightPanel.add(jLabel1, new XYConstraints(50, 30, -1, -1));
rightPanel.add(jButton1, new XYConstraints(50, 80, 120, 22));
rightPanel.add(tArea2, new XYConstraints(140, 50, 30, 20));
rightPanel.add(jLabel2, new XYConstraints(140, 30, -1, -1));
splitPane.setLeftComponent(leftPanel);
splitPane.setRightComponent(rightPanel);
splitPane.setDividerLocation(150);
splitPane.setDividerSize(6);
JScrollPane scrollPane = new JScrollPane(table);
leftTopPanel.add(scrollPane, new XYConstraints(0,0,149,200));
leftPanel.add(leftTopPanel, new XYConstraints(0, 0, 150,200));
this.add(splitPane, new XYConstraints(0,0,400,300));
private void showText(final String text) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
tArea2.setText(text);
// Check if the new value crosses the specified limits
checkBounds(tArea2);
public void checkBounds(Label tArea2) {
// Parses the value in the tArea2 as an integer
int value = Integer.parseInt(tArea2.getText());
// Check if the limit is passe
if (value > 100) {
tArea2.setBackground(Color.red);
else {
tArea2.setBackground(Color.lightGray);
} class TableRenderer extends JLabel implements TableCellRenderer {
public TableRenderer() {
setOpaque(true);
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column) {
JTextArea textA = (JTextArea) value;
textA.setLineWrap(true);
System.out.println("renderer");
textA.setBackground(Color.red);
return textA;
} public void jButton1_actionPerformed(ActionEvent e) {
String input = tArea1.getText();
showText(input);
public void tArea2_mouseClicked(MouseEvent e) {
this._disable();
graphFrame = new Thread(new graphForm(this));
graphFrame.start();
public void tArea2_mouseEntered(MouseEvent e) {
setCursor(new Cursor(Cursor.HAND_CURSOR));
public void tArea2_mouseExited(MouseEvent e) {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
class GUI_jButton1_actionAdapter
implements ActionListener {
private GUI adaptee;
GUI_jButton1_actionAdapter(GUI adaptee) {
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
class GUI_jButton1_mouseAdapter
extends MouseAdapter {
private GUI adaptee;
GUI_jButton1_mouseAdapter(GUI adaptee) {
this.adaptee = adaptee;
class GUI_tArea2_mouseAdapter
extends MouseAdapter {
private GUI adaptee;
GUI_tArea2_mouseAdapter(GUI adaptee) {
this.adaptee = adaptee;
public void mouseEntered(MouseEvent e) {
adaptee.tArea2_mouseEntered(e);
public void mouseClicked(MouseEvent e) {
adaptee.tArea2_mouseClicked(e);
public void mouseExited(MouseEvent e) {
adaptee.tArea2_mouseExited(e);
}Search the Swing forum. This question has been asked twice in the last couple of days.
Maybe you are looking for
-
I had a free trial of Adobe CC on my mac at home, which I since uninstalled . Later, I purchased on the PC I use at work with a Different email address than home. I have not been able to install at home. When I log in the email address is preprinte
-
My shuffle is not recognized in windows xp
How can I get my shuffle to be recognized in Windows xp?
-
Does Time Machine only work with external HDD's and Networks?
I have a Mac Mini that I just replaced the optical drive with a hard drive. This second HDD is formated into two partitions, with one of them being for my Time Machine backups, the other a media scratch drive. When I try to choose this volume in sett
-
Output Post Processor not coming up
Hi Friends, We have a single node production instance (R12.1.1 with 11.1.0.7) We cloned a test instance from this production instance. Now everything is fine except that the Output post Processor. OPP is not coming up. Also, there are no FNDOPP* logs
-
IPhone 5 crashes after the update 7.1.1
Phones crashes after the update 7.1.1 over wifi in the past I would update the phone over WIFI with no problem now It just WIPES out you're whole entire phone without telling you to back it up first then update. Please give me bring back my Photos,