BoraluGoda

Member
Jan 28, 2011
486
114
0
::: GiRiPuRa :::
Code:
void viewAllItem(){
      clrscr();
      menu1st();
      cout<<endl;
      cout<<endl;
      cout<<setw(28)<<"     ITEM NO"<<setw(18)<<"    ITEM NAME"<<setw(18)<<"PRICE"<<endl;
      for(int x=0;x<index;x++){
      itm = itmArr[x];
      cout<<endl;
      cout<<setw(25)<<itm.IT;
      cout<<setw(18)<<itm.name;
      cout<<setw(19)<<itm.price<<endl;

      }
}

Machn mata me sub progrm eke outputs tika notepad ekaka write karaganna widiya n notpad 1 aith read karaganna widiya kiyla denvda ? :(
 

kushame

Junior member
  • Aug 18, 2010
    284
    12
    18
    hi

    hamoma karanawa wage database systems hadanne natuwa alut deyak karana eka maxxa.

    make a software which connects to internet and do something..you can easily surf internet using java!

    mama software ekak kala tv freak kiyala hope you know about that!(I posted a thread also)

    its a software about searching streaming links fot tv epsiodes you wanna watch!
    it realy made a differnt in internet society. coz its the only software that does it.. so think something new.. take ur time... minissu online gihilla karana wadak software ekakin karanna puluwan unama eka nikanma hit wenawa..i knw coz i still get huge number of downloads per day!

    machn i love java hope u do 2.. so ona help ekak dennam..

    podi idea ekak ganna meka bala balapan
    mage wadak

    http://www.gettvfreak.com/p/download-tv-freak.html

    wwooww maru ne
    i feel i like need to do something new mama matalam internet eka sambandawa monawa hari karanna i love learn new things thanks friend :)
     

    akhilapraveen

    Active member
  • Jun 2, 2008
    335
    72
    28
    machan umba ahala tiyenna niyama prashnayak! meka java lovers late hugak ona wei!

    We all know to save data , we use databases such as SQL in every software. But the problem with this is If the data are saved in a database, User has to instal SQL sever with the software to work properly!

    This is pointless Coz installing the database with the software is hard!

    But Im gonna show you guys a way to save data in a text sheet without implementing databases!(This way is used by many modern softwares!!)

    here it is...

    //-------------------------------------------------------------------------

    import javax.swing.JTextField;
    import java.io.*;
    import javax.swing.JOptionPane;
    /**
    *
    * @author Akhila
    */
    public class JavaApplication12 {




    public void write(String text){

    String theline=text;
    try{

    FileOutputStream fout;

    //NOW ARE GIVING A PATH TO CREATE THE TEXT FILE, GIVE YOUR OWN PATH (THIS IS THE PATH FOR MY PC)
    fout = new FileOutputStream ("C:\\Users\\Akhila\\Documents\\akhila docs\\MYTEXT.txt");
    //PREVIOUS LINE HAS CREATED A TEXT FIILE CALLED MYTEXT.txt




    new PrintStream(fout).println (theline);

    fout.close();

    }

    catch(Exception e){}
    }


    }
    //-----------------------------------------------------------------------------

    NOW WE HAVE WRITTEN DATA TO A TEXT FILE NOW HERE THE CODING TO READ IT!

    //-------------------------------------------------------------------------


    import java.io.*;

    public class JavaApplication12{

    public String Read(){
    String line="";
    FileInputStream fin;

    try
    {

    //give the path of the created file
    fin = new FileInputStream ("C:\\Users\\Akhila\\Documents\\akhila docs\\MYTEXT.txt");

    line=( new DataInputStream(fin).readLine() );


    fin.close();

    return line;
    }

    catch (Exception e)
    {
    return line;
    }
    }
    }

    //-------------------------------------------------------------------------------

    Machan this is the way to do this! i know your using this coding for a small thing But By edting this code you can create a database in a text file and encrypt it also!!

    ENJOY!!!


     
    Last edited:

    akhilapraveen

    Active member
  • Jun 2, 2008
    335
    72
    28
    wwooww maru ne
    i feel i like need to do something new mama matalam internet eka sambandawa monawa hari karanna i love learn new things thanks friend :)

    MACHAN MAMA UMBATA WEBPAGE EKAK READ KARALA EKE TIYANA TEXT EKA GANNE KOHOMADA KIYALA KIYANNAM!

    this is how you read a URL!!!

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.util.*;
    import java.io.*;


    public class ReadWebPage {



    public String readnow(String txt){

    String LINexxx="";

    //String LINe="";

    String txt1=txt;
    try{
    String urltext = txt1;
    URL url = new URL(urltext);
    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    String line = "";

    while ((line = in.readLine()) != null){

    // System.out.println(line);
    String line1="";
    //line1=in.readLine();
    line1=line;
    LINexxx=(LINexxx+"----------"+line1);


    }
    in.close();

    return LINexxx;



    }


    catch (Exception e)

    {
    String Er="error is occured";
    return Er;
    //System.out.println(e.toString());

    }

    }




    }

    pass the web address with http to readnow method!
    ex=http://www.google.lk/
     
    Last edited:

    adasi

    Member
    Jul 1, 2011
    22
    0
    0
    41
    Ruwanwella
    malli serial port eken oyata ona deyak karanna puluwan!

    printer ekata set wenne parallel cable eka..so you can program it easily.
    but do u knw wat are tha data bits and status bits(status registry) and ack bits of tha parallel port??

    ewa tika dannattam oka liyanna tikak amarui

    if u knw them

    try this in visual CMD

    void _stdcall Out32(short PortAddress,short data);
    void main(){
    for(; ; ){

    Out32(0x378,0xff)


    }

    }


    meka terenawada kiyala kiyanna..otherwise you stil got lot to learn malla

    if u get this i can help u to create tha java code


    thanks ayya...i will try it and ask some help....
     

    adasi

    Member
    Jul 1, 2011
    22
    0
    0
    41
    Ruwanwella
    malli serial port eken oyata ona deyak karanna puluwan!

    printer ekata set wenne parallel cable eka..so you can program it easily.
    but do u knw wat are tha data bits and status bits(status registry) and ack bits of tha parallel port??

    ewa tika dannattam oka liyanna tikak amarui

    if u knw them

    try this in visual CMD

    void _stdcall Out32(short PortAddress,short data);
    void main(){
    for(; ; ){

    Out32(0x378,0xff)


    }

    }


    meka terenawada kiyala kiyanna..otherwise you stil got lot to learn malla

    if u get this i can help u to create tha java code



    meken wenne "This method call by itself"....ewa mata therenawa ayya.....

    data bits ,status bits(status registry) ,ack bits gananam mama echchara danne na ayya...

    Mata one report(jasper) ekak, view wenne nathuwa..print dialog eka open wenne nathuwa..kelinma print button eka press kalama print kara ganna..

    Mekata kiyanne direct print kiyalada koheda.......

    mata cord ekak hambuna...eka wada karanne na.......that is below..


    public class cls_Report_passBook {
    String reportDir = "D:\\easyBanker\\src\\Report\\";
    public void generateReport(String reportname, Map params) throws JRException{
    String printer="CutePDF Writer";

    PrintService service = null;

    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(MediaSizeName.ISO_A4);
    PrintService[] services3 = PrintServiceLookup.lookupPrintServices(null, null);

    for(int k=0;k<services3.length;k++){

    if(services3[k].getName().trim().equals(printer.trim())){
    service = services3[k];
    }
    }

    if(service == null){

    System.out.println("PRINTER NOT FOUND->"+printer);
    }else {


    JasperReport jr = JasperCompileManager.compileReport(reportDir + reportname);

    JasperPrint jp = JasperFillManager.fillReport(jr, params, new cls_Connect().connect());
    // JasperViewer.viewReport(jp, false);
    JRExporter exporter = new JRPrintServiceExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, service.getAttributes());
    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, service.getAttributes());
    exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
    exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);
    exporter.exportReport();

    }


    }

    }

    if you can put some cording regarding my problem..please..
     

    akhilapraveen

    Active member
  • Jun 2, 2008
    335
    72
    28
    meken wenne "This method call by itself"....ewa mata therenawa ayya.....

    data bits ,status bits(status registry) ,ack bits gananam mama echchara danne na ayya...

    Mata one report(jasper) ekak, view wenne nathuwa..print dialog eka open wenne nathuwa..kelinma print button eka press kalama print kara ganna..

    Mekata kiyanne direct print kiyalada koheda.......

    mata cord ekak hambuna...eka wada karanne na.......that is below..


    public class cls_Report_passBook {
    String reportDir = "D:\\easyBanker\\src\\Report\\";
    public void generateReport(String reportname, Map params) throws JRException{
    String printer="CutePDF Writer";

    PrintService service = null;

    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(MediaSizeName.ISO_A4);
    PrintService[] services3 = PrintServiceLookup.lookupPrintServices(null, null);

    for(int k=0;k<services3.length;k++){

    if(services3[k].getName().trim().equals(printer.trim())){
    service = services3[k];
    }
    }

    if(service == null){

    System.out.println("PRINTER NOT FOUND->"+printer);
    }else {


    JasperReport jr = JasperCompileManager.compileReport(reportDir + reportname);

    JasperPrint jp = JasperFillManager.fillReport(jr, params, new cls_Connect().connect());
    // JasperViewer.viewReport(jp, false);
    JRExporter exporter = new JRPrintServiceExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, service.getAttributes());
    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, service.getAttributes());
    exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
    exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);
    exporter.exportReport();

    }


    }

    }

    if you can put some cording regarding my problem..please..





    Malla i can give u coding a print a text file using java. when you click tha button, yur doc will be printed!
    but malla for direct printing you need to know the bit patterns.
    search google for tht.

    import java.awt.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.awt.print.*;
    import java.text.*;
    /**
    * The PrintText application expands on the
    * PrintExample application in that it images
    * text on to the single page printed.
    */
    public class JavaApplication12 implements Printable {
    /**
    * The text to be printed.
    */
    private static final String mText ="YOUR DATA HERE";
    /**
    * Our text in a form for which we can obtain a
    * AttributedCharacterIterator.
    */
    private static final AttributedString mStyledText = new AttributedString(mText);
    /**
    * Print a single page containing some sample text.
    */
    static public void main(String args[]) {
    /* Get the representation of the current printer and
    * the current print job.
    */
    PrinterJob printerJob = PrinterJob.getPrinterJob();
    /* Build a book containing pairs of page painters (Printables)
    * and PageFormats. This example has a single page containing
    * text.
    */
    Book book = new Book();
    book.append(new JavaApplication12(), new PageFormat());
    /* Set the object to be printed (the Book) into the PrinterJob.
    * Doing this before bringing up the print dialog allows the
    * print dialog to correctly display the page range to be printed
    * and to dissallow any print settings not appropriate for the
    * pages to be printed.
    */
    printerJob.setPageable(book);
    /* Show the print dialog to the user. This is an optional step
    * and need not be done if the application wants to perform
    * 'quiet' printing. If the user cancels the print dialog then false
    * is returned. If true is returned we go ahead and print.
    */
    boolean doPrint = printerJob.printDialog();
    if (doPrint) {
    try {
    printerJob.print();
    } catch (PrinterException exception) {
    System.err.println("Printing error: " + exception);
    }
    }
    }
    /**
    * Print a page of text.
    */
    public int print(Graphics g, PageFormat format, int pageIndex) {
    /* We'll assume that Jav2D is available.
    */
    Graphics2D g2d = (Graphics2D) g;
    /* Move the origin from the corner of the Paper to the corner
    * of the imageable area.
    */
    g2d.translate(format.getImageableX(), format.getImageableY());
    /* Set the text color.
    */
    g2d.setPaint(Color.black);
    /* Use a LineBreakMeasurer instance to break our text into
    * lines that fit the imageable area of the page.
    */
    Point2D.Float pen = new Point2D.Float();
    AttributedCharacterIterator charIterator = mStyledText.getIterator();
    LineBreakMeasurer measurer = new LineBreakMeasurer(charIterator, g2d.getFontRenderContext());
    float wrappingWidth = (float) format.getImageableWidth();
    while (measurer.getPosition() < charIterator.getEndIndex()) {
    TextLayout layout = measurer.nextLayout(wrappingWidth);
    pen.y += layout.getAscent();
    float dx = layout.isLeftToRight()? 0 : (wrappingWidth - layout.getAdvance());
    layout.draw(g2d, pen.x + dx, pen.y);
    pen.y += layout.getDescent() + layout.getLeading();
    }
    return Printable.PAGE_EXISTS;
    }
    }

    if you dont get the methods follow this steps.
    http://download.oracle.com/javase/tutorial/2d/printing/set.html

    oracle is a graet way to learn java!
     

    akhilapraveen

    Active member
  • Jun 2, 2008
    335
    72
    28
    GUYS WHEN YOU HAVA PROBLEM REGARDING JAVA! PLEASE POST HERE,DO NOT PM ME.
    COZ LOT OF PEOPLE MIGHT BE HAVING THE SAME PROBLEM. SO THEY ALSO CAN LEARN!

    CHEERS!
     

    adasi

    Member
    Jul 1, 2011
    22
    0
    0
    41
    Ruwanwella
    Malla i can give u coding a print a text file using java. when you click tha button, yur doc will be printed!
    but malla for direct printing you need to know the bit patterns.
    search google for tht.

    import java.awt.*;
    import java.awt.font.*;
    import java.awt.geom.*;
    import java.awt.print.*;
    import java.text.*;
    /**
    * The PrintText application expands on the
    * PrintExample application in that it images
    * text on to the single page printed.
    */
    public class JavaApplication12 implements Printable {
    /**
    * The text to be printed.
    */
    private static final String mText ="YOUR DATA HERE";
    /**
    * Our text in a form for which we can obtain a
    * AttributedCharacterIterator.
    */
    private static final AttributedString mStyledText = new AttributedString(mText);
    /**
    * Print a single page containing some sample text.
    */
    static public void main(String args[]) {
    /* Get the representation of the current printer and
    * the current print job.
    */
    PrinterJob printerJob = PrinterJob.getPrinterJob();
    /* Build a book containing pairs of page painters (Printables)
    * and PageFormats. This example has a single page containing
    * text.
    */
    Book book = new Book();
    book.append(new JavaApplication12(), new PageFormat());
    /* Set the object to be printed (the Book) into the PrinterJob.
    * Doing this before bringing up the print dialog allows the
    * print dialog to correctly display the page range to be printed
    * and to dissallow any print settings not appropriate for the
    * pages to be printed.
    */
    printerJob.setPageable(book);
    /* Show the print dialog to the user. This is an optional step
    * and need not be done if the application wants to perform
    * 'quiet' printing. If the user cancels the print dialog then false
    * is returned. If true is returned we go ahead and print.
    */
    boolean doPrint = printerJob.printDialog();
    if (doPrint) {
    try {
    printerJob.print();
    } catch (PrinterException exception) {
    System.err.println("Printing error: " + exception);
    }
    }
    }
    /**
    * Print a page of text.
    */
    public int print(Graphics g, PageFormat format, int pageIndex) {
    /* We'll assume that Jav2D is available.
    */
    Graphics2D g2d = (Graphics2D) g;
    /* Move the origin from the corner of the Paper to the corner
    * of the imageable area.
    */
    g2d.translate(format.getImageableX(), format.getImageableY());
    /* Set the text color.
    */
    g2d.setPaint(Color.black);
    /* Use a LineBreakMeasurer instance to break our text into
    * lines that fit the imageable area of the page.
    */
    Point2D.Float pen = new Point2D.Float();
    AttributedCharacterIterator charIterator = mStyledText.getIterator();
    LineBreakMeasurer measurer = new LineBreakMeasurer(charIterator, g2d.getFontRenderContext());
    float wrappingWidth = (float) format.getImageableWidth();
    while (measurer.getPosition() < charIterator.getEndIndex()) {
    TextLayout layout = measurer.nextLayout(wrappingWidth);
    pen.y += layout.getAscent();
    float dx = layout.isLeftToRight()? 0 : (wrappingWidth - layout.getAdvance());
    layout.draw(g2d, pen.x + dx, pen.y);
    pen.y += layout.getDescent() + layout.getLeading();
    }
    return Printable.PAGE_EXISTS;
    }
    }

    if you dont get the methods follow this steps.
    http://download.oracle.com/javase/tutorial/2d/printing/set.html

    oracle is a graet way to learn java!


    Thanks ayya you are great....jaya wewa
     

    Tharanga AD

    Member
    Dec 25, 2010
    20
    1
    3
    hard code karala hadagatha componant akak netbeens waling jfrme akakta adda karaganna kohomada? plz danna kenak kiyalla denna.
     

    adasi

    Member
    Jul 1, 2011
    22
    0
    0
    41
    Ruwanwella
    akila ayya......

    Mama use karana sinhala unicode.....kaputa unicode,kandy unicode & malathi web. But ewage samahara characters upset...wena hoda sinhala unicode font ekak thiyenawada?
     

    Attachments

    • upset_Character.jpg
      upset_Character.jpg
      17.9 KB · Views: 97

    cybz

    Member
    Oct 29, 2009
    172
    3
    0
    this not complex at all machan

    heres the codin,

    (im doing with t with a button, and button is on ma jframe)

    this is tha main class(compile this)
    //------------------------------------------------------------------------
    public class JavaApplication12 {

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {

    NewJFrame nw=new NewJFrame();


    nw.setVisible(true);
    // TODO code application logic here
    }
    }

    //--------------------------------------------------------------------


    Now i have implemented 2 buttons in ma jframe

    one button is used to hide the jtextfield and from other button you can view it

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
    NewJFrame.jTextField1.setVisible(false);
    // TODO add your handling code here:
    }



    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

    try{
    jTextField1.setVisible(true);
    }
    catch (Exception e){

    }
    // TODO add your handling code here:
    }


    this is tha basic idea of your software. Now you can edit it lik this

    add a panel to tha jframe and add jtextfield and button on to that

    goto panels customized code(write click on t and select customize code)

    and add jbutton 2s coding there

    now when you compile your main program jframe comesup!
    but not the textfield coz its visibility is off via tha panel.
    so only when user clicks on the button its visibilty is on.


    HOPE YOU GT THA IDEA!
    IF U STILL CANT GET IT POST HERE ILL SEND YOU MA APPLICATION FOLDER

    Ado Mehema newe ban....


    uba karanne predefined butten eka hide karala show karana sellama...
    :lol::lol::lol:
    uba kiyanne choo case ne...?

    Have to add dynamically man....If user needs 20 button code should be automatically generated. No of buttons is unknown untile runtime.
    Imagine that we have to create a realtime IDE....
    puluwamnam help karapan.
     

    akhilapraveen

    Active member
  • Jun 2, 2008
    335
    72
    28

    Ado Mehema newe ban....


    uba karanne predefined butten eka hide karala show karana sellama...
    :lol::lol::lol:
    uba kiyanne choo case ne...?

    Have to add dynamically man....If user needs 20 button code should be automatically generated. No of buttons is unknown untile runtime.
    Imagine that we have to create a realtime IDE....
    puluwamnam help karapan.


    You dont know the first thing about java.Its a pure object oriented programming language. Maybe ur a software engineer But machan never frgt tha concept of JAVA.

    I dont wanna argue with yu. But if u wanna bet ill make yur program with ma concept. brother, i just gave tha sample coding coz i thought ur capable of editing it.. U can do ur project with ma coding U jus have to use String Manipulation. No of items user wanna add is given at the runtime and its passed to ma class and for-loop will run to add them in the positions he picks. Just lik that you can do that.

    BTW u hav no idea about whats IDE :)
     

    amila325

    Well-known member
  • Jul 11, 2006
    9,188
    33
    48
    Have to implement a java app with ability to add new textbox, lables at runtime according to user interaction.
    If u can post sample code.
    Dont say question is not clear :P
    Use collections to hold the text fields or whatever filed you want hold.. but this may differ according to your need :)