Zooming a jpanel containing several jbuttons

My question is how to zoom a jpanel that contains several jbutton... I am not sure what method to use.... when using a Graphics2D object there seem to be only methods as g.drawString(...)
g.drawRectangle(..) etc... I am kind of familiar with
AffineTransform, scaling matrix, etc but not how to zoom a jpanel with jcomponent...
I hope some one out there understand what i am trying to do...please could you give me any idea
thanx

hi again
well that is the point i have written such sub class where i draw a rectangle and then I scale it etc..
to test paint () etc but that is what i do not want to ....
what I want to do is to draw is my subclass of Jbutton that has some specific properties I HAVE TO USE THEM... and only zoom these specific button and not everything else on my subclass of Jpanel...
Spanel extends JPanel
MybuttonClass m = new MybuttonClass();
paint()
how do I draw the myButton on the panel...after zooming in zoomin out...
there no such thing
g.draw(myButton);
does all this make a sense to you..
i hope so
thanx

Similar Messages

  • Zooming a Jpanel that contains Jbutton

    My question is how to zoom a jpanel that contains several jbutton... I am not sure what method to use.... when using a Graphics2D object there seem to be only methods as g.drawString(...)
    g.drawRectangle(..) etc... I am kind of familiar with
    AffineTransform, scaling matrix, etc but not how to zoom a jpanel with jcomponent...
    I hope some one out there understand what i am trying to do...please could you give me any idea
    thanx

    Hello.
    The solution could be the following:
    1. Create interface ZoomPane with the following methods:
    boolean isZoomMode
    float getZoomFactor
    2. ZoomPane interface must be implemented by some JComponent (JPanel will fit, assume it's called JZoomPanel)
    3. the paint method's body of the JZoomPanel should looks like:
    Graphics2D g2 = (Graphics2D)g;
    if(isZoomMode()){
    float zoomFactor = getZoomFactor();
    g2.scale(zoomFactor, zoomFactor);
    super.paint(g);
    4. Use updated RepaintManager.
    This solution solve all painting problem. The mouse event transformation problem can be solved as described above (by means of the glass pane).

  • JPanel containing JToolBars: how do I change its height?

    Hello,
    I have a JPanel containing several JToolBars. I add this Panel to the top of a GUI contentPane. The height of the JPanel seems to be too big - There seems to be about 4 pixels between the edge of the buttons, and the edge of the Panel, which goes into making the whole thing ugly.
    I have set the margins of the buttons to new Insets(0, 0, 0, 0), so the button icons and text take minimal room - however, I don't know how to do similar for a JPanel.
    I already have set a raised bevel border for this JPanel, so I cannot give it an empty border using new EmptyBorder(0, 0, 0, 0);
    Please help a man going mad - Itll be funny.

    By default a JPanel uses a FlowLayout. By default the FlowLayout uses a 5 pixel horizontal and vertical gap. Check out the FlowLayout API for info on how to change these values.

  • Changing a JPanel with a JButton

    Hi,
    In a JFrame, I add two JPanels in a BorderLayout. The first is in the North, the second in the South. The first JPanel contains a JButton. When an action is performed over this JButton, I want to completely change the southern JPanel. I get the JFrame content pane and add the new JPanel in BorderLayout.SOUTH in the actionPerformed method invoked by the JButton's action listener.
    Nothing occurs.
    What's wrong ?
    Thanks in advance.

    Hello
    After adding the new JPanel to the JFrame add the following lines where variable f is your JFrame:
    f.validate();
    f.repaint();Hope this helps
    David

  • I've had a VHS tape converted to DVD. The DVD contains several Video_TS files, which I am not familiar with. I was able to play the original on both my iMac and TV but not copy them. I had copies made but they won't play. Why?

    I've had a VHS tape converted to DVD. The DVD contains a Video_TS folder containing several Video_TS files. I tried to copy the disk. The Video_TS files copy but I can't play the DVD. What is the problem?

    Hi
    Most probably You've made Your copies as Data-DVDs.
    If You put in a blank DVD - Your Mac want's to format it and put it on DeskTop/Finder for You to put files and document onto it. Then on Eject it Burns it - and as a Data-DVD. They will never Play on any DVD-Player.
    If You want a Video-DVD then You've to go via a program that can structure Your DVD as such e.g. iDVD or Disk Util tool or Roxio Toast™.
    Disk Util tool - can copy a home made Video-DVD to new Video-DVD copies.
    Start Disk Util tool
    Insert Master DVD
    select to copy it
    Eject it when asked to do so
    Insert Blank DVD - WHEN YOUR Mac ASKS FOR IT - Else You make a Data-DVD which You don't want.
    THIS process do not work for Commercial CopyProtected DVDs - and would be illegal any way. Take Care.
    Yours Bengt W

  • Safari launches a window and contains several tabs

    Oh boy, My Safari was perfect for the most part in the last 3 years, that is to say, if I launch Safari to browse the web, the browser would launch with a new window, fresh with default page starting at top sites. And by top sites, I mean the various web sites or pages that i have previously gone to recently most frequently. These pages are presented in miniaturized thumbnails of the whole page, or the top part of the page, and are neatly presented in 4, 8, or 12 slots tabulation for my choosing, or that my keyboard focus would already be on the address bar so I could type any other url as I wish. But until the last 1-2 updates ago I start to notice something strange, when I launch Safari, the browser doesn't go to the usual way as I described above, instead it launches a window and contains several tabs. Of which are places i have been recently, but I wouldn't call those as "top sites" by a long shot. At first I didn't realize what's happening exactly. In fact it seemed to me a bit like when my Safari reopen the tabs from my previous session. It first started with a few tabs, and then a few more each week (actually my main browser is now Chrome sorry to say, but there are several personal reasons that I still use Safari to browse certain web sites, therefore, I may not open and use Safari every day. I think last week was still just 10 tabs or so, now it's 156 tabs... my mac constipates from the sharp drain of memory and it now happens even before the browser window has started rendering. Usually, when my mac is done with beach balling, i immediately right click on the first tab I see, and select "close all other tabs", then command-w to close the last tab. Then I reopen new tab/window (cmd-n) and start my browsing all fresh. A new window launches, but only to dump the 156 tabs all over on me again. clearing web data, cookies, clearing cache, disabling all extensions, nothing seems to work so far. And the Apple Care Support would probably tell me to format the hard disk and reinstall new. I've been down that road too many times already, almost as much as I had to do the same thing when i was using windows. Ugh, even Chrome is far from perfect, that's why i come back to Safari from time to time. And I find my Firefox experience is still clunky, ugh. Have we fallen in to the Dark Ages for web browsers or something?
    <Re-Titled By Host>

    Of which are places i have been recently
    Delete the cache ..
    Open a Finder window. From the Finder menu bar click Go > Go to Folder
    Type or copy paste the following
    ~/Library/Caches/com.apple.Safari/Cache.db
    Click Go then move the Cache.db file to the Trash.
    Quit and relaunch Safari to test.

  • How can I copy or export a mail box containing several other mailboxes (mavericks)

    how can I copy or export a mail box containing several other mailboxes from 10.8.4 to mavericks

    Hello Crusheen
    The article below will give you steps to export your mailboxes from Mail. When you export, it will ask where you want to save them and you should an option to Export all subfolders.
    Mail (Mountain Lion): Export mailboxes
    http://support.apple.com/kb/PH11712
    Regards,
    -Norm G.

  • Problem to print a JPanel containing jfreeChart

    I need help
    I am developping an application that should display and print reports with histograms.
    I make the histogram with Jfreechart and put it on a JPanel. the report is a Vector of JPanel.
    1. When i print only the panel containing the JFreechart, the panel is printed but the range axis label
    of JFreechart is inverted.
    2. When i print all the report, nothing appears on the page of the panel containing JFreechart.
    here is my printing code:
    //code
    public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
    if (pageIndex >= docToBePrinted.size()) {
    return (NO_SUCH_PAGE);
    } else {
    componentToBePrinted = docToBePrinted.get(pageIndex);
    //componentToBePrinted.repaint();
    Dimension dim = componentToBePrinted.getSize();
    double scaleX = pageFormat.getImageableWidth() / dim.width;
    double scaleY = pageFormat.getImageableHeight() / dim.height;
    double scale = Math.min(scaleX, scaleY);
    Graphics2D g2D = (Graphics2D) g;
    // g2D.translate(0, 0);
    g2D.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
    g2D.scale(scale, scale);
    g2D.setPaintMode();
    disableDoubleBuffering(componentToBePrinted);
    componentToBePrinted.print(g2D);
    g2D.dispose();
    //componentToBePrinted.printAll(g2D);
    enableDoubleBuffering(componentToBePrinted);
    //componentToBePrinted.
    return (PAGE_EXISTS);
    //end of code
    "docToBePrinted" is the report
    Could anyone help me please !

    I have the same problem. Similarly to another entry here, be very careful about how many times you reattempt it. I did it several times, hoping it would work out a kink, and it was on an expensive order, now there are over $2000 of "temporary authorizations" depleting my available credit on my card, and it's been that way for almost a week now.
    I am living overseas, and am unfortunately restricted to dial-up internet to upload this, and it either gets stuck at 64kb/8Mb or just jumps right to 8/8Mb, when there is nothing wrong with the my internet connection.
    I emailed Apple in response to the order cancellation email, and stated that perhaps it was the army firewall I'm behind, asking for the site the program connects to in an attempt to unblock the site if it's inadvertently getting blocked on my end. When they replied they said it's a technical issue and that I can call Apple to talk with someone, where they will determine how much the call will cost. That's outrageous to have something brand new, and have to pay for them to help you on an issue that truly may be as simple as giving out a website.
    In response to an earlier reply, I am using iPhoto 5.0.4, and I just purchased my G5 back in October. Is there a later version to iLife that I'm not finding?
    If anyone finds help with this issue, I would greatly appreciate some tips!
    Thanks so much,
    Dave

  • How to make a JPanel containing buttons  take up the width of the window?

    I'm creating a GUI and I have a button group that I want to be the width of the window. I have another JPanel on the same window that doesn't have a button group in it and it takes up the width of the window. I don't think I'm doing anything differently creating the two, but I need consistency.
    The best way I can explain this is with code, so I created an example of what I am doing here:
    import java.awt.*;
    import javax.swing.*;
    public class test extends JFrame {
         public test() {
              JPanel win = new JPanel();
              JPanel buttonsPanel = new JPanel();
              JPanel statusPanel = new JPanel();
              win.setLayout(new BoxLayout(win, BoxLayout.Y_AXIS));
              buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.Y_AXIS));
              statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.Y_AXIS));
    //          createRadioButtonsPanel
              ButtonGroup buttons = new ButtonGroup();
              JRadioButton currentMap = new JRadioButton("option1", true);
              JRadioButton newMap = new JRadioButton("option2");
              JRadioButton noMap = new JRadioButton("option3");
              buttons.add(currentMap);
              buttons.add(newMap);
              buttons.add(noMap);
              buttonsPanel.add(currentMap);
              buttonsPanel.add(newMap);
              buttonsPanel.add(noMap);
              buttonsPanel.setBorder(
                        BorderFactory.createTitledBorder("Create: "));
    //           createStatusPanel
              JLabel statusLabel = new JLabel("Loading...");
              statusLabel.setBorder(BorderFactory.createLoweredBevelBorder());
              statusLabel.setPreferredSize(new Dimension(400,20));
              statusLabel.setMinimumSize(new Dimension(400,20));
              statusLabel.setMaximumSize(new Dimension(400,20));
              statusPanel.add(statusLabel);
              JPanel statusButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
              JButton pauseSearch = new JButton("Pause");
              JButton cancelSearch = new JButton("Cancel");
              statusButtons.add(pauseSearch);
              statusButtons.add(cancelSearch);
              statusPanel.add(statusButtons);
              statusPanel.setBorder(BorderFactory.createTitledBorder("Status: "));
              win.add(buttonsPanel);
              win.add(statusPanel);
              getContentPane().add(win);
              pack();
              setVisible(true);
         public static void main(String args[]) {
              test s = new test();
    }When I compile and run this class I get this window:
    http://img136.imageshack.us/img136/1538/exampleek5.png
    You see how on the bottom, "Status" JPanel takes up the entire width of the window? When the window is resized, the border is also resized. I would love to have the top "Create" JPanel have the same behavior. How do I do this?
    Thanks in advance!

    It can get confusing when using the BoxLayout. The box layout takes into consideration the X alignment of the components as well as the minimum and maximum lengths.
    So I suggest you read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/layout/box.html]How to Use Box Layout for examples and explanations on how these values are used in the layout process.
    It may be easier to use a BorderLayout for the high level layout manger, since it will resize a components width when added to the NORTH, CENTER or SOUTH.

  • I need to use a JPanel as a JButton

    We have a requirement here to display a panel full of various text fields and colors, but have it act like a Button. Focus handling, click handling, etc...
    Anyone know of a JButton class that lets you use a JPanel as it's content instead of just a text string or icon?

    package testthing;
    import javax.swing.JFrame;
    public class Main {
         * @param args the command line arguments
        public static void main(String[] args) {
            JFrame frame = new NewJFrame();
            frame.setVisible(true);
    * NewJFrame.java
    * Created on Aug 27, 2010, 12:14:32 PM
    package testthing;
    import java.awt.Color;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.Insets;
    import javax.swing.JButton;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.WindowConstants;
    public class NewJFrame extends javax.swing.JFrame {
        /** Creates new form NewJFrame */
        public NewJFrame() {
            initComponents();
            jButton1.setLayout( new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.fill = GridBagConstraints.BOTH;
            gbc.weightx = 1.0;
            gbc.weighty = 1.0;
            jButton1.add(jPanel1, gbc);
        /** 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.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">
        private void initComponents() {
            GridBagConstraints gridBagConstraints;
            jButton1 = new JButton();
            jPanel1 = new JPanel();
            jLabel1 = new JLabel();
            jLabel2 = new JLabel();
            setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            getContentPane().setLayout(new GridBagLayout());
            jButton1.setContentAreaFilled(false);
            gridBagConstraints = new GridBagConstraints();
            gridBagConstraints.gridx = 0;
            gridBagConstraints.gridy = 0;
            gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
            gridBagConstraints.insets = new Insets(2, 2, 2, 2);
            getContentPane().add(jButton1, gridBagConstraints);
            jPanel1.setBackground(new Color(255, 204, 204));
            jPanel1.setLayout(new GridBagLayout());
            jLabel1.setText("jLabel1");
            gridBagConstraints = new GridBagConstraints();
            gridBagConstraints.insets = new Insets(4, 4, 4, 4);
            jPanel1.add(jLabel1, gridBagConstraints);
            jLabel2.setText("jLabel2");
            gridBagConstraints = new GridBagConstraints();
            gridBagConstraints.gridx = 0;
            gridBagConstraints.gridy = 1;
            gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
            gridBagConstraints.insets = new Insets(4, 4, 4, 4);
            jPanel1.add(jLabel2, gridBagConstraints);
            gridBagConstraints = new GridBagConstraints();
            gridBagConstraints.gridx = 1;
            gridBagConstraints.gridy = 1;
            gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
            gridBagConstraints.insets = new Insets(2, 2, 2, 2);
            getContentPane().add(jPanel1, gridBagConstraints);
            pack();
        }// </editor-fold>
        * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new NewJFrame().setVisible(true);
        // Variables declaration - do not modify
        private JButton jButton1;
        private JLabel jLabel1;
        private JLabel jLabel2;
        private JPanel jPanel1;
        // End of variables declaration
    }

  • How can I add  several  JButton into JList?

    I want to add several button into a Jlist. I tried this method, list.add(button,1),nothing shows up.I am not sure whether jList has the function.If it is,please show me how to achieve that.Thanks in advance!

    A JList is used to display text Strings. You should be able to add a JButton to the JList but all you will see is the toString() representation of the JButton. You will not see a button or be able to click on it.
    Try creating a panel using a GridLayout with a single column and add all you JButtons to the panel.

  • My Jpanel/container disappaer in internalframe

    why did my mouse disappaer whan my mouse move out from internalframe?
    for note: first time i load internalframe, it's ok. but second time i load internalframe, it's disapppear
    this way i load the second time:
    jpanel.removeAll();
    internlaframe.getContentPane().add(jpanel)
    internlaframe.revalidate();
    did i wrong?
    Edited by: sayunara on Apr 11, 2008 11:23 PM

    this the part of my class code, if i post my whole class code, it's to complex
    ThumbButton is the JPanel
    ThumbButton.box is the Box
    ThumbButton.ArrImage is the JButton(ImageIcon)
    ThumbFrame is the JInternalframe
    and I have a main frame call mainframe, main JPanel call mainpanel
    I add mainpanel to mainframe.
    mainframe.add(mainpanel);
    mainpanel.add(ThumbFrame);
    this code i load second time:
    ThumbButton.removeAll();
    ThumbFrame.validate();
    ThumbButton.box = null;
    ThumbButton.ArrImage = null;
    ThumbButton = null;
    System.gc();       
    ThumbButton = new thumbnail();
    ThumbButton.setSize(new Dimension(950, 650));
    ThumbFrame.getContentPane().add(ThumbButton);     
    ThumbButton.requestFocus();
    ThumbButton.revalidate();

  • Semantic Zoom - Show letters containing no items

    How can I show letters of the alphabet, which contain no items beginning with that letter (in gray) within the ZoomedOutView view of my semantic zoom control?
    I want to achieve something like this (excluding 'Social', 'Favorites' and '#'): 
    but I end up with this:
    MetropolitanDataSource.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace EELL
    using System;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Media;
    // To significantly reduce the sample data footprint in your production application, you can set
    // the DISABLE_SAMPLE_DATA conditional compilation constant and disable sample data at runtime.
    #if DISABLE_SAMPLE_DATA
    internal class SampleDataSource { }
    #else
    public class Item : System.ComponentModel.INotifyPropertyChanged
    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
    protected virtual void OnPropertyChanged(string propertyName)
    if (this.PropertyChanged != null)
    this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
    private string _Station = string.Empty;
    public string Station
    get
    return this._Station;
    set
    if (this._Station != value)
    this._Station = value;
    this.OnPropertyChanged("Station");
    private string _Zone = string.Empty;
    public string Zone
    get
    return this._Zone;
    set
    if (this._Zone != value)
    this._Zone = value;
    this.OnPropertyChanged("Zone");
    private string _Link = string.Empty;
    public string Link
    get
    return this._Link;
    set
    if (this._Link != value)
    this._Link = value;
    this.OnPropertyChanged("Link");
    public class GroupInfoList<T> : List<object>
    public object Key { get; set; }
    public new IEnumerator<object> GetEnumerator()
    return (System.Collections.Generic.IEnumerator<object>)base.GetEnumerator();
    public class StoreData
    public StoreData()
    Item item;
    item = new Item();
    item.Station = "Aldgate";
    item.Link = "/Lines and Stations/Metropolitan/Aldgate_(Metropolitan).xaml";
    Collection.Add(item);
    item = new Item();
    item.Station = "Moorgate";
    item.Link = "/Lines and Stations/Metropolitan/MOG_(Metropolitan).xaml";
    Collection.Add(item);
    private ItemCollection _Collection = new ItemCollection();
    public ItemCollection Collection
    get
    return this._Collection;
    internal List<GroupInfoList<object>> GetGroupsByCategory()
    List<GroupInfoList<object>> groups = new List<GroupInfoList<object>>();
    var query = from item in Collection
    orderby ((Item)item).Zone
    group item by ((Item)item).Zone into g
    select new { GroupName = g.Key, Items = g };
    foreach (var g in query)
    GroupInfoList<object> info = new GroupInfoList<object>();
    info.Key = g.GroupName;
    foreach (var item in g.Items)
    info.Add(item);
    groups.Add(info);
    return groups;
    internal List<GroupInfoList<object>> GetGroupsByLetter()
    List<GroupInfoList<object>> groups = new List<GroupInfoList<object>>();
    var query = from item in Collection
    orderby ((Item)item).Station
    group item by ((Item)item).Station[0] into g
    select new { GroupName = g.Key, Items = g };
    foreach (var g in query)
    GroupInfoList<object> info = new GroupInfoList<object>();
    info.Key = g.GroupName;
    foreach (var item in g.Items)
    info.Add(item);
    groups.Add(info);
    return groups;
    // Workaround: data binding works best with an enumeration of objects that does not implement IList
    public class ItemCollection : IEnumerable<Object>
    private System.Collections.ObjectModel.ObservableCollection<Item> itemCollection = new System.Collections.ObjectModel.ObservableCollection<Item>();
    public IEnumerator<Object> GetEnumerator()
    return itemCollection.GetEnumerator();
    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
    return GetEnumerator();
    public void Add(Item item)
    itemCollection.Add(item);
    #endif
    Metropolitan_line.xaml.cs
    using Exits_Expert_London_Lite.Common;
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Runtime.InteropServices.WindowsRuntime;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Navigation;
    // The Basic Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234237
    namespace Exits_Expert_London_Lite.Lines_and_Stations.Metropolitan
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class Metropolitan_line : Page
    public Metropolitan_line()
    this.InitializeComponent();
    StoreData _storeData = null;
    // creates a new instance of the sample data
    _storeData = new StoreData();
    // sets the list of categories to the groups from the sample data
    List<GroupInfoList<object>> dataLetter = _storeData.GetGroupsByLetter();
    // sets the CollectionViewSource in the XAML page resources to the data groups
    cvs2.Source = dataLetter;
    // sets the items source for the zoomed out view to the group data as well
    (semanticZoom.ZoomedOutView as ListViewBase).ItemsSource = cvs2.View.CollectionGroups;
    #region Data Visualization
    /// <summary>
    /// We will visualize the data item in asynchronously in multiple phases for improved panning user experience
    /// of large lists. In this sample scneario, we will visualize different parts of the data item
    /// in the following order:
    /// 1) Placeholders (visualized synchronously - Phase 0)
    /// 2) Tilte (visualized asynchronously - Phase 1)
    /// 3) Image (visualized asynchronously - Phase 2)
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="args"></param>
    void ItemsGridView_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args)
    ItemViewer iv = args.ItemContainer.ContentTemplateRoot as ItemViewer;
    if (args.InRecycleQueue == true)
    iv.ClearData();
    else if (args.Phase == 0)
    iv.ShowPlaceholder(args.Item as Item);
    // Register for async callback to visualize Title asynchronously
    args.RegisterUpdateCallback(ContainerContentChangingDelegate);
    else if (args.Phase == 1)
    iv.ShowStation();
    args.RegisterUpdateCallback(ContainerContentChangingDelegate);
    else if (args.Phase == 2)
    iv.ShowZone();
    // For imporved performance, set Handled to true since app is visualizing the data item
    args.Handled = true;
    /// <summary>
    /// Managing delegate creation to ensure we instantiate a single instance for
    /// optimal performance.
    /// </summary>
    private TypedEventHandler<ListViewBase, ContainerContentChangingEventArgs> ContainerContentChangingDelegate
    get
    if (_delegate == null)
    _delegate = new TypedEventHandler<ListViewBase, ContainerContentChangingEventArgs>(ItemsGridView_ContainerContentChanging);
    return _delegate;
    private TypedEventHandler<ListViewBase, ContainerContentChangingEventArgs> _delegate;
    #endregion //Data Visualization

    Yes, it only shows the letters that contain children items.
    Please have a look at my code snippet below and tell me what needs to change:
    internal List<GroupInfoList<object>> GetGroupsByLetter()
    var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToList();
    var groupByAlphabets = from letter in letters
    select new
    Key = letter,
    Items = (from item in Collection
    where ((Item)item).Station.StartsWith(letter.ToString(), StringComparison.CurrentCultureIgnoreCase)
    orderby ((Item)item).Station
    group item by ((Item)item).Station[0] into g
    select g)
    List<GroupInfoList<object>> groups = new List<GroupInfoList<object>>();
    foreach (var g in groupByAlphabets)
    GroupInfoList<object> info = new GroupInfoList<object>();
    info.Key = g.Key;
    foreach (var item in g.Items)
    info.Add(item);
    groups.Add(info);
    return groups;

  • How to pass/share components between different JPanels/Container

    Dear Friends,
    I know here a lot Java Guru, I met a problem below.
    How can I pass components between different JPanels??
    here, ListPanelMain.java is main,
    When I click a tree node in splitPane, I can see all its children on the right splitpane, but I hope they can be seen on another Panel called "ListRightPane.java"
    How to do it??
    Why cannot pass??
    [1]. main Program:
    package swing.com.test.test;
    import javax.swing.JFrame;
    import java.awt.BorderLayout;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JSplitPane;
    import javax.swing.JTextArea;
    import java.io.Serializable;
    import swing.com.test.test.ListPanel;
    import java.awt.GridLayout;
    public class ListPanelMain implements java.io.Serializable{
         private JFrame frame;
         * Launch the application
         * @param args
         public static void main(String args[]) {
              try {
                   ListPanelMain window = new ListPanelMain();
                   window.frame.setVisible(true);
              } catch (Exception e) {
                   e.printStackTrace();
         * Create the application
         public ListPanelMain() {
              initialize();
         * Initialize the contents of the frame
         private void initialize() {
              frame = new JFrame("FileTreePanelMain");
              frame.setBounds(100, 100, 900, 675);
         //     FieTreePanelComm      ftreecomm                = new      FieTreePanelComm();
              ListPanel                ftree                     = new      ListPanel("C:\\");
    //          ListAllFile           ftree                     = new      ListAllFile("C:\\");
         //     FileTreePanelText      fileTreePanelText      = new      FileTreePanelText(ftreecomm);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              final JPanel panel = new JPanel();
              panel.setLayout(new GridLayout(0, 2));
              frame.getContentPane().add(panel, BorderLayout.CENTER);
         //     final JSplitPane splitPane = new JSplitPane();
         //     frame.getContentPane().add(splitPane, BorderLayout.CENTER);
         //     splitPane.setLeftComponent(ftree);
              panel.add(ftree);
              final ListRightPanel listRightPanel = new ListRightPanel(ftree);
              //splitPane.setRightComponent(listRightPanel);
              panel.add(listRightPanel);
         frame.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
         System.exit(0);
         frame.pack();
         frame.setVisible(true);
    [2]. Program 2:
    package swing.com.test.test;
    //File System Tree
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.GridLayout;
    import java.io.File;
    import java.util.Iterator;
    import java.util.Vector;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.JPanel;
    import javax.swing.event.TreeModelEvent;
    import javax.swing.event.TreeModelListener;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.TreeModel;
    import javax.swing.tree.TreePath;
    import java.io.Serializable;
    public class ListPanel extends JPanel implements Serializable{
    protected JTree fileTree;
    private FileSystemModel fileSystemModel;
    private JTextArea ltextArea = new JTextArea();
    protected JTextArea fileDetailsTextArea = new JTextArea();
    private String str = "";
         public String getlTextArea() {
                   //textArea.getText();
                   return str;
         public String setlTextArea(String ta) {
                   ltextArea.setText(ta);
                   str = ta;
                   return str;
    public ListPanel(String directory) {
    //super("JTree FileSystem Viewer");
                   setLayout(new BorderLayout());
                   final JPanel panel = new JPanel();
                   panel.setLayout(new BorderLayout());
              add(panel, BorderLayout.CENTER);
    fileDetailsTextArea.setEditable(false);
    fileSystemModel = new FileSystemModel(new File(directory));
    fileTree = new JTree(fileSystemModel);
    fileTree.setEditable(true);
    fileTree.addTreeSelectionListener(new TreeSelectionListener() {
    public void valueChanged(TreeSelectionEvent event) {
    System.out.println("1. What we save is: getlTextArea() =" + getlTextArea() );
    File file = (File) fileTree.getLastSelectedPathComponent();
    fileDetailsTextArea.setText(getFileDetails(file));
    final ListRightPanel lrp = new ListRightPanel(this);
    lrp.textArea.setText(getFileDetails(file));
    setlTextArea(getFileDetails(file));
    System.out.println("2. What we save is: getlTextArea() =" + getlTextArea() );
              final JSplitPane splitPane = new JSplitPane();
              panel.add(splitPane, BorderLayout.CENTER);
              final JPanel panel_1 = new JPanel();
              splitPane.setLeftComponent(panel_1);
              panel_1.add(new JScrollPane(fileTree));
              final JPanel panel_2 = new JPanel();
              splitPane.setRightComponent(panel_2);
              panel_2.add(new JScrollPane(fileDetailsTextArea));
    setVisible(true);
    private String getFileDetails(File file) {
    if (file == null)
    return "";
    StringBuffer buffer = new StringBuffer();
    if (file.listFiles()!=null){
         for (int i=0; i< file.listFiles().length; i++){
         buffer.append(((file.listFiles())) + "\n");
         System.out.println("List all files");
    return buffer.toString();
    public static void main(String args[]) {
    new ListPanel("c:\\");
    class FileSystemModel implements TreeModel {
    private File root;
    private Vector listeners = new Vector();
    public FileSystemModel(File rootDirectory) {
    root = rootDirectory;
    public Object getRoot() {
    return root;
    public Object getChild(Object parent, int index) {
    File directory = (File) parent;
    String[] children = directory.list();
    return new TreeFile(directory, children[index]);
    public int getChildCount(Object parent) {
    File file = (File) parent;
    if (file.isDirectory()) {
    String[] fileList = file.list();
    if (fileList != null)
    return file.list().length;
    return 0;
    public boolean isLeaf(Object node) {
    File file = (File) node;
    return file.isFile();
    public int getIndexOfChild(Object parent, Object child) {
    File directory = (File) parent;
    File file = (File) child;
    String[] children = directory.list();
    for (int i = 0; i < children.length; i++) {
    if (file.getName().equals(children[i])) {
    return i;
    return -1;
    public void valueForPathChanged(TreePath path, Object value) {
    File oldFile = (File) path.getLastPathComponent();
    String fileParentPath = oldFile.getParent();
    String newFileName = (String) value;
    File targetFile = new File(fileParentPath, newFileName);
    oldFile.renameTo(targetFile);
    File parent = new File(fileParentPath);
    int[] changedChildrenIndices = { getIndexOfChild(parent, targetFile) };
    Object[] changedChildren = { targetFile };
    fireTreeNodesChanged(path.getParentPath(), changedChildrenIndices, changedChildren);
    private void fireTreeNodesChanged(TreePath parentPath, int[] indices, Object[] children) {
    TreeModelEvent event = new TreeModelEvent(this, parentPath, indices, children);
    Iterator iterator = listeners.iterator();
    TreeModelListener listener = null;
    while (iterator.hasNext()) {
    listener = (TreeModelListener) iterator.next();
    listener.treeNodesChanged(event);
    public void addTreeModelListener(TreeModelListener listener) {
    listeners.add(listener);
    public void removeTreeModelListener(TreeModelListener listener) {
    listeners.remove(listener);
    private class TreeFile extends File {
    public TreeFile(File parent, String child) {
    super(parent, child);
    public String toString() {
    return getName();
    [3]. Program 3:
    package swing.com.test.test;
    import java.awt.BorderLayout;
    import java.io.File;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.event.TreeModelEvent;
    import javax.swing.event.TreeModelListener;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.TreeModel;
    import javax.swing.tree.TreePath;
    import java.io.Serializable;
    public class ListRightPanel extends JPanel implements TreeSelectionListener, Serializable{
         protected JTextArea textArea;
    //     protected ListAllFile laf;
    private String str = "";
              public String getlTextArea() {
                        //textArea.getText();
                        return str;
              public String setlTextArea(String ta) {
                        str = ta;
                        return str;
         * Create the panel
         public ListRightPanel(ListPanel laff) {
              super();
              setLayout(new BorderLayout());
              final JPanel panel = new JPanel();
              panel.setLayout(new BorderLayout());
              add(panel, BorderLayout.CENTER);
              textArea = new JTextArea();
    final String st = laff.getlTextArea();
    System.out.println("####################################");
    System.out.println("st=" + st);
         laff.fileTree.addTreeSelectionListener(new TreeSelectionListener() {
         public void valueChanged(TreeSelectionEvent event) {
         //laff.textArea.setText(getFileDetails(file));
              textArea.setText(getlTextArea());
         System.out.println("ListRightPanel Was Invoked from ListPanel!!getlTextArea() =" + getlTextArea() );
         System.out.println("st=" + st);
              panel.add(textArea, BorderLayout.CENTER);
         public void valueChanged(TreeSelectionEvent e){};
    It is runnable program, just compile and run it in Console is ok,
    Regards
    Sunny

    Thnaks, code post again, see
    [1]. package swing.com.test.test;
    import javax.swing.JFrame;
    import java.awt.BorderLayout;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JSplitPane;
    import javax.swing.JTextArea;
    import java.io.Serializable;
    import swing.com.test.test.ListPanel;
    import java.awt.GridLayout;
    public class ListPanelMain implements java.io.Serializable{
         private JFrame frame;
          * Launch the application
          * @param args
         public static void main(String args[]) {
              try {
                   ListPanelMain window = new ListPanelMain();
                   window.frame.setVisible(true);
              } catch (Exception e) {
                   e.printStackTrace();
          * Create the application
         public ListPanelMain() {
              initialize();
          * Initialize the contents of the frame
         private void initialize() {
              frame = new JFrame("FileTreePanelMain");
              frame.setBounds(100, 100, 900, 675);
         //     FieTreePanelComm      ftreecomm                = new       FieTreePanelComm();
              ListPanel                 ftree                     = new      ListPanel("C:\\");
    //          ListAllFile            ftree                     = new      ListAllFile("C:\\");
         //     FileTreePanelText      fileTreePanelText      = new      FileTreePanelText(ftreecomm);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              final JPanel panel = new JPanel();
              panel.setLayout(new GridLayout(0, 2));
              frame.getContentPane().add(panel, BorderLayout.CENTER);
         //     final JSplitPane splitPane = new JSplitPane();
         //     frame.getContentPane().add(splitPane, BorderLayout.CENTER);
         //     splitPane.setLeftComponent(ftree);
              panel.add(ftree);
              final ListRightPanel listRightPanel = new ListRightPanel(ftree);
              //splitPane.setRightComponent(listRightPanel);
              panel.add(listRightPanel);
                frame.addWindowListener(new WindowAdapter() {
                     public void windowClosing(WindowEvent e) {
                         System.exit(0);
                 frame.pack();
                 frame.setVisible(true);
    }[2] Program 2
    package swing.com.test.test;
    //File System Tree
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.GridLayout;
    import java.io.File;
    import java.util.Iterator;
    import java.util.Vector;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JSplitPane;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.JPanel;
    import javax.swing.event.TreeModelEvent;
    import javax.swing.event.TreeModelListener;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.TreeModel;
    import javax.swing.tree.TreePath;
    import java.io.Serializable;
    public class ListPanel extends JPanel implements Serializable{
      protected JTree fileTree;
      private FileSystemModel fileSystemModel;
      private JTextArea ltextArea = new JTextArea();
      protected JTextArea fileDetailsTextArea = new JTextArea();
      private String str = "";
         public  String getlTextArea()  {
                   //textArea.getText();
                      return str;
         public  String setlTextArea(String ta)  {
                   ltextArea.setText(ta);
                   str = ta;
                      return str;
      public ListPanel(String directory) {
        //super("JTree FileSystem Viewer");
                   setLayout(new BorderLayout());
                   final JPanel panel = new JPanel();
                   panel.setLayout(new BorderLayout());
                  add(panel, BorderLayout.CENTER);
        fileDetailsTextArea.setEditable(false);
        fileSystemModel = new FileSystemModel(new File(directory));
        fileTree = new JTree(fileSystemModel);
        fileTree.setEditable(true);
        fileTree.addTreeSelectionListener(new TreeSelectionListener() {
          public void valueChanged(TreeSelectionEvent event) {
            System.out.println("1. What we save is: getlTextArea() =" + getlTextArea() );
            File file = (File) fileTree.getLastSelectedPathComponent();
            fileDetailsTextArea.setText(getFileDetails(file));
            final ListRightPanel lrp = new ListRightPanel(this);
            lrp.textArea.setText(getFileDetails(file));
            setlTextArea(getFileDetails(file));
            System.out.println("2. What we save is: getlTextArea() =" + getlTextArea() );
              final JSplitPane splitPane = new JSplitPane();
              panel.add(splitPane, BorderLayout.CENTER);
              final JPanel panel_1 = new JPanel();
              splitPane.setLeftComponent(panel_1);
              panel_1.add(new JScrollPane(fileTree));
              final JPanel panel_2 = new JPanel();
              splitPane.setRightComponent(panel_2);
              panel_2.add(new JScrollPane(fileDetailsTextArea));
        setVisible(true);
      private String getFileDetails(File file) {
        if (file == null)
          return "";
        StringBuffer buffer = new StringBuffer();
        if (file.listFiles()!=null){
             for (int i=0; i< file.listFiles().length; i++){
             buffer.append(((file.listFiles())) + "\n");
         System.out.println("List all files");
    return buffer.toString();
    public static void main(String args[]) {
    new ListPanel("c:\\");
    class FileSystemModel implements TreeModel {
    private File root;
    private Vector listeners = new Vector();
    public FileSystemModel(File rootDirectory) {
    root = rootDirectory;
    public Object getRoot() {
    return root;
    public Object getChild(Object parent, int index) {
    File directory = (File) parent;
    String[] children = directory.list();
    return new TreeFile(directory, children[index]);
    public int getChildCount(Object parent) {
    File file = (File) parent;
    if (file.isDirectory()) {
    String[] fileList = file.list();
    if (fileList != null)
    return file.list().length;
    return 0;
    public boolean isLeaf(Object node) {
    File file = (File) node;
    return file.isFile();
    public int getIndexOfChild(Object parent, Object child) {
    File directory = (File) parent;
    File file = (File) child;
    String[] children = directory.list();
    for (int i = 0; i < children.length; i++) {
    if (file.getName().equals(children[i])) {
    return i;
    return -1;
    public void valueForPathChanged(TreePath path, Object value) {
    File oldFile = (File) path.getLastPathComponent();
    String fileParentPath = oldFile.getParent();
    String newFileName = (String) value;
    File targetFile = new File(fileParentPath, newFileName);
    oldFile.renameTo(targetFile);
    File parent = new File(fileParentPath);
    int[] changedChildrenIndices = { getIndexOfChild(parent, targetFile) };
    Object[] changedChildren = { targetFile };
    fireTreeNodesChanged(path.getParentPath(), changedChildrenIndices, changedChildren);
    private void fireTreeNodesChanged(TreePath parentPath, int[] indices, Object[] children) {
    TreeModelEvent event = new TreeModelEvent(this, parentPath, indices, children);
    Iterator iterator = listeners.iterator();
    TreeModelListener listener = null;
    while (iterator.hasNext()) {
    listener = (TreeModelListener) iterator.next();
    listener.treeNodesChanged(event);
    public void addTreeModelListener(TreeModelListener listener) {
    listeners.add(listener);
    public void removeTreeModelListener(TreeModelListener listener) {
    listeners.remove(listener);
    private class TreeFile extends File {
    public TreeFile(File parent, String child) {
    super(parent, child);
    public String toString() {
    return getName();
    [3] Program 3:
    package swing.com.test.test;
    import java.awt.BorderLayout;
    import java.io.File;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.event.TreeModelEvent;
    import javax.swing.event.TreeModelListener;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.TreeModel;
    import javax.swing.tree.TreePath;
    import java.io.Serializable;
    public class ListRightPanel extends JPanel implements TreeSelectionListener, Serializable{
         protected JTextArea textArea;
    //     protected ListAllFile  laf;
        private String str = "";
              public  String getlTextArea()  {
                        //textArea.getText();
                           return str;
              public  String setlTextArea(String ta)  {
                        str = ta;
                           return str;
          * Create the panel
         public ListRightPanel(ListPanel  laff) {
              super();
              setLayout(new BorderLayout());
              final JPanel panel = new JPanel();
              panel.setLayout(new BorderLayout());
              add(panel, BorderLayout.CENTER);
              textArea = new JTextArea();
            final String st = laff.getlTextArea();
            System.out.println("####################################");
            System.out.println("st=" + st);
             laff.fileTree.addTreeSelectionListener(new TreeSelectionListener() {
                 public void valueChanged(TreeSelectionEvent event) {
                   //laff.textArea.setText(getFileDetails(file));
                      textArea.setText(getlTextArea());
                     System.out.println("ListRightPanel Was Invoked from ListPanel!!getlTextArea() =" + getlTextArea() );
                     System.out.println("st=" + st);
              panel.add(textArea, BorderLayout.CENTER);
           public void valueChanged(TreeSelectionEvent e){};
    }You can try this one, thanks again
    sunny

  • Using variable in fox formula containing several characteristics

    Hi @all,
    is it possible to use a variable in fox containing more than one characteristic? I need to have some additional information for a few 0SEM_POSITs but don't want to create an attribute.
    I've created variable ZSCV25 containing characteristics 0SEM_POSIT and ZSCADVDEL but wasn't able to get any data by using VARI.
    Anybody an idea? Thanks for your help.
    Regards,
    Thomas

    <FONT FACE = "Tahoma", Font Color = "Blue">
    Dear Thomas<br>
    I don't think FOX Formula Variable can contain more than one characteristic value. <br><br>However I can suggest you to try one thing. Create an Exit Variable and in its ABAP Code refer to the master data table of base variable and retrieve the value of its desired attribute. <br><br>For example, let us assume that you have a characteristic 0COMP_CODE and 0COUNTRY is its attribute. Now you want that depending on the value of 0COMP_CODE selected by User in another variable ZCOMP_CODE , 0COUNTRY should be automatically populated in variable ZCOUNTRY. So in this case, please make ZCOUNTRY as an Exit Variable and write ABAP Code for that. In the ABAP Code, get the value of 0COMP_CODE which is entered by User in the other variable ZCOMP_CODE. Then write a select statement in ABAP and retrieve the value of 0COUNTRY from the master data table of 0COMP_CODE where Company Code value is equal to value of variable ZCOMP_CODE.<br>
    I hope I am getting you and you are getting me :-)<br>
    <br>Please let me know in case of any confusion.
    <br><br>
    Hope it helps.<br><br>
    Cheers Abhijit<br>
    </FONT><FONT FACE = "Verdana", Font Color = "Red">
    Removed
    </FONT>

Maybe you are looking for