I use netbeans,and I insert an image on the lable which is on the desktop pane ,I want to rotate that image in its place ,what should i do?
please help me.
thanks.
I know that in a standalone application I create one of the application context instances which in turn creates the beans from conf files. But I can not see any such code in dispatched servlet. How then are the beans created in a web application?
I have a list of entities where creation order is important, but they do not contain a timestamp to use for sorting. Entities are added to the end of the list as they are created so they will be ordered correctly in the list itself.
After persisting the list using Hibernate the entities appear in the database table in the order that they were created. However when retrieving the list using a new Hibernate session the list is now in reverse order of insertion/creation.
Is this expected behaviour? Is there any way to retrieve the list in the same order as it appears in the table?
The primary key is a UUID, and the list of entities should always have been created on the same IP address and JVM. This mean sorting by UUID is a possibility but I'd rather not make assumptions.
Another possibility is if the list is guaranteed to always come out in reverse order I could always just work through it backwards.
Hi all,
Using the Synth LaF, I am unable to set a JLabel's FOREGROUND color for the DISABLED state. has anybody succeeded in doing this? Here is my label's style definition in my LaF.xml file.
<style id="whiteLabelStyle">
<opaque value="false"/>
<font name="Bitstream Vera Sans" size="16" />
<state>
<color type="FOREGROUND" value="WHITE"/>
</state>
<state value="DISABLED">
<color type="FOREGROUND" value="BLACK"/>
</state>
</style>
<bind style="whiteLabelStyle" type="name" key="WhiteOrbitLabel"/>
Please not that all the other styles defined in my LaF.xml file are rendered properly in my application including my label's WHITE normal state color (it just never goes to black when I do lbl.setEnabled(false)
Also, going through the Synth code, I have found the following comment in SynthStyle.getColor
if ((context.getComponentState() & SynthConstants.DISABLED) != 0) {
//This component is disabled, so return the disabled color.
//In some cases this means ignoring the color specified by the
//developer on the component. In other cases it means using a
//specified disabledTextColor, such as on JTextComponents.
//For example, JLabel doesn't specify a disabled color that the
//developer can set, yet it should have a disabled color to the
//text when the label is disabled. This code allows for that.
if (c instanceof JTextComponent) {
JTextComponent txt = (JTextComponent)c;
Color disabledColor = txt.getDisabledTextColor();
if (disabledColor == null || disabledColor instanceof UIResource) {
return getColorForState(context, type);
}
} else if (c instanceof JLabel
&& (type == ColorType.FOREGROUND || type == ColorType.TEXT_FOREGROUND)){
return getColorForState(context, type);
}
But I could not figure out how to set a disabled color for a JLabel
Thanks for your help!
Hi there,
the swt file dialog will give me an empty result array if I select too much files (approx. 2500files). The listing shows you how I use this dialog. If i select too many sound files, the syso will show 0. Debugging tells me, that the files array is empty in this case. Is there any way to get this work?
FileDialog fileDialog = new FileDialog(mainView.getShell(), SWT.MULTI);
fileDialog.setText("Choose sound files");
fileDialog.setFilterExtensions(new String[] { new String("*.wav") });
Vector<String> result = new Vector<String>();
fileDialog.open();
String[] files = fileDialog.getFileNames();
for (int i = 0, n = files.length; i < n; i++) {
if( !files[i].contains(".wav")) {
System.out.println(files[i]);
}
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(fileDialog.getFilterPath());
if (stringBuffer.charAt(stringBuffer.length() - 1) != File.separatorChar) {
stringBuffer.append(File.separatorChar);
}
stringBuffer.append(files[i]);
stringBuffer.append("");
String finalName = stringBuffer.toString();
if( !finalName.contains(".wav")) {
System.out.println(finalName);
}
result.add(finalName);
}
System.out.println(result.size())
;
I have an activity which pulls some JSON from my server, and then uses it to draw a list. That list launches further activities.
My problem is that I can't figure out a way to tell if the activity is still alive when you go back to it, so I end up re-querying my JSON from the server and redrawing the list every time the user goes back to the activity.
How can I tell if my activity is still alive so I can skip the redraw?
Hi,
till now i still worked with JSF and JPA without DAOs. Now i'd like to use DAOs. But how can i initialize the EntityManager in the DAO-Classes?
public class AdresseHome {
@PersistenceContext
private EntityManager entityManager;
public void persist(Adresse transientInstance) {
log.debug("persisting Adresse instance");
try {
entityManager.persist(transientInstance);
log.debug("persist successful");
} catch (RuntimeException re) {
log.error("persist failed", re);
throw re;
}
}
}
Have I to use Spring or is there a solution that works without Spring?
Thanks.
The code at the bottom is what I have. I removed the creation of all tags.
At the top in the xml file I get.<?xml version="1.0" encoding="UTF-8" standalone="no"?> Note that standalone is no, even thou I have it set to yes.
The first question: How do I get standalone = yes?
I would like to add <?xml-stylesheet type="text/xsl" href="my.stylesheet.xsl"?> at line two in the xml file.
Second question: How do I do that?
Some useful links? Anything?
DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
Document doc = docBuilder.newDocument();
<cut>
TransformerFactory transfac = TransformerFactory.newInstance();
transfac.setAttribute("indent-number", new Integer(2));
Transformer trans = transfac.newTransformer();
trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
trans.setOutputProperty(OutputKeys.STANDALONE, "yes");
trans.setOutputProperty(OutputKeys.INDENT, "yes");
trans.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, "name");
FileOutputStream fout = new FileOutputStream(filepath);
BufferedOutputStream bout= new BufferedOutputStream(fout);
trans.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(bout, "utf-8")));
I have an abstract entity:
public abstract class Entity extends JPanel implements FocusListener
And I have a TextEntity:
public class TextEntity extends Entity
Inside TextEntity's constructor I want to put a JTextArea that will cover the panel:
textArea = new JTextArea();
textArea.setSize(getWidth(),getHeight());
add(textArea);
But getWidth() and getHeight() returns 0. Is it a problem with the inheritance or the constructor?
i am fetching the data values from the database success fully. I have also stored them into a String array. I need to load the String array as the items of the ComboBox in response to key actionperformed . How can i reload the items of the ComboBox whenever a key is pressed as the fetched values depend on the key pressed. Rather simply, i need to dynamically refresh the ComboBox items. please help.
I have some JButtons in a JFrame (its layout is null). The background Color of the buttons are set Black. I have made the JFrame Transparent by using this code.
AWTUtilities.setWindowOpacity(this, 0);
But the problem is it also makes all the buttons transparent as well. I don't want that. I want to see the buttons remaining black but the other portions of the JFrame becoming transparent (so that I can see the desktop background). Please someone help me.
Thanks in advance.
For educational purposes I have set up a project layout like so (flat in order to suite eclipse better):
-product
|
|-parent
|-core
|-opt
|-all
Parent contains an aggregate project with core, opt and all. Core implements the mandatory part of the application. Opt is an optional part. All is supposed to combine core with opt, and has these two modules listed as dependencies.
I am now trying to make the following artifacts:
product-core.jar
product-core-src.jar
product-core-with-dependencies.jar
product-opt.jar
product-opt-src.jar
product-opt-with-dependencies.jar
product-all.jar
product-all-src.jar
product-all-with-dependencies.jar
Most of them are fairly straightforward to produce. I do have some problem with the aggregating artifacts though. I have managed to make the product-all-src.jar with a custom assembly descriptor in the 'all' module which downloads the sources for all non-transitive deps, and this works fine. This technique also allows me to make the product-all-with-dependencies.jar.
I however recently found out that you can use the source:aggregate goal in the source plugin to aggregate sources of the entire aggregate project. This is also true for the javadoc plugin, which also aggregates through the usage of the parent project.
So I am torn between my 'all' module approach and ditching the 'all' module and just use the 'parent' module for all aggregation. It feels unclean to have some aggregate artifacts produced in 'parent', and others produced in 'all'. Is there a way of making an 'product-all' jar in the parent project, or to aggregate javadoc in the 'all' project? Or should I just keep both?
Thanks
My understanding is serialVersionUID is applicable only to classes, because we can create an object only to classes and the concept of serialVersionUID is for object serialization and deserialization.
Hi,
I was doing my academic project and while building and testing i have put many println() statements.
But when I had to submit all prints should not be displayed.
Can i implement something like listener which will be invoked when System.out is tried to be executed and prevents it from displaying.
I dont know how feasible this idea is but just want to know whether its possible or not.
I know i could have used a log file or write into a file but again its just a thought came into my mind if I have to disable SOP how can i do it ..
thanks
I have an ApplicationContext.xml file with the following node:
<context:property-placeholder
location="classpath:hibernate.properties, classpath:pathConfiguration.properties" />
It specifies that both properties files will be used by my application. But if one of these files does not exist, no error ir thrown.
How can I throw an exception for any of these files? They should me mandatory.
Is it possible to: set a URI template in the mvc:view-controller element of the *-servlet.xml file or in a controller method and then use/get that path parameter in a jsp?
I understand that using @PathVariable in a controller method will give me access to the path parameter in that controller method. But how can I gain access to the path parameter in the jsp?
For example, is it possible to do something like:
*-servlet.xml file:
<beans...>
<mvc:view-controller path="/home" view-name="home"/>
<mvc:view-controller path="/home/{error}" view-name="home"/>
</beans>
jsp file:
<c:if test="${not empty param['error']}">
<span class="error">You have an error...</span>
</c:if>
From wiki: In computing, just-in-time compilation (JIT), also known as dynamic translation, is a technique for improving the runtime performance of a computer program.
So I guess JVM has another compiler, not javac, that only compiles bytecode to machine code at runtime, while javac compiles sources to bytecode,is that right?
why is my APP crashing when I invoke the AsyncTask?
public class Login extends Activity {
String mail;
EditText mailIn;
Button btSubmit;
@Override
protected void onCreate(Bundle tokenArg) {
super.onCreate(tokenArg);
setContentView(R.layout.login);
mailIn = (EditText)findViewById(R.id.usermail);
btSubmit = (Button)findViewById(R.id.submit);
btSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View thisView) {
new LoginProc().execute();
}
});
}
public class LoginProc extends AsyncTask<String, Void, Void> {
@Override
protected void onPreExecute() {
mailIn = (EditText)findViewById(R.id.usermail);
mail = mailIn.getText().toString();
super.onPreExecute();
}
@Override
protected Void doInBackground(String... params) {
Toast.makeText(getApplicationContext(), mail, Toast.LENGTH_SHORT).show();
return null;
}
}
}
I'm trying to make the String name get it's value on the preExecute method, but it happens that the app crashes on that point. Even if I take the preExecute and do that on the doInBrackground, it still crashes. What's wrong?
I have entities similar to:
ProductLine: id, name
ProductLineContents: content_id, product_line_id
Content: id, text, updated_time
What I'd like to do is: for each product line, get the latest content (so if theres two content entries associated to one product line, the latest updated_time is rturned, and if one content item is associated to two product lines, it is returned twice). Something similar to:
select content.* from productline
inner join productlinecontents
inner join content;
However I can't seem to figure out how to have Hibernate Criteria return a different entity than the original one it was created with. So if I wanted to start the criteria at the product line with createCriteria(ProductLine.class) along with the proper joins, then it only returns ProductLine objects, but I need Content objects.
What's the best way to accomplish this?
The actual data model is much more complex and can't be modified
So here is my code:
public MyClass (int y) {
super(y,x,x);
//some code
}
My problem is that in this case i want to generate a 'x' and sent to the super constructor. However the call to the superconstructor must be the first line in this constructor. Of course I could do something like this:
int x;
{
x = generateX();
}
But this feels ugly, and then the code will run no matter what constructor I use, which feels not so nice. Right now I am consider encapsulating my whole object in another object that only calculates x and then starts this object. Is this the best approach?
I am writing a tomcat app, and have a need to do authentication within the URL like this:
https://user:[email protected]
Except for the life of me i'm not sure how to set it up or able to find the docs to read up on it, clearly my google skills need work.
Can anyone tell me where i should be looking for this kind of info or where to start?
Cheers
Andy
BeanUtils copyProperties, out of the box, doesn't seem to handle copying from Boolean object properties to boolean primitive properties.
I figured I could create and register a converter to handle this, but that just didn't seem to work.
So, how can I use BeanUtils to copy the properties from class Source to class Destination where:
public class Destination {
private boolean property;
public boolean isProperty() {
return property;
}
public void setProperty(boolean property) {
this.property = property;
}
}
public class Source{
private Boolean property;
public Boolean getProperty() {
return property;
}
public void setProperty(Boolean property) {
this.property = property;
}
}
I have the following entities
Student
@Entity
public class Student implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
//getter and setter for id
}
Teacher
@Entity
public class Teacher implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
//getter and setter for id
}
Task
@Entity
public class Task implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne(optional = false)
@JoinTable(name = "student_task", inverseJoinColumns = { @JoinColumn(name = "student_id") })
private Student author;
@ManyToOne(optional = false)
@JoinTable(name = "student_task", inverseJoinColumns = { @JoinColumn(name = "teacher_id") })
private Teacher curator;
//getters and setters
}
Consider that author and curator are already stored in DB and both are in the attached state. I'm trying to persist my Task:
Task task = new Task();
task.setAuthor(author);
task.setCurator(curator);
entityManager.persist(task);
Hibernate executes the following SQL:
insert
into
student_task
(teacher_id, id)
values
(?, ?)
which, of course, leads to null value in column "student_id" violates not-null constraint
Can anyone explain this issue and possible ways to resolve it?