Problem using List of Lists in loop
I'm working on a test program that will pull in two text files and return a list of the words that are common among in each. I'm running into a logistical problem when trying to add elements of a list to a list of lists, and then clear the primary list for the next iteration of the loop. Here's my code:
import java.util.*;
import java.io.*;
public class IOList {
private static List<File>();
public static void main(String[] args) {
files = new ArrayList<File>();
Scanner s;
List<String> words = new ArrayList<String>();
List<List<String>> allWords = new ArrayList<List<String>>();
File a = new File(args[0]);
File b = new File(args[1]);
files.add(a);
files.add(b);
for (File file : files) {
try {
s = new Scanner(new BufferedReader(new FileReader(file)));
while (s.hasNext()) {
words.add(s.next());
int n = words.size();
allWords.add(words.subList(0, n));
words.clear();
} catch(FileNotFoundException e) {
System.err.println("Could not find file " + file);
System.exit(1);
List<String> fileA = allWords.get(0);
List<String> fileB = allWords.get(1);
fileA.retainAll(fileB);
fileB.retainAll(fileA);
fileA.addAll(fileB);
int size = fileA.size();
for (int i = 0; i < size; i++) {
String str = fileA.get(i - 1);
System.out.println(str);
}When I step through this code, netbeans gives me a message:
words.subList = >"subList" is not a known variable in current context<
If I use allWords.add(words); instead, the String elements populate to the first List of Strings contained in allWords, and are then removed when I call
words.clear();in the next step to prep it for the next iteration.
Can anyone suggest another way to do this while still working with the loop?
Thanks in advance
Just to make clear: subList() does not (necessarily)
create a new list but a view on the original list. If
that original list is modified, the sublist might
change and vice versa.subList() never creates a new list, the subList is always backed by the original list. If the original list is modified, the sublist is too, always. If the original list is structurally modified, the result is undefined, so don't do that.
http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html#subList(int, int)
Similar Messages
-
Problem using local variable in event loop
I have a state machine from which I want to monitor various controls, including "Start" and "Stop" buttons. Not every state needs to monitor the controls. At present, most states run timed loops. In the first state that reads the front panel, I have an Event structure (inside a While loop) that monitors the various controls' Change Value events. For numeric controls, I update variables (in shift registers) as needed. The "Start" button is used to end the While loop controlling the Event structure, allowing the State to exit to the next state.
My problem comes in subsequent states that employ this same idea. Here, I put a Local Variable bound to the Start button and use the same code, but it frequently happens that when I enter this particular state, I cannot "turn on" the control -- I push the button, but it stays off. Curiously, if it was On when I enter, I can turn it off, but then I'm stuck not being able to turn it on.
I mocked up a very simply routine that illustrates this. There are two sequences (corresponding to the two states). Both use an Event loop with a local variable bound to my Stop button (really this is an LED control with custom colors). I've deliberately moved the "initialization" (the declaration of the control in the block diagram) out of the Event loops -- putting it inside the first loop modifies the behavior in another strange way.
Here's my thinking on how I would expect this to work: The code outside Event Loop 1 should have little effect. Assume the Stop button is initially Off. You will "sit" in Event Loop 1 until you push the Stop button, changing its value to True; this value will be passed out of the Event case and cause the first While loop to exit. You now enter the second sequence. As I understand the Exit tunnel, it defaults to "False", so I'd expect to stay in the second Event loop until I turn the Stop button from On to Off, which will pass out a False, and keep me in the While for one more button push. However, this doesn't happen -- I immediately exit, as though the "True" value of the Stop local variable is being seen and recognized by the Event loop (even though it hasn't changed, at least not in the context of this second loop).
An even more curious thing occurs if I start this routine with the Stop button turned on. Now I start in my Event loop waiting for a change, but this time the change will be from On to Off, which won't cause an exit from the frame. This will be reflected by having the While loop count increment. We should now be in the state of the example above, i.e. in an Event loop waiting for the control to be pushed again, and turned On. However, clicking the control has no effect -- I cannot get it to "turn on".
Where am I going astray in my thinking? What is it about this method of doing things that violates the Labview paradigm? As far as I can tell, what I'm doing is "legal", and I don't see the flaw in my reasoning, above (of course not -- otherwise I'd have fixed it myself!). Note that because I'm using local variables inside Event loops (and I'm doing this because there are two places in my code where I want to do such testing), the Stop control is not latching (as required). Is there something that gets triggered/set when one reads a latched control? Do I need to do this "manually" using my local variable?
I'll try to attach the simple VI that illustrates this behavior.
Bob Schor
Attachments:
Simple Stop Conundrum.vi 14 KBaltenbach wrote:
Ravens Fan wrote:
NEVER have multiple event structures that share the same events.
Actually, that's OK. NOT OK is having multiple event structures in the same sequence structure.
See also: http://forums.ni.com/ni/board/message?board.id=170&message.id=278981#M278981
That's interesting. I had always thought I read more messages discouraging such a thing rather than saying it was okay. Your link lead me to another thread with this message. http://forums.ni.com/ni/board/message?board.id=170&message.id=245793#M245793. Now that thread was mainly concentrating on registered user events which would be a different, but related animal.
So if you have 2 event structures they each have their own event queue? So if you have a common event, one structure pulls it off its event queue and it does not affect the other structure's event queue? I guess the inherent problem with this particular VI was that the second event structure locked the front panel. Since the code never got to that 2nd event structure because the first loop never stopped because the change was from true to false. After reading your post and the others, I did some experimentation and turned off the Lock front panel on the 2nd structure, and that prevented the lockup of the program.
Overall, the example VI still shows problems with the architecture and I think your answer should put the original poster on the right track. I think as a rule I would probably never put the same event in multiple structures, I feel there are better ways to communicate the same event between different parts of a program, but I learned something by reading your reply and about how the event structures work in the background. Thanks. -
[SOLVED] problem using variable in "for do" loop statement
As 'm fairly new to scripting in linux there are still many things I don't know about the regular syntax. So I've made a script where in a variable $nb I retain the number of lines from the result of a series of commands. I have to use a variable as the number of lines from the output is not the same all the time.
To finish my script I need to use a for loop something like this
for i in {1..$nb}
do
echo "bla bla bla $i"
done
the thing is if $nb, for example, has the value 29 it outputs
bla bla bla {1..29}
without doing any loop.
So how can I use a variable, to define the edge of an interval in a for statement ?
Last edited by I'mGeorge (2011-06-18 16:19:16)The sanctioned method in Bash is using a C style for loop:
for ((i=0; i<nb;i++)); do
done
Because brace expansion is performed before parameter expansion, a range like {1..$nb} will fail. -
Problem using comma separated list with nested table element
Hi,
I have a comma separated list like that:
H23004,H24005,T7231,T8231,T9231And want to create a function which is creating a where clause for each element with an output like that:
UPPER('H23004') IN (UPPER(charge))
OR UPPER('H23005') IN (UPPER(charge))
OR UPPER('T7231') IN (UPPER(charge))
OR UPPER('T8231') IN (UPPER(charge))
OR UPPER('T9231') IN (UPPER(charge))Here is my test function which doesn't work correctly:
create or replace function FNC_LIST_TO_WHERE_CLAUSE(v_list in VARCHAR2) return varchar2 is
-- declaration of list type
TYPE batch_type IS TABLE OF pr_stamm.charge%TYPE;
-- variable for Batches
v_batch batch_type := batch_type('''' || replace(v_list,',',''',''') || '''');
return_script varchar2(1000);
BEGIN
-- loop as long as there are objects left
FOR i IN v_batch.FIRST .. v_batch.LAST
LOOP
--DBMS_OUTPUT.PUT_LINE(offices(i));
-- create where clause
IF i = 1 THEN
return_script := 'UPPER(' || v_batch(i) || ') IN (UPPER(charge))';
ELSE
return_script := return_script || ' OR UPPER(' || v_batch(i) || ') IN (UPPER(charge))';
END IF;
END LOOP;
return (return_script);
end;The out put looks like that:
UPPER('H23004','H24005','T7231','T8231','T9231') IN (UPPER(charge))I have no idea what I do wrong? It calculates the amount of array element wrong! (v_batch.LAST should be 5.)
v_batch.FIRST = 1
v_batch.LAST = 1
Regards,
Tobiastry this....
declare
text varchar2(1000) := 'H23004,H24005,T7231,T8231,T9231';
v_where varchar2(1000);
begin
text := text||',';
while instr(text,',') <> 0
loop
v_where := v_where || 'UPPER('''||substr(text,1,instr(text,',',1)-1)||''' IN (UPPER(charge)) OR ';
text := substr(text,instr(text,',',1)+1);
end loop;
v_where := substr(v_where,1,length(v_where)-3);
dbms_output.put_line(v_where);
end;
convert this one into function ... -
Problem in Expand when using Blocked ALV list
Hi All,
I am using the Blocked list ALV to display two lists in a program. One among them is a hierarchial ALV. When i click on the Expand button of this ALV it terminates with the runtime error "GETWA_NOT_ASSIGNED".
I was able to use this functionality using similar code in a stand alone hierarchial ALV list in another program without any problem.
I have assigned the Expand Field name as follows in both programs:
wa_layout-expand_fieldname = 'EXPAND'
Any suggestions or help in this would be highly appreciated.
Thanks & Reagrds,
PraveenHai Praveen
Check the following Code
*& Report ZALV_BLOCKLIST *
REPORT ZALV_BLOCKLIST NO STANDARD PAGE HEADING
LINE-SIZE 150
LINE-COUNT 60(4)
MESSAGE-ID Z00.
*..Type Definitions for ALV Report
TYPE-POOLS SLIS.
*..Includes
*for ICONs
*INCLUDE <ICON>.
Table/Structure declarations. *
TABLES: MARA,
MARC,
T134.
Internal Tables declaration *
*..To store Basic Report fields
DATA:BEGIN OF IT_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MATKL LIKE MARA-MATKL,
MEINS LIKE MARA-MEINS,
NTGEW LIKE MARA-NTGEW,
END OF IT_MARA.
*DATA:BEGIN OF IT_MATKL OCCURS 0,
MATKL LIKE T023-MATKL,
WGBEZ LIKE T023-WGBEZ,
END OF IT_MATKL.
DATA:BEGIN OF IT_MARC OCCURS 0,
WERKS LIKE MARC-WERKS,
LADGR LIKE MARC-LADGR,
MTVFP LIKE MARC-MTVFP,
DISPR LIKE MARC-DISPR,
DISMM LIKE MARC-DISMM,
DISPO LIKE MARC-DISPO,
END OF IT_MARC.
ALV Type declaration *
DATA:V_NO_DATA TYPE C.
ALV Type declaration *
DATA:V_REPID TYPE SYREPID.
DATA: IT_FIELDCATALOG_MARA TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCATALOG_MARA TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCATALOG_MARC TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCATALOG_MARC TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCATALOG_MATKL TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCATALOG_MATKL TYPE SLIS_FIELDCAT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
IT_EVENTS TYPE SLIS_T_EVENT,
WA_EVENTS TYPE SLIS_ALV_EVENT,
WA_KEYINFO TYPE SLIS_KEYINFO_ALV.
Selection Screen. *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR ,
S_MTART FOR MARA-MTART .
SELECTION-SCREEN END OF BLOCK B1.
Event:Initialization *
INITIALIZATION.
*Report Name
V_REPID = SY-REPID.
AT Selection Screen. *
AT SELECTION-SCREEN.
Event: Start-of-Selection *
START-OF-SELECTION.
PERFORM FETCH_DATA.
Event: End-of-Selection *
END-OF-SELECTION.
IF V_NO_DATA = ''.
MESSAGE I010 WITH 'NO DATA TO DISPLAY ! '.
EXIT.
ELSE.
PERFORM FILL_FIELDCAT_MARA.
PERFORM FILL_FIELDCAT_MAKT.
PERFORM FILL_FIELDCAT_MARC.
PERFORM FILL_LAYOUT.
PERFORM CALL_ALV_INIT.
PERFORM ADD_LISTS.
PERFORM DISPLAY_BLOCK_LIST.
ENDIF.
FORM DEFINITIONS *
*& Form FETCH_DATA
text
--> p1 text
<-- p2 text
FORM FETCH_DATA.
SELECT MATNR
MTART
MATKL
MEINS
NTGEW
INTO CORRESPONDING FIELDS OF TABLE IT_MARA
FROM MARA
WHERE MATNR IN S_MATNR
AND MTART IN S_MTART.
IF SY-SUBRC <> 0.
V_NO_DATA = ''.
ELSE.
V_NO_DATA = 'X'.
SELECT WERKS
LADGR
MTVFP
DISPR
DISMM
DISPO
INTO CORRESPONDING FIELDS OF TABLE IT_MARC
FROM MARC
WHERE MATNR IN S_MATNR.
ENDIF.
ENDFORM. " FETCH_DATA
*& Form FILL_FIELDCAT_MARA
text
--> p1 text
<-- p2 text
FORM FILL_FIELDCAT_MARA.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME =
I_STRUCTURE_NAME = 'IT_MARA'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = V_REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = IT_FIELDCATALOG_MARA
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT IT_FIELDCATALOG_MARA INTO WA_FIELDCATALOG_MARA.
CASE WA_FIELDCATALOG_MARA-FIELDNAME.
WHEN 'MATNR'.
WA_FIELDCATALOG_MARA-COL_POS = '1'.
WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARA-SELTEXT_L = 'Material NO'.
WHEN 'MTART'.
WA_FIELDCATALOG_MARA-COL_POS = '2'.
WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARA-SELTEXT_L = 'Mat Type'.
WHEN 'MATKL'.
WA_FIELDCATALOG_MARA-COL_POS = '3'.
WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARA-SELTEXT_L = 'Mat Group'.
WHEN 'MEINS'.
WA_FIELDCATALOG_MARA-COL_POS = '4'.
WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARA-SELTEXT_L = 'Measure Unit'.
WHEN 'NTGEW'.
WA_FIELDCATALOG_MARA-COL_POS = '5'.
WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARA-SELTEXT_L = 'Net Wt'.
WA_FIELDCATALOG_MARA-DO_SUM = 'X'.
ENDCASE.
MODIFY IT_FIELDCATALOG_MARA FROM WA_FIELDCATALOG_MARA INDEX SY-TABIX.
ENDLOOP.
ENDFORM. " FILL_FIELDCAT_MARA
*& Form FILL_FIELDCAT_MARC
text
--> p1 text
<-- p2 text
FORM FILL_FIELDCAT_MARC.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME = 'IT_MARC'
I_STRUCTURE_NAME =
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = V_REPID
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = IT_FIELDCATALOG_MARC
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT IT_FIELDCATALOG_MARC INTO WA_FIELDCATALOG_MARC.
CASE WA_FIELDCATALOG_MARC-FIELDNAME.
WHEN 'WERKS'.
WA_FIELDCATALOG_MARC-COL_POS = '1'.
WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARC-SELTEXT_L = 'PLANT NAME'.
WHEN 'LADGR'.
WA_FIELDCATALOG_MARC-COL_POS = '2'.
WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARC-SELTEXT_L = 'Loading Group'.
WHEN 'MTVFP'.
WA_FIELDCATALOG_MARC-COL_POS = '3'.
WA_FIELDCATALOG_MARC-OUTPUTLEN = '20'.
WA_FIELDCATALOG_MARC-SELTEXT_L = 'Checking group'.
WHEN 'DISPR'.
WA_FIELDCATALOG_MARC-COL_POS = '4'.
WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARC-SELTEXT_L = 'MRP PROFILE'.
WHEN 'DISMM'.
WA_FIELDCATALOG_MARC-COL_POS = '5'.
WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARC-SELTEXT_L = 'MRP TYPE'.
WHEN 'DISPO'.
WA_FIELDCATALOG_MARC-COL_POS = '6'.
WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.
WA_FIELDCATALOG_MARC-SELTEXT_L = 'MRP CONTROLLER'.
ENDCASE.
MODIFY IT_FIELDCATALOG_MARC FROM WA_FIELDCATALOG_MARC INDEX SY-TABIX.
ENDLOOP.
ENDFORM. " FILL_FIELDCAT_MARC
*& Form FILL_FIELDCAT_MAKT
text
--> p1 text
<-- p2 text
FORM FILL_FIELDCAT_MAKT.
ENDFORM. " FILL_FIELDCAT_MAKT
*& Form CALL_ALV_INIT
text
--> p1 text
<-- p2 text
FORM CALL_ALV_INIT.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
IT_EXCLUDING =
ENDFORM. " CALL_ALV_INIT
*& Form ADD_LISTS
text
--> p1 text
<-- p2 text
FORM ADD_LISTS.
*ADD IT_MARA TABLE TO THE OUTPUT
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCATALOG_MARA
I_TABNAME = 'IT_MARA'
IT_EVENTS = IT_EVENTS
IT_SORT =
I_TEXT = ' '
TABLES
T_OUTTAB = IT_MARA
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
**ADD IT_MARC TABLE TO THE OUTPUT
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCATALOG_MARC
I_TABNAME = 'IT_MARC'
IT_EVENTS = IT_EVENTS
IT_SORT =
I_TEXT = ' '
TABLES
T_OUTTAB = IT_MARC
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " ADD_LISTS
*& Form FILL_LAYOUT
text
--> p1 text
<-- p2 text
FORM FILL_LAYOUT.
WA_LAYOUT-ZEBRA = 'X'.
WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
ENDFORM. " FILL_LAYOUT
*& Form DISPLAY_BLOCK_LIST
text
--> p1 text
<-- p2 text
FORM DISPLAY_BLOCK_LIST.
WA_KEYINFO-HEADER01 = 'MATNR'.
WA_KEYINFO-ITEM01 = 'MATNR'.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
IS_PRINT =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_BLOCK_LIST .
Thanks & regards
Sreenivasulu P -
Reasons why to use Iterator for List rather than for loop ?
when i use the iterator and for loop for traversing through the list. it takes the same time for iterator and also for for loop. even if there is a change it is a minor millisecond difference.
what is the actual difference and what is happening behind the traversing list through iterator
if we are using we are importing extra classes ...if we are using for loop there is no need to import any classesIf you have an array-backed collection, like an ArrayList, then the difference between using an iterator and get() will be negligible.
However, if you have a linked list, using get() is O(n^2) whereas iterator is O(n).
So with an iterator, regardless of what your underlying data structure, a list of 100,000 elements takes 1,000 times as long to iterate over as a list with 100 elements. But using get() on a LinkedList, that same 100,000 element list will take 1,000,000 times as long as the 100 item list.
There's no real benefit to ever using get()
Side note: I've been comparing iterators to get(), not iterators to for loops. This is because whether it's a for or a while has nothing to do with whether you use an iterator or get(). The way I use iterators is for (Iterator iter = list.iterator(); iter.hasNext(); ) {
Foo foo = (Foo)iter.next();
} -
Problem adding item to list using a function. Error - Null pointer
Hi Guys,
I'm not sure what the problem is, but for some reason I am unable to add an item to a list using a function. I can add an item when I call it in the same function that the list is created, but I cannot add the item from anoter function. Here is the code:
Main:
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class main {
* @param args
public static void main(String[] args) {
JFrame JFrame = new JFrame();
JFrame.setSize(400,400);
testpanel panel1 = new testpanel();
panel1.setBackground(Color.red);
JPanel panel2 = new testpanel();
panel2.setBackground(Color.BLUE);
JFrame.add(panel1);
JFrame.add(panel2);
JFrame.setLayout(new FlowLayout());
//THIS GIVES ERROR:
//NullPointerException
panel1.addListItem("test");
JFrame.setVisible(true);
}And here is the testpanel class:
* To change this template, choose Tools | Templates
* and open the template in the editor.
* testpanel.java
* Created on Apr 7, 2010, 6:10:24 PM
import java.awt.List;
import java.awt.ScrollPane;
import java.awt.event.ActionListener;
* @author Snowraver1
public class testpanel extends javax.swing.JPanel {
public void addListItem(String string){
list.add(string);
/** Creates new form testpanel */
public testpanel() {
initComponents();
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jButton1 = new javax.swing.JButton();
ScrollPane scrollPane = new ScrollPane();
List list = new List();
jButton1.setText("jButton1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(49, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(46, 46, 46))
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(123, 123, 123)
.addComponent(jButton1)
.addContainerGap(139, Short.MAX_VALUE))
this.add(scrollPane);
scrollPane.add(list);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private ScrollPane scrollPane;
private List list;
// End of variables declaration//GEN-END:variables
}Thanks for the help!
-- SnowYou should check how you are initializing your variables in your testpanel class. You initialize your button correctly, but your other class variables are being overridden. As a result, your class variables still have a value of 'null'.
-
Problem with Thunderbird email:
When I send email using a mailing list, with my email included in the list, the message shows up in my Sent list and others receive it but it does not come to my email Inbox. The same problem occurs when I send the email to the mailing list addresses individually. When I send a simple test message to myself, I do receive it in my Inbox. Can you help me??
Bob GreenmanAre you using either cc or bcc? Is googlemail involved? Some email providers suppress cc's and bcc's to oneself since you will have a copy in your Sent folder.
-
Problem using customer-specific task list
Hi,
I've created a customer-specific task list zap0 (copy of sap0) and defined additional tasks for the list.
When using this task list for a change request, I get the message
Internal Phase Controller Problem
Message no. /TMWFLOW/TASKLIST176
The task list has status created, when trying to change the status, I get the message
INDICATED_CYCLE_NOT_FOUND
Does anyone know this problem?
Thanks in advance
StephanNote 927124 solves the problem ==> thread closed
-
How to get a list of lists of triangles using each vertex?
Hi,
Its my first time working with Java3D, i just have experience with C++ and OpenGL, but im trying to implement a mesh simplification algorithm and get already problems with the data structures for the geometry info of the object.
I load an *.obj file with the object loader and now i dont know how to get the data i need.
I have to make loops over each vertex and get all triangles and their vertices used by that vertex. Is this possible with the given Java3D Functions or do i have to implement my own data structures for the triangle stuff?
What i need is following:
- List of vertex coordinates (thats the easy part, GeometryInfo.getCoordinates())
- List of triangle definitions
- List of lists of triangles using each vertex
I dont know how to get the last two, i tried around with IndexedTriangleArray but could not get anything to work..
The IndexTriangleArray should contain the triangle definitions if i understood that right. The first 3 entries in the array build the first triangle pointing to its vertices, the next 3 entries the second triangle,... Is that correct?
Does someone have an idea how to solve that problem?
Thanks a lot
spoertschI tried around a bit and figured something out, but with big objects with a lot of vertices it is quite inefficent and very slow...
I have the array of coordinates(GeometryInfo.getCoordinates) and the array of coordinate indices (GeometryInfo.getCoordinateIndices()). In the coordinate indice array each set of 3 indices builds an triangle.
CoordinateArray[CoordIndex] = Point3f (Vertex)
CoordinateIndiceArray[Index] = CoordIndex => Coordinate[CoordIndex] = Point3f . . . . . . }
CoordinateIndiceArray[Index + 1] = CoordIndex => Coordinate[CoordIndex] = Point3f . . . } triangle
CoordinateIndiceArray[Index + 2] = CoordIndex => Coordinate[CoordIndex] = Point3f . . . }
Now i iterate over each index of the coordinates array and search for this index in the indice array, to find out which triangle uses that vertex. If i find one i calculate the first index of the triangle and add it in an ArrayList<Integer>. So i get an ArrayList for each vertex in which the beginning indices of the triangles that uses that vertex are found. But these iterations are of course very slow for big objects with a lot of vertices, but i havent found a better way yet.
Does someone know a more efficent and faster way to do it?
Thanks
spoertsch
Edit: Sorry, just read about the movement of the forum, startet new Thread on java.net
Message was edited by:
spoertsch -
SSDT - Using a SharePoint list data feed as source - "column does not exist in the rowset" error
Hey guys!
So, I want to use a SharePoint list data to create a cube/tabular model, in order to make a complex analysis in PPS using MDX.
To create the tabular model, I'm using the SS Data Tools, and importing a feed from the respective SharePoint list (using the _vti_bin/listdata.svcextension and then selecting the list(s) I wanna to import).
Everything looks fine and smooth, I can select and preview the data in the table import wizard, but in the end, when importing, I always get this error IF the table has one or more row of data (if the table is empty, it's ok...) - the <...>
column doesn't exist in the rowset.
(Curiously, when I have the same procedure in PowerPivot for Excel, I have no problems, everything works fine. The problem is that then I get again errors if I try to create a tabular model on SSDT importing a PowerPivot file).
Here's the error:
Had you already tried this in SSDT? Are you experiencing the same trouble?
Best regards, and thanks in advance!
Jorge Mateus
Jorge MateusI noticed something else too.
I can't process Tabular Models on both SSDT and SSMS (2012), but I can process Tabular Models created on PowerPivot.
I tried to create a Data Feed connection on PowerPivot, and it was successfully created. However, if restoring the PowerPivot Tabular DB on my SSAS Tabular instance and processing (full) the model through SSMS, it won't work.
Is there anything different on PowerPivot and SSDT related with Partitioning or connections to the data sources?
Regards,
Jorge
Jorge Mateus
Update:
When trying to Restore a PowerPivot file on my SSAS Tabular Server and full process the model:
The operation failed because the source does not contain the requested column. You can fix this problem by updating the column mappings.
More Details:
The 'X' column does not exist in the rowset.
An error occurred while processing the partition 'X_81dabac5-c250-4a8c-8832-ad7fcedd35cb' in table 'X_81dabac5-c250-4a8c-8832-ad7fcedd35cb'.
The current operation was cancelled because another operation in the transaction failed.
X is the first column of the source table, no matter if I chose others on the PowerPivot table.
When trying to import data from a data feed using SSDT:
The 'X' column does not exist in the rowset.
An error occurred while processing the partition 'X_ee6be81f-2235-4113-b404-cfcb20647a38' in table 'X_ee6be81f-2235-4113-b404-cfcb20647a38'.
The current operation was cancelled because another operation in the transaction failed.
X is the first chosen column to import. -
Apps missing from use cellular data list in iphone 6
So I got the new iPhone 6...and half of my apps are missing from the "use cellular data" list...those that are missing won't load when I try to open them...they just flash and shut down. I've tried turning off wifi...I've tried resetting the phone...nothing works. What's the point of the phone if you can't use the freaking apps when you aren't connected to wifi?? Anyone else having this problem?? Anyone know how to fix it??
Hi there Kalypsokel,
You may find the troubleshooting steps in the article below helpful.
iOS: An app you installed unexpectedly quits, stops responding, or won’t open
-Griff W. -
When i use view as list in finder and open a folder with many files i cant right click with mouse without selecting or highlighting a file....i just want to right click to paste an item or create a new folder...what can i do?
Thx for that im gonna try it....but is there a way to do it without using toolbar or cmd-c...? i mean using only the mouse?why does it have to highlight the file even though i click a bit next to it....?using icon view i can right click next to the folder and i wont have a problem but with list view that i prefer using it will highlight the whole row.....and i dont find free space to right click cause i got many files
-
Hi, I was looking to see if anyone knows how I can troubleshoot my connection problem with TFS view in excel. I'm trying to produce a tree view in Office 2013 as described in the following KB -
https://msdn.microsoft.com/en-us/library/dd286627.aspx
I have followed the instructions on the KB all the way up to : 'Add backlog items and tasks and their parent-child links using a tree list' and at this point I can't seem to get it to work as the button is greyed out.
Note that I have completed steps 1-6 for the previous procedure... all 6 steps work just fine. However on step 2 of the second procedure - the instructions state I should be able to 'Add Tree Level' - However the button is greyed out.
Anyone know what I need to do to enable the button to use the tree list in excel?
FrankFrank,
I believe your issue is that you have opened a Flat query and are trying to add tree levels. A flat query is just that and you cannot change the query type from Excel.
The second process is managing a backlog (which is a tree). TFS web access has a link on the backlog view to create a query. That query will be a "tree of work items" query that returns the items in the backlog including their parent-child relationships.
This type of query supports the Add Tree Level and Add Child functionality as does a new Input List (not bound to an existing query).
"You will find a fortune, though it will not be the one you seek." -
Blind Seer, O Brother Where Art Thou
Please Mark posts as answers or helpful so that others may find the fortune they seek. -
Creating a Report Using a SharePoint List
I am using a SharePoint List that Named as 'Service Requests'. It has some fields with Date, Time, Status. The Date & Time will be entered. The Status as three values & those will be selected using a Drop Down List Box. The Statuses are 'In Progress,
Completed, In completed'.
I want to create a Report using this SharePoint List that include status with other fields in monthly basis. As an example I want the report about the Service Requests within the December month.
I also need to know how am I able to link this report to a Web Menu that in the SharePoint Site. Because there is a web menu in that SharePoint Site. I have not developed this site so I don't know the type of the web menu of this site.
I think someone can help me to solve these problems.
Regards,
ChiranthakaHi Chiranthaka,
According to your description, my understanding is that you want to create a report based on a SharePoint list.
I agree with Trevor’s and Mohammad’s suggestion to use SQL Server Reporting Service to create the report for SharePoint list.
You need to configure Reporting Services for SharePoint 2010 and then use it to create reports.
Here are two links with the detailed steps to create report using SSRS with SharePoint for you to refer:
http://aaclage.blogspot.in/2011/11/create-reports-with-sharepoint-2010-and.html
http://nikpatel.net/2010/06/11/step-by-step-consuming-sharepoint-2010-lists-data-in-the-ssrs-2008-r2-reports/
Best regards.
Thanks
Victoria Xia
TechNet Community Support
Maybe you are looking for
-
MSI 6600GT PCI-E video playback issues
ANY video file i try to open opens fine but if i try to skip around in the video the sound cuts off and i get accelerated playback, the video goes really fast and does not recover, i have to close player and start again. My machine is pretty high spe
-
How can I get updated data in sub VI in real time?
Hello. I'm making application using Labview 7.0. What I want to do is the data acquisition changing some parameters. I get the data each time I changed variable parameters. I can do it in sub VI by inserting array component into 'for' loop. As loop i
-
Acrobat 9 Pro: Open all documents in same window - don't want!!
In Acrobat 7 there was a setting under Edit/Preferences/Documents that said "Show each document in its own window" I had this unchecked. I can't find this setting in 9, there is no such option (at least what I can find). I don't want all documents in
-
How to make a title randomly 'jumping around', not 'flowing'?
I'd like to create my own 'watermark title'. Idea: the ©k.schluter slightly rotates a bit and randomly (done), and 'jumps' randomly across the screen. Apply a 'random generator' to the titles x/y position, makes it moving/flowing. What I want is an i
-
Yellow lines and some purple around the screen, and freezing, help?!
hi i have an iMac G4 First generation, and lately, the computer has been malfunctioning in the strangest way; its been either crashing and freezing up, OR invaded by yellow and orange lines all around the screen... i tried a clean install of system s