I have .jpg images in my buttons. I also would like to put some text on top of the images. I use the following syntax for that:
JButton btn = new JButton(label,icon);
But I do not see text in the buttons (only image). What am I doing wrong?
Question is simple for an expert:
Integer[][] res= new Integer[][] {.....hard code some values here on 2 dim...}
How to I return here 2 rows and 3 values like this
1 2 3
4 5 6
Hi all, is there a method (maybe with Google Collections) to obtain the min value of a Map(Key, Double)
In traditional way, I would have to sort the map according to the values, and take the first/last one.
thanks
I expect it should share a common description, like XmlSchema or IDL and should generate classes for target language.
I found Thrift and it's really nice solution, but it doesn't support structures polymorphism.
I would like to have collections of base class objects, where I could place instances of subclasses, serialize this and deserialize at the opposite side. Some mechanism of polymorphic behavior support, like Visitor, would be a perfect.
Does anybody know something suitable for these requirements?
I personally quite like instance initializers - I use them to assign default values to things such as collections so when writing constructors I don't have to remember to assign them the same default values each time. It seems quite elegant to me - avoids annoying NPE's popping up and avoids duplicate code. A private method doesn't seem as nice because a) it can't assign values to final fields, b) it could be run elsewhere in code and c) the method still needs to be explicitly called at the start of each constructor.
However, the flip side with others I have spoken to is that they're confusing, some people reading the code might not understand what they do or when they're called and thus they could cause more problems than they solve.
Are proper use of these initializers something to be encouraged or avoided? Or is it an "each to their own" case?
Is there a simple way to clear all fields of an instance from a an instance? I mean, I would like to remove all values assigned to the fields of an instance.
ADDED
From the main thread I start a window and another thread which controls state of the window (the last thread, for example, display certain panels for a certain period of time). I have a class which contains state of the window (on which stage the user is, which buttons he already clicked).
In the end, user may want to start the whole process from the beginning (it is a game). So, I decided. So, if everything is executed from the beginning, I would like to have all parameter to be clean (fresh, unassigned).
ADDED
The main thread, creates the new object which is executed in a new thread (and the old thread is finished). So, I cannot create a new object from the old thread. I just have a loop in the second thread.
Query query=getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(
"select...
getHibernateTemplate().setCacheQueries(true);
List result= query.list();
getHibernateTemplate().setCacheQueries(false);
return result;
may i know when i do manual "createSQLQuery" how to use cacheQuery? the above doesnt cache the result. show_sql still showing every request get from database
Here's the deal :
I have Publication objets in my application.
I also have Vote objet.
I can add votes on publication. A vote is defined like this, forOrAgainst, LinkedPublication, date, author etc etc...
I want to sort Publication list by number of vote.
What is the best way to link them ?
Should i return a hashmap ? a treeset ?
How do i add votes to publication.
It's kinda messy in my brain now...
I have a jsp file in the root of .war file.
and then I have a folder named STUFF.
How do I get access to the file read.txt inside STUFF?
/Name_of_war/STUFF/read.txt is the correct path?
hello everyone,
Can anyone please tell the way to find out the mac address of a system which is:
1. Shutdown
2. Power plugged in
3. Connected to Lan
4. Nic card ON.
Kindly post the solution as i urgently need it in my project...
thank you
I have a question. What is wrong with regards to the below code:
ArrayList tempList2 = new ArrayList();
tempList2 = getXYZ(tempList1, tempList2);
//method getXYZ
getXYZ(ArrayList tempList1, ArrayList tempList2) {
//does some logic and adds objects into tempList2
return tempList2;
}
The code will get executed but it seems by passing tempList2 to the getXYZ method argument, it is doing object recycling.
My question is, Is recycling the tempList2 arraylist object correct?
I'm trying to get the resultCode to be OK inside my onActivityResult function. However, it keeps coming back as 0. I have spent several days on this, and can't figure out why it doesn't work. Here's my code. If anybody can help me, I'll be very grateful, Thanks.
My Activity1 class:
private class MyTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... urls) {
// process
return result;
}
@Override
protected void onPostExecute(String result) {
Intent i = new Intent(Activity1.this, Activity2.class);
i.putExtra("Value1", "This value one for ActivityOne ");
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(i, REQUEST_CODE);
textView.setText(result);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK && requestCode == REQUEST_CODE) {
// do something
}
}
My Activity 2 class:
@Override
public void finish() {
Intent data = new Intent();
data.putExtra("returnKey1", "return 1");
setResult(RESULT_OK, data);
super.finish();
}
My manifest:
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Activity1"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activity2"
android:label="@string/app_dialog_name"
android:launchMode="singleTop"
android:excludeFromRecents="true"
android:taskAffinity=""
android:theme="@android:style/Theme.Dialog">
</activity>
</application>
Which one of the following is NOT a pitfall of inheritance?
Base-derive classes should be totally separate and do not have an is-a relationship.
Base-derive classes should have been aggregate classes instead.
Inheritance may be inverted, example: Truck<-Vehicle should be Vehicle<-Truck.
Incompatible class hierarchies may be connected because of multiple inheritance.
Aggregation should have been used instead.
Functionality is transferred from a base class to a derived one.
In my opinion, NOT a pitfall of inheritance meas can use inheritance.
1 seems do without inheritance
2 aggregate substitute Base-derive I don't know
So, I think 5 is the answer.
It says I ended this statement wrong when if I input it into sql plus with just the addition of ; it works perfectly. What am I doing wrong?
Statement statement = connection.createStatement();
statement.executeUpdate("delete from aplbuk MODEL = '"+ textField_4.getText() + "'AND year = '" + textField_1.getText() + "' AND Litres = '" + textField_2.getText()
+ "' AND ENGINE_TYPE = '" + textField_3.getText() + "'");
statement.close();
Hello Team,
I am using the below code in my application ...
Process process = Runtime.getRuntime().exec(
"perl " + perlScript + " " + project + " " + fileName);
:
:
:
result = process.waitFor();
:
:
and this result gives the code 2 every time.....while running the application.
what could be the reason for the "reason code" ???
Thanks In Advance
My iPhone SDK and Objective-C learning is moving ahead quickly, thanks to several great books and online help (including this one). But I do have some basic questions due to what I already know that will be answered eventually, but I'd rather get a heads-up now if possible :)
Are there equivalents for LayoutManagers in Cocoa Touch? Are they used, or is absolute positioning used instead? I have seen some of the layout stuff in IB, but I'm not sure what to look at in code.
Aside from using the IB, are UIControls added directly to UIView instances using the addSubview (like add in Swing)?
These are just two concrete questions that I've thought of just now, but I would love to see any translation of Swing concepts to Cocoa Touch.
Is ther any way to get data from other sites and display in our jsp pages dynamically.
http://www.dictionary30.com/meaning/Misty see this url
in that one block is like
Wikipedia Meaning and Definition on 'Misty'
In that block they are fetching the data from Wikipedia and displaying into dictionaly30.
Question:
How they are fetching wiki data to their site.?
I need to display data like that in my jsp page by fetching from other site.
Hey Guys
I want to set two different look and fields on one frame.
I have two different panels in that.
i want to set two different look and field for both.
Can I do that?
And if yes then how?