Change variable name of component once declared
Hello,
I was wondering if you can change a variable name of a component so if i had the following declaration of a button like this:
JButton btn = new JButton();can i then change the variable name 'btn' to be 'button' after i have declared it like this ?
Many thanks in advance
ok, you might have a better solution for me actually....
What i have done so far is created a JTabbedPane in one class, i have also created a seperate class with extends a JPanel. This consists of two textboxs and two buttons. Now i want to add this class as a component to each new tab that i create in the other class.
However the problem that i have is the reference name that i give for the textboxs and buttons will be the same for the multiple tabs that i create which i guess will not work.
For example, i create 2 tabs each with one of these instances of this class in each. So therefore there will be two identical buttons with the same reference and two identical textboxes with the same reference.
This is the code for the class that extends a JPanel: (note: i have cut out all the layout code to simplify the code a little)
public class client extends javax.swing.JPanel {
private JButton Sbrowse_btn;
private JButton Sbrowseto_btn;
private JLabel SchosenFile_lbl;
private JLabel SchosenL_lbl;
private JTextField SchosenLoc_tf;
private JTextField Schosen_tf;
private JLabel SsaveTo_lbl;
private JLabel SuploadTo_lbl;
private JPanel jPanel2;
private JPanel jPanel3;
/** Creates new form client */
public client() {
initComponents();
private void initComponents() {
jPanel3 = new JPanel();
SuploadTo_lbl = new JLabel();
Sbrowse_btn = new JButton();
SchosenFile_lbl = new JLabel();
Schosen_tf = new JTextField();
jPanel2 = new JPanel();
SsaveTo_lbl = new JLabel();
Sbrowseto_btn = new JButton();
SchosenL_lbl = new JLabel();
SchosenLoc_tf = new JTextField();
}
Similar Messages
-
Hello all,
I have build a query with a variable fiscal period. I used this variable in input forms in Visual Composer (@fiscal_period) and in BW reports.
Now end users ask me to change the name of the variable to 'period'. Does this have impact on the existing Visual Composer model?
Thanks in advance,
RalphHi,
You just change the variable name. After that you need to map again it with input form field as @period, Otherwise it will not get the value. Just map it and deploy it again.
Thanks
Chandan -
Hi
I have a requirement where I want to loop 10 times over an internal table, but passing the same value to all.
For ex.
Do 10 times.
Read table itab into wa index sy-index.
if sy-subrc = 0.
var1 = wa-field.
endif.
Enddo.
My requirement is to change this VAR1 to VAR2 in next iteration, then to VAR3.......upto VAR10 for every iteration of loop.
Regards
Kapiltry this .
declare variable VAR1 to VAR 10 .
DATA: LV_FIELDNAME(9) TYPE C,
LV_PREFIX(3) TYPE C VALUE 'VAR'
LV_LINE_NUMBER(2) TYPE N .
FIELD-SYMBOLS : <FS_GLOBAL_VARIABLE>.
Do 10 times.
ADD 1 TO LV_LINE_NUMBER.
CONCATENATE LV_PREFIX
LV_LINE_NUMBER
INTO LV_FIELDNAME.
ASSIGN (LV_FIELDNAME) TO <FS_GLOBAL_VARIABLE>.
Read table itab into wa index sy-index.
if sy-subrc = 0.
<FS_GLOBAL_VARIABLE> = wa-field.
ENDIF.
ENDDO
Jitendra -
Changing variable name breaks serialization
I have a class like so
class aClass {
private static final long serialVersionUID = 1;
private ArrayList list = new ArrayList();
private void readObject(ObjectInputStream in)throws IOException, ClassNotFoundException {
in.defaultReadObject();
this.list = new ArrayList(this.list); //defensive copy
}The problem is i renamed 'list' to 'newList'. Now the deserialization fails. Is there any way around this? Its still a list and everything is the same but the name. I thought serialization used the positions of variables not their names? And I also thought since I had my UID the same it would just load it without complaint?
I have a bunch of files created with this in them, and I need a tip on how to convert them. thanks!easy peasy
class aClass {
private static final long serialVersionUID = 1;
private ArrayList list = new ArrayList();
private void readObject(ObjectInputStream in)throws IOException, ClassNotFoundException {
this.list = (ArrayList) in.readObject(); //<---new
this.list = new ArrayList(this.list); //defensive copy -
Changing variable name within loop
Instead of typing oit 8 different versions of this loop, I'd like to do something this where i increases value to define a new variable:
for (int i = 1; i < 9; i++)
double lbs[i] = (((dis * 2000) / 3456) * (ve)) * pr * 0.069 / 100;
BigDecimal bd[i] = new BigDecimal (lbs);
bd[i] = bd[i].setScale (1,BigDecimal.ROUND_UP);
lbs[i] = bd[i].doubleValue ();
String tflow[i] = Double.toString (lbs[i]);
oFlow[i].setText (tflow[i]);
i++;
In PHP that's how I do it, but how about Java? I tried searching for "variable variables" since that's the only want I know how to describe it.I put what you gave me inside of public void CalcBoost() { ... } and I'm getting the error:java.lang.NullPointerException
at Calculator.CalcBoost(Calculator.java:751)
at Calculator.iBoostActionPerformed(Calculator.java:672)
at Calculator.access$700(Calculator.java:69)
at Calculator$8.actionPerformed(Calculator.java:299)
at javax.swing.JTextField.fireActionPerformed(JTextField.java:491)
at javax.swing.JTextField.postActionEvent(JTextField.java:672)
at javax.swing.JTextField$NotifyAction.actionPerformed(JTextField.java:786)
at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1530)
at javax.swing.JComponent.processKeyBinding(JComponent.java:2438)
at javax.swing.JComponent.processKeyBindings(JComponent.java:2473)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2401)
at java.awt.Component.processEvent(Component.java:4909)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1713)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:627)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:831)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:741)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:592)
at java.awt.Component.dispatchEventImpl(Component.java:3506)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:480)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)This now points to: for (int i = 0; i < oFlow.length; i++) -
How to change dinamically variable name?
Is it possible to change variable name dinamically into loop?
loop at itab.
move itab-item to field_x.
endloop.
I would copy my itab-item into field_1, field_2......field_x at each loop.
Thanks
Alfonso.You have to use the field symbol for the field giornoX not for the structure
DATA: BEGIN OF wa_alv OCCURS 0,
pernr LIKE pa0001-pernr,
persk LIKE pa0001-persk,
des_grado_abbrev LIKE zhr_descr_grado-des_grado_abbrev,
vorna LIKE pa0002-vorna,
nachn LIKE pa0002-nachn,
giorno1 TYPE char12,
giorno2 TYPE char12,
giorno3 TYPE char12,
giorno4 TYPE char12,
giorno5 TYPE char12,
giorno6 TYPE char12,
giorno7 TYPE char12,
END OF wa_alv.
data tb_alv like table of wa_alv.
field-symbols: <giorno> type any.
data: name_giorno(13).
LOOP AT tb_alv ASSIGNING wa_alv
LOOP AT tb_orario.
do 7 times.
concatenate 'wa_alv-giorno' sy-index into name_giorno.
assign (name_giorno) to <giorno>.
giorno = tb_orario-orario.
enddo.
ENDLOOP.
ENDLOOP.
bye
enzo -
How to use an array for variable name of swing components using NetBeans
I'm completely new to Java and GUIs, so excuse me if I use the wrong terminology. I'm making a JFrameFrom in NetBeans. I'm getting really tired of typing instructions like jTextField15.setText(variable[15].text); I would like to make the variable names of my text fields an array so I can use a loop to change the values, text, tooltips, etc. When I click "change variable name" it won't let me put an array in. The code that Swing generates is protected and I can't change it. I know there must be a way to do this. Any help is appreciated.
Try not to use the NetBeans visual GUI builder. Then it should be easy to create an array of text fields:
JTextField[] tfs = new JTextField[15];
for (int i = 0; i < tfs.length; i++) {
tfs[i] = new JTextField(10);
}For laying out the text fields, see: [http://download.oracle.com/javase/tutorial/uiswing/layout/using.html] -
I need to change the name of Schema in the Insert command by using variable
Hi
I need to write a code to populate 450 schemas having same table names and also specify the columns needed to be inserted. for that i am trying to make the Schema Name a variable and put the whole statement in a loop to change the name of the Schema. its not working can any one guide me in this..Thae sample of my insert statement is
INSERT INTO A01.tablename
In this the "A" is constant and 01 is being changed to 02...450..
ThanksNot sure to completely understand your need, but assuming that column names and values to be inserted are the same for all schemas, here a short example :
SQL> desc a001.test
Name Null? Type
A NUMBER
B VARCHAR2(10)
SQL> desc a002.test
Name Null? Type
A NUMBER
B VARCHAR2(10)
SQL> desc a003.test
Name Null? Type
A NUMBER
B VARCHAR2(10)
SQL> declare
2 i number;
3 str varchar2(100);
4 begin
5 for i in 1..3 loop
6 str := 'insert into a'||lpad(i,3,'0')||'.test(a,b) values(1,'||chr(39)||'ABC'||chr(39)||')';
7 execute immediate (str);
8 end loop;
9 commit;
10* end;
SQL> /
PL/SQL procedure successfully completed.
SQL> select * from a001.test;
A B
1 ABC
SQL> select * from a002.test;
A B
1 ABC
SQL> select * from a003.test;
A B
1 ABC
SQL> -
How to declare internal table in BADI with variable name beginning with 0..
Gurus,
How to declare an internal table within a BADI. I have to implement a BADI UC_TASK_CUSTOM for BCS to BW load and there i have to declare an internal table like:
TYPES: BEGIN OF t_cube_data,
0cs_version TYPE /bi0/oics_version,
0sem_cgcomp TYPE /bi0/oisem_cgcomp,
bcs_vers TYPE /bic/oibcs_vers,
bcs_lcus TYPE /bic/oibcs_lcus,
bcs_ldch TYPE /bic/oibcs_ldch,
bcs_invcom TYPE /bi0/oibcs_invcom,
bcs_litem TYPE /bic/oibcs_litem,
bcs_llob TYPE /bic/oibcs_llob,
bcs_lmay TYPE /bic/oibcs_lmay,
0move_type TYPE /bi0/oimove_type,
pcompany TYPE /bi0/oipcompany,
bcs_lprg TYPE /bic/oibcs_lprg,
figlxref3 TYPE /bic/oifiglxref3,
fiscyear TYPE /bi0/oifiscyear,
fiscper3 TYPE /bi0/oifiscper3,
fiscvarnt TYPE /bi0/oifiscvarnt,
curkey_gc TYPE /bi0/oicurkey_gc,
unit TYPE /bi0/oiunit,
cs_trn_gc TYPE /bi0/oics_trn_gc,
cs_trn_qty TYPE /bi0/oics_trn_qty,
END OF t_cube_data
But with this declaration it gives a error saying that u cannot have a variable beginning with 0...like 0cs_version....
but i have to do it for my functionality to wrk...
Please help me do it....
how can i declare a internal table that allows me to have variable names that start with 0....
Please help....Its URGENT....
Thanks
SamMurali,
I need to have 0 before the variable name in the declaration of the internal table....how can i attain that....
Please suggest...
Thanks
Sam -
Help, can I declare an object using a variable name
I need to make a bunch of objects using a for loop, so I was wanting to name the object one of the variables that I read. But I basically want to know if I can do this.
private Software makeObject(String proName, int proStock, double proPrice,String objName){
Software objName = new Software(proName,proStock,proPrice);
return objName;
I want to create a Software object using the objName inputted to it. The software object holds three fields as you can see. The name, num in stock, and price. However it won't let me do this, because it says objName is a duplicate variable. Help would be appreciatedprivate Software makeObject(String proName, int proStock, double proPrice,String objName){
Software objName = new Software(proName,proStock,proPrice);
... it won't let me do this, because it
says objName is a duplicate variable. Help would be
appreciatedWell, it is duplicate. Change the name of one or the other of those variable names. -
J2EE Development Component - How to change vendor name
Hi,
While creating a new J2EE Development Component, I didn't change vendor name and have created complete application,
Now I want to update vendor name, can you please help me out how vendor name can be changed in existing application.
ThanksI have not tried it myself, however:
Try updating the references in your application-j2ee-engine.xml.
You may need to rename your project as well.
Good luck, Roelof -
Changing tab name in one component that used in different applications -FPM
Hi gurus,
I have an FPM component configuration, which have different tabs.
This component i have used in different applications.
I just want to know how can I dynamically change the name of one tab in different applicatins?
I want to change only the tab name. content in the tab is same.
For eg. If I open a Bid from Rfx, it should show "Rfx Information" as one tab name. But if i open a bid from Auction, it should show 'Auction Information'.
Content in this tab is same.
Is there any way to do that? Or shall I create different component config. for bid to use in Auction application and another one for RFx application?
Thanks,
PoduvalHi, 3Sherill3. This may help:
http://www.macupdate.com/info.php/id/16620 -
Variable name declared by using an object-------Where Used List
Hi,
Can anyone let me know how to find the variable names that are defined by using an object like 'sflight' in all the reports, classes,funciton modules.
For example
in a report 'ZREPORT' i have declared a variable data lt_sflight type table of sflight.
and in other report 'ZREPORT1' i have declared as data lt_sfli type table of sflight.
and i want to know the all the variable name that are declared by using sflight object say in all reports,FM'S and Classes
Edited by: PEEDNAS on Feb 3, 2011 10:02 AM
Edited by: PEEDNAS on Feb 3, 2011 10:08 AMHi Sumodh,
Thanks for your information but
the where used list internally uses 'RS_TOOL_ACCESS' FM for that FM if we give object type and object name then it gives some search results and from there we can check the variables names manually directly but i want to get the list of variable names directly
Regards,
Sandeep -
How do I change the name of a podcast once submitted to itunes??
how do I change the name of a podcast once submitted to itunes??
anyone know? I submitted my first podcast, then changed the name in feedburner. The new name is appearing once you are in the podcast window of my itunes, but not in the itunes store catalog. how do I fix?Here's what iTunes Podcaster help says:
http://www.apple.com/itunes/store/podcaststechspecs.html
Troubleshooting Your Feed
iTunes should update your listing at least once every 24 hours. If you made changes more than 24 hours ago that are not yet reflected in your iTunes listing, there is a good chance that your feed has broken. When iTunes encounters a broken feed, it ignores the feed and continues to display the old data.
Here is a set of recommended steps to fix your feed:
Ping your feed to make sure iTunes has attempted to update your feed recently.
Review the technical spec, particularly the example feed, to ensure that every detail of your podcast’s feed is supported by iTunes.
Use a feed validation service like www.feedvalidator.org to check for particular problems. This may be helpful in determining a specific problem with syntax.
If you used a software- or online-based feed creation service, check to ensure your settings there are correct and iTunes-compliant.
Subscribe to the feed in iTunes to see if it works. Open iTunes, go to the Advanced menu, choose "Subscribe to podcast..." and enter your feed’s URL.
Hope this helps - Podcaster's discussion board might have more answers:
http://discussions.apple.com/forum.jspa?forumID=1107 -
I have many contacts in address book from a certain company that just changed its name. Is there a way to globally change all the contacts to the new company name all at once?
Rando510 wrote:
Although clunky as you say, this sounds like a reasonably efficient way to accomplish what I was seeking.
Address Book has no global find/replace. Bob Grove suggested one possible workaround; however, a grep-capable text editor (eg, TextWrangler) is better than TextEdit if complex strings are involved.
An alternative is Bento (which is designed specifically to interact with the AB database), but it's not free.
Maybe you are looking for
-
How can I transfer all my music and apps from my computer to my new iphone?
how can I transfer all my music and apps from my computer to my new iphone?
-
Stop Invoice verification for QM stock.
Dear Experts , I need to stop the invoice verification (MIRO) unless the quality inspection for the GR materail is pending . How can this be achieved ? Regards Anis
-
Hello, i am trying to setup an AP521 in Standalone mode using CCA. But i am prompted to give a username and password. Do somebody knows ???????? I've checked every where on Cisco website with no result. Thanks for your help
-
HP Pavilion Entertainment PC WA7780A - dvd player broken - I can't download adobe flash player
I have had this lap top for two years. All of a suddend I can't play dvd's. I can't view anything that requires flash-player and I can't download adobe
-
How i can see the share point of any Group ?
Hi everybody ! First, sorry for my bad english- I wish to see everybody Share Points affected on a Group. It's possible ?