|
I think this answers your question, http://docs.oracle.com/javase/1.5.0/docs/guide/language/annotations.html[^]
Quote:
Once an annotation type is defined, you can use it to annotate declarations. An annotation is a special kind of modifier, and can be used anywhere that other modifiers (such as public, static, or final) can be used. By convention, annotations precede other modifiers. Annotations consist of an at-sign (@) followed by an annotation type and a parenthesized list of element-value pairs. The values must be compile-time constants.
Personally never used annotations for anything other than generating Java Docs and I'm not sure what your trying to use it for here? Are you really trying to define an interface?
|
|
|
|
|
Thanks, I'll take a look at the link. Per your question, I'm using annotations to for custom validation.
|
|
|
|
|
Annotations can be processed to produce code in various ways. The code of course would exist at run time.
If you are using an existing annotation processing system then what ever it does is what you can do, and you would look at the docs for that.
If your writing your own then add the functionality to keep track of it.
|
|
|
|
|
Hi everyone,
I am a beginner in Spring framework. I am learning about Spring Dependency Injection from [Dependency Injection]. My project have been written according to above tutorial. But there is an error when I run my project.
If anyone know about my problem, plz point me.
here is my project file linke : [My Spring Project]
the followings are the library I used in my project :
antlr-4.1-complete
commons-logging-1.1.3
spring-aop-3.2.4.RELEASE
spring-asm-3.1.4.RELEASE
spring-aspects-3.2.4.RELEASE
spring-beans-3.2.4.RELEASE
spring-context-3.2.4.RELEASE
spring-context-support-3.2.4.RELEASE
spring-core-3.2.4.RELEASE
spring-expression-3.2.4.RELEASE
Best Regards
Kaung Myat
|
|
|
|
|
No one is going to download your code and try to debug it for you. Please edit your question and add a proper explanation of your problem.
Veni, vidi, abiit domum
|
|
|
|
|
kmb89 wrote: there is an error
And the error message is: ? And the lines of code around the place where it happens?
|
|
|
|
|
I have this code which saves the value into database from JSpinner
SpinnerListModel monthModel = new SpinnerListModel();
String[] monthStrings = {"1Month","3Month","6Month","1Year"};
monthModel = new SpinnerListModel(monthStrings);
JSpinner spinner = new JSpinner(monthModel);
statement.setString(28,(String)monthModel.getValue().toString().toUpperCase());
But how to get that value back for Editing?
I tried
spinner.setText((String)monthModel.getValue(),29);
But it says
The method setText(String, int) is undefined for the type JSpinner
How do I get the values from Database?again to JSpinner.
|
|
|
|
|
You should have a database layer. It should NOT have any gui code in it.
It provides a public API that allows an external caller to interact with the layer.
The layer interacts with the database.
That public API would have a method/class that would represent "save interval" and "get interval" where the 'interval' values represent '1 month', '3 Months', '6 months' (and note that I am NOT saying to store "1 month" as a value.)
The 'save' method uses a database insert or perhaps update statement. And the 'get' uses a database query statement.
You code that and test it.
After you do that THEN your gui code, specifically the JSpinner uses the two methods.
|
|
|
|
|
Can anyone guide me how to write code to generate public and private keys using RSA algorithm, using your own functions? In other words, not using BigInteger etc. This seems impossible and I have a deadline of 31 October, 2013.
|
|
|
|
|
|
I'm not able to move forward with the ResultSet with this code on "next Button".
Here is the code
public void nextrecord()
{
Statement stmt = null;
String query = "select * from Employer";
try {
stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = stmt.executeQuery(query);
if(rs.isBeforeFirst());
{
while(rs.next())
{
firstNameTextField.setText(rs.getString(2));
lastNameTextField.setText(rs.getString(3));
addressTextField.setText(rs.getString(4));
}
}
}
catch (SQLException e )
{
e.printStackTrace();
}
}
The problem is when I click on the next button ,it takes me to the last record and skips all the records ,I wanted to go through all the records one by one ,clicking each record one by one.
There is one record present in the text fields before pressing next button.
|
|
|
|
|
Separate your actions...
0. Method to query the data, then store the record set.
1. Method to display a record.
Something like [untested code]
class Hatstand
extends Stuff
{
private RecordSet recordSet;
private void submitQuery()
{
Statement stmt = null;
String query = "select * from Employer";
try
{
stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
this.recordSet = stmt.executeQuery(query);
}
catch (SQLException e )
{
e.printStackTrace();
this.recordSet = null;
}
finally
{
setRecord(true);
}
}
private void setRecord(boolean forward)
{
boolean isNull = true;
if (this.RecordSet != null)
{
if (forward && !this.RecordSet.isLast())
{
this.RecordSet.next();
isNull = false;
}
else if (!forward && !this.RecordSet.isFirst())
{
this.RecordSet.previous();
isNull = false;
}
}
if (isNull)
{
firstNameTextField.setText(null);
lastNameTextField.setText(null);
addressTextField.setText(null); }
}
else
{
firstNameTextField.setText(rs.getString(2));
lastNameTextField.setText(rs.getString(3));
addressTextField.setText(rs.getString(4)); }
}
}
}
speramus in juniperus
|
|
|
|
|
Thanks for the Idea.
|
|
|
|
|
I have a String which has been splitted like this
String companyinforstring ="Company name.:Company profile no 1.:Company profile no 2.:Company profile no3.:---------------------------------------------------------------:Company address, :Street number, :Area,Area no2, :City. ";
for (String retval: companyinforstring.split(":"))
{
System.out.println(retval);
graphics.drawString(retval.toUpperCase(), 250, 200);
}
The Problem is that String which has been splitted, overlaping each String,How can this be solved?
|
|
|
|
|
graphics.drawString(retval.toUpperCase(), 250, 200);
You are drawing every line at the same point.
Veni, vidi, abiit domum
|
|
|
|
|
String[] str1 = companyinforstring.split(":");
for(int i=0;i<str1.length;i++)
{
graphics.drawString(str1[0].toUpperCase(), 360, 50);
graphics.drawString(str1[1].toUpperCase(), 360, 60);
graphics.drawString(str1[2].toUpperCase(), 360, 70);
graphics.drawString(str1[3].toUpperCase(), 360, 80);
graphics.drawString(str1[4].toUpperCase(), 360, 90);
graphics.drawString(str1[5].toUpperCase(), 360, 100);
graphics.drawString(str1[6].toUpperCase(), 360, 110);
graphics.drawString(str1[7].toUpperCase(), 360, 120);
graphics.drawString(str1[8].toUpperCase(), 360, 130);
}
Is there any simple way of doing it?
Please let me know
|
|
|
|
|
chdboy wrote: Is there any simple way of doing it? Of course, use a loop, something like:
int lineHeight = 10;
int currentLine = 50;
for (String strText: companyinforstring.split(":"))
{
graphics.drawString(strText.toUpperCase(), 360, currentLine);
currentLine += lineHeight;
}
Veni, vidi, abiit domum
|
|
|
|
|
thanks a lot
|
|
|
|
|
Using applets i create one text editor in there when they enter maximum words cursor should go to the new page this is my issue . so if any know know how to overcome this problem pls help me out.
Thanks and Regards.
Naveenkrishna
|
|
|
|
|
Member 10356313 wrote: pls help me out. With what? All you have given us is a description of what you think your code should do.
Veni, vidi, abiit domum
|
|
|
|
|
This code i wrote to create the editor. Everything is working fine but if I entered maximum characters cursor is not moving to new page.
public JTextComponent createEditor(final Source source)
{
if(source.getSourceType() == Source.SERIALIZATION)
return deserializeEditor(source.getSerializedObject());
if(source.getSourceType() == Source.CONTENT)
return createEditorFromPage(new Page() {
public void setPage(JTextPane pane)
{
if(source.getBaseUrl() != null)
try
{
URL baseUrl = new URL(source.getBaseUrl());
((HTMLDocument)pane.getDocument()).setBase(baseUrl);
}
catch(MalformedURLException e)
{
e.printStackTrace();
}
pane.setText(source.getContent());
}
});
else
return createEditorFromPage(new Page() {
public void setPage(JTextPane pane)
throws IOException
{
pane.setPage(source.getSourceUrl());
}
});
}
public JTextComponent createEditorFromPage(Page page)
{
JTextPane p = new JTextPane();
Dimension dim = new Dimension(labelDimension.getWidth(), labelDimension.getHeight());
p.setPreferredSize(dim);
p.setMaximumSize(dim);
p.setSize(dim);
HTMLEditorKit kit = createEditorKit();
p.setEditorKit(kit);
p.setTransferHandler(new PlainTextTransferHandler());
if(page != null)
try
{
page.setPage(p);
}
catch(IOException e)
{
System.err.println("Attempted to read a bad URL: " + e.getMessage());
}
else
System.out.println("create empty label");
javax.swing.text.Style style = p.addStyle("24pts", null);
StyleConstants.setFontSize(style, 24);
style = p.addStyle("12pts", null);
StyleConstants.setFontSize(style, 12);
style = p.addStyle("Italics", null);
StyleConstants.setItalic(style, true);
style = p.addStyle("Bold", null);
StyleConstants.setBold(style, true);
p.addMouseListener(new PopupMenuMouseListener(new PopupMenuFactory((HTMLDocument)p.getDocument()), p));
p.setDragEnabled(!hiddenMode);
initializeDocument((HTMLDocument)p.getDocument(), p, kit);
return p;
}
|
|
|
|
|
Please use <pre> tags around your code so it looks readable:
if(source.getSourceType() == Source.SERIALIZATION)
return deserializeEditor(source.getSerializedObject());
if(source.getSourceType() == Source.CONTENT)
As to your actual problem you have not explained where in the code you expect it to go to a new page, and what actually happens at that point.
Veni, vidi, abiit domum
|
|
|
|
|
<pre>
if(source.getSourceType() == Source.SERIALIZATION)
return deserializeEditor(source.getSerializedObject());
public JTextComponent deserializeEditor(InputStream inputStream)
{
JTextPane p;
System.out.println("deserialize existing document...");
p = new JTextPane();
p.setPreferredSize(new Dimension(labelDimension.getWidth(), labelDimension.getHeight()));
javax.swing.text.EditorKit kit = createEditorKit();
p.setEditorKit(kit);
ObjectInputStream ois = null;
try
{
ois = new ObjectInputStream(inputStream);
Object obj = null;
if((obj = ois.readObject()) != null && (obj instanceof Document))
{
Document doc = (Document)obj;
p.setDocument(doc);
System.out.println("set deserialized document");
}
}
catch(IOException e)
{
System.err.println(e.getMessage());
e.printStackTrace();
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
finally
{
safeClose(ois);
}
p.setDragEnabled(!hiddenMode);
return p;
}
public JTextComponent createEditorFromPage(Page page)
{
JTextPane p = new JTextPane();
Dimension dim = new Dimension(labelDimension.getWidth(), labelDimension.getHeight());
p.setPreferredSize(dim);
p.setMaximumSize(dim);
p.setSize(dim);
HTMLEditorKit kit = createEditorKit();
p.setEditorKit(kit);
p.setTransferHandler(new PlainTextTransferHandler());
if(page != null)
try
{
page.setPage(p);
}
catch(IOException e)
{
System.err.println("Attempted to read a bad URL: " + e.getMessage());
}
else
System.out.println("create empty label");
javax.swing.text.Style style = p.addStyle("24pts", null);
StyleConstants.setFontSize(style, 24);
style = p.addStyle("12pts", null);
StyleConstants.setFontSize(style, 12);
style = p.addStyle("Italics", null);
StyleConstants.setItalic(style, true);
style = p.addStyle("Bold", null);
StyleConstants.setBold(style, true);
p.addMouseListener(new PopupMenuMouseListener(new PopupMenuFactory((HTMLDocument)p.getDocument()), p));
p.setDragEnabled(!hiddenMode);
initializeDocument((HTMLDocument)p.getDocument(), p, kit);
return p;
}
</pre>
Save event is there if they click save event whole HTML image is going to save in BLOB object. In there I'm checking if its already save value or new value if its saved value it call deserializeEditor () in this method binary value is converting to string then it will show in editor if its new string value means just it will call createEditorFromPage() event which i showed in above code.
My problem is when they entering text in editor if its reach maximum characters or maximum lines it should open new page.
Its like "Wold document"
sorry while keypress the value I don't no which event is going to fire.please suggest which event is going to fire with any example.
naveenkrishna
|
|
|
|
|
I'm not able to get the printout.
Here is the code.
public class Billing extends Frame implements ActionListener,Printable
{
JButton printbtn = new JButton("Print");
}
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
throws PrinterException
{
if (pageIndex > 0)
{
return NO_SUCH_PAGE;
}
Graphics2D g2d = (Graphics2D)graphics;
g2d.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
graphics.drawString("Hello world!", 100, 100);
return PAGE_EXISTS;
}
public Billing
(
printbtn.addActionListener(this);
JPanel panel = new JPanel();
panel.setLayout(new MigLayout("debug,fillx,filly", "[]rel:push[]", "[]1[]"));
panel.add(printbtn);
frame.add(panel);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
)
@Override
public void actionPerformed(ActionEvent e)
{
else if (e.getSource().equals(printbtn))
{
System.out.println("You have clicked on Print Button!");
PrinterJob pj = PrinterJob.getPrinterJob();
job.setPrintable(this);
if (pj.printDialog() == true)
{
try
{
pj.print();
}
catch (PrinterException exc)
{
System.out.println(exc);
}
}
System.out.println("Print Job Ends Here!!!!XXXXX!!!!");
}
}
|
|
|
|
|
Please get your code to a compilable form - everyone trying to read this has to guess what you actually mean several times to get that right.
Regards,
ab
|
|
|
|
|