Ashutosh Deo

Greenhorn
+ Follow
since Jul 12, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Ashutosh Deo

I have to retain the exact value of a Double and convert it into a string.

Double value = 105312453566.35363465;

I tried doing a toString() on the above Double value... but it returns me an output 1.0531245356635364E11



Hence I tried converting it into a BigDecimal format using the below code... so that I can retain the exact value..

BigDecimal newValue = new BigDecimal(value);
System.out.println("BigDecimal Value: " + newValue);

But the output which I get is like this :

BigDecimal Value: 105312453566.3536376953125

which is again not what I want.


How can I get the exact value?
16 years ago
I am able to store all the values in the CSV file into a String Array. But I can't figure out how to aggregate the common values...

The output will be as shown in the image... though in CSV format..

Please refer the image.


For instance...

The values (G01,38020) are same in the first 2 rows...

Hence these 2 rows are clubbed together in the output.... You can also see the addition of the values in the LAST 2 columns.... FOR those 2 rows.


The third row also has (G01,38020) but has a different value (Dec-07) in the fifth column... Hence its shown separately..


The change in values needs to be seen only in the first 5 columns.
The addition needs to be done only for the last 2 columns.

Can you help me out in this?
[ July 18, 2008: Message edited by: Ashutosh Deo ]
16 years ago
Aggregating the rows.
16 years ago
Hi..

I am facing a problem in aggregating some CSV data, using Java.

My input is like this:

G01,38020, XX, 3M EUR, Sep-07,10,23
G01,38020, XX, 3M EUR, Sep-07,11, ,72
G01,38020, XX, 3M EUR, Dec-07,14, ,500


My expected output is:

G01,38020, XX, 3M EUR, Sep-07,10,23, ,
, , XX, 3M EUR, Sep-07,11, ,72,
, , , , , ,23,72,
, , XX, 3M EUR, Dec-07,14, ,500,
, , , , , ,0,500,


Check out the image for convenience:


I need to calculate sum for the values in the last two columns.


Can anyone suggest me on how to approach this problem?
[ July 17, 2008: Message edited by: Ashutosh Deo ]
16 years ago
How about using StringTokenizer?
16 years ago
I have this condition statement.

if(firstval != secondval )
then(result1)
else if(secondValue == null)
then(result2)
else(result3)


I want to store the sub parts of each condition in separate strings.

For eg. in the above string,

For the first if Condition, I need the sub parts to be saved in Strings as follows ->

leftCondition = "firstval"
operator = "!="
rightCondition = "secondval"
result = "result1"

Similarly I need 4 sub parts for the else if condition and 1 sub part(result3) for the last else condition.


Can someone give me the java code for the same?

[ July 12, 2008: Message edited by: Ashutosh Deo ]
[ July 12, 2008: Message edited by: Ashutosh Deo ]
16 years ago

Originally posted by pete stein:

3) set combobox invisible. make visible on radiobutton press.




Thanks a lot Pete. This approach worked best for me.

I have stopped using Netbeans as it doesn't give me much flexibility in editing and re-arranging the code as I want it. I don't find the "Back-door" Entry to the code so user-friendly. Hence I switched over to Eclipse.


Thanks once again for your inputs.

Cheers
17 years ago
Hi,

I found out where to include that method. I included it in the Class and simply called the PopulateCurrencies() method from the Customize Code Property of the JCombobox.

I got the string array and then passed it to the setModel method.


I have a special requirement - The JComboBox should be hidden until I click on some Radio button. i.e. I want the JComboBox to be created and populated during runtime. (Populated according to the Radio button action listener and the PopulateCurrencies() method)

How do I hide the component and display it with the populated values whenever the radio button is clicked?
17 years ago
I will try that out Pete, Thanks


My program structure is like this-

I created a New Project -> Java Application -> New JFrame Form in the Package.

Then I designed the GUI with all the components.

The GUI Source is something like this ->


public class CSGenerator extends javax.swing.JFrame
{

public CSGenerator()
{
initComponents();
}


//ActionPerformed Methods of some of the components.



private void initComponents()
{
//Automatically Generated Code

jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "12", "123" })); //HardCoded Values

//Automatically Generated Code

}


public static void main(String args[])
{ // Main Method with the run() function}


//Variables Declaration

}


As you can see, The setModel method is in the Automatically generated code and the only way to Customize that particular code is by going to the Customize Code property of the JComboBox component. But I can't figure out where do I write my PopulateCurrencies() Method and then pass the curr[] array to the DefaultComboBox Model object.
[ April 29, 2008: Message edited by: Ashutosh Deo ]
17 years ago
Hi!

I have developed a GUI using Swing in Netbeans 6.0.1

I have a JComboBox component which I need to populate with some specific currencies(Strings), retrieved by using a Third-Party Software API.

I have a method PopulateCurrencies() which contains the code to retrieve those strings. This method contains an array of Strings - curr[] which stores the retrieved currencies using APIs.

My Questions -

1) Where do I include this Method code in the Program? (If in the GUI Source, Where Exactly?)

2) How Do I associate the Method with the JComboBox ?



Note: I tried to use the JComboBox's model property in properties
I selected "Value from Existing Component" for setting the model and then selected "Method Call".

But I could not figure it out.


I'd be glad if anyone helps me out!
17 years ago