Simple swing question, probably

Guys,
New to Swing, new to Java:
I realize I can disable buttons on an application with setEnabled(false). Is there a way to make them disappear altogether?
I have a small desktop app that I would like to make user configurable in that certain buttons not useful to some clients can be disabled. I can grey them out, but it sure would look nice if I could make it where they're not painted at all...
Anyone?
TIA
chewy...

do setVisible(false)To be a little clearer, that'd be:
button.setVisible(false);

Similar Messages

  • Simple Swing Question

    can swing components (eg JLabel) be added to a Container (eg Panel)?

    Why not add it to a JPanel? It's not a good idea to mix awt and swing components together, you just risc weird behaviour.

  • Simple Swing Question for HTML

    I am trying to load a web page and I know how to do that using JEditorPane or JTextPane, but what I need to do is for the program to be able to load the page, enter a username and password in 2 of the <input> text fields and then submit it.
    IMPORTANT: I don't mean that I or a user would login, I mean the program I write would auto login.
    Does anyone know how this is accomplished?
    I do know how to do it with Javascript, but this needs to be a Java application.
    Once loaded I would then do some web scraping, again with Java, this I think I know how to do.
    Thanks,
    Dan

    Hi!
    Maybe you can find one part of the solution here (Reply 2,3,4)
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=285307
    or here
    http://forum.java.sun.com/thread.jspa?threadID=786631&messageID=4470190#4470190
    This would be the part for getting the username and password.
    How to submit it I do not know. I would look at class HttpURLConnection and the tutorial: http://java.sun.com/docs/books/tutorial/networking/urls/index.html

  • Simple performance question

    Simple performance question. the simplest way possible, assume
    I have a int[][][][][] matrix, and a boolean add. The array is several dimensions long.
    When add is true, I must add a constant value to each element in the array.
    When add is false, I must subtract a constant value to each element in the array.
    Assume this is very hot code, i.e. it is called very often. How expensive is the condition checking? I present the two scenarios.
    private void process(){
    for (int i=0;i<dimension1;i++)
    for (int ii=0;ii<dimension1;ii++)
      for (int iii=0;iii<dimension1;iii++)
        for (int iiii=0;iiii<dimension1;iiii++)
             if (add)
             matrix[i][ii][iii][...]  += constant;
             else
             matrix[i][ii][iii][...]  -= constant;
    private void process(){
      if (add)
    for (int i=0;i<dimension1;i++)
    for (int ii=0;ii<dimension1;ii++)
      for (int iii=0;iii<dimension1;iii++)
        for (int iiii=0;iiii<dimension1;iiii++)
             matrix[i][ii][iii][...]  += constant;
    else
    for (int i=0;i<dimension1;i++)
    for (int ii=0;ii<dimension1;ii++)
      for (int iii=0;iii<dimension1;iii++)
        for (int iiii=0;iiii<dimension1;iiii++)
           matrix[i][ii][iii][...]  -= constant;
    }Is the second scenario worth a significant performance boost? Without understanding how the compilers generates executable code, it seems that in the first case, n^d conditions are checked, whereas in the second, only 1. It is however, less elegant, but I am willing to do it for a significant improvement.

    erjoalgo wrote:
    I guess my real question is, will the compiler optimize the condition check out when it realizes the boolean value will not change through these iterations, and if it does not, is it worth doing that micro optimization?Almost certainly not; the main reason being that
    matrix[i][ii][iii][...]  +/-= constantis liable to take many times longer than the condition check, and you can't avoid it. That said, Mel's suggestion is probably the best.
    but I will follow amickr advice and not worry about it.Good idea. Saves you getting flamed with all the quotes about premature optimization.
    Winston

  • A few simple Logic questions...please help.

    I have a few probably simple Logic questions, that are nonetheless frustrating me, wondering if someone could help me out.
    1. I run Logic 8, all of the sounds that came with logic seem to work except organ sounds. I can't trigger any organ sounds (MIDI) on Logic, they won't play. I have a Yamaha Motif as my midi controller.
    Any idea why?
    2. I've starting running into a situation where I will record a MIDI track, the notes are recorded but they won't playback. The only track effected is the one that was just recorded. All other midi tracks playback.
    I have to cut the track, usually go out of Logic and back in, re record for it to playback properly. Any idea why this may be happening?
    3. How important is it to update to Logic 9. Are there any disadvantages down the road if I don't upgrade. If I purchase the $200 upgrade, do I get a package of discs and material, or it just a web download.
    Any help is appreciated!
    Colin

    seeren wrote:
    Data Stream Studio wrote:
    3) You get a full set of disks and manuals.
    They're including manuals now?
    I think his referring to the booklets ...on how to install etc
    It would be great to see printed manuals though ...I love books especially Logic/Audio related !!
    A

  • Simple/silly question: how do I set/change default font/color for outgoing mail messages?

    Simple/silly question: how do I set/change default font/color for outgoing mail messages?

    Just a suggestion..........
    Download Thunderbird.  Easier to use when it comes to what you want to do w/your emails. 

  • 4 Simple Flash Questions that Are Stumping Me!

    What is the Frame Rate for Web Animations
    Q1. I am making an animation which will be played on the web. What is the default frame rate (fps) of Flash CS5? And what is the frame rate of for web?
    Q2. My animation needs to be 30 seconds long. So at 15 fps that would mean I need to use 600 frames in Flash?
    How Do I Mask everything so all I see is the Content on the Stage?
    I have a wide image that extends past my movies stage size so when I preview my movie the image is visible. How do I mask out anything that extends past my movies window size? I believe I can create a layer named "mask" and place it above all other layers, but I forget how to make the mask. Any help is appreciated.
    How to Fade a Graphic
    I have a graphic element (some type) and I want it to fade from 0% to 100%. In older versions of Flash I could just select the symbol and then set it's alpha value to 0%, move a few keyframes and then set the alpha to 100%. Voila! but now it doesn't seem to work that way. How can I do this in CS5?

    Ned, it says 24 fps which means there is 24 frames per second so each 24 frames is 1 second.
    Date: Fri, 4 Nov 2011 05:35:16 -0600
    From: [email protected]
    To: [email protected]
    Subject: 4 Simple Flash Questions that Are Stumping Me!
        Re: 4 Simple Flash Questions that Are Stumping Me!
        created by Ned Murphy in Flash Pro - General - View the full discussion
    1 You can create your character as a movieclip and copy/paste that movieclip from one file to another. 2. One way to create a movieclip is to copy all the frame of the animation's timeline (select them all, right click the selection, choose Copy Frames), then create a new movieclip symbol (Insert -> New Symbol...etc) right click on its only keyframe and chhose Paste Frames.  THat will put all the layers and frames you copied into the movieclip The only way to come close to being certain about the timing of you animation is to use code to keep track of the time, something like getTimer()..  The frame rate that a file plays at is not a reliable means of dictating the time it takes due to a variety of factors which include the amount of content you are trying to process and performance limits of the user's machine.
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4007420#4007420
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4007420#4007420. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Flash Pro - General by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Simple Quick Question

    wrong section, post was moved.
    Message was edited by:
    Rob17

    you titled "simple quick question"...
    .. complicated to answer..
    a) the TermsOfUse of the iTS don't allow any processing of purchased files, these are "copy protected"..
    b) iM has a voice-over function..
    c) iM is a video-edit app.. easy to use... just learn to handle it...
    d) iM allows to "extract" audio (=muting the original audio, adding your own..)
    e) to learn iM, spend some time here: http://www.apple.com/ilife/tutorials/imovie/index.html
    f) use pencil and paper first! WRITE and scribble, what shall happen when in your movie/parody... make a script, draw a storyboard .. THEN launch iM.. in other words: think first, then edit.. iM is just a tool, it does not "create"... Picasso needed a papertowel and half a stencil to create art....
    g) to get comfortable with iM, start with your own, small, short (3min!) project... import some stills, edit them, add a funny voice-over, add sounds, add music... good? make a bigger one...
    h) .. in our Lecture II, we teach you how to import shows from TV, youtube, wherever..
    standard disclaimer:
    be nice to ©opyrights ...

  • Simple query question

    hi all,
    I have a XMLType table with one column - I have presently one row, in my column xmlsitedata I have stored one large xml file.The schema definition is given below:
    <?xml version="1.0" encoding="UTF-8" ?>
    - <xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    - <xs:element name="siteList">
    - <xs:complexType>
    - <xs:sequence>
    <xs:element name="site" type="siteType" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    - <xs:complexType name="siteType">
    - <xs:sequence>
    <xs:element name="nameEn" type="xs:string" />
    <xs:element name="nameFr" type="xs:string" />
    </xs:sequence>
    <xs:attribute name="code" type="xs:string" />
    </xs:complexType>
    </xs:schema>
    I have executed the query below:
    select x.XMLSITEDATA.extract('/siteList/site/nameEn/text()').getCLOBVal() "stName" from wsitelist x;
    and I get all english names of some 200 locations, however, there is 1 row selected and all names show up on one row. How do I split them into 200 or whatever rows?
    Thanks,
    Kowalsky

    Have a look at the answer provided in the following thread.
    very simple XML question
    This may solve your problem.
    use xmlsequence.
    Alvinder

  • Probably a simple newbie question...

    Hi. I'm teaching myself DVD SP (4.2) by putting together a very simple project but am stumped on what's probably an obvious solution.
    I have as my first play a quick slideshow with an accompanying music track. It automatically goes into my main Menu as its End Jump. I'd like that music track to continue on uninterrupted into the Menu. How do I do that? Right now it cuts out as it goes into the Menu.
    Thanks in advance...

    Make the slideshow in the other apps or you can change the slideshow to a track (make sure to make a copy it is only one way conversion) then bring that into a track (or add the other elements to the end of the converted slideshow) and use buttons over video to make a "menu"
    Often you can make the similar slideshow quickly in iMovie or iPhoto if needed then bring that into FInal Cut (or AE) to finish the rest of the movie
    Some animated background concepts
    http://dvdstepbystep.com/motion.php
    http://dvdstepbystep.com/useelements.php

  • Simple Question (Probably) About Buttons

    I am delving into Web programming for the first time. I am
    used to event driven programming. How and where do I code for a
    button's OnClick event? I want the button to perform an action
    OTHER THAN simply a submit.
    Just to keep my example simple, let's say I want to open up a
    small window which says "Thank You" once the button was clicked.
    Where do I put this code.
    Thanks in advance for helping a really discouraged and
    frustrated newby.

    You cannot add such things to Flash objects. That
    functionality would have
    to be implemented in the object's Actionscript.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "MrJCG1" <[email protected]> wrote in
    message
    news:ek752i$f5i$[email protected]..
    > Thanks. I don't know why I never thought of functions. I
    was trying to
    > attach
    > several lines of code to the onClick event and it wasn't
    working. But...
    >
    > If I create a function called test, what is the correct
    syntax to call it?
    > Here's what I have. Is this correct???
    >
    > <object
    classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    > codebase="
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#ve
    > rsion=5,0,0,0" name="btnAddToCart" width="105"
    height="33"
    > id="btnAddToCart"
    > onclick="Test()">
    >
    >

  • Probably a simple networking question (newbie here)

    Hi everyone,
    When I installed Solaris 10 inside of a VMWare Workstation vm, I got to the portion of the network configuration where it asked about LDAP or DNS or NFS, and I chose "None" because my setup is not a member of a domain. Now, when I go online, I have no Internet connection.
    I have the interface listed in ifconfig -a and it has an IP address of 192.168.0.4 issued by DHCP. Everything is right, except there is no Default Gateway listed, nor does it have my DNS servers listed.
    How would I go about setting these in Solaris? I'm not entirely familiar with vi or edit, so a step-by-step will be nice.
    I should note, that I'm able to access my Windows Workgroup computer (the physical host) and copy files from it. I just don't have any Internet access. Also, the IP for my physical computer (the Windows share) is my DNS IP, although that shouldn't matter.
    Thank you for any help you can provide.
    Patrick.

    First of all, in /etc/hosts file ;
    the first line indicates loopback address(IP) & the second line indicates the IP of the your machine followed by the hostname ( which is "unknown in your case as you have not assigned any hostname). The commented line in second line tells that , the IP is assigned by a dhcp-server.
    you can assign router IP in a file called "/etc/defaultrouter".you only have to give the IP address of the router in this file.To make this as default router address for you system , you have reboot the system.
    You can change your hostname from "unknown" by issuing this command :
    #setuname -n XYZ
    (where XYZ is the new hostname)
    you can also check the changed hostname by doing this ;
    #uname -n

  • Audio question, probably incredibly simple

    So I'm new to FCE (though not to editing - am a bit rusty) and all is going pretty well EXCEPT - having put an audio file from iTunes into my project, I now cannot figure out what to do to get it to actually play while I'm viewing the sequence. Can hear the audio when I drag the playhead back and forth, but I only get a barcode tone when playing the project back in the viewer. Do I need to render the audio or something? Thanks.

    If you hear a beeping sound when playing the Timeline, it means that your audio clip doesn't match your Sequence settings. Typically this is from using MP3 files, which FCE does NOT work with natively.
    You can render in FCE, but if you make changes afterward, you'll need to re-render. The best way to handles this is to convert the footage to AIFF format at 48khz, 16 bit PRIOR to importing into your FCE project so it will match the Sequence settings. This will completely eliminate the need to render the audio.
    -DH

  • MSI x976 Power UP Edition Realtek Audio Question, probably a simple answer HELP!

    I have the x975 Power up board and 6400 conroe, so far clocked at 2.8ghz.  One hell of a processor, man they really meant it was going to be un upgrade from my [email protected] and it is.  Anyway, I have a set of Klipsch Promedia 4.1's that I still love and enjoy.  How do I utilize these speakers on the realtek hd audio card.  I selected 4.1 on the setup screen and plugged the front channel into the green plug, and it works great.  So where do I plug in the rear channel speakers, which color plug?  I want just to listen to music playing through all 4 speakers, and the surround effect in games, obviously minus the center channel.  I have a santa cruz, that does just what I need, but its dated technology and I really want to utilize the HD realtek if possible, its not like it will slow down the computer, haha.

    Quote from: NovJoe on 22-August-06, 10:44:25
    I'm not sure if Realtek Audio will do an upmix from 2.1 to 4.1 but you can also check if your speakers are able to do it.
    Yup, it's inside there...

  • What is the flaw in this simple Swing program ?

    Hi all ,
    I tried one simple animation in Swing .
    Here's what the program has to do :
    when a button called "play" is clicked a circle should be moved from upper left corner down to the lower right corner.
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class MyAnimation extends JFrame {
       int width;
       int height;
       MyAnimation animation ;
       MyDrawPanel drawpanel ;
       public static void main(String[] args) {
         MyAnimation gui=new MyAnimation();
         gui.go();
       } //close main()
       public void go() {
           animation = new MyAnimation();
           JButton button = new JButton("Play");
           button.addActionListener(new ButtonListener());
           drawpanel = new MyDrawPanel();
           animation.setTitle("Ball Animation");
           animation.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
           animation.getContentPane().add(BorderLayout.SOUTH,button);
           animation.getContentPane().add(BorderLayout.CENTER,drawpanel);
           animation.setSize(300,300);
           animation.setVisible(true);
       } //close go()
       class ButtonListener implements ActionListener {
           public void actionPerformed(ActionEvent ae) {
              for(width=0,height=0;width<130&&height<130;width++,height++) {
                       System.out.println("before calling");
                       animation.repaint();
                       System.out.println("W ="+width+"H ="+height);
                   try {
                       Thread.sleep(50);
                   }catch(Exception ex) { }
             } //close for
        } //close actionPerformed()
    } //close ButtonListener
          class MyDrawPanel extends JPanel {
                public void paintComponent(Graphics g) {
                   g.setColor(Color.blue);
                   g.fillRect(0,0,this.getWidth(),this.getHeight());
                   int w= this.getWidth();
                   int h = this.getHeight();
                   //System.out.print(w,h);
                   g.setColor(Color.green);
                   g.fillOval(width,height,40,40);
                   System.out.println("paintcomponent");
               } //close paintcomponent()
         } //closeMyDrawPanel()
    } //close MyAnimation()I noticed when a button is clicked everything goes fine(code reached Listener and loop is executed) expect that repaint() method is not invoked with in a loop(invoked only once at the end of loop).
    but if I embed the same loop code with in go() method without a Listener class it's works Fine !
    Why it's not happening when the code is within Litener class?
    Two more additional questions :
    What is the difference between calling the repaint() method with JFrame instance and JPanel instance ?
    In that program why System.out.print() method which is in MyDrawPanel class can't be invoked ?
    Thanks in advance

    Axel_Richter wrote:
    May be you could have a chance to animate without threads by using paintImmediately directly. I have never tried this, because to use threads is not so difficult at all.animation without explicit calls to thread:
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class MyAnimation extends JPanel
        private static final int TIME_PERIOD = 10;
        private static final String PLAY = "Play";
        private static final String PAUSE = "Pause";
        private static final String RESET = "Reset";
        int width = 0;
        int height = 0;
        MyDrawPanel drawpanel = new MyDrawPanel();
        private Timer timer = new Timer(TIME_PERIOD, new TimerAL());
        public MyAnimation()
            super(new BorderLayout());
            setPreferredSize(new Dimension(300, 300));
            JButton button = new JButton("Play");
            button.addActionListener(new ButtonListener());
            add(button, BorderLayout.SOUTH);
            add(drawpanel, BorderLayout.CENTER);
        class ButtonListener implements ActionListener
            public void actionPerformed(ActionEvent event)
                String command = event.getActionCommand();
                if (command.equals(PLAY))
                    timer.start();
                    ((JButton)event.getSource()).setText(PAUSE);
                else if (command.equals(PAUSE))
                    timer.stop();
                    ((JButton)event.getSource()).setText(RESET);
                else if (command.equals(RESET))
                    timer.stop();
                    ((JButton)event.getSource()).setText(PLAY);
                    width = 0;
                    height = 0;
                    repaint();
        class TimerAL implements ActionListener
            public void actionPerformed(ActionEvent arg0)
                if (width < (drawpanel.getWidth() - 40) &&
                        height < (drawpanel.getHeight() - 40))
                    width++;
                    height++;
                    drawpanel.repaint();
                else
                    timer.stop();
        class MyDrawPanel extends JPanel
            public void paintComponent(Graphics g)
                g.setColor(Color.blue);
                g.fillRect(0, 0, this.getWidth(), this.getHeight());
                int w = this.getWidth();
                int h = this.getHeight();
                // System.out.print(w,h);
                Graphics2D g2 = (Graphics2D)g;
                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                    RenderingHints.VALUE_ANTIALIAS_ON);
                g2.setColor(Color.green);
                g2.fillOval(width, height, 40, 40);
        private static void createAndShowGUI()
            JFrame frame = new JFrame("Ball Animation");
            frame.getContentPane().add(new MyAnimation());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        public static void main(String[] args)
            SwingUtilities.invokeLater(new Runnable()
                public void run()
                    createAndShowGUI();
    }

Maybe you are looking for