Java.awt availability in CDC Toolkit ?

Hi guys and girls,
I've just tried out the Sun Java Toolkit for CDC 1.0 .. I tried making a simple app which uses awt components, such as Frame, Label, Button .. but the Label and Button just wont compile. I always thought that CDC has all the lib for the j2se's java.awt.
Quoted from CDC FAQ :
CDC currently supports three profiles. Foundation Profile provides basic application support APIs without any additional support for GUIs. Personal Basis Profile includes all of the APIs contained in Foundation Profile and adds support for lightweight AWT GUI components and the xlet application model. Personal Profile includes all of the APIs contained in Personal Basis Profile and adds support for full AWT compatibility and the applet application model.
Do i miss something .. ? Please help pointing out for me ..
I understand that there's swing from the AGui. So i tried making a new project with a simple class containing a simple JFrame, containing a JPanel which contains a button, which can be clicked to trigger a message type JOptionPane. But when the JOptionPane appears, it fills up the entire screen, i dont quite understand what is wrong.
Here's the code :
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class HelloWorld {
      * @param args
     public static void main(String[] args) {
          final JFrame frame = new JFrame("Ahiak");
          final JPanel panel = new JPanel(new FlowLayout());
          JButton but = new JButton("Click Me !");
          panel.add(but);
          frame.getContentPane().add(panel);
          but.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                    JOptionPane.showMessageDialog(panel, "hahah !");
          frame.setVisible(true);
}Please show some compassion and click the reply button, lol -_-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

I don't know about swing, but you can try using AWT and compile it with J2SE (set compliance to 1.4). The jar file should work on your mobile device with Personal Profile.

Similar Messages

  • Deprecation warning for getFontMetrics(java.awt.Font) in java.awt.Toolkit

    Hi all,
    When I use the following code
    JComponent c;
    FontMetrics metrics = getToolkit().getFontMetrics(c.getFont());
    I get this following warning during compilation:-
    warning: getFontMetrics(java.awt.Font) in java.awt.Toolkit has been deprecated
    JDK suggests to use getLineMetrics() of the Font class.
    But there's an issue with that: if I use getLineMetrics(), there is no API method that I can use to get the width of a string as opposed to FontMetrics which provides stringWidth(String str) method for that purpose. In fact all the methods in FontMetrics are not mapped into LineMetrics.
    Could anyone please help or provide me at least some pointers on how to tackle this issue so that I can get rid of the deprecated method along with the existing methods mapped to equivalent APIs? The bottomline is that I should be able to maintain the existing functinality of my application for those part of code that uses getToolkit().getFontMetrics().
    Thank you for your help in advance.
    -Sanjoy Das

    Use Graphics.getFontMetrics(font) instead.
    After creation your frame and calling frame.show();
    You can access it like that
    frame.show();
    frame.getGraphics().getFontMetrics(new Font("Arial",0,10));
    before showing graphics is null.
    Or just create a BufferedImage and ask it for graphics.
    BufferedImage img=new BufferedImage(...);
    img.getGraphics().getFontMetrics(font);
    regards
    Stas

  • Quality of Cursors created with java.awt.Toolkit(createCutsomCursor)

    Hi -
    I encountered a small problem while creating my own cursors for my Java application , I used the java.awt.Toolkit Objects createCustomCursor method to use a .GIF image as a cursor ... it worked but the quality of that cursor is horrible, the outline is rough ... I tried the same with a transparent PNG file afterwards unfortunately the same result , does anyone know why the quality is that bad or may this just be a problem of the choosen color pool ?
    Help would be very appreciated since I have no clue how to use .cur files ... seems like a non supported format , in case someone knows how to import those it would help a lot if you would drop some lines of code.
    I am currently using Java 2 SDK 1.4.0_01 , newest version.
    Thanks for you time and thanks in advance for possible answers
    -- Harald Scheckenbacher

    I noticed this problem too. It looks like the routine is generating cursors which are scaled to to the maximum size of the system. On my win XP system,
    Dimension dim = toolkit.getBestCursorSize(256, 256);
    int maxColors = toolkit.getMaximumCursorColors();
    return 32,32 and 256 respectively
    If I provide a 16x16, all the pixels have been pixel doubled. If I specify a 32x32 image, then the cursor looks perfect. This looks like a bug for the java folks. Not sure why someone would ever want a cursor image to be pixel scaled.
              

  • Java.awt.Toolkit - Coldfusion - HELP

    Greetings.
    I am having a hard time with the following code:
    <cfobject action="create" type="java" class="java.awt.Toolkit" name="fileObj">
    <cfscript>
    img = fileObj.getDefaultToolkit().getImage("images/products/39321.jpg");
    width = img.getwidth();
    height = img.getheight();
    </cfscript>
    <cfoutput>#height#</cfoutput>
    I keep getting the following error:
    java.lang.NoClassDefFoundError
    My version of Java is 1.4.2. I'm running Redhat Linux 4.0. Coldfusion MX 6.1.
    I know this isn't a Coldfusion forum, but I really need some help here.
    I'm new to Java technologies, so any help will be greatly appreciated.

    can ColdFusion load Java objects?
    Presuming that it can, then ColdFusion probably needs some configuration to tell it the Java directory or where the class files are (JavaHome/jre/lib/rt.jar)

  • Substitute of java.awt.ToolKit.getDefaultToolKit.beep()

    Hello everybody. I am designing a Swing Application and there I am using java.awt.ToolKit.getDefaultToolKit.beep() method to generate sound in various operations. I want to know is it possible to generate own sound as a substitute of this method? I think it is possible. How can I do this? Thank you.

    Thank you for giving reply.
    As I wish to play .mp3 file I had downloaded an API from Javalobby . I tried it, here is my code :
    package player;
    import java.io.File;
    import java.io.IOException;
    import javax.sound.sampled.AudioFormat;
    import javax.sound.sampled.AudioInputStream;
    import javax.sound.sampled.AudioSystem;
    import javax.sound.sampled.DataLine;
    import javax.sound.sampled.SourceDataLine;
    * @author Tanmoy
    * @Super Scientific Calculator
    * @version 1.2010
    public class Player {
         private File audioFile;
         public Player(String path) {
              this.audioFile = new File(path);
         public void play() {
              AudioInputStream din = null;
              try {
                   AudioInputStream in = AudioSystem.getAudioInputStream(audioFile);
                   AudioFormat baseFormat = in.getFormat();
                   AudioFormat decodedFormat = new AudioFormat(
                        AudioFormat.Encoding.PCM_SIGNED,
                        baseFormat.getSampleRate(), 16, baseFormat.getChannels(),
                        baseFormat.getChannels() * 2, baseFormat.getSampleRate(),
                        false);
                   din = AudioSystem.getAudioInputStream(decodedFormat, in);
                   DataLine.Info info = new DataLine.Info(SourceDataLine.class, decodedFormat);
                   SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);
                   if (line != null) {
                        line.open(decodedFormat);
                        byte[] data = new byte[4096];
                        line.start();
                        int nBytesRead;
                        while ((nBytesRead = din.read(data, 0, data.length)) != -1) {
                             line.write(data, 0, nBytesRead);
                        line.drain();
                        line.stop();
                        line.close();
                        din.close();
              } catch (Exception e) {
              } finally {
                   if (din != null) {
                        try {
                             din.close();
                        } catch (IOException e) {
    }And the calling, piece of code is :
    try {
                                  Parser parser = new Parser(parsingString, displayPanel.getCurrentBase(),
                                       displayPanel.getCurrentBase(), displayPanel.getTrigoMode(),
                                       displayPanel.getScale());
                                  String output = parser.solve();
                                  displayPanel.outputTextField.setText(output);
                                  displayPanel.outputTextField.setCaretPosition(displayPanel.outputTextField.getText().length());
                                  displayPanel.charLabel.setText((Integer.toString(output.length())));
                                  if (message == null) {
                                       message = "No Exception";
                             } catch (InvalidSyntaxException invalidSyntaxException) {
                                  message = invalidSyntaxException.getMessage();
                                  JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE);
                                  new Player("/resources/what_the_hell.mp3").play();
                                  displayPanel.outputTextField.setText("0");
                                  displayPanel.charLabel.setText("0");
                             }But I can not able to here the sound.
    What to do now?
    Thank you.

  • DataFlavors in java.awt.datatransfer

    Hello
    I'm in the process of developing an application that manages the clipboard . The program runs in the "SystemTray" using the java Toolkit , on the user's request the application takes the content of the clipboard and sends it to other computers on the network that has the program and puts them in the client;s clipboard , that way the user only has to use the copy/paste functions much like if the data was resided on the computer .So far i was able to manage for pictures ,plain text and String selections , the problem is in File selections , now the "JavaFileList" flavor returns an "ArrayList" containing a String representation of the path of each file , which makes it impossible for the client to copy the content to this clipboard unless he has the same directory naming on his computer.I tried implementing a different File Selection that takes each single file as an instance of java.io.File and adds them to a vector , but still the program returns an "ArrayList" with the paths as strings ,i wanted to know should I write a new DataFlavor different than the "JavaFileListFlavor" or the error resides some where else because it worked for images , done by implementing an ImageSelection class much like the StringSelection already given by java.awt.datatransfer.
    Thank you for your collaboration.
    Edited by: Wafic1 on May 14, 2009 8:36 PM

    Strings and arrays are actually stored in the clipboard in their binary representation - and thus they can be copied easily. Files however exist as a pointer to the actual file content on the hard disk. If you copy the reference to a 4GB iso to the clipboard, you will obviously not copy the entire file.
    If you want to copy the file, you will have to do it manually. You can either store small files in the clipboard by reading them to byte[]s (implementing your own data flavor), or you can use URIs (if you have some means of the target machine accessing the source machines, such as smb or ftp).
    By the way, didn't you already post this question before?

  • Eexception in java.awt.AWTError

    Hi all,
    I am starting with java in my Ubuntu box, and am faced with a problem.
    Consider a simple program
    import javax.swing.*;
    import java.awt.*;
    class helloSwing{
         public static void main(String[] args)
              JFrame myWindow;
              myWindow = new JFrame();
              myWindow.setSize(300,200);
              myWindow.setTitle("My First Swing Application");
              myWindow.setVisible(true);
              System.exit(0);
    }when I run this program
    neo@tathagata:~/Java Progs$ java helloSwingThis is the error I am getting
    Exception in thread "main" java.awt.AWTError: Cannot load AWT toolkit: gnu.java.awt.peer.gtk.GtkToolkit
       at java.awt.Toolkit.getDefaultToolkit() (/usr/lib/libgcj.so.6.0.0)
       at java.awt.EventQueue.invokeLater(java.lang.Runnable) (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.SwingUtilities.invokeLater(java.lang.Runnable) (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.RepaintManager.addInvalidComponent(javax.swing.JComponent) (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JComponent.revalidate() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JComponent.setOpaque(boolean) (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JPanel.JPanel(java.awt.LayoutManager, boolean) (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JPanel.JPanel() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JRootPane.createGlassPane() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JRootPane.getGlassPane() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JRootPane.JRootPane() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JFrame.createRootPane() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JFrame.getRootPane() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JFrame.frameInit() (/usr/lib/libgcj.so.6.0.0)
       at javax.swing.JFrame.JFrame() (/usr/lib/libgcj.so.6.0.0)
       at helloSwing.main(java.lang.String[]) (Unknown Source)
       at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
       at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
    Caused by: java.lang.ClassNotFoundException: gnu.java.awt.peer.gtk.GtkToolkit not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:./,file:./], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
       at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
       at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.6.0.0)
       at java.lang.ClassLoader.loadClass(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
       at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.6.0.0)
       at java.lang.Class.forName(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
       at java.awt.Toolkit.getDefaultToolkit() (/usr/lib/libgcj.so.6.0.0)
       ...17 moreIt appears whenever I'm importing some packages it is creating a problem.
    With whatever little knowledge of Java I have, I suspect I have messed up in the enviornment variables somewhere.
    So here are my
    PATH=/usr/local/qt-x11-opensource-src-4.1.0/bin:/usr/local/bin:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/bin/X11:/usr/games:/home/neo/jdk1.3.1_17/bin/:/usr/sbin:/usr/java/jdk1.3.1_17/bin
    JAVA_HOME=/usr/java/jdk1.3.1_17Can anybody suggest me an easy link where classpath is explained?
    I'm am helpless, coz if this is not getting fixed I need to go back to Windoz ..
    leaving Ubuntu, which would be really painful.
    Please help. Thanks in Advance.

    Cool, I glad it's working. And thanks for the kind words (although
    your link sent me some sort of Introduction page, I eventually found
    "Tatha's blog").
    Now all I have to do is get my setup correct. Also 1.5, also Ubuntu.
    I screwed something up when I installed Netbeans, and couldn't
    understand how the Debian people have set things up. I just type the
    executable's path at the command line (easy with *nix) or let Eclipse
    just do the right thing.
    Cheers,
    Peter

  • Java.awt.Dialog in Java 1.6 has a memory leak

    When a modal Dialog opens a modal sub-dialog, the Dialog stays in memory after both the sub-dialog and the Dialog itself is disposed.
    The field that contains the leaked object is Dialog.modalDialogs (static). The methods which causes the leak are Dialog.modalHide and Dialog.modalShow.
    Whenever a modal Dialog is opened, Dialog.modalShow is called, and adds itself to Dialog.modalDialogs.
    When it closes, Dialog.modalHide is called and removes one copy of itself from Dialog.modalDialogs. Then Dialog.modalShow is called on all previously blocked modal dialogs. When the sub-dialog is opened and closed, Dialog.modalDialogs contains two references to the main Dialog, and only one of them is removed when Dialog.modalHide for that Dialog is called.
    To detect the leak, just put a break point in Dialog.modalHide, after modalDialogs.remove(this);. When opening a Dialog and closing it without opening a sub-dialog, the Dialog.modalDialogs field should be empty. When a sub-dialog was opened and closed before the main Dialog is closed, the Dialog.modalDialogs field contains a reference to the disposed main Dialog.
    This leak does not exist in 1.5.0_10 (no Dialog.modalDialogs field). I have searched the bug database, but I have not found this bug there. Could anyone confirm this?
    A simple code to reproduce the leak:
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    public class Test {
       public static void main(String[] args) {
          final JFrame frame = new JFrame() {
             protected void processWindowEvent(WindowEvent e) {
                super.processWindowEvent(e);
                if (e.getID() == WindowEvent.WINDOW_CLOSING) {
                   System.exit(0);
          JButton button = new JButton("Dialog");
          button.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent aE) {
                JButton subButton = new JButton("SubDialog");
                subButton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent aE) {
                      JOptionPane.showMessageDialog(frame, "SubDialog");
                JOptionPane.showMessageDialog(frame, subButton);
          frame.getContentPane().add(button);
          frame.pack();
          // Center the window
          Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
          Dimension frameSize = frame.getSize();
          if (frameSize.height > screenSize.height) {
             frameSize.height = screenSize.height;
          if (frameSize.width > screenSize.width) {
             frameSize.width = screenSize.width;
          frame.setLocation((screenSize.width - frameSize.width) / 2,
                (screenSize.height - frameSize.height) / 2);
          frame.setVisible(true);
    }

    Sorry, I just found the bug in the bugdatabase (with google of course,):
    [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6497929]

  • Can I draw *.bmp, *.png in java.awt.canvas ?

    In paint method of my program, I get image from Toolkit like this:
    public class CanCanvas extends Canvas{
    //In loadImage method
    Toolkit.getDefaultToolkit().getImage(
                        getClass().getClassLoader().getResource(
                                  resource.getString("bg.jpg")));
    //.... In paint method
    if (image != null && image.size() > 0) {
                   for (int j = 0; j < image.size(); j++) {
                        Image image1 = (Image) image.elementAt(j);
                        Rectangle rectangle = (Rectangle) imgLocation.elementAt(j);
                        g.drawImage(image1, rectangle.x, offset + rectangle.y,
                                  rectangle.width, rectangle.height, null);
                        i = i <= rectangle.y + rectangle.height + 7 ? rectangle.y
                                  + rectangle.height + 7 : i;But there is something very strange, if my image is *.jpg or *.gif, it runs ok, otherwise -*.bmp, *.png-, it can't draw the image.
    Would anyone tell me why ? Is the reason java.awt.canvas ?
    Thanks in advance ^ ^

    If you'd bother to read the documentation of the methods you're using, you'd know:
    http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Toolkit.html#getImage(java.lang.String)
    Returns an image which gets pixel data from the specified file, whose format can be either GIF, JPEG or PNG.

  • Java.awt.Image getWidth() and getHeight() not working!

    Right- this is want I want to do.
    I have a background image which is added as a background image to a third party API class which extends Java.awt.Container. Such container is then added to the Content Pane of MyClass (which extends JFrame)
    I want to read the width and height of the image and resize MyClass accordingly.
    Problem is calling theImage.getWidth(MyClass.this) or theImage.getWidth(theThirdPartyAPIContainer) always return -1 and -1 denoting that no information is available.
    What do I need to do to obtain the height and width?

    Post here, cos don't know your email.
    Anyway
    - Can't use setPreferredSize because the Conatiner which is added to the ContentPane is a Awt Component not a Swing JComponent!
    - Also, the background is added AFTER the this.pack()and this.show().
    -I figured out that I could access Insets.top, Insets.left, Insets.right, Insets.bottom.
    I have basically the following
    |JMenuBar |
    L____________________________________________|
    | |
    | |
    | |
    | Third Party Class extending java.awt.Container |
    | containing an image of known size |
    | |
    L____________________________________________|
    I am fine for the width I do
    Insets frameInsets = this.getInsets();
    width = image.getWidth() + frameInsets.left + frameInsets.right;
    Height is the problem
    After some Trial an error it LOOKS on Solaris as if the following is right-
    height = image.getHeight()+frameInsets.top+ myJMenuBar.getSize()+getHeight+ myJMenuBar.getInsets().top + myJMenuBar.getInsets().bottom
    I cannot comprehend whether this is just a coincidence or not as I don't know why frameInsets.bottom should in any case be excluded.
    Here are the dimensions-
    frameInsets.left = 6
    frameInsets.right= 6
    frameInsets.top =28
    frameInsets.bottom = 6
    JMenuBar height = 23
    JMenuBar's Insets.top = 1
    JMenuBar's Insets.bottom = 1
    What should be the 'correct' calculations and does the Insets for the JMenuBar and the JFrame overlaps?

  • How to restrict the maximum size of a java.awt.ScrollPane

    Dear all,
    I would like to implement a scroll pane which is resizable, but not to a size exceeding the maximum size of the java.awt.Canvas that it contains.
    I've sort of managed to do this by writing a subclass of java.awt.ScrollPane which implements java.awt.event.ComponentListener and has a componentResized method that checks whether the ScrollPane's viewport width (height) exceeds the content's preferred size, and if so, resizes the pane appropriately (see code below).
    It seems to me, however, that there ought to be a simpler way to achieve this.
    One slightly weird thing is that when the downsizing of the pane happens, the content can once be moved to the left by sliding the horizontal scrollbar, but not by clicking on the arrows. This causes one column of gray pixels to disappear and the rightmost column of the content to appear; subsequent actions on the scrollbar does not have any further effect. Likewise, the vertical scrollbar can also be moved up once.
    Also, I would like a java.awt.Frame containing such a restrictedly resizable scrollpane, such that the Frame cannot be resized by the user such that its inside is larger than the maximum size of the scrollpane. The difficulty I encountered with that is that setSize on a Frame appears to set the size of the window including the decorations provided by the window manager (fvwm2, if that matters), and I haven't been able to find anything similar to getViewportSize, which would let me find out the size of the area inside the Frame which is available for the scrollpane which the frame contains.
    Thanks in advance for hints and advice.
    Here's the code of the componentResized method:
      public void componentResized(java.awt.event.ComponentEvent e)
        java.awt.Dimension contentSize = this.content.getPreferredSize();
        this.content.setSize(contentSize);
        java.awt.Dimension viewportSize = getViewportSize();
        System.err.println("MaxSizeScrollPane: contentSize = " + contentSize);
        System.err.println("MaxSizeScrollPane: viewportSize = " + viewportSize);
        int dx = Math.max(0, (int) (viewportSize.getWidth() - contentSize.getWidth()));
        int dy = Math.max(0, (int) (viewportSize.getHeight() - contentSize.getHeight()));
        System.err.println("MaxSizeScrollPane: dx = " + dx + ", dy = " + dy);
        if ((dx > 0) || (dy > 0))
          java.awt.Dimension currentSize = getSize();
          System.err.println("MaxSizeScrollPane: currentSize = " + currentSize);
          setSize(new java.awt.Dimension(((int) currentSize.getWidth()) - dx, ((int) currentSize.getHeight()) - dy));
        System.err.println();
      }Best regards, Jan

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    public class ScrollPaneTest
        GraphicCanvas canvas;
        CustomScrollPane scrollPane;
        private Panel getScrollPanel()
            canvas = new GraphicCanvas();
            scrollPane = new CustomScrollPane();
            scrollPane.add(canvas);
            // GridBagLayout allows scrollPane to remain at
            // its preferred size during resizing activity
            Panel panel = new Panel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            panel.add(scrollPane, gbc);
            return panel;
        private WindowListener closer = new WindowAdapter()
            public void windowClosing(WindowEvent e)
                System.exit(0);
        private Panel getUIPanel()
            int w = canvas.width;
            int h = canvas.height;
            int visible = 100;
            int minimum = 200;
            int maximum = 500;
            final Scrollbar
                width  = new Scrollbar(Scrollbar.HORIZONTAL, w,
                                       visible, minimum, maximum),
                height = new Scrollbar(Scrollbar.HORIZONTAL, h,
                                       visible, minimum, maximum);
            AdjustmentListener l = new AdjustmentListener()
                public void adjustmentValueChanged(AdjustmentEvent e)
                    Scrollbar scrollbar = (Scrollbar)e.getSource();
                    int value = scrollbar.getValue();
                    if(scrollbar == width)
                        canvas.setWidth(value);
                    if(scrollbar == height)
                        canvas.setHeight(value);
                    canvas.invalidate();
                    scrollPane.validate();
            width.addAdjustmentListener(l);
            height.addAdjustmentListener(l);
            Panel panel = new Panel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(2,2,2,2);
            gbc.weightx = 1.0;
            addComponents(new Label("width"),  width,  panel, gbc);
            addComponents(new Label("height"), height, panel, gbc);
            gbc.anchor = GridBagConstraints.CENTER;
            return panel;
        private void addComponents(Component c1, Component c2, Container c,
                                   GridBagConstraints gbc)
            gbc.anchor = GridBagConstraints.EAST;
            c.add(c1, gbc);
            gbc.anchor = GridBagConstraints.WEST;
            c.add(c2, gbc);
        public static void main(String[] args)
            ScrollPaneTest test = new ScrollPaneTest();
            Frame f = new Frame();
            f.addWindowListener(test.closer);
            f.add(test.getScrollPanel());
            f.add(test.getUIPanel(), "South");
            f.pack();
            f.setLocation(200,200);
            f.setVisible(true);
            f.addComponentListener(new FrameSizer(f));
    class GraphicCanvas extends Canvas
        int width, height;
        public GraphicCanvas()
            width = 300;
            height = 300;
        public void paint(Graphics g)
            super.paint(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            int dia = Math.min(width, height)*7/8;
            g2.setPaint(Color.blue);
            g2.draw(new Rectangle2D.Double(width/16, height/16, width*7/8, height*7/8));
            g2.setPaint(Color.green.darker());
            g2.draw(new Ellipse2D.Double(width/2 - dia/2, height/2 - dia/2, dia-1, dia-1));
            g2.setPaint(Color.red);
            g2.draw(new Line2D.Double(width/16, height*15/16-1, width*15/16-1, height/16));
        public Dimension getPreferredSize()
            return new Dimension(width, height);
        public Dimension getMaximumSize()
            return getPreferredSize();
        public void setWidth(int w)
            width = w;
            repaint();
        public void setHeight(int h)
            height = h;
            repaint();
    class CustomScrollPane extends ScrollPane
        Dimension minimumSize;
        public Dimension getPreferredSize()
            Component child = getComponent(0);
            if(child != null)
                Dimension d = child.getPreferredSize();
                if(minimumSize == null)
                    minimumSize = (Dimension)d.clone();
                Insets insets = getInsets();
                d.width  += insets.left + insets.right;
                d.height += insets.top + insets.bottom;
                return d;
            return null;
        public Dimension getMinimumSize()
            return minimumSize;
        public Dimension getMaximumSize()
            Component child = getComponent(0);
            if(child != null)
                return child.getMaximumSize();
            return null;
    class FrameSizer extends ComponentAdapter
        Frame f;
        public FrameSizer(Frame f)
            this.f = f;
        public void componentResized(ComponentEvent e)
            Dimension needed = getSizeForViewport();
            Dimension size = f.getSize();
            if(size.width > needed.width || size.height > needed.height)
                f.setSize(needed);
                f.pack();
         * returns the minimum required frame size that will allow
         * the scrollPane to be displayed at its preferred size
        private Dimension getSizeForViewport()
            ScrollPane scrollPane = getScrollPane(f);
            Insets insets = f.getInsets();
            int w = scrollPane.getWidth() + insets.left + insets.right;
            int h = getHeightOfChildren() + insets.top + insets.bottom;
            return new Dimension(w, h);
        private ScrollPane getScrollPane(Container cont)
            Component[] c = cont.getComponents();
            for(int j = 0; j < c.length; j++)
                if(c[j] instanceof ScrollPane)
                    return (ScrollPane)c[j];
                if(((Container)c[j]).getComponentCount() > 0)
                    return getScrollPane((Container)c[j]);
            return null;
        private int getHeightOfChildren()
            Component[] c = f.getComponents();
            int extraHeight = 0;
            for(int j = 0; j < c.length; j++)
                int height;
                if(((Container)c[j]).getComponent(0) instanceof ScrollPane)
                    height = ((Container)c[j]).getComponent(0).getHeight();
                else
                    height = c[j].getHeight();
                extraHeight += height;
            return extraHeight;
    }

  • Simplifying a java.awt.Shape

    Hi,
    I have a problem where i have a shape created by an AREA object (basically unioning shapes to create a larger shape). The shape visually appears to be just a plain old square however the shape contains 200 segments!
    The algorithm i'm using tp examine the shape will be much more effecient of I can simplify the segments. I'm hoping there is some available software or utility that exists to take an existing java.awt.Shape that has redundant data and "simplify" it by removing superfulous information.
    i.e. if I did a line segmenet from 0,0 to 1,1 then a line segment from 1,1 to 2,2 that would be collapsed to a line segment from 0,0 to 2,2.
    I realize there's the PathIterator's flattening ability however I would like the simplifying shape to condense two quad curves to one cubic curve if possible and not necessarily change everything to lineto segments.
    Does anyone have any resources or information that might help me with this?
    Thanks!
    Trevor

    Hi
    Use the Java Threading Model ...
    This is a Sample Program that use Buffered Image as a Source
    import java.awt.Color;
    import java.util.ArrayList;
    public class Joint implements Runnable
            ArrayList points;
         byte startside,closedside;
         byte type; //0 line 1 arc
         boolean closed;
         Junction closedwith,parent;
         // Area shapeimage;
            int pixels[];
            int startpoint,width;
            Color color = Color.black;
            TraceResult result;
    public Joint(TraceResult Result,int pix[],int start,int w,Junction j)
            result = Result;
            startpoint = start;
            System.arraycopy(pix,0,pixels,0,pix.length);
            parent = j;
            //startside = side;
            points = new ArrayList();
            width = w;
    public boolean isonsamejuncion()
            return (parent==closedwith);
    public void run()
            int i;
            int p=nextPoint(0);
            while(p!=0)
            {       points.add(new Integer(p));
                    p = nextPoint(p);
                      /* Joint t = new Joint(pixels,width,parent);
                       Thread thread = new thread(t);
                       thread.start(); continue;*/
            /* else  { closed = false; closedwith = null; break;  }
    private final int nextPoint(int i)
    {       boolean M,N2,NE2,E2,SE2,S2,SW2,W2,NW2;
            int l=pixels.length;
            int N,E,S,W,NE,NW,SE,SW;
            int NP,EP,SP,WP,NEP,NWP,SEP,SWP;
            Junction j;
            if (!(M = color.equals(new Color(pixels))))
    closed=false;
    closedwith=null;
    return 0;
    //Trace points
    EP = i+1 ;
    WP = i-1 ;
    SP = i+width ;
    NP = i-width ;
    SEP = i+width+1 ;
    SWP = i+width-1 ;
    NEP = i-width+1 ;
    NWP = i-width-1 ;
    E =( (EP <= l) && color.equals(new Color(pixels[EP])) )?3:0;
    W =( (WP >= 0) && color.equals(new Color(pixels[WP])) )?11:0;
    S =( (SP <= l) && color.equals(new Color(pixels[SP])) )?5:0;
    N =( (NP >= 0) && color.equals(new Color(pixels[NP])) )?1:0;
    SE=( (SEP <= l) && color.equals(new Color(pixels[SEP])) )?300:0;
    SW=( (SWP >= 0) && color.equals(new Color(pixels[SWP])) )?500:0;
    NE=( (NEP <= l) && color.equals(new Color(pixels[NEP])) )?100:0;
    NW=( (NWP >= 0) && color.equals(new Color(pixels[NWP])) )?1100:0;
    int sum=N+E+S+W+NE+NW+SW+SE;
    switch (sum)
    case 1: //N
    case 3: //E
    case 5: //S
    case 11: //W
    case 100: //NE
    case 300: //SE
    case 500: //SW
    case 1100: //NW
    closed=false;
    closedwith=null;
    return 0;
    case 4: //N + E
    return points.contains(new Integer(EP))?NP:EP;
    case 6: //N + S
    return points.contains(new Integer(SP))?NP:SP;
    case 8: //S + E
    return points.contains(new Integer(EP))?SP:EP;
    case 16: //S + W
    return points.contains(new Integer(WP))?SP:WP;
    case 12: //N + W
    return points.contains(new Integer(WP))?NP:WP;
    case 14: //W + E
    return points.contains(new Integer(EP))?WP:EP;
    case 400: //NE + SE
    return points.contains(new Integer(SEP))?NEP:SEP;
    case 600: //NE + SW
    return points.contains(new Integer(SWP))?NEP:SWP;
    case 800: //SW + SE
    return points.contains(new Integer(SEP))?SWP:SEP;
    case 1600: //SW + NW
    return points.contains(new Integer(NWP))?SWP:NWP;
    case 1200: //NE + NW
    return points.contains(new Integer(NWP))?NEP:NWP;
    case 1400: //NW + SE
    return points.contains(new Integer(SEP))?NWP:SEP;
    case 101: //NE + N
    return points.contains(new Integer(NP))?NEP:NP;
    case 301: //SE + N
    return points.contains(new Integer(NP))?SEP:NP;
    case 501: //SW + N
    return points.contains(new Integer(NP))?SWP:NP;
    case 1101: //NW + N
    return points.contains(new Integer(NP))?NWP:NP;
    case 103: //NE + E
    return points.contains(new Integer(EP))?NEP:EP;
    case 303: //SE + E
    return points.contains(new Integer(EP))?SEP:EP;
    case 503: //SW + E
    return points.contains(new Integer(EP))?SWP:EP;
    case 1103: //NW + E
    return points.contains(new Integer(EP))?NWP:EP;
    case 105: //NE + S
    return points.contains(new Integer(SP))?NEP:SP;
    case 305: //SE + S
    return points.contains(new Integer(SP))?SEP:SP;
    case 505: //SW + S
    return points.contains(new Integer(SP))?SWP:SP;
    case 1105: //NW + S
    return points.contains(new Integer(SP))?NWP:SP;
    case 111: //NE + W
    return points.contains(new Integer(WP))?NEP:WP;
    case 311: //SE + W
    return points.contains(new Integer(WP))?SEP:WP;
    case 511: //SW + W
    return points.contains(new Integer(WP))?SWP:WP;
    case 1111: //NW + W
    return points.contains(new Integer(WP))?NWP:WP;
    case 15: //N + E + W
    if(points.contains(new Integer(WP)))
    N2 = NP-width >0 && color.equals(new Color(pixels[NP-width]));
    E2 = EP+1 < 1 && color.equals(new Color(pixels[EP+1]));
    if (N2 && E2)
    j=new Junction(i,NP,EP,-1,WP,-1,-1,-1,-1,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,NP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,EP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (N2)
    return NP;
    else
    return EP;
    }else if(points.contains(new Integer(EP)))
    N2 = NP-width >0 && color.equals(new Color(pixels[NP-width]));
    W2 = WP-1 > 0 && color.equals(new Color(pixels[WP-1]));
    if (N2 && W2)
    j=new Junction(i,NP,EP,-1,WP,-1,-1,-1,-1,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,NP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,WP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (N2)
    return NP;
    else
    return WP;
    }else if(points.contains(new Integer(NP)))
    W2 = WP-1 >0 && color.equals(new Color(pixels[WP-1]));
    E2 = EP+1 < 1 && color.equals(new Color(pixels[EP+1]));
    if (W2 && E2)
    j=new Junction(i,NP,EP,-1,WP,-1,-1,-1,-1,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,WP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,EP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (W2)
    return WP;
    else
    return EP;
    case 9: //N + E + S
    if(points.contains(new Integer(SP)))
    N2 = NP-width >0 && color.equals(new Color(pixels[NP-width]));
    E2 = EP+1 < 1 && color.equals(new Color(pixels[EP+1]));
    if (N2 && E2)
    j=new Junction(i,NP,EP,SP,-1,-1,-1,-1,-1,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,NP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,EP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (N2)
    return NP;
    else
    return EP;
    }else if(points.contains(new Integer(EP)))
    N2 = NP-width >0 && color.equals(new Color(pixels[NP-width]));
    S2 = SP+width > 0 && color.equals(new Color(pixels[SP+width]));
    if (N2 && S2)
    j=new Junction(i,NP,EP,SP,-1,-1,-1,-1,-1,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,NP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,SP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (N2)
    return NP;
    else
    return SP;
    }else if(points.contains(new Integer(NP)))
    S2 = SP+width >0 && color.equals(new Color(pixels[SP+width]));
    E2 = EP+1 < 1 && color.equals(new Color(pixels[EP+1]));
    if (S2 && E2)
    j=new Junction(i,NP,EP,SP,-1,-1,-1,-1,-1,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,SP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,EP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (S2)
    return SP;
    else
    return EP;
    case 17: //N + W + S
    if(points.contains(new Integer(SP)))
    N2 = NP-width >0 && color.equals(new Color(pixels[NP-width]));
    W2 = WP-1 > 0 && color.equals(new Color(pixels[WP-1]));
    if (N2 && W2)
    j=new Junction(i,NP,-1,SP,WP,-1,-1,-1,-1,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,NP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,WP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (N2)
    return NP;
    else
    return WP;
    }else if(points.contains(new Integer(WP)))
    N2 = NP-width >0 && color.equals(new Color(pixels[NP-width]));
    S2 = SP+width <l && color.equals(new Color(pixels[SP+width]));
    if (N2 && S2)
    j=new Junction(i,NP,-1,SP,WP,-1,-1,-1,-1,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,NP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,SP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (N2)
    return NP;
    else
    return SP;
    }else if(points.contains(new Integer(NP)))
    S2 = SP+width >l && color.equals(new Color(pixels[SP+width]));
    W2 = WP-1 > 0 && color.equals(new Color(pixels[WP-1]));
    if (W2 && S2)
    j=new Junction(i,NP,-1,SP,WP,-1,-1,-1,-1,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,SP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,WP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (S2)
    return SP;
    else
    return WP;
    case 19: //E + S + W
    if(points.contains(new Integer(SP)))
    W2 = WP+width <l && color.equals(new Color(pixels[WP+width]));
    E2 = EP+1 < 1 && color.equals(new Color(pixels[EP+1]));
    if (W2 && E2)
    j=new Junction(i,-1,EP,SP,WP,-1,-1,-1,-1,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,WP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,EP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (W2)
    return WP;
    else
    return EP;
    }else if(points.contains(new Integer(EP)))
    W2 = WP+width <l && color.equals(new Color(pixels[WP+width]));
    S2 = SP+width <l && color.equals(new Color(pixels[SP+width]));
    if (W2 && S2)
    j=new Junction(i,-1,EP,SP,WP,-1,-1,-1,-1,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,WP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,SP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (W2)
    return WP;
    else
    return SP;
    }else if(points.contains(new Integer(WP)))
    S2 = SP+width <l && color.equals(new Color(pixels[SP+width]));
    E2 = EP+1 < 1 && color.equals(new Color(pixels[EP+1]));
    if (S2 && E2)
    j=new Junction(i,-1,EP,SP,WP,-1,-1,-1,-1,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,SP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,EP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (S2)
    return SP;
    else
    return EP;
    case 20: //N + E + S +W
    case 1500: //NE + SE + NW
    if(points.contains(new Integer(NW)))
    NE2 = NEP-width+1 < 0 && color.equals(new Color(pixels[NEP-width+1]));
    SE2 = SEP+width+1 < 1 && color.equals(new Color(pixels[EP+width+1]));
    if (NE2 && SE2)
    j=new Junction(i,-1,-1,-1,-1,NEP,SEP,-1,NWP,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,NEP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,SEP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (NE2)
    return NEP;
    else
    return SEP;
    }else if(points.contains(new Integer(SEP)))
    NE2 = NEP-width+1 >0 && color.equals(new Color(pixels[NP-width+1]));
    NW2 = NWP-width-1 > 0 && color.equals(new Color(pixels[NWP-width-1]));
    if (NE2 && NW2)
    j=new Junction(i,-1,-1,-1,-1,NE,SE,-1,NW,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,NEP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,NWP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (NE2)
    return NEP;
    else
    return NWP;
    }else if(points.contains(new Integer(NEP)))
    NW2 = NWP-width-1 >0 && color.equals(new Color(pixels[WP-width-1]));
    SE2 = SEP+width+1 < 1 && color.equals(new Color(pixels[SEP+width+1]));
    if (NW2 && SE2)
    j=new Junction(i,-1,-1,-1,-1,NE,SE,-1,NW,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,NWP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,SEP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (NW2)
    return NWP;
    else
    return SEP;
    case 900: //NE + SE + SW
    if(points.contains(new Integer(SWP)))
    NE2 = NEP-width+1 >0 && color.equals(new Color(pixels[NEP-width+1]));
    SE2 = SEP+width+1 < 1 && color.equals(new Color(pixels[SEP+width+1]));
    if (NE2 && SE2)
    j=new Junction(i,-1,-1,-1,-1,NEP,SEP,SWP,-1,3,result);
    if(result.contains(j))
    closedwith=j;
    closed=true;
    return 0;
    else
    result.add(j);
    Joint j1=new Joint(result,pixels,NEP,width,j);
    Thread t=new Thread(j1);
    t.start();
    Joint j2=new Joint(result,pixels,SEP,width,j);
    Thread t1=new Thread(j2);
    t1.start();
    }else if (NE2)
    return NEP;
    else

  • Problem with Horizontal Scroll on java.awt.List

    I use the same code for a General Application as a CDC Application.
    I have no problem at all with the General Application but on the CDC I can't scroll to the right (horizontal).
    Why do I get this problem on the CDC application and not on a regular application?
    I use the PP-1.0 Profile for the CDC application. Does it not support horizontal scroll on java.awt.List?
    This is the code:
    * Main.java
    * Created on den 22 augusti 2007, 10:52
    package cdcapplication6;
    * @author  Erik Rothman
    public class Main extends java.awt.Frame {
        /** Creates new form Main */
        public Main() {
            initComponents();
              for (int i = 0; i < 10; i++) {
                   list1.add("Short text");
                   list1.add("Some very long text indeed. Some very long text indeed.");
        /** 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.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents() {
            list1 = new java.awt.List();
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            add(list1, java.awt.BorderLayout.CENTER);
            pack();
        }// </editor-fold>                       
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {                         
            System.exit(0);
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Main().setVisible(true);
        // Variables declaration - do not modify                    
        private java.awt.List list1;
        // End of variables declaration                  
    }

    I use the same code for a General Application as a CDC Application.
    I have no problem at all with the General Application but on the CDC I can't scroll to the right (horizontal).
    Why do I get this problem on the CDC application and not on a regular application?
    I use the PP-1.0 Profile for the CDC application. Does it not support horizontal scroll on java.awt.List?
    This is the code:
    * Main.java
    * Created on den 22 augusti 2007, 10:52
    package cdcapplication6;
    * @author  Erik Rothman
    public class Main extends java.awt.Frame {
        /** Creates new form Main */
        public Main() {
            initComponents();
              for (int i = 0; i < 10; i++) {
                   list1.add("Short text");
                   list1.add("Some very long text indeed. Some very long text indeed.");
        /** 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.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents() {
            list1 = new java.awt.List();
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            add(list1, java.awt.BorderLayout.CENTER);
            pack();
        }// </editor-fold>                       
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {                         
            System.exit(0);
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new Main().setVisible(true);
        // Variables declaration - do not modify                    
        private java.awt.List list1;
        // End of variables declaration                  
    }

  • Specifying classpath in Sun CDC Toolkit

    Hi All,
    I am using Sun CDC Toolkit 1.0. i need to specify a jar in the classpath whose APIs are used by the application at runtime. i have tried using the "-classpath" option, but the APIs in the jar are not being found and i get a "java.lang.NoClassDefFoundError:" error.
    D:\softwares\CDCTK10\bin\emulator.exe -classpath deleteme.jar -Xdevice:DefaultColorPhone -jar POC.jarjava.lang.NoClassDefFoundError: deleteme.DeleteMe
    at Main.main(Main.java:15)
    at java.lang.reflect.Method.invoke(Method.java:302)
    at sun.misc.CVM.runMain(CVM.java:464)
    deleteme.jar and POC.jar are both present in the current directory from where the command is being run.
    The UserGuide mentions using "-classpath:" followed by the jar names, but this option is not recognized by the emulator.
    Any pointers are greatly appreciated.
    Thanks in advance,
    -abhi

    It turns out that the correct way to specify what i want is as follows:
    D:\softwares\CDCTK10\bin\emulator.exe -classpath -Xdevice:DefaultColorPhone -cp POC.jar;deleteme.jar Main
    where Main is the fully qualified classname of the main application class that is present in POC.jar
    -abhi

  • Java.awt.Window: inner size

    Whilst it is clearly easy to work out the external size of a java.awt.Window object, does anybody have a way of querying the inner size of the Window (i.e. the available internal space, once the window's borders have been taken into account )?
    Many thanks
    Ali

    GAHick,
    Get the total window size, then get the insets of the window, subtract the window size from the windows insets and you will be left with the total available internal space.
    -- Bud

Maybe you are looking for

  • Why can't I sign into Facebook this morning?

    This morning I am unable to sign into my Facebook account on any of my apple devices, Imac, Iphone, Ipad. I get a message that Facebook is down for maintainance. When I did a google search on this problem, the help sites that came up did not look lik

  • Average Result of a data item not Average!

    I have chosen to install a Grand Total (at right) Columns Average of a calculated field, which is a data item in my crosstab report. The resulting values are always erroneous. The Sum(data-item) Total columns I use are accurate, but the Average Total

  • .msi do not install normally, but they do from terminal msiexec

    I have a very strange problem happening right now and have tried every possible way to fix it or find a way around it. Whenever I try to install any .msi file normally by just clicking on it in the explorer it fails with "Error 1359.An internal error

  • How to create a new employment status in action info type 0000?

    Hi All, how do we add  new employment status in action info type 0000? As we all know right now we have Active, Inactive, Retire, Withdrawn.....reguirement with my client is to add a new on onleave. Can you someone please help me on this? Thanks Much

  • Material Managent view

    Hi, Regarding to the first question on material management view  I would like to clarify further that while creating a material using Material master I could able to see only MRP 1 and MRP 2  view but not the MRP 3 & MRP 4 view .How can i see all fou