Creating a user defined control in java using java Beans
Hi,
I want to create a user defined control for drawing a line like a line control which is used in Visual Basic. I have created a program which will be drawing a line in runtime..but i cant use the same program in the beans to act as a user defined control to work as a line control ..b'coz i extend the class with JPanel..so when i drag and drop the control i am getting the panel only...so can u give me some ideas to create the line control...i am attaching the code which i created ...so pls do make some modification or correction to work as a line control....
Thank u in advance..........
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
import javax.swing.event.*;
public class Line extends JPanel
BufferedImage image;
Color color;
Stroke stroke;
Point start = new Point();
Point end = new Point();
public Line()
color = Color.blue;
stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER);
protected void paintComponent(Graphics g)
super.paintComponent(g);
if(image == null)
initImage();
g.drawImage(image, 0, 0, this);
// Draw temp line over image.
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setPaint(Color.red);
g2.drawLine(start.x, start.y, end.x, end.y);
public void setTempPoints(Point p1, Point p2) {
start = p1;
end = p2;
repaint();
public void draw(Point p1, Point p2)
Graphics2D g2 = image.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setPaint(color);
g2.setStroke(stroke);
g2.drawLine(p1.x, p1.y, p2.x, p2.y);
g2.dispose();
start = end;
repaint();
private void clearImage()
Graphics g = image.getGraphics();
g.setColor(getBackground());
g.fillRect(0, 0, image.getWidth(), image.getHeight());
g.dispose();
repaint();
private void initImage()
int w = getWidth();
int h = getHeight();
image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
g2.setPaint(getBackground());
g2.fillRect(0,0,w,h);
g2.dispose();
public static void main(String[] args)
Line wbclient = new Line();
DrawingListener listener = new DrawingListener(wbclient);
wbclient.addMouseListener(listener);
wbclient.addMouseMotionListener(listener);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(wbclient);
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
class DrawingListener extends MouseInputAdapter
Line wbclient;
Point start;
Point end;
final int MIN_DIST = 5;
public DrawingListener(Line fh)
this.wbclient = fh;
public void mousePressed(MouseEvent e)
start = e.getPoint();
public void mouseReleased(MouseEvent e)
end=e.getPoint();
if(start.distance(end) > MIN_DIST)
wbclient.draw(start, end);
public void mouseDragged(MouseEvent e)
wbclient.setTempPoints(start, e.getPoint());
}
%TYPE is PL/SQL syntax, which thus cannot be used inside SQL.
The other way around, SQL can be used inside PL/SQL.
Regards,
K.
Similar Messages
-
Creating a user defined control using java Beans
Hi,
I want to create a user defined control which is used to draw a line ...
same as we using in VB as Line control.In java we will create the component using using Beans . I created a code
which will draw a line in the run time .For tat i extend the class with JPanel,but i cant use the same program in beans....b'coz it simply draws the jpanel when we drag and drop that control in the form....
so can u give me some ideas to create a control which is used to draw a line .....i am attaching the same which i did .....
thank u in advance...
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
import javax.swing.event.*;
public class Line extends JPanel
BufferedImage image;
Color color;
Stroke stroke;
Point start = new Point();
Point end = new Point();
public Line()
color = Color.blue;
stroke = new BasicStroke(1f, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER);
protected void paintComponent(Graphics g)
super.paintComponent(g);
if(image == null)
initImage();
g.drawImage(image, 0, 0, this);
// Draw temp line over image.
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setPaint(Color.red);
g2.drawLine(start.x, start.y, end.x, end.y);
public void setTempPoints(Point p1, Point p2) {
start = p1;
end = p2;
repaint();
public void draw(Point p1, Point p2)
Graphics2D g2 = image.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setPaint(color);
g2.setStroke(stroke);
g2.drawLine(p1.x, p1.y, p2.x, p2.y);
g2.dispose();
start = end;
repaint();
private void clearImage()
Graphics g = image.getGraphics();
g.setColor(getBackground());
g.fillRect(0, 0, image.getWidth(), image.getHeight());
g.dispose();
repaint();
private void initImage()
int w = getWidth();
int h = getHeight();
image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
g2.setPaint(getBackground());
g2.fillRect(0,0,w,h);
g2.dispose();
public static void main(String[] args)
Line wbclient = new Line();
DrawingListener listener = new DrawingListener(wbclient);
wbclient.addMouseListener(listener);
wbclient.addMouseMotionListener(listener);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(wbclient);
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
class DrawingListener extends MouseInputAdapter
Line wbclient;
Point start;
Point end;
final int MIN_DIST = 5;
public DrawingListener(Line fh)
this.wbclient = fh;
public void mousePressed(MouseEvent e)
start = e.getPoint();
public void mouseReleased(MouseEvent e)
end=e.getPoint();
if(start.distance(end) > MIN_DIST)
wbclient.draw(start, end);
public void mouseDragged(MouseEvent e)
wbclient.setTempPoints(start, e.getPoint());
}Hi Ravi,
How about something like this:
IUserMaint user = UMFactory.getUserFactory().newUser("myNewUser");
user.setFirstName("1st Name");
user.setLastName("2nd Name");
user.setEmail("[email protected]");
user.save();
user.commit();
IUserAccount uacc = UMFactory.getUserAccountFactory().newUserAccount("myNewUser", user.getUniqueID());
uacc.setPassword("initial");
uacc.setPasswordChangeRequired(false);
uacc.save();
uacc.commit();
Hope this helps.
Daniel -
User defined function in java for message mapping
I wrote the following user defined function in java for message mapping and mapped vendor with this. The aim of this function is to write a error file at defined path when i send empty Vendor value from File to RFC-Function module BAPI_PO_CREATE. The "err.txt" error file is not written when i execute in TEST but the value "ERROR" is returned to destination Vendor Field.
public String validation(String a, Container container) {
//write your code here
if (a.equals("")) {
try {
String source = "Vendor cannot be empty";
char buffer[] = new char[source.length()];
source.getChars(0, source.length(), buffer, 0);
for (int i = 0; i < buffer.length; i +=2)
f0.write(buffer<i>);
f0.close();
FileWriter f1 = new FileWriter("/10.10.0.55/sapmnt/trans/edixiin/err.txt");
f1.write(buffer);
f1.close();
catch (IOException e) {}
return "ERROR";Hi Senthil,
Check these things :
1) Whether you have permission to create a file in that directory.
2) try giving this
10.10.0.55
sapmnt
trans
edixiin
err.txt
3) Also check for permissions.
Hope this will help you.
Regards
Suraj -
How to create a user defined trigger and execute my form
Hi All,
I am working with oracle Apps r12 and oracle forms 10g.
I have created a custom form. So i need to create a special menu and when the user click the menu it need to open a new block and query it accordingly.
I have followed this link
http://egeapp.egeseramik.com:8000/pls/prod/fndgfm/fnd_help.get/us/fnd/@g_special#g_special
and created a special menu in my custom form
In PRE_FORM trigger i have coded this
APP_SPECIAL.INSTANTIATE('SPECIAL3','&ACTION HISTORY DETAILS',NULL,TRUE,'LINE');
and IN PRE_BLOCK i have coded this
APP_SPECIAL.ENABLE('SPECIAL3',PROPERTY_ON);.
Now the special menu is enabled when i press it shows error
that frm-40700 no such trigger:special3.
Now i came to know that we need to create a user defined trigger put the code and when we press special menu it need to query it accordingly.
Can any one tell the steps that how to do that accordingly.
Thanks & regards
SrikkanthHi ,
The problem is fixed, the link mentioned below might be use full for doing this.
http://docs.oracle.com/cd/E18727_01/doc.121/e12897/T302934T457083.htm
regards
Srikkanth -
How to create windows users and groups from Java
Hi,
Can any one please tell me, which Package/API will helps to create windows users and groups from Java.
Thanks,
M.Prem.You can't do it with pure Java, and it's not in the core API. You'd have to write a native function to do it, using whatever API Windows provides, and then call it with JNI. Or look for a third party native-based Java library that already does that.
-
How to create a user defined type base on existing table
Hi Everyone,
Are there any way to create a user defined type base on existing table us as :
CREATE OR REPLACE Type MyTable Is Table Of PART%ROWTYPE;
where Part is a table.
Regards,
JDangHi JDAng,
Can't be done. %ROWTYPE is a PL/SQL construct, and as such cannot be used in SQL.
Regards
Peter -
How do you create a user defined functions UDF and passing a value like a ID to GEt a Value.
How do you create a user defined functions UDF and passing a
value like a ID to GEt a Value.
using a query.
are there example.
Thankstons of examples at cflib.org - good place to start, even
though many
udfs there are a bit outdated in their code...
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com -
Create a user defined approval query
anybody can help me whitch syntax i have to use to create a user defined query for an approval template please?
for Exp: i want to create a query to check if a the customer in an invoice ="C0001"
so select distinct 'true' where ????(current invoice customercode)="C0001"
10xHi.......
Try This......
Select Distinct 'True' From OCRD T0 where T0.CardCode='C0001' and T0.CardCode=$[OINV.CardCode.0]
Hope this will solve the problem......
Reagards,
Rahul -
Syntax error when creating a user-defined table type in SQL Server 2012
Why am I getting a syntax error when creating a user-defined table type in SQL Server 2014?
CREATE TYPE ReportsTableType AS TABLE
( reportId INT
, questionId INT
, questionOrder INT );
Results:
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'AS'.Hope these posts could help,
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/37a45a9a-ed8c-4655-be93-f6e6d5ef44be/getting-incorrect-syntax-while-creating-a-table-type-in-sql-server-2008-r2?forum=transactsql
Regards, Dineshkumar,
Please Mark as Answer if my post answers your question and
Vote as Helpful if it helps you -
How to to create new user in Azure AD by using C# programming manually
Hi
I am using MVC 5 with Azure AD.
I want to create new user in Azure AD by using C# programming manually, I don't want to configure it.
Suppose I have an application where We have an option to create new user, so how we can write program for it.
Thanks in advance!!Hello,
Microsoft Azure forums are over here:
https://social.msdn.microsoft.com/forums/azure/en-US/home
Karl
When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
My Blog: Unlock PowerShell
My Book:
Windows PowerShell 2.0 Bible
My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}}) -
Replace VBX Control with Java Bean
Hi All,
While compiling 6i forms in 10g I got this error of VBX Control (Obsolete)
The document says replace it with JavaBeans.
I don’t know how to replace a VBS Control with Java Bean but this is what I did, I selected the item type as Bean Area.
But the item do have a trigger
begin
control_lib.when_tab_changed(:control.tab_ctl)
end
The Package CONTROL_LIB is coded as below.
Will this code work, technically I think yes, but its always better to ask experts before I move this to test...
package body control_lib is
g_tab_id number := 0
procedure when_tab_changed
(p_tab_id number) is
l_err_txt varchar2(255);
begin
if :system.block_status != 'QUERY' then
if not good_quiet_post(l_err_txt) then
raise form_trigger_failure;
end if
end if
if p_tab_id = 0 then
rpt_ln_lib.new_tab;
elsif p_tab_id = 1 then
stat_lib.new_tab;
elsif p_tab_id = 2 then
per_acc_rl_lib.new_tab;
end if
g_tab_id := p_tab_id
exception
when form_trigger_failure then
:control.tab_ctl := g_tab_id
synchronize
end when_tab_changed
Thanks to all.
HabeebA Java bean is another technology than VBX control.
If some document says: Replace it with java bean it certainly means to use a similar java bean with a similar functionality.
I do not know a java bean, which runs VBX controls.
So you surely have to look at what yout VBX does an than to look after a proper java bean (or to write an own one). -
Is it possible to create user defined control in labview
in .net we can create user defined contol in which i can put more then one control and,, can use it as single control when needed,, but,, how this possible in labview,,
actually in my program i have a tab control and,, in that tab control there are 8 pages,, now there are 5 different kind option selection for each page lets say "a" "b" "c" "d" "e",,,,,.,. so,, when i select "a" configuration for tabpage 1 should show.. "a"(control collection) on tabpage1....and,, same should b possible for all 8 pages............................. this can possible if its possible to create user defined contorl in labview
while in .net its very easy task i m confused here,..,.
i put these controls in another 5 different VI,,,, and tried to call in subpanel but,, i dont find the solution,,,
Attachments:
tabcontrol.vi 1 KBHi,
I've tried to open you attachment but LabVIEW tells me it's not a vi... could you check it and repost please ?
I'm not really sure of what you need but you CAN customize you control in LabVIEW, it is not hard, you just have to know how it works
Sometimes being good at another programation language confuse you more than it helps because you try to do as you are used to... the difficulty it to "translate" functions from a language to another.
I do know how frustrating it can be when you think "Damned, it would take me only 5 minutes to do that with language a and after 10 hours with language b it is still not working "
You have to get in LabVIEW way of thinking, I wish you good luck !
A quick exemple... this might not do exactly what you need but it may help you anyway.
When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"
Attachments:
exemple.vi 55 KB -
Error creating a user defined report in the grid control
I am trying to create a simple User Defined report in the Grid OEM
Under the 'Elements' tab I have a 'Type' - 'Database Table from SQL'
And I have this 'Statement' - SELECT * FROM SYS.DBA_USERS
When I Click the 'Preview' button I get this error.
Error rendering element. Exception: ORA-00942: table or view does not exist
I'm logged on as SYSTEM.
Isn't the SYS.DBA_USERS table accessible by SYSTEM?
Any advice on what I'm doing wrong/
Edited by: bfee_sdc on Oct 19, 2010 9:12 AMWhat are the tricks?
It has to be some what supported since I found this somewhere in an Oracle note...
How to create custom reports on tables other than mgmt* views.
To create reports on other tables, grant permissions to MGMT_VIEW user as MGMT_VIEW is responsible for creating reports in grid control
SQL> GRANT SELECT on SYSMAN.<table_name> to MGMT_VIEW;
And then create the reports in the reporting framework referencing SYSMAN.<table_name> in the query.
I tried GRANT SELECT on SYS.DBA_USERS to MGNT_VIEW but this did not work. -
How to provide value to a User Defined field thru java code
I am using OIM 11.1.1.5.
I have a user defined field called Unique-Customer-Number. This field need to be pre-populated during user creation (using OIM Web UI) and the value comes from a java code.
Can any of you tell me the high level steps to implement this.
Thanks!
KabiThanks Rajiv,
I just followed everything on metalink 1262803.1. My console shows the followings during Metadata import.
weblogicImportMetadata.bat :-
Starting import metadata script ....
Please enter your username :weblogic
Please enter your password :
Please enter your server URL [t3://localhost:7001] :t3://10.10.99.99:7001
Connecting to t3://10.10.99.99:7001 with userid weblogic ...
Successfully connected to Admin Server 'adm_server01' that belongs to domain 'server01'.
Warning: An insecure protocol was used to connect to the server. To ensure on-the-wire security, the SSL port or Admin port should be used instead.
Location changed to domainRuntime tree. This is a read-only tree with DomainMBean as the root.For more help, use help(domainRuntime)
Disconnected from weblogic server: adm_eimsdv1s01
End of importing metadata script ...
Exiting WebLogic Scripting Tool.
How I will I know that my plugin/ event-Handler is registered successfully. Is there any screen where I can see all registered plugins ? -
Creating a user-defined field in VL06
Dear all ,
Please guide me how to add few user defined fields in the output list of standard VL06 transaction code - (Delivery Monitor Report - WS_DELIVERY_MONITOR) - I have to add in the option of 'List Outbound deliveries' -
Pls revert.
Thanks in Advance.
P.G.RHai
Follow the bellow steps for creating User Defined Field Exit
Step by step procedure for creating Field Exits
There are eight steps to creating a field exit:
Step 1: Determine Data Element
Step 2: Go To Field Exit Transaction
Step 3: Create Field Exit
Step 4: Create Function Module
Step 5: Code Function Module
Step 6: Activate Function Module
Step 7: Assign Program/Screen
Step 8: Activate Field Exit
Step 1: Determine Data Element
- Before you can begin adding the functionality for a field exit, you must know the corresponding data element.
- An easy way to determine the data element associated to a particular screen field is to:
Go the appropriate screen.
Position the cursor in the appropriate field.
Press F1 for field-level help.
Click on the Technical info pushbutton (or press F9) on the help dialog box.
On this Technical Information dialog box, the data element will be specified if the field is 'painted' from the ABAP/4 Dictionary.
Step 2: Go To Field Exit Transaction
- The transaction to create field exits is CMOD.
- You can use the menu path Tools -> ABAP/4 Workbench -> Utilities -> Enhancements -> Project management.
- From the initial screen of transaction CMOD, choose the Text enhancements -> Field exits menu path.
- After choosing this menu path, you will be taken to the field exits screen. From here, you can create a field exit.
NOTE : Even though you use transaction CMOD to maintain field exits, you do not need to create a project to activate field exits.
Step 3: Create Field Exit
- From the field exit screen of transaction CMOD, choose the Field exit -> Create menu path.
- After choosing this menu path, a dialog box will prompt you for the appropriate data element .
- Enter the data element name and click the Continue pushbutton.
- Now, you will be able to create the function module associated to the data elements field exit.
Step 4: Create Function Module
- You will automatically be taken to the Function Library (SE37) after entering a data element name and clicking the Continue pushbutton.
- In the Function module field, a function module name will be defaulted by the system based on the data element specified. This name will have the following convention:
FIELD_EXIT_<data element>
- You can add an identifier (an underscore followed by a single character ).
- The first function module for a data elements field exit must be created without an identifier.
- To create the function module, click on the Create pushbutton, choose menu path Function module -> Create, or press F5.
- After choosing to create the function module, you will get the warning: "Function module name is reserved for SAP". This message is just a warning so a developer does not accidentally create a function module in the field exit name range. By pressing Enter, you will be able to go ahead and create the function module.
- Before coding the function module, you will have to specify the function modules attributes -- function group, application, and short text.
Step 5: Code Function Module
- From the function modules attributes screen, click on the Source code pushbutton or choose the Goto -> Function module menu path to the code of the function module.
- Here you will add your desired functionality for the field exit.
- Remember that field exits function module will have two parameters -- one importing parameter called "INPUT" and one exporting parameter called "OUTPUT". These parameters will be set up automatically by the system.
- You must remember to assign a value to the OUTPUT field. Even if the value does not change, it must be moved from the INPUT field to the OUTPUT field.
Step 6: Activate Function Module
- After coding the function module, you must remember to activate it.
- Use the Function module -> Activate menu path to activate the function module.
- At this point, you can return to the field exit transaction.
- You should be able to 'green arrow' back to this transaction.
- When you return to the field exit transaction, you will see an entry for the newly created field exit.
- At this point, the field exit is global. That is, it applies to all screens that use a particular data element. On any screen that uses the data element, the corresponding field exit function module will be triggered, once it is active.
- Also, the field exit will not be triggered yet because it is inactive.
Step 7: Assign Program/Screen
- This step is only needed if you want to make a field exit local.
- To make a field exit local, select the field exit and click on the Assign prog./screen pushbutton.
- In the dialog box , indicate the appropriate program name and screen number.
This information indicates that the field exit is local to the specified screen in the specified program.
- In the dialog box, you determine which function module gets executed for the field exit by specifying the identifier in the Fld. Exit field.
- If this field is left blank, the function module triggered will be 'FIELD_EXIT_<data element>'.
- If a single-character identifier is entered into the field, the function module triggered will be 'FIELD_EXIT_<data element>_<identifier>'.
Step 8: Activate Field Exit
- The field exit must be active for it to be triggered by the system.
- Activate the field exit by choosing the Field exit -> Activate menu path.
- After assigning the field exit to a change request, its status will change to Active and it will be triggered automatically on the appropriate screen(s).
NOTE : In order to activate the field exit the profile parameter abap/fieldexit = YES must be set on all application servers
Regards
Sreeni
Maybe you are looking for
-
How to find description for the bugs fixed in a CPU ( Critical patch alert)
Hi I am having a hell of a time trying to figure out WHICH BUGS are fixed in the recent Critical patch alert I looked into the README file of the patch ( in my case its 8534387 for Solaris SPARC ) - but even in the README file there is only the list
-
I don't know where my photos go when syncing my iPhone to my iMac
I don't know where my photos go when syncing my iPhone to my iMac
-
Display the HCM Form in Webdynpro
Hi all, I have a HCM processing form, which I need to display in the Web dynpro application through Interactive form UI element. To do this I am binding the Template ID (I am getting the template id from tcode - PHAP_CATALOG ) with the data source of
-
Windows 7 doesn't display pdf properties
Windows 7 doesn't display pdf properties/metadata, like title, comments, author, subject etc. This was a great feature in XP. Anybody know a workaround?
-
Subscription renewal charged.
Hello, I was recently charged (today) on my credit card for new minutes on my subscription. However, my account still shows 0 minutes left. Help! //Josef