How to dynamically resize JPanel at runtime??

Hello Sir:
I met a problem, I need to resize a small JPanel called panel within a main Control JPanel (with null Layout) if I click the mouse then I can Drag and Resize this small JPanel Border to the size I need at runtime, I know I can use panel.setSize() or panel.setPreferredSize() methods at design time,
But I have no idea how to do it even I search this famous fourm,
How to dynamically resize JPanel at runtime??
Can any guru throw some light or good example??
Thanks

Why are you using a null layout? Wouldn't having a layout manager help you in this situation?

Similar Messages

  • How to resize JPanel at Runtime ??

    Hi,
    Our Project me t a problem as below, we hope to resize JPanel at Runtime , not at design time, ie, when we first click the button called "Move JPanel" , then we click the JPanel, then we can drag it around within main panel, but we hope to resize the size of this JPanel when we point to the border of this JPanel then drag its border to zoom in or zoom out this JPanel.
    Please advice how to do that??
    Thanks in advance.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.util.Vector;
    import javax.swing.*;
    import javax.swing.border.LineBorder;
    import javax.swing.event.*;
    public class ResizeJPanels extends JPanel
        protected JLabel label1, label2, label3, label4, labeltmp;
        protected JLabel[] labels;
        protected JPanel[] panels;
        protected JPanel selectedJPanel;
        protected JButton btn  = new JButton("Move JPanel");
        int cx, cy;
        protected Vector order = new Vector();      
         public static void main(String[] args)
            JFrame f = new JFrame("Test");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new ResizeJPanels().GroupJLabels());
            f.setSize(600,700);
            f.setLocation(200,200);
            f.setVisible(true);
         private MouseListener ml = new MouseAdapter() {  
              public void mousePressed(MouseEvent e) {   
                   Point p = e.getPoint();      
                   JPanel jp = new JPanel();
                   jp.setLayout(null);
                   Component[] c = ((JPanel)e.getSource()).getComponents();
                   System.out.println("c.length = " + c.length);      
                   for(int j = 0; j < c.length; j++) {        
                        if(c[j].getBounds().contains(p)) {     
                             if(selectedJPanel != null && selectedJPanel != (JPanel)c[j])
                                  selectedJPanel.setBorder(BorderFactory.createEtchedBorder());
                             selectedJPanel = (JPanel)c[j];            
                             selectedJPanel.setBorder(BorderFactory.createLineBorder(Color.green));
                             break;             
                        add(jp);
                        revalidate();
    public JPanel GroupJLabels ()
              setLayout(null);
            addLabels();
            label1.setBounds( 125,  150, 125, 25);
            label2.setBounds(425,  150, 125, 25);
            label3.setBounds( 125, 575, 125, 25);
            label4.setBounds(425, 575, 125, 25);
            //add(btn);
            btn.setBounds(10, 5, 205, 25);
                add(btn);
           determineCenterOfComponents();
            ComponentMover mover = new ComponentMover();
             ActionListener lst = new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                     ComponentMover mover = new ComponentMover();
                           addMouseListener(mover);
                           addMouseMotionListener(mover);
              btn.addActionListener(lst);
              addMouseListener(ml); 
              return this;
        public void paintComponent(final Graphics g)
             super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
             Point[] p;
            g2.setStroke(new BasicStroke(4f));
           for(int i = 0 ; i < order.size()-1; i++) {
                JPanel l1 = (JPanel)order.elementAt(i);
                JPanel l2 = (JPanel)order.elementAt(i+1);
                p = getCenterPoints(l1, l2);
                g2.setColor(Color.black);
               // g2.draw(new Line2D.Double(p[0], p[1]));            
        private Point[] getCenterPoints(Component c1, Component c2)
            Point
                p1 = new Point(),
                p2 = new Point();
            Rectangle
                r1 = c1.getBounds(),
                r2 = c2.getBounds();
                 p1.x = r1.x + r1.width/2;
                 p1.y = r1.y + r1.height/2;
                 p2.x = r2.x + r2.width/2;
                 p2.y = r2.y + r2.height/2;
            return new Point[] {p1, p2};
        private void determineCenterOfComponents()
            int
                xMin = Integer.MAX_VALUE,
                yMin = Integer.MAX_VALUE,
                xMax = 0,
                yMax = 0;
            for(int i = 0; i < labels.length; i++)
                Rectangle r = labels.getBounds();
    if(r.x < xMin)
    xMin = r.x;
    if(r.y < yMin)
    yMin = r.y;
    if(r.x + r.width > xMax)
    xMax = r.x + r.width;
    if(r.y + r.height > yMax)
    yMax = r.y + r.height;
    cx = xMin + (xMax - xMin)/2;
    cy = yMin + (yMax - yMin)/2;
    private class ComponentMover extends MouseInputAdapter
    Point offsetP = new Point();
    boolean dragging;
    public void mousePressed(MouseEvent e)
    Point p = e.getPoint();
    for(int i = 0; i < panels.length; i++)
    Rectangle r = panels[i].getBounds();
    if(r.contains(p))
    selectedJPanel = panels[i];
    order.addElement(panels[i]);
    offsetP.x = p.x - r.x;
    offsetP.y = p.y - r.y;
    dragging = true;
    repaint(); //added
    break;
    public void mouseReleased(MouseEvent e)
    dragging = false;
    public void mouseDragged(MouseEvent e)
    if(dragging)
    Rectangle r = selectedJPanel.getBounds();
    r.x = e.getX() - offsetP.x;
    r.y = e.getY() - offsetP.y;
    selectedJPanel.setBounds(r.x, r.y, r.width, r.height);
    //determineCenterOfComponents();
    repaint();
    private void addLabels()
    label1 = new JLabel("Label 1");
    label2 = new JLabel("Label 2");
    label3 = new JLabel("Label 3");
    label4 = new JLabel("Label 4");
    labels = new JLabel[] {
    label1, label2, label3, label4
    JLabel jl = new JLabel("This is resizeable JPanel at Runtime");
    jl.setBackground(Color.green);
    jl.setOpaque(true);
              jl.setFont(new Font("Helvetica", Font.BOLD, 18));
    JPanel jp = new JPanel();
    jp.setLayout(new BorderLayout());
    panels = new JPanel[]{jp};
              jp.setBorder(new LineBorder(Color.black, 3, false));
    jp.setPreferredSize(new Dimension(400,200));
    jp.add(jl, BorderLayout.NORTH);
    for(int i = 0; i < labels.length; i++)
    labels[i].setHorizontalAlignment(SwingConstants.CENTER);
    labels[i].setBorder(BorderFactory.createEtchedBorder());
    jp.add(labels[i], BorderLayout.CENTER);
    jp.setBounds(100, 100, 400,200);
    add(jp);

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.MouseInputAdapter;
    public class Resizing extends JPanel {
        public Resizing() {
            super(null);
            addPanel();
            PanelControlAdapter control = new PanelControlAdapter(this);
            addMouseListener(control);
            addMouseMotionListener(control);
        private void addPanel() {
            JLabel jl = new JLabel("This is resizeable JPanel at Runtime");
            jl.setBackground(Color.green);
            jl.setOpaque(true);
            jl.setFont(new Font("Helvetica", Font.BOLD, 18));
            JPanel jp = new JPanel();
            jp.setLayout(new BorderLayout());
            jp.setBorder(new LineBorder(Color.black, 3, false));
            jp.add(jl, BorderLayout.NORTH);
            jp.setBounds(50,50,400,200);
            add(jp);
        public static void main(String[] args) {
            JFrame f = new JFrame("Test");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new Resizing());
            f.setSize(500,400);
            f.setLocation(100,100);
            f.setVisible(true);
    class PanelControlAdapter extends MouseInputAdapter {
        Resizing host;
        Component selectedComponent;
        LineBorder black;
        LineBorder green;
        Point offset = new Point();
        Point start = new Point();
        boolean dragging = false;
        boolean resizing = false;
        public PanelControlAdapter(Resizing r) {
            host = r;
            black = new LineBorder(Color.black, 3, false);
            green = new LineBorder(Color.green, 3, false);
        public void mouseMoved(MouseEvent e) {
            Point p = e.getPoint();
            boolean hovering = false;
            Component c = host.getComponent(0);
            Rectangle r = c.getBounds();
            if(r.contains(p)) {
                hovering = true;
                if(selectedComponent != c) {
                    if(selectedComponent != null)  // reset
                        ((JComponent)selectedComponent).setBorder(black);
                    selectedComponent = c;
                    ((JComponent)selectedComponent).setBorder(green);
                if(overBorder(p))
                    setCursor(p);
                else if(selectedComponent.getCursor() != Cursor.getDefaultCursor())
                    selectedComponent.setCursor(Cursor.getDefaultCursor());
            if(!hovering && selectedComponent != null) {
                ((JComponent)selectedComponent).setBorder(black);
                selectedComponent = null;
        private boolean overBorder(Point p) {
            Rectangle r = selectedComponent.getBounds();
            JComponent target = (JComponent)selectedComponent;
            Insets insets = target.getBorder().getBorderInsets(target);
            // Assume uniform border insets.
            r.grow(-insets.left, -insets.top);
            return !r.contains(p);
        private void setCursor(Point p) {
            JComponent target = (JComponent)selectedComponent;
            AbstractBorder border = (AbstractBorder)target.getBorder();
            Rectangle r = target.getBounds();
            Rectangle ir = border.getInteriorRectangle(target, r.x, r.y, r.width, r.height);
            int outcode = ir.outcode(p.x, p.y);
            Cursor cursor;
            switch(outcode) {
                case Rectangle.OUT_TOP:
                    cursor = Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_TOP + Rectangle.OUT_LEFT:
                    cursor = Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_LEFT:
                    cursor = Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_LEFT + Rectangle.OUT_BOTTOM:
                    cursor = Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_BOTTOM:
                    cursor = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_BOTTOM + Rectangle.OUT_RIGHT:
                    cursor = Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_RIGHT:
                    cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
                    break;
                case Rectangle.OUT_RIGHT + Rectangle.OUT_TOP:
                    cursor = Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR);
                    break;
                default:
                    cursor = Cursor.getDefaultCursor();
            selectedComponent.setCursor(cursor);
        public void mousePressed(MouseEvent e) {
            Point p = e.getPoint();
            if(selectedComponent != null) {
                Rectangle r = selectedComponent.getBounds();
                if(selectedComponent.getCursor() == Cursor.getDefaultCursor()) {
                    offset.x = p.x - r.x;
                    offset.y = p.y - r.y;
                    dragging = true;
                } else {
                    start = p;
                    resizing = true;
        public void mouseReleased(MouseEvent e) {
            dragging = false;
            resizing = false;
        public void mouseDragged(MouseEvent e) {
            Point p = e.getPoint();
            if(dragging || resizing) {
                Rectangle r = selectedComponent.getBounds();
                if(dragging) {
                    r.x = p.x - offset.x;
                    r.y = p.y - offset.y;
                    selectedComponent.setLocation(r.x, r.y);
                } else if(resizing) {
                    int type = selectedComponent.getCursor().getType();
                    switch(type) {
                        case Cursor.N_RESIZE_CURSOR:
                            r.height -= p.y - start.y;
                            r.y = p.y;
                            break;
                        case Cursor.NW_RESIZE_CURSOR:
                            r.width -= p.x - start.x;
                            r.x = p.x;
                            r.height -= p.y - start.y;
                            r.y = p.y;
                            break;
                        case Cursor.W_RESIZE_CURSOR:
                            r.width -= p.x - start.x;
                            r.x = p.x;
                            break;
                        case Cursor.SW_RESIZE_CURSOR:
                            r.width -= p.x - start.x;
                            r.x = p.x;
                            r.height += p.y - start.y;
                            break;
                        case Cursor.S_RESIZE_CURSOR:
                            r.height += p.y - start.y;
                            break;
                        case Cursor.SE_RESIZE_CURSOR:
                            r.width += p.x - start.x;
                            r.height += p.y - start.y;
                            break;
                        case Cursor.E_RESIZE_CURSOR:
                            r.width += p.x - start.x;
                            break;
                        case Cursor.NE_RESIZE_CURSOR:
                            r.width += p.x - start.x;
                            r.height -= p.y - start.y;
                            r.y = p.y;
                            break;
                        default:
                            System.out.println("Unexpected resize type: " + type);
                    selectedComponent.setBounds(r.x, r.y, r.width, r.height);
                    start = p;
    }

  • How to dynamic select based on runtime value ?

    how to dynamic select based on runtime value ?
    I want to write a select function, which do selecting based on parameters. eg,
    CREATE OR REPLACE FUNCTION myfunction
    (tableName VARCHAR2, pkName VARCHAR2, pkValue VARCHAR2, requestString VARCHAR2)
    RETURN VARCHAR2 AS
    BEGIN
    select requestString from tableName where pkName=pkValue;
    RETURN NULL;
    END;
    myfunction('users', 'user_id', '100', 'user_name'); it will select 'user_name' from table 'users' where 'user_id' = '100'.
    This way could save lots of coding. but it can't pass compiler. how to work out ?
    Thanks.

    While this may save code, if used frequently it will be ineffecient as all [explicative deleted]. The danger is that it would be used even for repeatable statements.
    This mode of operation ensures that every statement [calling the funciton] needs to be reparsed, which is extremely expensive in Oracle (in CPU cycles, recursive SQL and shared pool memory).
    Such reparsing is rarely a good thing for the environment ... it could easily lead to buying more CPU (bigger box) and therefore adding more Oracle license ... which could quickly exceed the typical developer's salary.
    However - if you really, really want to do this, look up 'execute immendiate' in the PL/SQL manuals.

  • How to dynamically resize taskflow popup set as inlineDocument.

    I've been trying to figure out how to dynamically set the WindowHeight and WindowWidth of a taskflow deployed as a inlineDocument popup. Sadly, neither the forums nor google came to the rescue so I had to actually figure this one out on my own. But at least now is my opportunity to work up some forum karma! :)
    Sample workspace containing the solution is here: http://www.williverstravels.com/JDev/Forums/Threads/2337969/MaxPopupSize.zip
    General Strategy for Solution:
    - Pull the browser height and width using Javascript
            function browserSize(evt)
              var button = evt.getSource();
              var agent = AdfAgent.AGENT;
              var windowWidth = agent.getWindowWidth();
              var windowHeight = agent.getWindowHeight();
              AdfCustomEvent.queue(button, "customEvent",
                width: windowWidth,
                height: windowHeight
              true);
              evt.cancel();
            }- Using a clientListener and serverListener, pull this information into a managed bean and set height / width in button's setWindowWidth(), setWindowHeight() attribute.
      public void onButtonClick(ClientEvent clientEvent)
        Double dw = (Double)clientEvent.getParameters().get("width")-100;
        Double dh = (Double)clientEvent.getParameters().get("height")-100;
        this.popupButton.setWindowWidth(dw.intValue());
        this.popupButton.setWindowHeight(dh.intValue());
        ActionEvent aE = new ActionEvent(this.getPopupButton());
        aE.queue();  
      }- Due to JSF Lifecycle complications, the managed bean will need to call a different button than the one which holds the client and server listener. It will be the second button (popupButton in the code above) which then calls the popup.
    Props to Frank for the client / server listener tutorial: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/56-handle-doubleclick-in-table-170924.pdf
    Props to Martin Deh for the javascript insights: http://martindeh.blogspot.com/2011/03/dynamic-resizing-for-popup-dialogs.html
    Hope this helps someone down the road.
    Will

    Thanks LovettWB ...
    Your question helped me a lot...  I am able to pass these two parameters width/height to my bean and am able to set it to pop-up :)                                                                                                                                                                                                                                                                                                                                   

  • How to dynamically resize a Spark Label?

    If i set the text of a spark label at runtime, the label dont resize automatically. How can i resize the correct width of a spark label at runtime?
    Thanks in advance

    The sample will be helpful to you:
    <fx:Script>
            <![CDATA[
                protected function button1_clickHandler(event:MouseEvent):void
                    // TODO Auto-generated method stub
                    lbl.text = lbl.text + " hi ";
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <s:Label id="lbl" height="20" text="hello" backgroundColor="#FFcc12" x="157" y="83"/>
        <s:Button label="ok" click="button1_clickHandler(event)"  x="177" y="152"/>

  • How to dynamically resize virtualbox console (Arch within Arch setup)

    My host is Arch, and my guest is Arch.  The guest running console without X.  I got 1024x728 resolution by adding vga=772 in guest's menu.1st file.  Is there a way to dynamically resize the guest's console dimensions by dragging virtualbox's window corner, as you can with a windows guest OS?

    Dynamic resizing only works from within X, it doesn't work when in console mode, as it requires the Guest Additions installed.  It might of course work in the future if Virtualbox includes a framebuffer driver with guest additions, but somehow I very much doubt they will

  • How to dynamically resize JOptionPane

    Hi All.
    I have a JOptionPane that contains a JPanel as the message (BorderLayout). The JPanel has a JComboBox on the north part and another JPanel in the center. When the combo changes selection the panel in the center is changed. Basically the combo represents some sort of selection and the panel is changed based on the selection to enter some specific search criteria.
    The problem I have is the search criteria panels are of different sizes. Therefore I want to resize the JOptionPane every time a combo selection is made.
    Does anybody know how to do this?
    nes

    Hi ICE,
    Here is some example code explaining my problem. Sorry it is a bit long but it explains my exact requirement.
    < 74philip the problem with calling JOptionPane.createInternalFrame is that it does not block until the Ok button is pressed. That is why I cannot use this solution >
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class TestFrame3
        extends JFrame
        implements ActionListener
        protected JPanel m_panel = new JPanel( new BorderLayout() );
        protected JPanel m_propertyPanel1 = new JPanel();
        protected JPanel m_propertyPanel2 = new JPanel();
        protected JPanel m_propertyPanel3 = new JPanel();
        protected JDesktopPane m_desktopPane = new JDesktopPane();
        protected JComboBox m_combo;
        protected JButton m_button;
        protected JOptionPane m_pane;
        public TestFrame3()
            initGUI();
        public void actionPerformed( ActionEvent event )
            if ( event.getSource() == m_combo )
                switch ( m_combo.getSelectedIndex() )
                    case ( 1 ):
                        m_panel.remove( m_propertyPanel1 );
                        m_panel.remove( m_propertyPanel3 );
                        m_panel.add( m_propertyPanel2, BorderLayout.CENTER );
                        break;
                    case ( 2 ):
                        m_panel.remove( m_propertyPanel1 );
                        m_panel.remove( m_propertyPanel2 );
                        m_panel.add( m_propertyPanel3, BorderLayout.CENTER );
                        break;
                    default:
                        m_panel.remove( m_propertyPanel2 );
                        m_panel.remove( m_propertyPanel3 );
                        m_panel.add( m_propertyPanel1, BorderLayout.CENTER );
                        break;
                //  THIS IS WHERE I WOULD LIKE TO RESIZE/PACK THE OPTION PANE
                //       m_pane.???????
                //  BUT HOW??
                m_panel.validate();
                m_panel.repaint();
            else if ( event.getSource() == m_button )
                m_pane = new JOptionPane();
                m_pane.showInternalConfirmDialog( m_desktopPane, m_panel,
                                                  "Test",
                                                  JOptionPane.OK_CANCEL_OPTION );
        private void initGUI()
            initSelectionCombo();
            initPropertyPanels();
            m_button = new JButton( "Go For It..." );
            m_button.addActionListener( this );
            getContentPane().setLayout( new BorderLayout() );
            getContentPane().add( m_desktopPane, BorderLayout.CENTER );
            getContentPane().add( m_button, BorderLayout.SOUTH );
            setSize( 800, 900 );
            show();
        private void initSelectionCombo()
            Vector v = new Vector();
            v.addElement( "Property Panel 1" );
            v.addElement( "Property Panel 2" );
            v.addElement( "Property Panel 3" );
            m_combo = new JComboBox( v );
            m_panel.add( m_combo, BorderLayout.NORTH );
            m_combo.addActionListener( this );
        private void initPropertyPanels()
            JLabel property1 = new JLabel( "Property 1" );
            JLabel property2 = new JLabel( "Property 2" );
            JLabel property3 = new JLabel( "Property 3" );
            m_propertyPanel1.setLayout( new GridBagLayout() );
            m_propertyPanel1.setBorder( BorderFactory.createLineBorder( Color.RED ) );
            m_propertyPanel1.add( property1,
                                  new GridBagConstraints( 1, 2, 1, 1, 1, 1,
                GridBagConstraints.EAST, GridBagConstraints.REMAINDER,
                new Insets( 3, 3, 3, 3 ), 0, 0 ) );
            m_propertyPanel1.add( property2,
                                  new GridBagConstraints( 2, 1, 1, 1, 1, 1,
                GridBagConstraints.EAST, GridBagConstraints.BOTH,
                new Insets( 3, 3, 3, 3 ), 0, 0 ) );
            m_propertyPanel1.add( property3,
                                  new GridBagConstraints( 6, 5, 1, 1, 1, 1,
                GridBagConstraints.EAST, GridBagConstraints.BOTH,
                new Insets( 3, 3, 3, 3 ), 0, 0 ) );
            JLabel property4 = new JLabel( "Property 4" );
            property4.setBounds( 10, 10, 100, 20 );
            JButton property5 = new JButton( "Property 5" );
            property5.setBounds( 40, 60, 190, 40 );
            m_propertyPanel2.setBorder( BorderFactory.createLineBorder( Color.GREEN ) );
            m_propertyPanel2.setLayout( null );
            m_propertyPanel2.add( property4 );
            m_propertyPanel2.add( property5 );
            m_propertyPanel3.setLayout( new FlowLayout( FlowLayout.CENTER, 10, 10 ) );
            m_propertyPanel3.setBorder( BorderFactory.createLineBorder( Color.BLUE ) );
            JButton property6 = new JButton( "Property 6" );
            JButton property7 = new JButton( "Property 7" );
            JButton property8 = new JButton( "Property 8" );
            JButton property9 = new JButton( "Property 9" );
            m_propertyPanel3.add( property6 );
            m_propertyPanel3.add( property7 );
            m_propertyPanel3.add( property8 );
            m_propertyPanel3.add( property9 );
            m_panel.add( m_propertyPanel1, BorderLayout.CENTER );
        public static void main( String args[] )
            SwingUtilities.invokeLater( new Runnable()
                public void run()
                    new TestFrame3();
    }nes

  • How to dynamically resize a display component to avoid vertical scroll bars?

    Hi,
    I have a Flex 2 chart embedded within my html page. I have a
    hard coded height and width for the object tag. The problem is that
    my Flex 2 chart application is created dynamically based on the
    meta-data and as such may or may not be bigger in size than the
    size that I have set. In such cases, Flex shows the scroll bar.
    On creationComplete, I want to be able to detect the true
    size of the flex app i.e size that includes both the view area and
    the area that is hidden but scrollable. I have tried height, width,
    verticalScrollBar.maxHeight etc. but none of them give me the
    height and width of the whole app. Is there a way to get that in
    ActionScript?
    Thank you,
    AN

    Hi!
    Try to read this:
    http://blogs.sun.com/winston/entry/button_header_table
    I hope it will help You.
    Thanks,
    Roman.

  • How to dynamic order of groups & How to fetch data at runtime from database

    Post Author: ferikpatel
    CA Forum: Formula
    I am using visual studio .net application having inbuilt crystal report feature. Now, what I want to do is, i have create 5 groups in crystal report, but dynamically want to change the order of those reports as per user's selection.
    How to do that?
    Also, how to fetch database item on runtime which is not selected through data expert as its relation is depends on situation. Say if one field's value is 5 than i want to get name of customer, but if same field's value is 6 than i want to get name of suppliers. In database both supplier and customers tables are different however they are connected with base table.
    I'm bit new in crystal report. Please help me out if it is possible.

    Post Author: Charliy
    CA Forum: Formula
    You don't actually change the order of the groups.  You group on a formula and change contents of the formula based on the parameter.
    IF {?Group1} = "Manager" then {table.Manager}
    else if {?Group1} = "Invoice Date" then Totext({table.InvDate},"yyyyMMdd")    note all options must be the same date type, so numbers and dates are converted
    else . . .

  • How do I stop iPhone Safari from dynamically resizing the visual viewport?

    Sorry I post this here, but I couldn't access the developer forums (no error given, it just keeps returning me to this page https://developer.apple.com/devforums/) I'm not even sure wether that's been moved here and it's just the redirection non working.
    I need to Stop iPhone Safari from dynamically resizing the visual viewport, or in other words, to stop it from trying to "fit" the layout into the viewport.
    Why?
    Because any recalculation javascript does on absolutely positioned elements makes the whole site super IRRESPONSIVE.
    I don't know wether the issue is the element going out the already-set layout viewport (which triggers the page resizing to fit the visual viewport) or just the calculations being made constantly, but I can stop the calculations from happening when not "touching" the screen, but I need a way to stop the page resizing.
    I tried setting the viewport width to 1040px, as my layout width, and it fixed the header's width being narrower than the body (or shifted left?), but the whole page is still resized with every motion-frame (one every 3 seconds, due to overloading the redrawing engine)
    Is there a way to prevent that?

    No, that link doesn't solve it. It just says the same is found everywhere online.
    There's probably no way to do it, as per their way they "accidentally" omitted the oposite case: the page being wider than 980. They only mention what to do if the site is narrower. Something I learned is big companies (with reputation management) could let you run in circles for years no answer rather than telling you something is not possible.
    I'm the developer (can't access the dev forums, don't know why) and I DID setup the viewport, scale and other properties but none of them stopped from re-fitting the new re-sized layout in the viewport. They just ensure the "initial" view.
    I think the feature I'm looking for must be achieved with some JavaScript function targeting Safari-proprietary variable/property… if even possible.
    I just had to make things never reaching the edge until somebody contributes something useful

  • How to dynamically discover runtime properties of app server within webapp

    Hi friends,
    Does anyone know if the Servlet API provide any methods to dynamically discover app server runtime properties such as which http and https ports the server is listening at?
    It's not the same as ServletRequest.getServerPort() which only give you back the port the incoming request comes from.
    I want to be able to say redirect user requests to https, WITHOUT in advance knowledge of the https port configured for the app server, which means no hardcoding of the port number.
    Thanks very much for help.

    You could always add a web resource collection to your web.xml and specify the transport guarantee to be integral.

  • How to dynamically determine Receivers within BPM

    I’m trying to design a way to determine my receivers within my BPM process during runtime.   My Scenario is as follows:
    SAP IDOC
        V
      XI
                 XI uses JAVA Mapping MT1 to determine vendors and if customer receives PIDX
                             JAVA Mapping MT2 to creates the PIDX output file if required
      V
    SENDs to required Vendor (PIDX if required otherwise email)
    My problem is how to dynamically determine the appropriate receiving vendor for my PIDX.
    I can not use the condition editor on the standard Receiver Determination because the output message (PIDX) doesn't have specific enough information to determine the vendor.
    Other than the customer number there are no other values and we don't want to use customer number because each vendor can have multiple customer numbers (hundreds).
    I've tried various attempts but none seem to work.  This could also be because I have limited knowledge of BPMs and this is my first complex development.  Below are the different attempts I've made at dynamically determining the receiver.  Any input would be appreciated.
    Receiver Scenario 1 
      I developed an interface mapping with MT1 as input and the SAP Receiver Determination as output.  The problem is for me to use this, the interface mapping had to reference the PIDX output (MT2 instead of MT1) which has no data that I can use to determine the receiver.
    Receiver Scenario 2
    I added a receiver step right before my send step and used the receiver list.  This appears to send the PIDX to everyone in the list and there is no way to evaluate or eliminate a name from the list. 
    Receiver Scenario 3
    I created a context object in the Integration Builder and assigned it to a field in MT1.  I then added a switch step with a branch for each vendor.  Within each specific branch there is a Send step that has the context object name I created in the "Send Context" field.  However, on the configuration side I’m unable to access the context object which I created on the design side.  Whenever I open the condition editor and select the radiobutton for "Context Object" the list  does not include the context object I created in the Integration Builder.

    Hi,
    Try using the enhaced receiver determination concept.
    Maybe based on certain field values you can write a UDF which calculates the receiver.
    Try this Blog out
    Link : [
    http://help.sap.com/saphelp_nw70/helpdata/en/43/a5f2066340332de10000000a11466f/frameset.htm]
    Regards,
    Abhishek
    Award if helpful.

  • Dynamically resize JTable cell to fit a JList

    Hi!
    I've been banging my head trying to add some dynamic behavior to a TableCellEditor. In short I'm trying trying to make it resize the height of the current row (the one it is in) to reflect the changes made to the JList used to let the user edit the cells value (which is a list of items).
    I've come across some threads dealing with the problem of resizing a cell to fit its content. This however is usually only done once (in the 'getTableCellEditorComponent' function) and so only provides half the answer. Also, since the editor is only active during cell editing I've been trying to make it revert to the old cell height after the editing is done.
    So far I have not come up with any decent solution to this problem and was hoping someone out there might have an idea or have read something similar and can point me to something helpful... anyone?
    Cheers!
    Teo

    The Swing tutorial on[url http://java.sun.com/docs/books/tutorial/uiswing/components/table.html]How to Use Tables shows how to dynamically change the size to Table Columns.
    If you need help calculating the acutal size then try searching the forum. Using keywords "resize jtable column" (keywords I took directly from your topic title) I found some promising postings.

  • Declare dynamic internal table during runtime error

    Hi Gurus,
    I have encounter a problem here. I would like to have several block of alv list output; for each customer open items details. Thus, i need to create dynamic internal table duirng runtime as i do not know how many customers that should be output before user enter from the selection screen field for customer code.
    I tried to search in the forums and found this website [Runtime Declaration of Internal Table;.
    But when i tried to execute it, i have an error. The field symbols that i passed into the call function REUSE_ALV_BLOCK_LIST_APPEND for parameter t_outtab does not match. May i know how do i go about it?
    Or are there any other solutions to display this kind of reports? I ever think of using hierarchy list alv. But it does not match the requirement. I would like to display the total amount for each customer. Can hierarchy list able to do so? Or it can only display as the grand total at the end of the report? I think it would be best to display as alv block output.
    Your help will be much appreciated. <offer removed by moderator>
    Thanks
    Edited by: Thomas Zloch on Oct 22, 2010 11:23 AM

    the problem comes up, when there are fields in the table which represent numbers with decimals (type p). Best is to reference the field directly what comes from SAP. Replace the LOOP At idetails ... ENDLOOP with:
    LOOP AT idetails INTO xdetails.
        CLEAR xfc.
        xfc-fieldname = xfc-ref_field = xdetails-name .
        xfc-ref_table   = p_table.
    *    xfc-datatype = xdetails-type_kind.
    *    xfc-inttype = xdetails-type_kind.
    *    xfc-intlen = xdetails-length.
    *    xfc-decimals = xdetails-decimals.
        APPEND xfc TO ifc.
      ENDLOOP.

  • Making a customable resizable JPanel, but it only works in certain L&F

    Hi,
    I have created the following resizable JPanel (so that I can set a minimum size it can be dragged to).
    However, I need it to work under the system L&F, which is XP, but it wont work.
    The code is below. if you run it the first time, and try to resize the dialog to a small value, you will see it shrinks in size, to a certain point.
    then if you comment out the 2 lines i specified, and run it again, it wont. Anyone have any ideas? is this a known bug?
    import javax.swing.*;
    import java.awt.event.ComponentListener;
    import java.awt.event.ComponentEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.*;
    public class ResizeTest extends JDialog {
         public ResizeTest(JFrame owner) {
              super(owner);
              this.addComponentListener(resizeListener);
              /* comment out the following 2 lines */
              setUndecorated(true);                  
            getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
         private ComponentListener resizeListener = new ComponentListener() {
              public void componentHidden( ComponentEvent i_e ) { }
              public void componentMoved( ComponentEvent i_e ) { }
              public void componentResized( ComponentEvent i_e ) {
                   int width = ResizeTest.this.getWidth();
                   int height = ResizeTest.this.getHeight();   
                  if( width < 50 ) { width = 50; }
                   if( height < 50 ) { height = 50; }
                   ResizeTest.this.setSize( width, height );
             public void componentShown( ComponentEvent i_e ) { }
         private static void test() {
              final JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JButton launchButton = new JButton("showDialog");
              frame.setContentPane(launchButton);
              final ResizeTest testDialog = new ResizeTest(frame);
              testDialog.setMinimumSize(new Dimension(300, 300));
              testDialog.setSize(500, 500);
              testDialog.setPreferredSize(new Dimension(500, 500));
              launchButton.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        testDialog.pack();
                        testDialog.setVisible(true);
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        frame.pack();
                        frame.setVisible(true);
         public static void main(String[] args) {
              test();
    }

    okay... I see what the problem is.
    1) With those lines uncommented: The L&F is handling the window decorations. Because of this, it's basically a JWindow with custom painting and mouse handling. When you resize, it's constantly calling setSize, which constantly firing events, so your minimum sizing works as you expect.
    2) With those lines commented: The OS is handling the window decorations. Because of this, there are 2 caveats:
    a) There is a minimum width of the window of what looks like about 120-130 pixels. So you can't go any smaller then that for width. And for height, no smaller then the titlebar and lower border.
    b) It only fires the component events when the mouse is released, cuz that's how the undelying native windows deal with it... or at least with Java.
    For #1 above, there's still a minimum size for the L&F decorated windows. But this is related to what content is showing in the titlebar. Which in the case of the decorations showing, is smaller then what your were defining as a minimum.
    So, basically, it's not a bug. It's just the way it is. It's always been like this.

Maybe you are looking for

  • Itunes 10 error 7 (windows 127)

    I keep trying to install the new itunes and i have tried everything and an error keeps popping up, how can i get my itunes to work right

  • Target file of the same name as source file

    Hi,     I am working on a file to file scenario. I need the target file name to be same as the source file name.     I checked the adapter specific message attributes in the sender as well as receiver file adapter,and also checked the file name.    

  • Java.lang.IllegalStateException: HttpSession is invalid problem

    Hi, I get randomly in my application "java.lang.IllegalStateException: HttpSession is invalid" exception thrown when I call getAttribute() method on a HttpSession instance. weblogic.servlet.internal.session.SessionData.getAttribute(SessionData.java:4

  • Importing problems with Gopro?

    I just got a GoPro but it will only let me download some videos to iphoto and imove, but most of the time it won't. It keeps saying "There was a problem importing 1 of 1 clips from your camera. Please review the imported movies carefully" or how it c

  • Auto check in Mail App on iPhone 4

    Hi, Sometimes the Mail App automatically checks for new e-mails and alerts me... but not always. A few times in the last couple of weeks I've missed staying in "live" contact with friends because the Mail App did not check for new messages at all unt