Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6620575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:07:09+00:00 2026-05-25T21:07:09+00:00

This is first time I at a question in here. Im new in J2ME,

  • 0

This is first time I at a question in here.

Im new in J2ME, and now im developing a small application, but i get problem when i wanna show data into table. But in J2me not support table there for that i know another way can represent for table such as create table by Canvas or CustomItem.

In Canvas i can draw 2 lines something like:

-----------------------
|
|
|
|

but i dont know how can get coordinate of 2 lines remain such as like:

                         |
                         |
                         | 
                         |
                         |
--------------------------

two draw a rectangular in whole screen,

i know drawline method has 4 factors x1,y1,x2,y2.

but i can not calculate x point and y point to draw two lines above

I need you help me explain or give me example

My Code:

package test;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

/**
 *
 * @author J2MENewBie
 */
public class TableCanvasExample extends Canvas {
    private int cols=3;
    private int rows =50;
    protected void paint(Graphics g) {
        g.setColor(0x94b2ff);
        g.fillRect(0, 0, this.getWidth(), this.getHeight());
        //draw two lines
        g.setColor(0xf8011e);
        g.drawLine(0, 0, 0, this.getWidth());
        g.drawLine(0, 0, this.getHeight(), 0);

    }

}

package test;

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.*;

/**
 * @author J2ME NewBie
 */
public class TableCanvasMidlet extends MIDlet {
    private TableCanvasExample tbcve;

    public TableCanvasMidlet(){
        tbcve = new TableCanvasExample();
    }
    public void startApp() {
        Display.getDisplay(this).setCurrent(tbcve);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
}

P/s: the vertical line doesn’t full size i dont know why ???

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:07:09+00:00Added an answer on May 25, 2026 at 9:07 pm

    too much same-looking zeroes in your code – try using descriptive names instead:

        int w = getWidth(), h = getHeight(); // I think this way it's easier to read
    
        int xLeft = 0, yTop = 0; // descriptive names for zeroes
        // below, replace w - 1 -> w and h - 1 -> h if lines drawn are off-by-one
        int xRight = w - 1, yBottom = h - 1; // names for top - right coordinates
    
        g.drawLine(xLeft, yTop, xLeft, yBottom); // your left vertical
        g.drawLine(xLeft, yTop, xRight, yTop); // your top horizontal
    
        g.drawLine(xRight, yTop, xRight, yBottom); // add right vertical
        g.drawLine(xLeft, yBottom, xRight, yBottom); // add bottom horizontal
    

    if rectangle drawn doesn’t look like you expect find where there is wrong semantic in code above

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry, this's my first time to ask a question here. So, I don't have
This is my first time here so I hope I post this question at
this is my first time posting here, I have a question which I have
This is a really basic question but this is the first time I've used
This might sound like a noob question but this is the first time I'm
first question here, this is regarding the iPhoneOS3 not MacOSX. I am fairly new
This is the first time i'm asking a question here at stack overflow so
First, I've taken the time to review this question which seems to be the
Important: This question is getting quite long, if this is the first time you're
First time I post a question, so here it goes. I want to push

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.