Click here to Skip to main content
15,888,984 members
Home / Discussions / Java
   

Java

 
QuestionHow to using jena lib with rdf for semantic web. Pin
Fatih Khoirul Umam19-Jan-16 14:14
Fatih Khoirul Umam19-Jan-16 14:14 
SuggestionRe: How to using jena lib with rdf for semantic web. Pin
Richard MacCutchan19-Jan-16 23:15
mveRichard MacCutchan19-Jan-16 23:15 
QuestionAs regards the voice chat in spark im. Pin
superman_kgy16-Jan-16 4:41
superman_kgy16-Jan-16 4:41 
AnswerRe: As regards the voice chat in spark im. Pin
Richard MacCutchan16-Jan-16 4:44
mveRichard MacCutchan16-Jan-16 4:44 
Questionhow to calculate 4 year degree completed data in resume Pin
Member 1216598516-Jan-16 0:34
Member 1216598516-Jan-16 0:34 
AnswerRe: how to calculate 4 year degree completed data in resume Pin
Peter Leow16-Jan-16 0:50
professionalPeter Leow16-Jan-16 0:50 
AnswerRe: how to calculate 4 year degree completed data in resume Pin
Richard MacCutchan16-Jan-16 2:33
mveRichard MacCutchan16-Jan-16 2:33 
Questionprint jPanel Pin
Member 122400217-Jan-16 23:27
Member 122400217-Jan-16 23:27 
Hello,
I have an application that needs to print the contents of a JPanel, and I using this code
Java
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(new Printable() {
 
            @Override
            public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
                if (pageIndex > 0) {
            return NO_SUCH_PAGE;
        }
         
        int marge=30;
        int x = (int)pageFormat.getImageableX();
        int y = (int)pageFormat.getImageableY();
                 
        graphics.setFont(new Font("Times new roman", Font.BOLD, 14));
        graphics.setColor(Color.BLACK);
        graphics.drawString("ACTE DEMANDER\n", x + marge, y + marge);
 
panel.print(graphics);;           
 
        return PAGE_EXISTS;
            }
 
        });
boolean doPrint = job.printDialog();
if(doPrint) {
    try {
         
        job.print();
    }
    catch (PrinterException e1) {
            JOptionPane.showMessageDialog(null, e1);
    }
}


and it works well, but that code display the border of JTextArea, which is supposed to be borderless after being printed and the content of this JTextArea are not all displayed texts are cut.
So I decided to print one by one the contents of this JPanel but its content does not switch to the line as I did in my interface but it is superimposed one above the other.
this is my second code


Java
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(new Printable() {
 
            @Override
            public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
                if (pageIndex > 0) {
            return NO_SUCH_PAGE;
        }
         
        int marge=30;
        int x = (int)pageFormat.getImageableX();
        int y = (int)pageFormat.getImageableY();
                 
        graphics.setFont(new Font("Times new roman", Font.BOLD, 14));
        graphics.setColor(Color.BLACK);
        graphics.drawString("ACTE DEMANDER\n", x + marge, y + marge);
 
jLabel1.print(graphics);
jLabel2.print(graphics);
jLabel3.print(graphics);
jTextArea1.print(graphics);
jTextPane1.print(graphics);           
 
        return PAGE_EXISTS;
            }
 
        });
boolean doPrint = job.printDialog();
if(doPrint) {
    try {
         
        job.print();
    }
    catch (PrinterException e1) {
            JOptionPane.showMessageDialog(null, e1);
    }
}


How then could I do to make them lines or retrieve the contents of my JTextArea whatever the length of the text and there is newline. All help in both cases are welcome.
thank you for helping me
Best regards.
AnswerRe: print jPanel Pin
Richard MacCutchan8-Jan-16 1:17
mveRichard MacCutchan8-Jan-16 1:17 
Questionmini game in java Pin
Member 113848203-Jan-16 20:20
Member 113848203-Jan-16 20:20 
AnswerRe: mini game in java Pin
Richard MacCutchan3-Jan-16 22:04
mveRichard MacCutchan3-Jan-16 22:04 
QuestionHow to fix the intervals on y-axis using java. Pin
Member 1223574229-Dec-15 22:21
Member 1223574229-Dec-15 22:21 
QuestionRe: How to fix the intervals on y-axis using java. Pin
Richard MacCutchan29-Dec-15 22:36
mveRichard MacCutchan29-Dec-15 22:36 
QuestionJava sqlite connection error Pin
rafiullah_Omar28-Dec-15 21:56
rafiullah_Omar28-Dec-15 21:56 
SuggestionRe: Java sqlite connection error Pin
Richard MacCutchan28-Dec-15 22:17
mveRichard MacCutchan28-Dec-15 22:17 
GeneralRe: Java sqlite connection error Pin
rafiullah_Omar29-Dec-15 18:19
rafiullah_Omar29-Dec-15 18:19 
GeneralRe: Java sqlite connection error Pin
Richard MacCutchan29-Dec-15 22:19
mveRichard MacCutchan29-Dec-15 22:19 
GeneralRe: Java sqlite connection error Pin
rafiullah_Omar29-Dec-15 22:56
rafiullah_Omar29-Dec-15 22:56 
GeneralRe: Java sqlite connection error Pin
Richard MacCutchan29-Dec-15 23:16
mveRichard MacCutchan29-Dec-15 23:16 
AnswerRe: Java sqlite connection error Pin
rah_sin28-Dec-15 22:21
professionalrah_sin28-Dec-15 22:21 
GeneralRe: Java sqlite connection error Pin
rafiullah_Omar29-Dec-15 18:08
rafiullah_Omar29-Dec-15 18:08 
GeneralRe: Java sqlite connection error Pin
jschell30-Dec-15 7:10
jschell30-Dec-15 7:10 
GeneralRe: Java sqlite connection error Pin
rafiullah_Omar31-Dec-15 7:32
rafiullah_Omar31-Dec-15 7:32 
GeneralRe: Java sqlite connection error Pin
Richard MacCutchan31-Dec-15 22:49
mveRichard MacCutchan31-Dec-15 22:49 
GeneralRe: Java sqlite connection error Pin
rafiullah_Omar1-Jan-16 7:14
rafiullah_Omar1-Jan-16 7:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.