473,372 Members | 1,236 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

exporting non-public type through public api

I have this code and for some reason I keep getting an error where it says "exporting non-public type through public api ".. I'm not sure why this keeps happening but it does so for getCircleInfo / drawCircle. Thanks for your help.

- Me.

Expand|Select|Wrap|Line Numbers
  1. package shapemaker;
  2.  
  3. import java.awt.*;
  4. import javax.swing.*;
  5.  
  6. public class ShapeMaker {
  7.  
  8.     private JFrame win;
  9.     private Container contentPane;
  10.  
  11.     public ShapeMaker (  ) {
  12.         win = new JFrame("Shape Maker");
  13.         win.setSize(400, 300);
  14.         win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  15.         win.setVisible(true);
  16.         contentPane = win.getContentPane();
  17.         contentPane.setBackground(Color.WHITE);
  18.     }
  19.  
  20.     public static void main(String[] args) {
  21.         ShapeMaker shapeMaker = new ShapeMaker();
  22.         shapeMaker.start();
  23.     }
  24.  
  25.     public void start (  ) {
  26.         Circle circle = new Circle (  );
  27.         getCircleInfo(circle);
  28.         drawCircle(circle);
  29.     }
  30.  
  31.     public void getCircleInfo ( Circle circle ) {
  32.         double radius;
  33.         int x, y;
  34.         radius = Double.parseDouble ( JOptionPane.showInputDialog (win, "Enter Radius") );
  35.         circle.setRadius(radius);
  36.         circle.setFillColor(Color.orange);
  37.         circle.setPenColor(Color.black);
  38.         x = Integer.parseInt( JOptionPane.showInputDialog ( win, "Enter X Cord:" ) );
  39.         circle.setXCord(x);
  40.         y = Integer.parseInt( JOptionPane.showInputDialog ( win, "Enter Y Cord:" ) );
  41.         circle.setYCord(y);
  42.     }
  43.  
  44.     public void drawCircle ( Circle circle ) {
  45.         Graphics g = contentPane.getGraphics();
  46.         circle.draw(g);
  47.     }
  48. }
Feb 21 '09 #1
14 14460
Nepomuk
3,112 Expert 2GB
Could we have a look at that Circle class? Also, when do you get this error?

Greetings,
Nepomuk
Feb 21 '09 #2
The error I get is that no circle comes up when I run this code and I am not sure why.

Circle Class:
Expand|Select|Wrap|Line Numbers
  1. package shapemaker;
  2.  
  3. import java.awt.*;
  4.  
  5. class Circle {
  6.  
  7.     private double Radius;
  8.     private int XCord, YCord;
  9.     private Color penColor, fillColor;
  10.  
  11.     // Constructors
  12.     public Circle ( ) {
  13.         //setRadius(0);
  14.         this(0);
  15.     }
  16.  
  17.     public Circle ( double r ) {
  18.         setRadius(r);
  19.         penColor = Color.BLACK;
  20.         fillColor = Color.WHITE;
  21.         XCord = 0;
  22.         YCord = 0;
  23.     }
  24.  
  25.     // Set Methods
  26.     public void setRadius ( double r ) {
  27.         Radius = 0;
  28.  
  29.         if (r > 0) {
  30.             Radius = r;
  31.         }
  32.     }
  33.  
  34.     public void setXCord ( int x ) {
  35.         XCord = 0;
  36.  
  37.         if (x > 0) {
  38.             XCord = x;
  39.         }
  40.     }
  41.  
  42.     public void setYCord ( int y ) {
  43.         YCord = 0;
  44.  
  45.         if (y > 0) {
  46.             YCord = y;
  47.         }
  48.     }
  49.  
  50.     public void setPenColor ( Color pen ) {
  51.         penColor = pen;
  52.     }
  53.  
  54.     public void setFillColor ( Color fill ) {
  55.         fillColor = fill;
  56.     }
  57.  
  58.     // Get Methods
  59.     public double getArea (  ) {
  60.         return Math.pow( ( Math.PI * Radius ) , 2 );
  61.     }
  62.  
  63.     public double getCircumference (  ) {
  64.         return ( Math.PI * ( Radius * 2 ) );
  65.     }
  66.  
  67.     public void draw ( Graphics g ) {
  68.         int width = (int) (Radius * 2);
  69.         int height = (int) (Radius * 2);
  70.         g.drawString("This", -10, -10);
  71.  
  72.         g.drawOval(XCord, YCord, width, height);
  73.         g.setColor(penColor);
  74.         g.fillOval(XCord, YCord, width, height);
  75.         g.setColor(fillColor);
  76.  
  77.         g.dispose();
  78.     }
  79. }
  80.  
Feb 22 '09 #3
JosAH
11,448 Expert 8TB
@DeadSilent
So the error you mentioned in your original posting automagically disappeared? btw, I expected to see a paintComponent(Graphics g) method for drawing purposes. Where is it?

kind regards,

Jos
Feb 22 '09 #4
This was for a project and paintComponent() was not required to run the program in NetBeans, I'm just starting to learn Java so the graphics / drawing class functions I'm starting to learn. What exactly would I use the paintComponent() for?
Feb 22 '09 #5
JosAH
11,448 Expert 8TB
@DeadSilent
I don't believe that; there's always a paintComponent() method under the hood somewhere. NetBeans is not a magic wizard that solves it all for you.

@DeadSilent
Please check the "Read This First" article; it's the first article in this group; it contains a link to the tutorials; one of them is the Swing tutorial. At least read that one before you attempt to draw anything at all.

kind regards,

Jos

ps. how come that mysterious error message you mentioned before disappeared automagically?
Feb 22 '09 #6
Ohh its still there, I'm just going to research swing more in depth and hope I can get something figured out before tomorrow.
Feb 22 '09 #7
JosAH
11,448 Expert 8TB
@DeadSilent
You can't expect a program to run correctly (or run at all) when such error messages are printed. What exactly issued that message? The compiler? The Java virtual machine itself? Something else?

kind regards,

Jos
Feb 23 '09 #8
Read my first post, I believe I stated the issue clearly. :\
Feb 23 '09 #9
JosAH
11,448 Expert 8TB
@DeadSilent
Yes you did and you immediately forgot all about it and mentioned another problem (Swing related); that's why I kept asking about it. Don't add more problems to the problem pool but first solve the original problem(s).

kind regards,

Jos
Feb 23 '09 #10
LOL! Sorry about that, I got confused for a second.
Feb 23 '09 #11
Yarn
1
For the exporting non-public type through public API thing, try making the method headings just void getCircleInfo ( Circle circle ) and void drawCircle ( Circle circle ). Take away the publics. Because every class in the program is part of one package, all the classes should be able to access the methods and fields from all other classes in the package even if the methods and fields have no public-private declaration. So this should work, because it gets rid of the public API, but still allows all classes access. I'm not sure exactly why all this happens, but I get the same thing with NetBeans when I try to use certain classes as parameters. I've found that this usually makes the IDE shut up. I've used other compilers/editors (i.e.) JCreator and this seems to be a problem specific to NetBeans. As for the paintComponent() method, chances are that it is in one of those collapsed sections of uneditable text that are generated by the design panel.
Mar 4 '09 #12
The warning is coming from your line five (5): the class Circle has no designation [i.e. public, private, etc];

Make it public and warning will disappear.
Mar 27 '09 #13
As to your other issues, only Classes should be capitalized; for the sake of future debugging efforts, change your variables [like Radius to 'radius'] to lower-case, so in-code references do not imply it is a reference to a static Class.
Mar 27 '09 #14
Based on your codes:
// Constructors
public Circle ( ) {
//setRadius(0);
this(0);
}

public Circle ( double r ) {
setRadius(r);
penColor = Color.BLACK;
fillColor = Color.WHITE;
XCord = 0;
YCord = 0;
}
and from shapemaker

public void start ( ) {
Circle circle = new Circle ( );
getCircleInfo(circle);
drawCircle(circle);
}
Your constructor for a Circle requires a radius parameter; your default is 0 and no other value is passed; I contend you ARE drawing a circle, though one of radius = 0, at coords (0,0).
Mar 27 '09 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Angel Cat | last post by:
I'm exporting a large file from a large Production database (SQL). Users are currently updating and inserting new records. Does the export take a snapshot of the data when it starts ? or will...
3
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works...
1
by: Janne Ruuttunen | last post by:
Hello DB2 people, I'm having problems exporting >= 250000 lobs to IXF files with the LOBSINFILE option, using a legacy DB2 2.1 system on Win NT. If I don't specify a path for the lobs,...
0
by: Mike P | last post by:
I'm exporting a datagrid to excel, but I can't get non-English characters such as , and to appear properly in the Excel document (they are fine on my webpage). Here is my code : ...
1
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream...
7
by: victorsk | last post by:
Hello, I have a dll which I compiled in VB. Now I would like to use this dll in MapBasic program. However, I keep getting an error saying that the function which I am calling cannong be found....
2
by: bienwell | last post by:
Hi, I have a question about exporting data from datagrid control into Excel file in ASP.NET. On my Web page, I have a linkbutton "Export data". This link will call a Sub Function to perform...
2
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to...
0
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
hi, I trying to export data display on a gridview that supports any language (like chinese, japanese, thai, french) shown here is chinese only. There is no problem exporting english language...
1
by: Marty Klunk | last post by:
I have an Access97 data base where we are exporting records out to a text file that is then sent to a customer via EDI transmission. The problem I am having is that during the export process access...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.