473,791 Members | 2,901 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

exporting non-public type through public api

8 New Member
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 14526
Nepomuk
3,112 Recognized Expert Specialist
Could we have a look at that Circle class? Also, when do you get this error?

Greetings,
Nepomuk
Feb 21 '09 #2
DeadSilent
8 New Member
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 Recognized Expert MVP
@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
DeadSilent
8 New Member
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 Recognized Expert MVP
@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
DeadSilent
8 New Member
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 Recognized Expert MVP
@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
DeadSilent
8 New Member
Read my first post, I believe I stated the issue clearly. :\
Feb 23 '09 #9
JosAH
11,448 Recognized Expert MVP
@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

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

Similar topics

4
1984
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 it freeze the database so all udpates/inserts happen after the export completes? Also, how do I get the delta of data that wasn't exported, if I want to get the difference the next day?
3
9249
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 only exporting to single worksheet. but i need to export data to multiple worksheets. it is very urgent to us. so please help me in code.
1
7495
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, defining more than 250 base names for the lobs leads to an error message something like "DB2 encountered an unexpected error when sending the query to the backend process" (I don't have the exact message at hand). It doesn't matter how short the base...
0
1345
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 : Response.Clear(); Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel"; Response.Charset = "iso-8859-1"; this.EnableViewState = false;
1
3169
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 As System.IO.MemoryStream = 3 myReport.ExportToStream( ExportFormatType.PortableDocFormat) 4 Response.Clear() 5 Response.Buffer() = True
7
1895
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. After doing some research, I learned that VB's functions are not exportable and suggestion is to get PowerBasic or XBasic. I am just starting with VB so I am not sure if I am right, but can somebody please tell me if I can make exportable...
2
2416
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 exporting ALL data from the datagrid control. Exporting data works fine when I show all data on the datagrid control. I'd like to shows only 30 records on the datagrid control instead of ALL data using page navigation, and perform exporting...
2
3185
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 set this up so as to do it reliably and minimize overhead? There are currently no constraints on the destination table. Assume the user or some configuration specifies the database name, server name, and filename+fullpath. The server is SQL...
0
1717
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 data, problem starts exporting non-english data using approach shown below, the data is retrieve in database in an xml format. Is there a simple way to be able to make this work? Response.ContentEncoding = System.Text.Encoding.UTF8;
1
4917
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 is converting my number fields to scientific notation and they are getting bounced by our customer's EDI program. Example is .0027 is showing in the text file as 2.7E-3. I have tried setting formatting to fixed with 4 decimals, general with 4, no...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.