Swing in java

I am trying to add two label and two combobox horizontally like this
label1 combobox1
label2 combobox2
in below code "SwingConstants.LEFT "shows me right label and combobox.But for next label and combobox i set "SwingConstants.BOTTOM" and it gives me erroor "java.lang.IllegalArgumentException: horizontalAlignment"
protected JComponent getNewAdditionalPane() {
JPanel wAnswer = new JPanel();
wAnswer.setLayout(new BoxLayout(wAnswer, BoxLayout.X_AXIS));
wAnswer.setBorder(BorderFactory.createTitledBorder(CfoTextRef.lookup ("KEY_CardPropertiesConstant"))); //$NON-NLS-1$
JLabel wTabLabel = new JLabel(CfoTextRef.lookup("KEY_TablabelPfxStaticTextLabel2") + " ", SwingConstants.LEFT); //$NON-NLS-1$ //$NON-NLS-2$
JLabel wTabLabel1 = new JLabel(CfoTextRef.lookup("KEY_TablabelPfxStaticTextLabel4") + " ", SwingConstants.BOTTOM); //$NON-NLS-1$ //$NON-NLS-2$
wAnswer.add(wTabLabel);
wAnswer.add(wTabLabel1);
wAnswer.add(getTabLabelComboBox());
wAnswer.add(getTabLabel1ComboBox());
wAnswer.add(Box.createHorizontalGlue());
return wAnswer;
}

That's because BOTTOM is not a horizontal alignment property.

Similar Messages

  • JFC/Swing and java Swing

    Are JFC Swing and java Swing both different?
    Thanks.

    Nope. Swing is Swing.
    http://java.sun.com/docs/books/tutorial/uiswing/14start/about.html

  • AWT vs SWING vs JAVA 2D vs JFC

    Hi,
    can you please describe or show me the path to find the difference
    among 4. (mentioned in subject line)
    The basic difference i know, what i want is how to decide when to use
    what?
    In my view, awt is used no where these days.
    swing and Java 2D (what is this?) are used mostly but which to choose
    for my application, how to decide? and What is JFC all about?
    sometimes it becomes very confusing.
    Can anyone throw some light on these terms.
    - Thanks
    Azodious
    Edited by: Azodious on Jan 26, 2008 5:23 AM

    Azodious wrote:
    i didn't search on Google because here experts have some special answers. by special answers i mean less words but exact answer. with a lot of learning.
    i am expectng those kind of answers.You may be waiting a long time. Your question is very broad, very general, and most experts would likely refer you to reference sources.
    This may be a language thing, but to say you "expect" answers is awfully presumptuous.
    otherwise i'd to go through all those many pages again and again to grasp a simple but conceptual thing.Have at it.

  • How to Swing in Java?

    Hi folks,
    I'm trying to write very basic GUI, but have just realized that I do not have swing library. When tried to download it from web various sources were saying that it has been discontinued (Life of Product Ended). Could anyone tell from were am I suppose to download swing library and whats going on with this library anyway?
    Thanks in advance.

    [Originally distributed as a separately downloadable library, Swing has been included as part of the Java Standard Edition since release 1.2. The Swing classes and components are contained in the javax.swing package hierarchy.|http://en.wikipedia.org/wiki/Swing_%28Java%29#History]
    Btw, I like your subject line.

  • Is Jdeveloper itself based on adf swing or java swing?

    Hi Experts,
    Is jdeveloper itself developed on java swing or adf swing?
    Also, i need to build a jdev plug-in, if i develop this plugin using adf-swing will it work?

    extensions can be added to jdev..
    if u r on release 2 use
    http://docs.oracle.com/cd/E24382_01/doc.1112/e20067/toc.htm
    for release 1
    http://www.oracle.com/technetwork/developer-tools/jdev/extension-094911.html

  • Is swing purely Java?

    I had an argument with my friend on Swing and it's platform independence. My friends argument was that, swing cannot be platform independent if one of it's parent classes has a native method.
    For eg: JLabel extends JComponent extends Container extends Component
    And Component has a native method, and hence swing can't be purely Java? Even I am confused? Can someone explain?

    Hi,
    as far as I understood it (but I might be wrong) the difference between AWT and Swing is the following (among others):
    With AWT there are native calls to draw the components, eg. the OS says how to draw a button. These are known as heavyweight components.
    With Swing all components are drawn with Java (except some Windows). These are known as lightweight components. (This also allows the concept of the pluggable L&F.)
    Yes, Swing components do extend AWT components, but I think that some methods are overriden or there are some switches or something like this, to avoid those native calls.
    -Puce

  • Serialize Swing Document - java.io.InvalidClassException

    Hi,
    I'm tryin to serialize a javax.swing.text.Document from a JTextPane (DefaultStyledDocument). This works without problems and I can deserialize it in the same app.
    Unfortunately I'm getting the following error if I try to deserialize it with another app.
    java.io.InvalidClassException: javax.swing.text.DefaultStyledDocument; local class incompatible: stream classdesc serialVersionUID = 940485415728594881, local class serialVersionUID = 940485415728614849The UIDs are always the same above. The data was transmitted over network. The data is valid, both byte arrays in both apps have the same Hash.
    Any help appreciated! :-)
    Best Regards,
    Stephen

    Problem solved!
    It was java.lang.String fault!
    I converted the byte[] array of the serialized object to a String.
    String str = new String( bytearray );and back.
    byte[] array = str.getBytes();Data was corrupted when the String was constructed from the byte array. It is not possible to convert the byte[] array of a serialized object to a string using String() constructor!
    You have to en/decode it with base 64!

  • Need suggestion regarding Layout Manager using Swing in Java

    I have developed a swing application where i am having problem with selecting the right layout manager.
    I am attaching the file where it contains the method for addingComponents to the Content Pane. But, the code that i have written
    contains lot of spaces between first panel and second panel and so forth.
    Please suggest.
    <<Code>>
    public void addComponentsToPane(Container contentPane) {
              this.contentPane = contentPane;
    //          File Panel
              JPanel jfile1panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
              JPanel jfile2panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
              JPanel jfile3panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
              JLabel jfile1 = new JLabel("Select File:");
              jtfile1 = new JTextField(50);
              jbfile1 = new JButton("Button1");
              jfile1panel.add(jfile1);
              jfile1panel.add(jtfile1);
              jfile1panel.add(jbfile1);
              jbfile1.addActionListener(this);
              JLabel jfile2 = new JLabel("Select File:");
              jtfile2 = new JTextField(50);
              jbfile2 = new JButton("Button2");
              jfile2panel.add(jfile2);
              jfile2panel.add(jtfile2);
              jfile2panel.add(jbfile2);
              jbfile2.addActionListener(this);
              JLabel jfile3 = new JLabel("Select File:");
              jtfile3 = new JTextField(50);
              jbfile3 = new JButton("Button3");
              jfile3panel.add(jfile3);
              jfile3panel.add(jtfile3);
              jfile3panel.add(jbfile3);
              jbfile3.addActionListener(this);
              //Button Panel
              JPanel jbuttonpanel = new JPanel();
              jbuttonpanel.setLayout(new FlowLayout(FlowLayout.CENTER));
              JButton jbcmd1 = new JButton("Submit");
              JButton jbcmd2 = new JButton("Cancel");
              jbuttonpanel.add(jbcmd1);
              jbuttonpanel.add(jbcmd2);
              jbcmd1.addActionListener(this);
              jbcmd2.addActionListener(this);
              //Content Pane               
              contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
              contentPane.add(jfile1panel);
              contentPane.add(jfile2panel);
              contentPane.add(jfile3panel);
              contentPane.add(jbuttonpanel);
    }

    But, the code that i have written contains lot of spaces between first panel and second panel and so forth.use pack(), see if it makes a difference
    as you're using FlowLayout, make the frame not resizable

  • Quick question on swing JButton (java programming)

    hi,
    Before you read, i am still a student! so if this question seems silly i am sorry, but i havent been able to find an answer!.
    I am using the following type of code:
    JButton SlowDownB = new JButton(new ImageIcon("Images/slow.jpg"));
    But the problem i have is that i am adding images of various sizes to different buttons, and i want all the buttons to be the same size (in a row). So i set the button sizes as follows:
    SlowDownB = new JButton(new ImageIcon("Images/slow.jpg"));
    SlowDownB.setPreferredSize(new Dimension(60,60));
    SlowDownB.setMaximumSize(new Dimension(60,60));
    SlowDownB.setMinimumSize(new Dimension(60,60));
    But now the problem is that it does not show the whole image :-(, is there a way to make the image/icon resize into the button?
    Thanks in advance to any replies,
    Regards,
    Daniel

    Maybe something like:
    List buttons = new ArrayList();
    // add the buttons to the List.
    Rectangle bigRect = new Rectangle();
    Rectangle r = new Rectangle();
    Dimension d = new Dimension();
    for (Iterator i = buttons.iterator(); i.hasNext();) {
      JComponent comp = (JComponent)i.next();
      r.setSize(comp.getSize(d));
      bigRect.add(r);
    d.width  = bigRect.width;
    d.height = bigRect.height;
    for (Iterator i = buttons.iterator(); i.hasNext();) {
      JComponent comp = (JComponent)i.next();
      comp.setSize(d);
    }

  • [SOLVED] XFCE - Java Swing button theme?

    I'm running XFCE, and I notice that all Swing-based Java applications use the ugly Swing button theme. When I used GNOME 3, some of them would adapt to the GNOME button theme (and would look like they belonged on the system).
    Is this issue with XFCE, my current GTK theme (dorian), or Java, and how can I change this?
    Last edited by 2mac (2014-01-01 22:17:07)

    Thank you for the information.
    I followed the wiki by adding
    export _JAVA_OPTIONS="-Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel"
    to my ~/.bashrc file.
    To test, I launched the Minecraft launcher (one of the applications which does support style changes between desktops), and got back this information:
    Picked up _JAVA_OPTIONS: -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
    Error parsing gtk-icon-sizes string: ''
    And it had no effect. Any ideas?
    Last edited by 2mac (2013-12-31 16:35:39)

  • Reg: Embedding Firefox with Java Swing

    Sir,
    The thing is We all know that Mozilla Firefox is open source.
    How to embed the mozilla firefox with Java Swing or java AWT Frame.
    Could me suggest me the ways to do it, the code and also the concept behind it?
    I put the same question in forum but i didnot get any response.and i also googled a lot,but none was help ful
    Could u please help us Sir?
    Thanks..

    you can use webrenderer or jxbrowser library...to embed web browser in your swing application.
    otherwise Use OLE with java to embed IE in your swing application....

  • Really basic Java Swing question

    Hi,
    I'm really stuck, cannot seem to compile anything. I'm using the newest SDK, 1.4 or whatever. Can someone please briefly explain how they'd compile and run a swing program using MSDOS Prompt. Thanks.
    Nick

    Here be an empty swing frameimport java.awt.*;
    import javax.swing.*;
    public class MyJFrame extends JFrame {
      public MyJFrame() {
          super("My first JFrame");
          Container c  = getContentPane();
          JPanel panel = new JPanel();     
          c.add(panel);
      public static void main(String[] args) {
        MyJFrame frame = new MyJFrame();
        frame.setSize(200,200);
        frame.setLocation(200, 300);
        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
        frame.setVisible(true);
    }You compile and run it in the same way as any DOS based command line program.

  • Lighter Java GUI than awt and swing?

    I had recently came across a company website (http://www.bambookit.com) where they developed a java gui library without using awt and swing (seems to what they claim). And on top of that it uses xml to generate the gui components (they call widgets) and the whole library size is only 95kb and supports java 1.1.x and above. Their demos on the applets loads super fast, never know/experience that java applets can actually be this quick. But this confuses me, how is it possible to develop a gui alternative to awt with the basic java classes and no dependency on awt? But since the applets are awt based, it means that they must have some dependencies.
    This is an extract from their website (that it seemed they did not use awt)
    "Java has a fundamental flaw in its paint thread that made it very difficult to build extremely large applications without getting severe performance and resource penalties (This affects both AWT and Swing based applications). It�s main repaint queue\thread when assigning paint regions to various controls uses the Graphics objects to �clip� them. On a Sun Solaris machine this does not cause any problems, however on a windows machine each Graphics object consumes a system resource/handle, (a limit of around 16,000 exists on Win 95 and Win 98 machines). Each Bitmap image, each font object, each icon consumes a single system resource or handle. If a full repaint is performed on an application containing 1000 controls, it would consume at LEAST 1000 system resource handles. If the application was updated many times a second, lets say 10 times a second, then that equates to 10,000 handles a second. This is not taking into account labels within controls, the various fonts styles and sizes created, the various images that get loaded. This could easily exceed 20,000 system resource requests a second. Bambookit on the other hand utilizes the clip routines and passes along a SINGLE Graphics objects to all its various controls. This alone is a HUGE savings in system resources and performance."
    Two questions came to my mind:
    1) Is it possible to build applet gui without using awt and swing in java? If so the only way to do is to use JNI calls?
    2) Am I wrong in interpreting www.bambookit.com's message that they are not using awt?
    Any comments about this?
    Regards,
    Stanly

    They use AWT as basis for their drawing-layer, as any other lightweight toolkits too.
    If you just want a very fast & light alternative to swing/awt have a look at www.lwvcl.com !
    I use it for a large applet-applikation that has to be java-1.1 compatible. It was a horor when using AWT which was implemented different over all JVMs available and very slow (although native widgets were used).
    With lwvcl (which has only 150kB!) I can use state of the art applets that work very fast on modern jvms like 1.4, give me the ability to compile my applikation to native code using GCJ (using the swt-prt of the library) or distribute it to old-school 1.1 browser where it also runs quite fine...
    Its free for GPL and very cheap for commercial use.
    lg Clemens

  • Accessdenied (java.lang.RuntimePermission accessClassInPackage.sun.swing)

    accessdenied (java.lang.RuntimePermission accessClassInPackage.sun.swing)

    the detailed message is given below.
    Exception in read object===>access denied (java.lang.RuntimePermission accessClassInPackage.sun.swing)
    java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.swing)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPackageAccess(Unknown Source)
         at sun.applet.AppletSecurity.checkPackageAccess(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClassInternal(Unknown Source)
         at java.lang.Class.forName0(Native Method)
         at java.lang.Class.forName(Unknown Source)
         at java.io.ObjectInputStream.resolveClass(Unknown Source)
         at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
         at java.io.ObjectInputStream.readClassDesc(Unknown Source)
         at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
         at java.io.ObjectInputStream.readObject0(Unknown Source)
         at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
         at java.io.ObjectInputStream.defaultReadObject(Unknown Source)
         at java.awt.Component.readObject(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
         at java.io.ObjectInputStream.readSerialData(Unknown Source)
         at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
         at java.io.ObjectInputStream.readObject0(Unknown Source)
         at java.io.ObjectInputStream.readArray(Unknown Source)
         at java.io.ObjectInputStream.readObject0(Unknown Source)
         at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
         at java.io.ObjectInputStream.readSerialData(Unknown Source)
         at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
         at java.io.ObjectInputStream.readObject0(Unknown Source)
         at java.io.ObjectInputStream.readArray(Unknown Source)
         at java.io.ObjectInputStream.readObject0(Unknown Source)
         at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
         at java.io.ObjectInputStream.readSerialData(Unknown Source)
         at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
         at java.io.ObjectInputStream.readObject0(Unknown Source)
         at java.io.ObjectInputStream.readObject(Unknown Source)
         at epmj.workflow.ObjectTransmit.readObject(ObjectTransmit.java:44)
         at epmj.workflow.WfApplet12.PKJinitUI(WfApplet12.java:1286)
         at epmj.workflow.WfApplet12.init(WfApplet12.java:326)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)

  • Problem with win2000sp3 and Java web start

    I have JRE and Java web start (1.2.0_01, build b01) which come downloading file j2re-1_4_1_01-windows-i586-i.exe from sun.
    I have win2000pro running on my PC.
    I had updated win2000 to service pack 2 and everything was fine.
    Now i decided to update to service pack 3 (in the process I also updated other components) from Microsoft and:
    1) Java applets seem to be running fine within i.e.
    2) If i try to run an application from java web start my PC freezes and I have to restart it.
    3) Staroffice 6.0, which runs on Java, seems to be fine.
    I reinstalled both sp3 and jre etc, with no result.
    Is this a known problem?
    Thanks to all.
    Maurizio

    I suspect that you have hit a known problem with Swing on Java 1.4.1 with buggy video drivers. Do you have an ATI card? They are the worst offenders. ATI released new drivers for its Radeon line today. They fix the problem.

Maybe you are looking for

  • Applet Button acting weirdly...

    Hello I'm quite new at Java, and new to this forum, so don't be too hard;) I've got a problem with a awt.button in an Applet. When i click on the button it seems to send two events, and thus executing twice the code. I would like it to execute only o

  • Lost photos on iphoto

    I was editing some downloaded photos in iphoto (large jpeg files from a nikon D7000) when I got the spending wheel.  The program close and got the dreaded window that the program terminated due to a problem. When I open iphoto back up that and two ot

  • Presentation of text in emails

    the distance of textrows is wrong or the letters overlapps. why?

  • Does the iPhone 3 charger work with the 4s?

    Hi! I just got he 4s for a gift. I was wondering if the the older Iphone charger works with this one? She has an iPhone 3 and has he car charger etc.. thanks! Jim

  • How can I burn a DVD with iMovie (my Mac does not have iDVD)?

    Please help!  I have Googled everything I can think of to solve this problem.  I have a Mac desktop that did not come with iDVD (as they no longer do!).  I have movies that I have loaded onto iMovie, but cannot figure out how to get them onto a DVD.