How to set the size of a class that extends JDialog

Hi,
I was trying to set the size of my dialog window to be 600 by 600, but couldn't change it. Here is my code:
public class alii extends JDialog {
/** Creates new form alii */
public alii(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
private void initComponents() {
Container contentPane = getContentPane();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
pack();
public static void main(String args[]) {
JFrame frame = new JFrame();
alii a = new alii(new javax.swing.JFrame(), true);
frame.setSize(600,500);
frame.setLocation(200,200);
frame.setVisible(true);}}
Please help me with this and explain to me what is the problem and what needs to be changed.
Cheers

Hi,
The code you sent me doesn't work, and the code I posted wasn't a complete, but there is the complete one. You can see now what the code does.
* alii.java
* Created on 15 November 2003, 13:31
* @author Ali
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import java.io.*;
import java.applet.*;
import java.net.*;
public class sun extends JDialog {
int x[] = new int[4];
int y[] = new int[4];
int w[] = new int[4];
int h[] = new int[4];
int Y_ax = 310;
double DrawGraf[][] = new double[4][4];
String line[] = new String[9];
double Perc[] = new double[4];
double Sum=0;
GUICanvas can;
double graphvalue[] = new double [5];
/** Creates new form alii */
public sun(Frame parent, boolean modal) {
super(parent, modal);
initComponents();
//setVisible(true);
//setSize(600,500);
//setLocation(200,200);
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
private void initComponents() {
//Container contentPane = getContentPane();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
//contentPane.setSize(700,700);
//pack();
public void drawthegraph(String s)
/* try {
URL url = new URL(
"http://localhost:111/test/servlet/Compare?value="+s);
BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));
for (int c = 0; c<9; c++)
line[c] = in.readLine();
in.close();
}catch (Exception e){
e.printStackTrace();
graphvalue[0] = 200;
graphvalue[1] = 200;
graphvalue[2] = 100;
graphvalue[3] = 300;
graphvalue[4] = 20;
//graphvalue[4] = can.d2i(graphvalue[4]);
//System.out.println(line[8]);
Sum = graphvalue[0]+graphvalue[1]+graphvalue[2]+graphvalue[3];
Perc[0] = graphvalue[0]/Sum*200;
Perc[1] = graphvalue[1]/Sum*200;
Perc[2] = graphvalue[2]/Sum*200;
Perc[3] = graphvalue[3]/Sum*200;
System.out.println(Perc[0]);
DrawGraf[0][0] = 130;
DrawGraf[0][1] = Y_ax - Perc[0];
DrawGraf[0][2] = 60;
DrawGraf[0][3] = Perc[0];
DrawGraf[1][0] = DrawGraf[0][0]+60;
DrawGraf[1][1] = Y_ax - Perc[1];
DrawGraf[1][2] = 60;
DrawGraf[1][3] = Perc[1];
DrawGraf[2][0] = DrawGraf[1][0]+60;
DrawGraf[2][1] = Y_ax - Perc[2];
DrawGraf[2][2] = 60;
DrawGraf[2][3] = Perc[2];
DrawGraf[3][0] = DrawGraf[2][0]+60;
DrawGraf[3][1] = 310 - Perc[3];
DrawGraf[3][2] = 60;
DrawGraf[3][3] = Perc[3];
for(int d=0;d<4;d++)
x[d]=d2i(DrawGraf[d][0]);
y[d]=d2i(DrawGraf[d][1]);
w[d]=d2i(DrawGraf[d][2]);
h[d]=d2i(DrawGraf[d][3]);
repaint();
static int d2i(double d) {return (int) Math.round(d);}
public void paint (Graphics g)
g.setColor(Color.red);
for(int d=0;d<4;d++)
g.fill3DRect(x[d],y[d],w[d],h[d],true);
g.setColor(Color.blue);
g.drawLine(130,130,130,310);
g.drawLine(130,310,370,310);
g.setColor(Color.black);
g.drawString("WELCOME TO Ali",150,100);
g.drawString("Region: Lambeth",430,150);
g.drawString("Manger: ",430,170);
g.drawString("Location: ",430,190);
g.drawString("Number of Staff: "+graphvalue[4],430,210);
g.drawString("Week1",135,345);
g.drawString("Week2",195,345);
g.drawString("Week3",255,345);
g.drawString("Week4",315,345);
g.drawString(" "+"20 -",100,295);
g.drawString(" "+"40 -",100,255);
g.drawString(" "+"60 -",100,215);
g.drawString(" "+"80 -",100,175);
g.drawString("100 -",100,135);
g.setColor(Color.yellow);
g.drawLine(130,290,370,290);
g.drawLine(130,250,370,250);
g.drawLine(130,210,370,210);
g.drawLine(130,170,370,170);
g.drawLine(130,130,370,130);
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt) {
setVisible(false);
dispose();
* @param args the command line arguments
public static void main(String args[]) {
JFrame frame = new JFrame();
sun sn = new sun(frame, true);
frame.setSize(600,500);
frame.getContentPane().add(sn);
frame.setLocation(200,200);
frame.setVisible(true);
You were right that I am know to this, but getting there slowly and thanks for your help.
Cheers

Similar Messages

  • How to set the size of a JTabbedane to the size of the frame

    I have a tabbed pane in a frame, I would like to know how to set the size of the tabbed pane, so that it occupies the whole of the frame which has been set to screen size.
    Thanks

    Is it not possible to use it with a GridBagLayout?Your question was "How do I get a tabbed pane to take all the space of the frame"?
    You where given the answer. Did you try it? Did it work? Then why are you questioning the suggestion?
    Its one line of code if you use a BorderLayout which by the way was specifically designed for this purpose.
    Yes you can do it with a GridBagLayout with about 5 lines of code.
    So the question is why would you want to write 5 lines of code when you can use one?
    If your question was "How do I waste my time forcing the GridBagLayout to size a component to take up all the space of the frame", then you would have received a different answer. (Although most people would have told you to use a BorderLayout anyway, since its easier).

  • How to modify the blob size, or how to set the size?

    i want to know how to modify the blob size, or how to set the size?
    what's the default size of blob?
    Thanks in advance.

    Blob datatype can contain binary data with a maximum size of 4 GB.
    when you enter 10kb file, the database will only use 10kb to store the file (depending on block size etc)
    if you want to modify the blob size, you may do like this:
    SQL> create materialized view t_mv refresh fast on commit
    2 as select id, dbms_lob.getlength(x) len from t;
    Materialized view created.
    SQL> alter table t_mv add constraint t_mv_chk check (len < 100);
    Table altered.

  • Sun ONE Studio 4 aka Forte: How to set the output path for classes ?

    Help !
    Beginner's question:
    Sun ONE Studio 4 aka Forte:
    How to set the output path for classes ?
    As default, the class files are created in the same directory as the
    sources.
    In opposite, both JBuilder and Together support that there is a tree
    with the sources and another tree with the classes.
    The first answer I got was "not possible with Forte, but just if you write your own "ANT Build script" !
    a) Please point me to a ready-to-use ANT script for this purpose, if such is available
    b) Is using ANT instead of the MAKE as comfortable ? Besides the separation of sourcecode and classes, I would like to keep everything else to be the same, i.e. I don�t want to edit the ANT file if I enlarge the project by directories or files.
    Tia
    Sincerely
    Rolf

    You can set S1S's options to place newly created .class files in a specific location.
    Identify the compiler that is being used - Open the S1S's Tools/Options window, expand Editing and select Java Sources. Note the Default Compiler value. (If it's one if the Ant options, you use Ant to specify this option, not S1S.)
    Open the S1S's Tools/Options window, expand Building/Compiler Types and select the appropriate compiler.
    The Properties tab of the compiler has the property Target, which sets the filesystem where the compiler output is directed. If you choose <not set>, the .class files are written to their source directory.
    When you set the Target, your change affects all classes that use this compiler.
    Very few options can't be set in S1S; the challenge is finding out where they're set!

  • How to set the Size to an extension of an applet?

    Greetings,
    I have a frame that i added to ti a class that extends from applet, on this extension there are two pannels.
    i want that when i resize the frame aslo the apllet will be resized. i added to the frame a compenentlistener and when the frame gets an resize event i call the setSize method of the applet with the frame's dimention, but it doesnt work. How do i do it correctly?

    I have not tried this yet but maybe it works:
    At the applet tag set size of the applet to "100%"
    and use HSPACE and WSPACE.
    Don't know, if it'll work.

  • How to set the size for height of iView tray?

    Hi,
    I have created a ABAP webdynpro component and integrated this comp with iView. Then i integrated iView into Page in portal. That is working fine.
    But the size of tray/window which is displayed in the page is very small.
    How to increase the height of that Tray/window/iView containing my component?

    Hi,
    By changing the maximum automatic height and Minimum automatic height property of the iview you can set the size for height of your iview.
    to do this follow the setps:
    goto content administrator -> portal content -> your folder where you created your iview or directly to your iview -> right click -> open -> object,
    and now in property category choose appearance-Size from the drop down menu and set the above properties to your required height.
    if you want the end user to modify this property set the property to read/write .
    *********please reward points if the information is helpful to you********************

  • How to set the size of printing subject

    I have a deskjet 3520 all in one and my computer is a laptop dv6 with windows7 prof. 64bit.
    I want to print out PCB traces so that I can make my own but I don't know to how set the size
    with this printer. They take up the whole page when I want them to be 2.35x3.35.
    Don't know if this can be done with this printer.
    Any help would be apreciated.
    This question was solved.
    View Solution.

    Can you post a link to a sample, or upload here a sample?  That would make it easier to debug what is going on.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • How to set the size of SUM()/SUM() of NUMBER Tyep?

    I met the oracle truncation error when I post the
    SUM(a field)/SUM(b field), a and b field are NUMBER Type
    From the OCI Doc, Numbers with up to 38 digits precision.
    and I set the size of data buffer 41 for NUMBER TYPE.
    (for example)
    rc = OCIDefineByPos( hstmt, &m_pDefine, ((CEBOracle *)pDatabase)->m_hpErr, index,
                   (dvoid *) m_lpszBindData, m_nBufSize+1, SQLT_STR,
                   (dvoid *) m_cbIndicator, (ub2 *) 0, (ub2 *) 0, OCI_DEFAULT);
    I always set the output datatype as SQLT_STR
    and m_nBufSize is 41 for NUMBER Type
    my client met the error when the result is 0.00012345678912345678912345678912345678912
    I think that it's not a solution that just enlarge the number form 41 -> 45
    How can I avoid this problem when user send the SQL Statement that the result has unlimited decimal number?
    Thank you in advancd

    ORA-01406 fetched column value was truncated
    I found the reason of that problem.
    I migrated from OCI Ver7 to Ver8
    If I set the buffer size to 10 (actually 40 in my program) and the result was
    0.0000000000000000001
    When I debuged the output buffer
    The result was 1.0E-19
    but now 0.00000000 and truncation error
    how to change floating point and scientific expression automatically depend on the result like OCI Ver7 and SQL PLUS?
    I changed define function
    odefin(m_hstmt, ii+1, (UCHAR *) m_lpszData[ii], m_lpLength[ii]+1, SQLT_STR, -1, m_lpcbValue[ii], 0, -1, -1, 0, 0);
    to
    m_rc = OCIDefineByPos( m_hstmt, &pDef, ((CEBOracle*) m_pDatabase)->m_hpErr, ii+1,
              (dvoid *) m_lpszData[ii], m_lpLength[ii]+1, SQLT_STR,
              (dvoid *) m_lpcbValue[ii], (ub2 *) 0, (ub2 *) 0, OCI_DEFAULT );

  • How to set the size of popups from KM Navigation Iview

    Hello guys
    Does any of you know how I can set the size of the window that pops up when you click on a resource/file in a KM navigation iview?
    I have tried to enter "width=100,height=100" (without the quotes) in the Window Features property of the KM Navigation Iview, but it does not influence the size of the popups.
    Any suggestions to what could be wrong? Or is it not possible at all to control the size of that popup?
    Kind regards,
    Martin

    Hi,
    I cheched yesterday if I could find the command, sorry I couldn't.
    I also realized that the layout generates html link tags (ie. <a />) for the resource links, no javascript open link functions (ie. window.open), wich doesn't alowed (as far as I know) to give size to the pop-up window.
    So to make the link of the resource (gived by the <b>displayname(contectlink)</b> property set) I think you would have to <i>create (develop)</i> the layout, so the link will be rendered with window_size.
    You have other option, you can take off the "<i>contentLink</i>" setting. and add the <b>download</b> command, so the user who want to open / save the document can click on this command and do it in their PC.
    I.E, Create a copy of the <b>download</b>, and add this to the Collection render displayed porpeties:
    rnd:command(command=Z_download/style=link)
    You ca also use and icon to represent the download (you can set that icon in the command)
    I.E, rnd:command(command=Z_download_icon/style=icon)
    This last options represents a problem with the km-only-read content like xml files generaded by xml forms, it can only be readed in the km-portal.
    I hope this might help you.
    Best regards,
    Jorge M.

  • How to set the size of JTextPane according to the size of text??

    hello
    how can i set the size of JTextPane according to the size of text it would contain in such a way that JTextPane should not have ScrollBar.

    StanislavL wrote:
    width should be defined for your container width. suppose you have a very long row of text. Widht full screen widht it wraps into 2 lines but if you set widht of your window to half screen widht there should be 4 lines.
    But you can use the same code and get preferred widht as well.u mean like this :
    objTextPane.getParent().getWidth();Edited by: 811243 on Sep 6, 2011 5:32 AM

  • How to set the size of combo box  using jsf

    I face problem when i set the size of a combo in jsf

    Is it not possible to use it with a GridBagLayout?Your question was "How do I get a tabbed pane to take all the space of the frame"?
    You where given the answer. Did you try it? Did it work? Then why are you questioning the suggestion?
    Its one line of code if you use a BorderLayout which by the way was specifically designed for this purpose.
    Yes you can do it with a GridBagLayout with about 5 lines of code.
    So the question is why would you want to write 5 lines of code when you can use one?
    If your question was "How do I waste my time forcing the GridBagLayout to size a component to take up all the space of the frame", then you would have received a different answer. (Although most people would have told you to use a BorderLayout anyway, since its easier).

  • How to set the size of the frame in the decoration controls

    Hi,
    I am drawing some frames or boxes using the patterns in the "Decorations" control in labview.
    Is there other way to set the size of the frames or boxes rather than to drag them? also how can I change the color of the borders?
    Thanks,
    Joyce
    Solved!
    Go to Solution.

    Select the item.  Go to the Resize Objects button on the toolbar.  Pick the last one which shows a resize within a dialog bubble.  Now a dialog pops up which lets you define the height and width.
    To color something, Shift right click to bring up the toolbox.  Pick the paint brush.  Click on the thing you want to change such as the border.  It might now be the wrong color, so right click which brings up the color picker.  Now select the color you actually want.  If you want something to be transparent, pick the T at the upper right corner of the color dialog box.

  • How to set the size of a Font in Pixel?

    Hi,
    i know how to get the screen resolution of the current monitor and I know how to use Fonts (and I know how to read the API, but that didnt help).
    Is there a way to set the size (or at least the height) of a Font in pixel rather then in points?
    All I actually need is how many pixels the height of my String will be when I print it on the screen.
    I use Swing and drawString(...) to draw my String (this information shouldnt matter, but just in case).
    thanx

    Hi,
    search doc about FontMetrics, you'll find infos about how to get the font height... If I remember well, you need to get the Graphics of the component, then call getFontMetrics() or getFontMetrics(font) to obtain the metrics, then call getHeight() to know the font height...

  • How to set the size of an open dialog

    HI Everyone:
    I cannot set the size of the open dialog.
    I create a menu and menu item called "open"
    The menu item "open" will call OpenFile().
    However, I cannot set the size of the open dialog
    Everytime when the open dialog pops up
    the size isn't 500 x 500.
    Does anyone know what's wrong with this program ?
    Thanks a lot,
    Rodger
    ================================================================
    public void OpenFile(){
    JFileChooser fc = new JFileChooser();
    fc.setSize(new Dimension(500,500));
    fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fc.showOpenDialog(this);
    ================================================================

    Try this and then tell us if it worked:
    JFileChooser fc = new JFileChooser();
    fc.setPreferredSize(new Dimension(500,500));
    fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    JDialog d = new JDialog(new JFrame());
    d.setSize(500, 500);
    d.getContentPane().setLayout(new FlowLayout());
    d.getContentPane().add(fc);
    d.setVisible(true);

  • How to set the size of folder in KM

    Hi everyone,
    This is Nagaraja.........i am new to SAP Enterprise Portal and
    I have created a folder in Knowledge Management and i want to
    restrict the number of files uploaded into that folder by enduser.
    i.e., i want to set the size of the folder.
    can you please help me in doing this task.
    Thank you.

    Hi Nagaraja,
    welcome to SCN!
    You posted a common question here in the KM forums and I will try to update it into the Wiki. If you search for this topic you will find similar answers like: Restricting the folder size of the KM Repositories pointing to the existing Weblog.
    Hope this answers your question,
    Robert

Maybe you are looking for

  • Not logging in?

    After I enter my @mac info in preferences of ichat nothing happens. Everything in the buddy menu is greyed out. I tried a test message to tryichatav, but I get an error saying "could not send instant message to tryichatav" . If I go back to my prefer

  • Apple 21" studio Display monitor-help

    I have a G4 and just got an apple 21" studio display monitor I work in photoshop CS2 what do I put the resolution at? Color and refresh? what should the white point and gamman be? what should the profile on themonitor display? I WENT INTO THE PREFERE

  • OS5.1 forced album artwork screen saver on me.  How do I get rid of it?

    I just loaded the newest OS for the Apple TV.  I use my own photos for my screen saver.  But the new OS has forced album artwork into my photo rotation.  All I see is album artwork.  I dont want that.  Anyone know how to get rid of it?  There is no o

  • SAP Best Practice For Unicode Upgrades - NetWeaver 2004s

    Team SAP, I have a customer that is starting to plan for a Unicode upgrade.  The question from the customer is as follows: What is the SAP Best Practice for Unicode Upgrades?  They will be upgrading from a BW 3.5 System to NetWeaver 2004s, and their

  • Can't connect to FTP

    Hi, I have a big problem. I can't connect to my FTP anymore. I tried CyberDuck, FileZilla, Dreamweaver CS4 everything! I think my mac has something blocked, because Finder even can't connect to my FTP. Can anybody help me?