GridBagLayout & Canvas question

I hit a snag during my homework assignment. I am in the making of a RTS game, and want to draw on a Canvas, which I'm placing within a Panel that has a GridbagLayout using the following code:
pane = new Panel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
//pane.add(new Label(), c);
c.gridx = 0;
c.gridy = 0;
c.fill = GridBagConstraints.BOTH;
pane.add(field, c);As I understand this should place and size the field (Canvas) to fill out all the available space in the panel, but all I see is a big white nothing. http://users.hszk.bme.hu/~fm649/javasnag0.png The funny thing is that if I delete the comment tag before
pane.add(new Label(), c);then I actually get what I wanted, the field (Canvas) is drawn correctly in the appropriate place and size (except for the label itself in the center of the window). http://users.hszk.bme.hu/~fm649/javasnag1.png Any ideas why is this happening?
Thanks in advance, Mike

the making of a RTS game, and want to draw on a
Canvas, which I'm placing within a Panel that has aYou want to draw on a canvas? By default canvas is not equiped to do this. If you want a canvas you can draw on, check out my code below. If you are using AWT instead of swing you might have to modify this a little, but it shouldn't be too hard
You are welcome to use and modify this code, but please do not change the package or take credit for it as your own work.
tjacobs.ui.PaintArea.java
====================
* Created on Jun 15, 2005 by @author Tom Jacobs
package tjacobs.ui;
import java.awt.image.BufferedImage;
import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import tjacobs.MathUtils;
* PaintArea is a component that you can draw in similar to but
* much simpler than the windows paint program.
public class PaintArea extends JComponent {
     BufferedImage mImg; //= new BufferedImage();
     int mBrushSize = 1;
     private boolean mSizeChanged = false;
     private Color mColor1, mColor2;
     static class PaintIcon extends ImageIcon {
          int mSize;
          public PaintIcon(Image im, int size) {
               super(im);
               mSize = size;
     public PaintArea() {
          super();
          setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
          addComponentListener(new CListener());
          MListener ml = new MListener();
          addMouseListener(ml);
          addMouseMotionListener(ml);
          setBackground(Color.WHITE);
          setForeground(Color.BLACK);
     public void paintComponent(Graphics g) {
          if (mSizeChanged) {
               handleResize();
          //g.drawImage(mImg, mImg.getWidth(), mImg.getHeight(), null);
          g.drawImage(mImg, 0, 0, null);
          //super.paintComponent(g);
          //System.out.println("Image = " + mImg);
          //System.out.println("Size: " + mImg.getWidth() + "," + mImg.getHeight());
     public void setBackground(Color c) {
          super.setBackground(c);
          if (mImg != null) {
               Graphics g = mImg.getGraphics();
               g.setColor(c);
               g.fillRect(0, 0, mImg.getWidth(), mImg.getHeight());
               g.dispose();
     public void setColor1(Color c) {
          mColor1 = c;
     public void setColor2(Color c) {
          mColor2 = c;
     public Color getColor1() {
          return mColor1;
     public Color getColor2() {
          return mColor2;
     class ToolBar extends JToolBar {
          ToolBar() {
               final ColorButton fore = new ColorButton();
               fore.setToolTipText("Foreground Color");
               final ColorButton back = new ColorButton();
               back.setToolTipText("Background Color");
               JComboBox brushSize = new JComboBox();
               //super.createImage(1, 1).;
               FontMetrics fm = new FontMetrics(getFont()) {};
               int ht = fm.getHeight();
               int useheight = fm.getHeight() % 2 == 0 ? fm.getHeight() + 1 : fm.getHeight();
               final BufferedImage im1 = new BufferedImage(useheight, useheight, BufferedImage.TYPE_INT_RGB);
               Graphics g = im1.getGraphics();
               g.setColor(Color.WHITE);
               g.fillRect(0, 0, useheight, useheight);
               g.setColor(Color.BLACK);
               g.fillOval(useheight / 2, useheight / 2, 1, 1);
               g.dispose();
               //im1.setRGB(useheight / 2 + 1, useheight / 2 + 1, 0xFFFFFF);
               final BufferedImage im2 = new BufferedImage(useheight, useheight, BufferedImage.TYPE_INT_RGB);
               g = im2.getGraphics();
               g.setColor(Color.WHITE);
               g.fillRect(0, 0, useheight, useheight);
               g.setColor(Color.BLACK);
               g.fillOval(useheight / 2 - 1, useheight / 2 - 1, 3, 3);
               g.dispose();
//               im2.setRGB(useheight / 2 - 1, useheight / 2 - 1, 3, 3, new int[] {     0, 0xFFFFFF, 0,
//                                                            0xFFFFFF, 0xFFFFFFF, 0xFFFFFF,
//                                                            0, 0xFFFFFF, 0}, 0, 1);
               final BufferedImage im3 = new BufferedImage(useheight, useheight, BufferedImage.TYPE_INT_RGB);
               g = im3.getGraphics();
               g.setColor(Color.WHITE);
               g.fillRect(0, 0, useheight, useheight);
               g.setColor(Color.BLACK);
               g.fillOval(useheight / 2 - 2, useheight / 2 - 2, 5, 5);
               g.dispose();
//               im3.setRGB(useheight / 2 - 2, useheight / 2 - 2, 5, 5, new int[] {     0, 0, 0xFFFFFF, 0, 0, 
//                                                            0, 0xFFFFFF, 0xFFFFFFF, 0xFFFFFF, 0,
//                                                            0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF,
//                                                            0, 0xFFFFFF, 0xFFFFFFF, 0xFFFFFF, 0,
//                                                            0, 0, 0xFFFFFF, 0, 0}, 0, 1);
               //JLabel l1 = new JLabel("1 pt", new ImageIcon(im1), JLabel.LEFT);
               //JLabel l2 = new JLabel("3 pt", new ImageIcon(im2), JLabel.LEFT);
               //JLabel l3 = new JLabel("5 pt", new ImageIcon(im3), JLabel.LEFT);
               brushSize.addItem(new PaintIcon(im1, 1));
               brushSize.addItem(new PaintIcon(im2, 3));
               brushSize.addItem(new PaintIcon(im3, 5));
               //brushSize.addItem("Other");
               add(fore);
               add(back);
               add(brushSize);
               PropertyChangeListener pl = new PropertyChangeListener() {
                    public void propertyChange(PropertyChangeEvent ev) {
                         Object src = ev.getSource();
                         if (src != fore && src != back) {
                              return;
                         Color c = (Color) ev.getNewValue();
                         if (ev.getSource() == fore) {
                              mColor1 = c;
                         else {
                              mColor2 = c;
               fore.addPropertyChangeListener("Color", pl);
               back.addPropertyChangeListener("Color", pl);
               fore.changeColor(Color.BLACK);
               back.changeColor(Color.WHITE);
               brushSize.addItemListener(new ItemListener() {
                    public void itemStateChanged(ItemEvent ev) {
                         System.out.println("ItemEvent");
                         if (ev.getID() == ItemEvent.DESELECTED) {
                              return;
                         System.out.println("Selected");
                         Object o = ev.getItem();
                         mBrushSize = ((PaintIcon) o).mSize;
               //Graphics g = im1.getGraphics();
               //g.fillOval(0, 0, 1, 1);
               //BufferedImage im1 = new BufferedImage();
               //BufferedImage im1 = new BufferedImage();
     protected class MListener extends MouseAdapter implements MouseMotionListener {
          Point mLastPoint;
          public void mouseDragged(MouseEvent me) {
               Graphics g = mImg.getGraphics();
               if ((me.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
                    g.setColor(mColor1);
               } else {
                    g.setColor(mColor2);
               Point p = me.getPoint();
               if (mLastPoint == null) {
                    g.fillOval(p.x - mBrushSize / 2, p.y - mBrushSize / 2, mBrushSize, mBrushSize);
                    //g.drawLine(p.x, p.y, p.x, p.y);
               else {
                    g.drawLine(mLastPoint.x, mLastPoint.y, p.x, p.y);
                    //g.fillOval(p.x - mBrushSize / 2, p.y - mBrushSize / 2, mBrushSize, mBrushSize);
                    double angle = MathUtils.angle(mLastPoint, p);
                    if (angle < 0) {
                         angle += 2 * Math.PI;
                    double distance = MathUtils.distance(mLastPoint, p) * 1.5;
                    if (angle < Math.PI / 4 || angle > 7 * Math.PI / 4 || Math.abs(Math.PI - angle) < Math.PI / 4) {
                         for (int i = 0; i < mBrushSize / 2; i ++) {
                              g.drawLine(mLastPoint.x, mLastPoint.y + i, p.x, p.y + i);
                              g.drawLine(mLastPoint.x, mLastPoint.y - i, p.x, p.y - i);
//                              System.out.println("y");
//                              System.out.println("angle = " + angle / Math.PI * 180);
                    else {
                         for (int i = 0; i < mBrushSize / 2; i ++) {
                              g.drawLine(mLastPoint.x + i, mLastPoint.y, p.x + i, p.y);
                              g.drawLine(mLastPoint.x  - i, mLastPoint.y, p.x - i, p.y);
//                              System.out.println("x");
//                    System.out.println("new = " + PaintUtils.printPoint(p));
//                    System.out.println("last = " + PaintUtils.printPoint(mLastPoint));
                    //System.out.println("distance = " + distance);
                    //Graphics2D g2 = (Graphics2D) g;
                    //g2.translate(mLastPoint.x + mBrushSize / 2, mLastPoint.y);
                    //g2.rotate(angle);
                    //g2.fillRect(0, 0, (int) Math.ceil(distance), mBrushSize);
                    //g2.rotate(-angle);
                    //g2.translate(-mLastPoint.x + mBrushSize / 2, -mLastPoint.y);
//                    g.setColor(Color.RED);
//                    g.drawRect(p.x, p.y, 1, 1);
               mLastPoint = p;
               g.dispose();
               repaint();
          public void mouseMoved(MouseEvent me) {}
          public void mouseReleased(MouseEvent me) {
               mLastPoint = null;
     private void handleResize() {
          Dimension size = getSize();
          mSizeChanged = false;
          if (mImg == null) {
               mImg = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
               Graphics g = mImg.getGraphics();
               g.setColor(getBackground());
               g.fillRect(0, 0, mImg.getWidth(), mImg.getHeight());
               g.dispose();
          else {
               int newWidth = Math.max(mImg.getWidth(),getWidth());
               int newHeight = Math.max(mImg.getHeight(),getHeight());
               if (newHeight == mImg.getHeight() && newWidth == mImg.getWidth()) {
                    return;
               BufferedImage bi2 = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_RGB);
               Graphics g = bi2.getGraphics();
               g.setColor(getBackground());
               g.fillRect(0, 0, bi2.getWidth(), bi2.getHeight());
               g.drawImage(mImg, mImg.getWidth(), mImg.getHeight(), null);
               g.dispose();
               mImg = bi2;
     public JToolBar getToolBar() {
          if (mToolBar == null) {
               mToolBar = new ToolBar();
          return mToolBar;
     private ToolBar mToolBar;
     public static void main (String args[]) {
          PaintArea pa = new PaintArea();
          JPanel parent = new JPanel();
          parent.setLayout(new BorderLayout());
          parent.add(pa, BorderLayout.CENTER);
          pa.setPreferredSize(new Dimension(150, 150));
          parent.add(pa.getToolBar(), BorderLayout.NORTH);
          WindowUtilities.visualize(parent);
     protected class CListener extends ComponentAdapter {
          public void componentResized(ComponentEvent ce) {
               mSizeChanged = true;
MathUtils.java
===========
* Created on Nov 7, 2004 by @author Tom Jacobs
package tjacobs;
import java.awt.Point;
* Simple math routines spelled out. There's euclideanDistance, factorial,
* combinations, distance.<p>
* Pretty standard really.
public class MathUtils {
     private MathUtils() {
          super();
     public static double euclideanDistance(Point p1, Point p2) {
          return Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2));
     public static int factorial(int x) {
          int pow = 1;
          while (x > 1) {
               pow = pow * x;
               x--;
          return pow;
     public static int getCombinations(int total, int picks, boolean replacing, boolean ordered) {
          int ans = 0;
          if (replacing && ordered) {
               ans = (int)Math.pow(total, picks);
               //total / Math.pow(totalpicks)
          else if (!replacing && ordered){
               ans = factorial (total);
               ans /= factorial(total - picks);
          } else if (replacing && !ordered) {
               ans = factorial(total + picks - 1);
               ans /= factorial(picks);
               ans /= factorial(total - picks);
          else if (!replacing && !ordered) {
               ans = factorial(total);
               ans/= factorial(picks);
               ans/= factorial(total - picks);               
          return ans;
     public static double distance (Point p1, Point p2) {
          return distance(p1.x, p1.y, p2.x, p2.y);
     public static double distance(double x1, double y1) {
          return distance(x1, y1, 0, 0);
     public static double distance (double x1, double y1, double x2, double y2) {
          return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
     public static double angle (Point p1, Point p2) {
          return angle(p1.x, p1.y, p2.x, p2.y);
     public static double angle (double x1, double y1, double x2, double y2) {
          double xdiff = x1 - x2;
          double ydiff = y1 - y2;
          double tan = xdiff / ydiff;
          double atan = Math.atan2(ydiff, xdiff);
          return atan;
     public static double reflectOff(double ray, double reflectOff) {
          return reflectOff + reflectOff - ray;
     //Testing only
/*     public static void main(String args[]) {
          System.out.println(reflectOff(0, Math.PI / 4) / Math.PI);
          System.out.println(reflectOff(Math.PI / 2, Math.PI) / Math.PI);
          System.out.println(reflectOff(5 * Math.PI / 4, Math.PI / 2) / Math.PI);
          System.out.println(reflectOff(Math.PI, Math.PI / 2));
WindowUtils.java
===============
package tjacobs.ui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.Popup;
import javax.swing.SwingUtilities;
public abstract class WindowUtilities {
     public static final int RESIZE_MARGIN_SIZE = 4;
     private static Window sExitWindow = null;
     public static interface CreatePopupWindow {
          public JDialog createPopupWindow(Point p);
     * Returns an point which has been adjusted to take into account of the
     * desktop bounds, taskbar and multi-monitor configuration.
     * <p>
     * This adustment may be cancelled by invoking the application with
     * -Djavax.swing.adjustPopupLocationToFit=false
    public static Point adjustPopupLocationToFitScreen(Component popup, Component invoker, int xposition, int yposition) {
     Point p = new Point(xposition, yposition);
        if(//popupPostionFixDisabled == true ||
                    GraphicsEnvironment.isHeadless())
            return p;
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Rectangle screenBounds;
        Insets screenInsets;
        GraphicsConfiguration gc = null;
        // Try to find GraphicsConfiguration, that includes mouse
        // pointer position
        GraphicsEnvironment ge =
            GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice[] gd = ge.getScreenDevices();
        for(int i = 0; i < gd.length; i++) {
            if(gd.getType() == GraphicsDevice.TYPE_RASTER_SCREEN) {
GraphicsConfiguration dgc =
gd[i].getDefaultConfiguration();
if(dgc.getBounds().contains(p)) {
gc = dgc;
break;
// If not found and we have invoker, ask invoker about his gc
if(gc == null && invoker != null) {
gc = invoker.getGraphicsConfiguration();
if(gc != null) {
// If we have GraphicsConfiguration use it to get
// screen bounds and insets
screenInsets = toolkit.getScreenInsets(gc);
screenBounds = gc.getBounds();
} else {
// If we don't have GraphicsConfiguration use primary screen
// and empty insets
screenInsets = new Insets(0, 0, 0, 0);
screenBounds = new Rectangle(toolkit.getScreenSize());
int scrWidth = screenBounds.width -
Math.abs(screenInsets.left+screenInsets.right);
int scrHeight = screenBounds.height -
Math.abs(screenInsets.top+screenInsets.bottom);
Dimension size;
size = popup.getPreferredSize();
if( (p.x + size.width) > screenBounds.x + scrWidth )
p.x = screenBounds.x + scrWidth - size.width;
if( (p.y + size.height) > screenBounds.y + scrHeight)
p.y = screenBounds.y + scrHeight - size.height;
/* Change is made to the desired (X,Y) values, when the
PopupMenu is too tall OR too wide for the screen
if( p.x < screenBounds.x )
p.x = screenBounds.x ;
if( p.y < screenBounds.y )
p.y = screenBounds.y;
return p;
     public static MouseListener addAsPopup(final CreatePopupWindow cpw, Component owner) {
          if (cpw == null || owner == null) {
               return null;
          MouseListener ml = new MouseAdapter() {
               CreatePopupWindow create = cpw;
               public void mousePressed(MouseEvent ev) {
                    testPopup(ev);
               public void mouseReleased(MouseEvent ev) {
                    testPopup(ev);
               private void testPopup(MouseEvent ev) {
                    if (ev.isPopupTrigger()) {
                         final JDialog pop = create.createPopupWindow(ev.getPoint());
                         //pop.setUndecorated(true);
                         if (pop == null) {
                              return;
                         Window w = SwingUtilities.getWindowAncestor(ev.getComponent());
                         pop.setLocation(ev.getX() + w.getX(), ev.getY() + w.getY());
                         pop.pack();
                         pop.addWindowListener(new WindowAdapter() {
                              public void windowDeactivated(WindowEvent we) {
                                   pop.dispose();
                         pop.setFocusableWindowState(true);
                         pop.setVisible(true);
                         pop.requestFocus();
                         //pop.show();
          owner.addMouseListener(ml);
          return ml;
     public static MouseListener addAsPopup(final JPopupMenu popup, Component owner) {
          if (popup == null || owner == null) {
               return null;
          //popup.setUndecorated(true);
          MouseListener ml = new MouseAdapter() {
               JPopupMenu pop = popup;
               public void mousePressed(MouseEvent ev) {
                    testPopup(ev);
               public void mouseReleased(MouseEvent ev) {
                    testPopup(ev);
               private void testPopup(MouseEvent ev) {
                    if (ev.isPopupTrigger()) {
                         //pop.setLocation(ev.getPoint());
                         //pop.pack();
                         //pop.setVisible(true);
                         //JPopupMenu pop = new JPopupMenu();
                         //pop.add(new JMenuItem("Hi"));
                         pop.show(ev.getComponent(), ev.getX(), ev.getY());
          owner.addMouseListener(ml);
          return ml;
     public static MouseListener addAsPopup(final JDialog popup, Component owner) {
          if (popup == null || owner == null) {
               return null;
          //popup.setUndecorated(true);
          MouseListener ml = new MouseAdapter() {
               Window pop = popup;
               public void mousePressed(MouseEvent ev) {
                    testPopup(ev);
               public void mouseReleased(MouseEvent ev) {
                    testPopup(ev);
               private void testPopup(MouseEvent ev) {
                    if (ev.isPopupTrigger()) {
                         pop.setLocation(ev.getPoint());
                         pop.pack();
                         pop.setVisible(true);
          owner.addMouseListener(ml);
          return ml;
     public static Point getBottomRightOfScreen(Component c) {
     Dimension scr_size = Toolkit.getDefaultToolkit().getScreenSize();
     Dimension c_size = c.getSize();
     return new Point(scr_size.width - c_size.width, scr_size.height - c_size.height);
     public static Window visualize(Component c) {
          return visualize(c, sExitWindow == null);
     public static Window visualize(Image im) {
          return visualize(new JLabel(new ImageIcon(im)));
     public static Window visualize (Component c, int width, int height) {
          return visualize(c, sExitWindow == null, width, height);
     public static Window visualize(Component c, boolean exit, int width, int height) {
          JFrame f;
          Window w;
          if (c instanceof Window) {
               w = (Window) c;
          else {
               f = new JFrame();
               f.getContentPane().add(c);
               w = f;
          // to be thread safe, this should be synchonized.
          // but it doesn't really matter in everyday situations
          if (sExitWindow == null) {
               sExitWindow = w;
          w.setSize(width, height);
          w.setLocation(100, 100);
          if (exit) {
               w.addWindowListener(new WindowClosingActions.Exit());
          w.setVisible(true);
          return w;          
     public void center(Window w) {
          Dimension dim = w.getSize();
          Dimension scr = Toolkit.getDefaultToolkit().getScreenSize();
          w.setLocation((scr.width - dim.width)/2, (scr.height - dim.height)/2);
     public static Window visualize(Component c, boolean exit) {
          JFrame f;
          Window w;
          if (c instanceof Window) {
               w = (Window) c;
          else {
               f = new JFrame();
               f.getContentPane().add(c);
               w = f;
          w.pack();
          w.setLocation(100, 100);
          if (exit) {
               w.addWindowListener(new WindowClosingActions.Exit());
          w.setVisible(true);
          return w;

Similar Messages

  • Tabbed canvas question...

    I have a tabbed canvas with 2 tab pages on it which is set on a master canvas. On the master canvas I have some items.
    How do i make it so when I click on an item not in the tabbed canvas that the tab shown on the tabbed canvas is the first one???
    Message was edited by:
    Ben Cramphorn

    i donno if i could actually understand your question correctly, but by what i cud make out, you want to progamatically goto the first tab page of the tab canvas by pressing a button in the main canvas,
    to do that u can write go_item(any_item_on_that_page), in the when button pressed trigger of the button in the main canvas.
    this will take you to the tab page, also set "raise on entry" property to TRUE of the tab canvas.
    i hope it works for u
    Regards,
    Mayank

  • Stacked Canvas question in Forms [32 Bit] Version 10.1.2.3.0 (Production)

    Hi Friends, I am not sure if my explanation will suffice for resolution to this easy problem that is causing me so much grief.
    I have a form with one content canvas ROOT_CNV, One tab canvas TAB_CNV with two tab pages and One STACK Canvas Stack_CNV.
    All these canvases are on one Window ROOT_WINDOW.
    The tab canvas (TAB_CNV) is tabular in nature.
    There is a menu button that you can press that switches one record in the tab canvas and place this record in the stack_cnv. All the fields on the stack_cnv are mirror_image of the Tab canvas record that is the items are synchronised.
    NOW THE PROBLEM. When you press the switch button and you are in the stack canvas and you try to query any record, the form will take you back to the tab canvas and the fields will freezes, there are lots of forms here with this functionality that woks, but I cannot figure out while this particular one is behaving lke this.
    I have made the Stack canvas smaller, however, the issue is till the same, I think it has to do with the stacking order and I had already rearrange this to know avail, any suggestion will be appreciated.
    Thank you.
    Tab canvas
    Page 1        Page 2
    *===== ========*
    record     proj              sub         Status
    *1 A 1 ACTIVE*
    *2 B 1 PENDING*
    *3 C 1 ACTIVE*
    *4 C 2 ACTIVE*
    Click on the Menu Icon on record 1, then the stack canvas shows up (Stack_CNV) in a form Format
    **STACK_CNV* Page1 Page2*
    *===== =======*
    Prog:       A                Sub  : 1
    Status :   ACTIVE
    The tab pages still shows up on the stack canvas which is okay, however, when you try to query from the stack canvas, it takes you back to the tab canvas and everything freezes. Both canvas are on Root_cnv content canvas.

    Hi Ade2
    Pls Create a KEY-ENTQRY trigger at the form level add the following code :
    GO_BLOCK('dept');
    CLEAR_BLOCK(no_commit);
    ENTER_QUERY;Hope this helps...
    Regards,
    Amatu Allah

  • TAB CANVAS Question

    Hiiii
    i want to ask if i can detrmine the number of Tabs to be shown at the tab page at the same Time and the the others to be in the List that appear with the Tabs when the TabPage is full ....

    I don't understand your question. When you are designing your form, you know the number of tabs that can be shown at the same time when you test the form. If you have too many tabs, then you can show some tabs and hide the others. You can use a tab or a button to show and hide a set of tabs.

  • Canvas Question

    I have a form with two canvases : one a content canvas, the other a tabbed canvas. The functionality I require from the form is for the two canvases to be displayed in one window where the content canvas contains the master block and (below that of the master) the tabbed canvas contains the detail blocks.
    I am facing a problem whereby only the first canvas shows at runtime; the tabbed canvas does not display...
    Any thoughts on how to solve this problem?

    Hai,
    If the positions of both canvases are same, then only 1 canvas can be seen (in which the cursor is pointed.)
    Check the properties Viewpoint X Position, Viewpoint Y Position, Viewpoint Width and Viewpoint Height.
    Regards,
    Manu.

  • How to draw with mouse on Html 5 canvas inside browser (using createJs).

    Hi Everyone,
    In Flash AS2/3 we can draw with mouse in browser (of course inside Flash Player). How can we do that in Flash CC Canvas using CreateJs (result must be in canvas not in flash player). Something like this http://www.codicode.com/art/how_to_draw_on_a_html5_canvas_with_a_mouse.aspx
    Thanks in Advance

    This is a bit more of a JavaScript / Canvas question than a Flash question. I realize you're using the Flash product but Flash CC is just giving you an IDE with limited JavaScript automation.
    In this mode you're expected to be familiar with JavaScript and CreateJS. Are you?
    If not, what you might want to do is look at a sister product for HTML5 Canvas automation called EaselJS. It's a JavaScript library that makes using the Canvas very easy. Have a look at the commands here:
    http://www.createjs.com/Docs/EaselJS/modules/EaselJS.html
    You might find you don't need Flash CC to perform what you want. Otherwise this conversation may tip so deeply into JavaScript and CreateJS that it might be more prudent to use the Dreamweaver forum.

  • JTextPane questions

    I have put JTextPane in JFrame with GridBagLayout.
    Questions:
    1) When I type text into JTextPane then the JTextPane control starts to expand size horizontaly. Why is this happening and how to make JTextPane not to change size when I type text in it?
    2) How to set margin in JTextPane? I have tried setMargin() but nothing
    happens.
    3) How to change attributes of some text already in JTextPane?

    I don't understand your first message at all
    abillconsl.
    As for my 1) question I have found a solution with
    setPrefferedSize and using JScrollPane.
    Can someone help on 2) and 3) question?My first post was code that, if you were to run it,
    you'd see that the JTextPane does not expand with
    your keying in.
    My second post was adding additional information and
    attempting to explain that I could not code anything
    closer than that to what you need because you did not
    give enough detail; and any other threads you might
    have made that seem to have been alluded to in this
    thread I have no knowledge of.
    At any rate, I made an attempt to help you out, and
    you could say thank you ... that would be nice. Ditto
    for puckstopper31
    ~BillI really appreciate your help, I didn't mean to say anything bad.
    Thanks!
    Message was edited by:
    BobMil

  • Follow up question about image not looking good in canvas-Shane?

    I guess this is a follow up question for Shane....
    You wrote this in response to someone a year ago which helped me out.
    Shane's Stock Answer #49 - Why is the quality different between what I see in the Viewer and what I see in the Canvas?
    Well... the viewer is just that-- a viewer. It will display anything that fcp will recognize as usable video or graphics. The canvas is a viewer too, but at the pixel dimension specified by the settings of your project and sequence.
    For example, if your graphic or footage is much higher resolution than your 720x480 DV sequence, FCP is interpolating down your file to fit the settings of the sequence. Usually this makes it look not so hot. DV is a 5:1 compression working with a 4:1:1 color depth. Your pristine picture images and graphics are being crushed.
    Same with picture files. HIgh res pics now adopt the sequence settings and will render to those specs, and most likely they are not as high quality.
    So, based on your answer, I made an HDV sequence, dropped my DVCPro50-NTSC footage and my tiffs into the sequence and now the stills look great. Is this an okay workaround or do you have another suggestion? I'm worried about this HD sequence taking too long to make a compressed QT from in the end.
    Thanks!

    Photo JPEG is a good option.  But this all depends on what your final output will be.  If you are going to make a DVD, then that is SD, so using an HD sequence setting makes no sense.  Photo JPEG is good, but not realtime in FCP.  DV50 or ProRes NTSC are good options.
    Unless you are making an HD master...in which case ProRes 422 for HD is good

  • A few questions about Canvas and other Image related stuff.

    I am just starting to play around with Canvas in the hopes of using it to make a little game (not an applet) in my spare time. I have gotten a ball to bounce around the screen and switch colors when it bounces without too much work. (hooray for me!).
    I was wondering:
    1) If you always have to repaint the whole area of the canvas, or can you repaint sections of the screen?
    2) Can there only be one canvas per frame, or if you can have more, like say, one for each sprite (I tried in my own simplistic way but the second canvas overrode the first when I added it to the frame) or do you have to lay out all the sprites in one canvas every time before you paint?
    3) Is Canvas the best platform for rendering my animations and doing collision detection, or are other ways of presenting the images better? By better I mean lower usage of resources, higher speed, accessibility of events that occur. (I have read in the mindprod java glossary "[Canvas] receives all the raw mousing events. Panels, in contrast, see only a few.")
    4) In a call to paint which tells it to display some images which are much larger than the frame the canvas is in, is time and effort spent working on those pixels that aren't displayed or does it take about the same amount of resources as for images that fit in the frame since the same amount of picture is actually displayed?
    5) Is there any convenient way to layers with canvas besides just controlling the order in which the images are painted. (I will admit I haven't searched for this information yet, because I just thought about it.)
    6) Is there any other information you guys would care to bestow on me?
    If any of this question is ridiculous, obvious, ignorant or any other negative adjective, then I apologize. I will continue messing around in the meantime.
    Thanks
    --John                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Okay, well I got it to work by drawing them both to the same canvas. duh I guess.
    Can you have more than one canvas in a frame? How do you set the size if so.
    How do I implement the z-order? I thought of doing it manually by sending the paint method a list of objects to paint and manually managing the order of that list. Would that be an acceptable way to do it?
    Should I only be trying to paint to one canvas? What I would like to do is have several canvases with transparent backgrounds so that I can draw different layers in the same frame. That way flying stuff would be painted on a different canvas than stuff on the ground, and then putting it all in a frame would tie the pictures together into a scene. Kind of like how they do distance in animation by having different layers of drawings on clear plastic that they can move at different speeds to give the illusion of depth.
    Any advise? Sorry for the douba-post
    Thanks
    --John                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Canvas/Viewer Zooming past 100% question?

    When I zoom the Canvas or Viewer past 100%, I think I should start to see actual pixels. By the time I get to 800%, I should be able to see the actual pixels, albeit very small. When I do this with Apple Intermediate or Apple ProRes MOV's, at like 800% I see what looks like VERY smoothed pixels. Is my output going to look like that? When I convert my input with a 3rd party codec such as CineformHD at the same resolution (I'm using 1920x1080 with all codecs), and when I zoom in, I start to see the pixel structure as I'm used to in Photoshop. I like it much better when I see the pixel structure.
    Is FCP actually smoothing the view with the Apple codecs because it thinks it looks better with a smoother view? (Though when I make a change in the video parameters, for a brief second, you actually see the pixels then it switches back to the smooth view.)
    I guess the question is, is that what its doing--smoothing? And the second is, can I make it so that the apparent "smoothing" doesn't happen? Thanks.

    Final Cut Pro's Canvas always shows a low-res proxy to conserve resources for real time playback.
    To truly assess your video quality, you need a calibrated external monitor.

  • JDAPI with multi canvas form and LAF questions

    I'm trying to use jdapi to apply LAF project on my forms, it works great with simple forms, but with multi canvases and blocks form it doesn't apply LAF for all of them. I can follow the code of the done one for the rest, but i have questions:
    do i have to set a different bean for each block?
    who overrides, the bean or the property set for the item?
    and sorry i have another questions concerning LAF:
    can i define a new scheme, and if yes, how?
    if i want to show an image for a button, the path should be relative to what? as till now i failed to set an image for a button.
    Thanks

    Hello,
    I have just tested and the result is OK.
    I have built a Forms module with 2 content canvases, each one containing a block.
    After running the JDAPI_LAF tool, the new module contains a LAF_BLOCK with two Bean area, each one one a different canvas.
    <p>Concerning the image on the button, the syntax is explained in the documentation</p>
    See the SET_IMAGE method.
    Francois

  • Motion canvas on a second monitor question

    Ok, so after jumping through multiple flaming hoops to get the app store to update motion to 5.0.1 i have a question concerning one of the "improvements"
    Putting your canvas on a second monitor.  Is there a way to do so WITHOUT the toolbar going with it?  Please?  Awww come on?!?  

    Well, why?  The tool bar is full of the tools you use in the Canvas itself.  Why would you want to move them far away from the Canvas?  I don't see that it would make sense to move the tools used in the Canvas and Layers pane to a different monitor where they're NOT used.
    The F8 function also quickly switches to a really nice setup hiding the Inspector and Layers panes.

  • Another canvas related question

    Here is my scenario:
    I have content canvas (say CC), a stacked canvas (SC) and a tab canvas (TC). On the CC, I have the TC always showing in the bottom half. In the upper half of the CC, I have some text items, list items etc always showing.
    When the user selects certain options of the drop down lists in the CC and/or TC, I want to display the stacked canvas(SC) while still displaying the TC in the bottom half of the CC. SC has only a text item and an ok button on it. This text field is to capture the comments of the user. What I am trying to accomplish is to capture the user comments from the SC, assign it to a data block item when the user clicks on the 'ok' button on the SC and then hide the SC. Since there are multiple drop down list items in the SC and TC, I plan to re-use the same SC to capture the comments. Don't know if this is a good way to do it and if it can be accomplised or not. Any suggestions/ideas are appreciated.
    The issue that I am facing is when I display the SC upon changing a list item in the CC, then the TC
    disappears.Neither does the SC appear with the text box and the ok button on it.
    1. I am using the show_view to display the SC.
    2. For the SC properties itself, I set the
    Raise on entry =NO, '
    visible = 'YES'
    3. All the canvases share the same WINDOW
    4. My canvases are ordered in the following order
    SC
    CC
    TC
    5. Using forms 6i.
    Pardon my ignorance about the workings of the canvases (I always struggled to understand how the various canvases work). Also, these questions were probably asked many times before....but figured might re-ask. Pls. excuse my laziness in this regard.
    Questions:
    1. Can I have all the 3 canvases showing at a same point in time? (does reports allow that?)
    2. Has any one implemented what I am trying to accomplish? If yes, how did you do it?
    Edited by: Megastar_Chiru on Jul 13, 2010 11:30 AM
    Edited by: Megastar_Chiru on Jul 13, 2010 11:33 AM

    If the "TC" disappears, maybe the SC overlaps it.
    If the SC isn't displayed, try using a GO_ITEM('THE_TEXT_ITEM'); instead of using SHOW_VIEW.
    Another option might be:
    Create a second form and put the "comment-field" on a canvas in that form. In the WHEN-LIST-CHANGED-trigger where you actually show the SC, do a CALL_FORM to that new form to capture the users comment and proceed when the called form is ended.

  • Canvas "View" Question - FCP 6.05

    FCP version 6.05 - A question about the canvas (and viewer also) window "view" choices. Please refer to the lefthand-most pop up menu (located between the time code windows.) While I keep my canvas and viewer set to "Fit to Window", I would like a clarification of "Correct for Aspect Ratio" at the bottom of the view choices. What exactly is being corrected? At times this line is grayed out; others not. It's not covered in the manual (at least I cannot find it), nor can I find it in the APTS book

    Video pixels are not square (unlike the way computers display pixel). Video pixels in a 4:3 frame are narrower than tall and those in a 16:9 are wider than tall. If you are shooting DV/NTSC, both images are 720x480 pixels.
    Using "correct for aspect ratio", will display the images using non-square pixels - ie as your television will display the image.
    If you do not select "correct" the image will be displayed using square pixels with the result that a 4:3 image will be stretched horizontally and the 16:9 image will be squished horizontally.
    x

  • Question about image size, canvas size and Picture frame

    Hi,
    This has always been a little confusing so let me describe what my question is:
    Assume I have a created a new PSD that is 8 1/2 x 11.
    The canvas size is the same 8 1/2 x 11.
    I want to put a border around the picture (say 1/2 of an inch all around), and put the finished picture in a Picture frame.  After it is in the frame, you would be able to see the entire picture plus the border.
    Q.  Should I change (reduce image size) of the PSD to (for this example), 8 x 10 1/2.      Then increase the canvas size to 8 1/2 x 11.  After I increased the canvas size, do a  Paint Bucket fill with white (to create the White border)?  then print the changed size PSD on 8 1/2 x 11 paper so that it will fit into a 8 1/2 x 11 picture frame
    I realize I could have just created the new PSD to be 8 x 10 1/2 in the first place.
    Hope I made this somewhat clear.
    Bob

    1: Decrease the size as you describe.
    2. Go to File>New or Ctrl N
    3. Make the box 8.5x11. Make sure the other data conforms to your image.
    4. Now,holding down Ctrl-Shift, Drag the image to the new box and release the mouse. Your image will be centered in the box.
    Note: there may be a method to do this including any adjustment layers, but I usually only do this as a last step, flattening a copy of the working file.

Maybe you are looking for