Results 1 to 12 of 12
  1. #1
    orion_mcl is offline Member
    Join Date
    Aug 2007
    Posts
    17
    Rep Power
    0

    Unhappy Displayable container and JButton

    Hi everybody. First, I want to apologize if my thread title is not very clear :o. I want to ask you to help me with this problem. I've just seen the JDateChooser component toedter.com (Java & More) website. I am programming a component very similar to this JDateChooser component, is to say, I want to have a JTextField and a JButton together. When the button is pressed it have to display a component (a JPanel I think) to show me some fields to input data and make calculations and put the result into the JTextField. How can I do this? I am sure it is very similar to this component because when the JDateChooser button is pressed the calendar appears to choose the date and put the selected one into the JTextField. How can I program the calendar container? And how can I make appear this container next to the text field? :confused:

    Here's an image of this JDateChooser component:

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  3. #3
    orion_mcl is offline Member
    Join Date
    Aug 2007
    Posts
    17
    Rep Power
    0

    Default I mean this...

    Hi everybody. I want to program something like this:



    It seems it is using a combo box in the "Date & Time" field. When you push this component it displays the container with all the controls that you can see.

    I just want to have the combobox (if it is a combobox) and the container.
    Please help me with this.

    Thanks in advance.

  4. #4
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    What have you tried so far and what does or doesn't work? Your question is somewhat general, and the best that I can do is to direct you to the Sun Swing tutorials that tell how to create JComboBoxes, JSpinners, JButtons, and the like (look here: How to use Swing Components)

    You're far better off doing as much of this yourself as you can and then coming here and asking a specific question regarding something that doesn't work or a specific point that you don't understand.

    Buena suerte!

  5. #5
    orion_mcl is offline Member
    Join Date
    Aug 2007
    Posts
    17
    Rep Power
    0

    Talking Custom JComboBox editor

    Hi. What I want to program is a custom combo box. When the combobox button is pushed it has to display a container (that contains any other components like text fields or buttons) instead of the list items.

    I can't tell it is exactly a combobox but it seems. As you can see in the image I previously posted there's an object in the "Date&Time" field that it is like a combobox but it displays the time and date controls.

    Please give me a hand with this problem. I just want to have this combobox that has a container (maybe a JPanel with another components inside) as custom editor.

    Thanks in advance.

  6. #6
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    You've yet to post code showing what you've tried though. Please consider showing us that you've put a little effort into this.

  7. #7
    orion_mcl is offline Member
    Join Date
    Aug 2007
    Posts
    17
    Rep Power
    0

    Default

    Hi everybody. Thanks curmudgeon for answer. I had a few ideas to solve my problem but they didn't work. I know it would be helpful to show you what I've done until now but I want to tell you that all that I want is to have a combobox (if it is) with a container as custom editor. I want to have something like the component shown in the image I posted previously, the DateTimePicker from Lavantech.I don't mind the controls and the clock.

    Please help me with this.

    Thanks.

  8. #8
    dlorde is offline Senior Member
    Join Date
    Jun 2008
    Posts
    339
    Rep Power
    7

    Default

    A combo box is a control intended for displaying/selecting from lists of items. If you want to display a frame when the control is pushed, why not just use a button? You can make it whatever size you need and give it text and an icon if necessary - why are you so keen on misusing a combo box?

  9. #9
    orion_mcl is offline Member
    Join Date
    Aug 2007
    Posts
    17
    Rep Power
    0

    Talking A group of components?

    Hi everybody. Thanks dlorde for answering me. And yes, it's true that I've been trying to solve my problem using an combobox but sometime ago I realized that it's not the solution.

    And I want to ask you to give some ideas to solve this problem. I tried using and JDialog and displaying it very close to the left bottom corner of a JTextField but it is impossible to take out the decoration, it's to say, the frame border.

    How did the Lavantech programmers to have this group of a button, a text field and a container (to contain the controls) that is shown when the button is pushed? :o

    Please help me.

    Thanks.

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I thought that decorations can be removed. JDialog inherits from Dialog which has a method setUndecorated(boolean decorate).
    Last edited by Fubarable; 05-27-2010 at 05:03 PM.

  11. #11
    orion_mcl is offline Member
    Join Date
    Aug 2007
    Posts
    17
    Rep Power
    0

    Exclamation JDialog and setUndecorated method

    Hi everybody. And that's true Fubarable, JDialog inherits from Dialog and setUndecorated method exists but produces this exception:

    Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The dialog is displayable.
    at java.awt.Dialog.setUndecorated(Dialog.java:1321)
    at timepicker.ClockDialog.<init>(ClockDialog.java:11)
    at timepicker.MainFrame.clockButtonActionPerformed(Ma inFrame.java:49)
    at timepicker.MainFrame.access$000(MainFrame.java:8)
    at timepicker.MainFrame$1.actionPerformed(MainFrame.j ava:37)
    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
    ...

    But if still it could work it would be just a little window near the text field and the button then I'd have to deal with focus issues. I'm sure it is possible to have this container joined to the text field and the button, just like the DateTimePicker component from Lavantech but how? I don't know yet.

    Thanks.

  12. #12
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    You may be calling setDecorated(...) after you've rendered the dialog by packing the GUI or calling setVisible(true). Make sure you set decorations before rendering. Please let us know if this helps or not.

Similar Threads

  1. Applet as container .
    By pawankumarom in forum Java Applets
    Replies: 5
    Last Post: 04-23-2009, 07:17 AM
  2. Replies: 3
    Last Post: 04-22-2009, 12:01 AM
  3. AWT can we make a Tabbed container?
    By Panchitopro in forum AWT / Swing
    Replies: 0
    Last Post: 05-15-2008, 11:31 PM
  4. Calling displayable from a canvas class
    By Snalk in forum CLDC and MIDP
    Replies: 0
    Last Post: 03-29-2008, 12:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •