How to resize painted components

Hi All,
I am working on a simple project called "WhiteBoard" which is veryu similar to MS-Paint. Could anyone please tell me how to resize the components which I have drawn on the panel. Thanks in advance.
Regards,
Shankar.

Cast the Graphics instance passed to the paintComponent() method of your board to a Graphics2D.
Then use the scale(double sx, double sy) method of the Graphics2D instance to zoom
your board in or out.
IMPORTANT NOTE: If you use a mouse listener on the board, you'll have to convert the mouse
coordinates according to the zoom factor.

Similar Messages

  • How to resize the components in a JFrame when the JFrame Resizes?

    Hi all,
    i have some problems with my app. I have set the JFrame resizable and that works fine for the JFrame but not for the components in the JFrame.
    So my question is how can i set the components in a JFrame to resize automatically when the JFrame resizes?
    Here are the important things from my code,...if you need more, just let me know, its my first post in a forum .
    Its a JFrame with a JTabbedPane and on the Tabs are Panels with buttons and Tables.
    Thank you in advance!
    public class MainMonitor extends JFrame {
    public MainMonitor() {
              super();
              initialize();
              setVisible(true);
         private void initialize() {
              this.setSize(1145, 785);
              this.setIconImage(Toolkit.getDefaultToolkit().getImage("Images/c.gif"));
              this.setContentPane(getJContentPane());
              this.setTitle("Company Manager");
              this.setResizable(true);
              this.setLocationRelativeTo(null);
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(null);
                   jContentPane.setOpaque(true);
                   jContentPane.add(getJTabbedPane(), null);
                   jContentPane.add(getJPanel11(), null);
              return jContentPane;
         private JTabbedPane getJTabbedPane() {
              if (jTabbedPane == null) {
                   jTabbedPane = new JTabbedPane();
                   jTabbedPane.setLocation(new Point(6, 69));
                   jTabbedPane.setSize(new Dimension(1120, 684));
                   jTabbedPane.addTab("P", null, getJPanel(), null);
                   jTabbedPane.addTab("K", null, getJPanel1(), null);
                   jTabbedPane.addTab("B", null, getJPanel2(), null);
              return jTabbedPane;
         

    Giasaste wrote:
    Thanks a lot, i didnt knew that the Layout Manager is a must.It's not a must, but it is the way to allow your app to be resized nicely and makes it much easier to maintain and enhance your program. Imagine creating a complex gui then later decide that you want another radiobutton and to remove a jlabel / jtextfield pair. with layout managers a chore becomes easy.

  • FI-SL How to define  formula components ID(report painter)

    Hi Experts
    please teach me how to define formula components ID.(it is related to report painter)
    I cannot see by GS13(variable)
    Regards.

    I sloved by myself. it automatically made when I add the row or culumn.
    but after delete the  row or culumn. it may have a problem.... I do not know.
    thanks.

  • Scaling / Resizing Catalyst Components in Builder

    Hi,
    I'm looking at setting up the proper workflow for a large project. We envision multiple developers and multiple designers on the project.
    The major sticking point now is scaling and resizing the components generated by Catalyst once they're in Builder. One would think that once you've skinned, for example, a scrollbar in Catalyst that you could then resize it in Builder to match different layouts.
    However, as I suspect you already know, the sizes do not change at all in Builder.
    We can get into the source code in builder and add in a bunch of width/height = 100% attributes, but these break down at the point that there are Paths defined in the code. The Path elements would need to be re-coded to scale.
    So, I really have two questions:
    1) What exactly does "Convert to Optimized Graphic" do? Will this recreate all Paths to standard shapes that will scale?
    2) Is there a better system coming in the next Beta? If so, can you describe it a bit?
    Thanks a lot,
    Kirk

    This morning I sat down to use catalyst for the first time. I am preparing for a talk at Flash on The Beach in Brighton this year and I was hoping to be able to show how a view build in Catalyst could be injected into an app using Robotlegs.
    I watched http://tv.adobe.com/watch/adc-presents/create-spark-component-skins-using-flash-catalyst and thought that looked cool.
    I also watched http://tv.adobe.com/watch/flash-catalyst-cs5-feature-tour/sending-your-project-to-a-develo per, and saw the component library output looked awesome.
    So I started to build an interface, first by creating a custom button component (much like the first video) and then distributing those buttons in a completely custom button holder component. It is this button holder that would be injected, and in the holder each button would have an id so that references to them could be obtained after injection into the application.
    From the videos above this looked eminently doable and quite a good workflow. Designer design and layout components that get built into a library, and developers use those components in an application without actually recoding the components.
    This sounded great, but imagine my dissapointment when I discovered
    1) A custom component can not be resized in the design view of Catalyst - you have to create another component class with a different size!
    2) A component/skin developed in Catalyst can not even resize when imported into Flash Builder unless you recode it.
    3) You can't name instances of components in the design view.
    So my plan was completely foiled. I mean, surely a button skin/component can not be considered a button skin/component unless it can be resized!
    I like Flex and I think Flex 4 is a big step forward, however I have never met a designer who liked it. Designers cannot effectively layout applications themselves using Flex. In fact where I work they are pushing to prevent ANY future flex development because of the problems with designers not being able to do this (we make and maintain some very highly skinned Flex 3 applications). I am the only front end Flex developer there and anytime I start to develop in Flex it is seen as very awkward and a problem.
    I hoped that Catalyst would solve some of these problems, but it unfortunately fails dismally because of the above problems that I mentioned.
    These three things would go a long way to improving developer design workflow for Flex and Catalyst. Any ideas for if/when this functionality might be included?

  • I can't figure out how to resize my picture for my home or lock screens.

    I can't figure out how to resize my picture for my home or lock screens. It shouldn't be his difficult. Any suggestions? I'm running the latest software. Thanks.

    whichever app store you are connecting to, hyou need a credit card with an address in that country. Also, itunes gift cards must be in local currency too.
    If you are in japan, you need to use the japan app store

  • How to resize a jpg/gif file to a fix size using jimi ?

    I have search from the web and didn't find any example on doing this.
    Can any one give example on how to resize a jpg image. let say 120x240
    to a fixed size 40x40 ?
    thank you

    Hi.
    When you got that image in form of a file, just load it and invoke the image's getScaledInstance(...)-method.
    Here's how it could work:
    import java.awt.*;
    public class Test {
    public static void main(String[] argv) {
      // define where the image comes from:
      URL toImage = new URL("file:/C:/test.jpg");  // or the like
      // get the image:
      Image image = Toolkit.getDefaultToolkit().createImage(toImage);
      // scale the image to target size (40x40 here):
      Image smallImage = image.getScaledInstance(40, 40, Image.SCALE_DEFAULT);
      // you might want to do other things like displaying it afterwards
    }HTH & cheers,
    kelysar

  • How to resize a table in Pages 5?

    How to resize a table in Pages 5? It can be resized vertically but not horizontally.

    stuart13 wrote:
    How to resize a table in Pages 5? It can be resized vertically but not horizontally.
    The controls are in the Format panel, Arrange Tab.
    Jerry

  • 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

  • How to resize a photo from CameraUI?

    Hi there,
    i really need som help here. I cant seem understand how to resize an still image taken with the camera. Here are the code so far(also with the upload part). I just need a thumbnail to be uploaded to the server, not the HQ-image. Any ideas?
              Simple AIR for iOS Package for selecting a cameraroll photo or taking a photo and processing it.
              Copyright 2012 FIZIX Digital Agency
              http://www.fizixstudios.com
              For more information see the tutorial at:
              http://www.fizixstudios.com/labs/do/view/id/air-ios-camera-and-uploading-photos
              Notes:
              This is a barebones script and is as generic as possible. The upload process is very basic,
              the tutorial linked above gives information on how to post the image along with data to
              your PHP script.
              The PHP script will collect as $_FILES['Filedata'];
              import flash.display.MovieClip;
              import flash.events.MouseEvent;
              import flash.events.TouchEvent;
              import flash.ui.Multitouch;
        import flash.ui.MultitouchInputMode;
              import flash.media.Camera;
              import flash.media.CameraUI;
              import flash.media.CameraRoll;
              import flash.media.MediaPromise;
        import flash.media.MediaType;
              import flash.events.MediaEvent;
              import flash.events.Event;
              import flash.events.ErrorEvent;
              import flash.utils.IDataInput;
              import flash.events.IEventDispatcher;
              import flash.events.IOErrorEvent;
              import flash.utils.ByteArray;
              import flash.filesystem.File;
              import flash.filesystem.FileMode;
              import flash.filesystem.FileStream;
              import flash.errors.EOFError;
              import flash.net.URLRequest;
              import flash.net.URLVariables;
              import flash.net.URLRequestMethod;
                        // Define properties
                        var cameraRoll:CameraRoll = new CameraRoll();                                        // For Camera Roll
                        var cameraUI:CameraUI = new CameraUI();                                                            // For Taking a Photo
                        var dataSource:IDataInput;                                                                                          // Data Source
                        var tempDir;                                                                                                                        // Our temporary directory
                        CameraTest() ;
                        function CameraTest()
                                  Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
                                  // Start the home screen
                                  startHomeScreen();
                        // =================================================================================
                        // startHomeScreen
                        // =================================================================================
                        function startHomeScreen()
                                  trace("Main Screen Initialized");
                                  // Add main screen event listeners
                                  if(Multitouch.supportsGestureEvents)
                                            mainScreen.startCamera.addEventListener(TouchEvent.TOUCH_TAP, initCamera);
                                            mainScreen.startCameraRoll.addEventListener(TouchEvent.TOUCH_TAP, initCameraRoll);
                                  else
                                            mainScreen.startCamera.addEventListener(MouseEvent.CLICK, initCamera);
                                            mainScreen.startCameraRoll.addEventListener(MouseEvent.CLICK, initCameraRoll);
                        // =================================================================================
                        // initCamera
                        // =================================================================================
                        function initCamera(evt:Event):void
                                  trace("Starting Camera");
                                  if( CameraUI.isSupported )
                                            cameraUI.addEventListener(MediaEvent.COMPLETE, imageSelected);
                                            cameraUI.addEventListener(Event.CANCEL, browseCancelled);
                                            cameraUI.addEventListener(ErrorEvent.ERROR, mediaError);
                                            cameraUI.launch(MediaType.IMAGE);
                                  else
                                            mainScreen.feedbackText.text = "This device does not support Camera functions.";
                        // =================================================================================
                        // initCameraRoll
                        // =================================================================================
                        function initCameraRoll(evt:Event):void
                                  trace("Opening Camera Roll");
                                  if(CameraRoll.supportsBrowseForImage)
                                            mainScreen.feedbackText.text = "Opening Camera Roll.";
                                            // Add event listeners for camera roll events
                                            cameraRoll.addEventListener(MediaEvent.SELECT, imageSelected);
                                            cameraRoll.addEventListener(Event.CANCEL, browseCancelled);
                                            cameraRoll.addEventListener(ErrorEvent.ERROR, mediaError);
                                            // Open up the camera roll
                                            cameraRoll.browseForImage();
                                  else
                                            mainScreen.feedbackText.text = "This device does not support CameraRoll functions.";
                        // =================================================================================
                        // imageSelected
                        // =================================================================================
                        function imageSelected(evt:MediaEvent):void
                                  mainScreen.feedbackText.text = "Image Selected";
                                  // Create a new imagePromise
                                  var imagePromise:MediaPromise = evt.data;
                                  // Open our data source
                                  dataSource = imagePromise.open();
                                  if(imagePromise.isAsync )
                                            mainScreen.feedbackText.text += "Asynchronous Mode Media Promise.";
                                            var eventSource:IEventDispatcher = dataSource as IEventDispatcher;
                                            eventSource.addEventListener( Event.COMPLETE, onMediaLoaded );
                                  else
                                            mainScreen.feedbackText.text += "Synchronous Mode Media Promise.";
                                            readMediaData();
                        // =================================================================================
                        // browseCancelled
                        // =================================================================================
                        function browseCancelled(event:Event):void
                                  mainScreen.feedbackText.text = "Browse CameraRoll Cancelled";
                        // =================================================================================
                        // mediaError
                        // =================================================================================
                        function mediaError(event:Event):void
                                  mainScreen.feedbackText.text = "There was an error";
                        // =================================================================================
                        // onMediaLoaded
                        // =================================================================================
                        function onMediaLoaded( event:Event ):void
                                  mainScreen.feedbackText.text += "Image Loaded.";
                                  readMediaData();
                        // =================================================================================
                        // readMediaData
                        // =================================================================================
                        function readMediaData():void
                                  mainScreen.feedbackText.text += "Reading Image Data.";
                                  var imageBytes:ByteArray = new ByteArray();
                                  dataSource.readBytes( imageBytes );
                                  tempDir = File.createTempDirectory();
                                  // Set the userURL
                                  var serverURL:String = "http://www.hidden_in_this_example.com/upload.php";
                                  // Get the date and create an image name
                                  var now:Date = new Date();
                                  var filename:String = "IMG" + now.fullYear + now.month + now.day + now.hours + now.minutes + now.seconds;
                                  // Create the temp file
                                  var temp:File = tempDir.resolvePath(filename);
                                  // Create a new FileStream
                                  var stream:FileStream = new FileStream();
                                  stream.open(temp, FileMode.WRITE);
                                  stream.writeBytes(imageBytes);
                                  stream.close();
                                  // Add event listeners for progress
                                  temp.addEventListener(Event.COMPLETE, uploadComplete);
                                  temp.addEventListener(IOErrorEvent.IO_ERROR, ioError);
                                  // Try to upload the file
                                  try
                                            mainScreen.feedbackText.text += "Uploading File";
                                            //temp.upload(new URLRequest(serverURL), "Filedata");
                                            // We need to use URLVariables
                                            var params:URLVariables = new URLVariables();
                                            // Set the parameters that we will be posting alongside the image
                                            params.userid = "1234567";
                                            // Create a new URLRequest
                                            var request:URLRequest = new URLRequest(serverURL);
                                            // Set the request method to POST (as opposed to GET)
                                            request.method = URLRequestMethod.POST;
                                            // Put our parameters into request.data
                                            request.data = params;
                                            // Perform the upload
                                            temp.upload(request, "Filedata");
                                  catch( e:Error )
                                            trace(e);
                                            mainScreen.feedbackText.text += "Error Uploading File: " + e;
                                            removeTempDir();
                        // =================================================================================
                        // removeTempDir
                        // =================================================================================
                        function removeTempDir():void
                                  tempDir.deleteDirectory(true);
                                  tempDir = null;
                        // ==================================================================================
                        // uploadComplete()
                        // ==================================================================================
                        function uploadComplete(event:Event):void
                                  mainScreen.feedbackText.text += "Upload Complete";
                        // ==================================================================================
                        // ioError()
                        // ==================================================================================
                        function ioError(event:Event):void
                                  mainScreen.feedbackText.text += "Unable to process photo";

    1. Create a BitmapData of the correct size of the full image
    2. Use BitmapData.setPixels to create pixel data from your byteArray
    3. Make a new Bitmap, Bitmap.bitmapData = BitmapData
    4. Create a matrix with the correct scaling factors for your thumbnail
    5. Create a new BitmapData the size of your thumb
    6. Use BitmapData.draw to draw your image data from the Bitmap to the new BitmapData with the scaling matrix
    7. Use BitmapData.getPixels to create a bytearray from your thumb BitmapData
    8. save it
    You'll have to look up the AS3 reference to see how all these methods work.

  • As a JSF Developer, I want to understand technically how the JSF View Components are rendered as html and how there events are binded to Server.I want to know each Java Class that is involved in flow.

    As a JSF Developer, I want to understand technically how the JSF View Components are rendered as html and how there events are binded to Server.I want to know how flows goes to the server and server understands the method which is to be called of managed bean. I know it is with annotation @ManagedBean and method name, but how Call is binded with annotation @ManagedBean.
    In short, i want to know the internal implementation of JSF Framework.

    As a JSF Developer, I want to understand technically how the JSF View Components are rendered as html and how there events are binded to Server.I want to know how flows goes to the server and server understands the method which is to be called of managed bean. I know it is with annotation @ManagedBean and method name, but how Call is binded with annotation @ManagedBean.
    In short, i want to know the internal implementation of JSF Framework.

  • How to change the components in a visible JPanel?

    How to change the components in a visible JPanel?
    Is there any way to change the components in a JPanel while it is already visible in a JFrame? I tried the na�ve approach of removing the components and adding new ones, but the effect is not the expected.
    For now I'm opening new frames with newly created panels.

    After adding/removing components to/from a panel try:
    panel.revalidate();
    panel.repaint() // sometimes this is also needed, I'm
    not sure whyI'm not certain, but I think that panel.revalidate() implicitly calls repaint() only if something actually changed in the layout. If nothing changed, it sees no reason to repaint; hence, if something changed in appearance but not in layout, you have to repaint it yourself.
    Or something like that. I'm no expert. ;)

  • How to resize my monitor resolution in OS X 10.5.8

    Hello I have a question I am new to mac and I was trying to resize my desktop resolution. I'm using a 720i TV utilizing the HDMI and using the convertor to make it DVI and for some reason when I use the 720 resolution its all off center and it won't let me resize it like it does in Windows but it works when i have it at 1280 x 960 problem is I don't want that resolution it doesn't look as good on my TV. I have tried everything and can't find any software that will allow me to do this. And I use the same monitor for my Windows machine and it works perfect PLEASE HELP

    Yeah..... I know that I want to know how to resize a resolution the 1280 x 720 doesn't show up right it's making everything go off the sides so I can't see everything on my desktop in windows my nvidia control panel would allow me to resize my monitor to fit any resolution i want to know how to do that on a mac

  • How to resize all pages -Acrobat 9 Pro Extended ? ?

    I came across a pre-existing pdf file of an old book of genealogy.  According to the front pages, it was 'Digitized by Microsoft', so I know nothing on how it was generated.  Total pages are in excess of 1,100.
    In viewing the pages, they are reflected as 2 pages to a view; not the book opened with the spine in the middle, but images side by side ... in numerical order ... and they appear as a normal sized 2 page for that view.  When I print out a page, by number, it also prints out in a normal size on an 8x11 inch sheet of paper.
    However, rather than print page by page on individual sheets of paper, I want to print out multiple pages, 2 to a sheet of paper.  In doing this, the images of the pages come up as 3x5 inch; thus not readable if printed without the usage of magnifier.
    Not that familiar with the program, but tried to do a resize process by setting some adjustments and then to a new pdf file.  It did not change that much ... and increased the file size dramatically.
    I am a novice to these processes.  Can someone advise how to resize the whole file, with images of pages side by side, so that when multiple print is used for 2 pages the size comes up closer to something like 5x7 inch each?
    Thanks

    Let me try it this way.....
    1.  The pdf file, when initially opened up, in the opening view shows 2 simotaneous pages side by side ... with hardly a divider between them.  This at this point has nothing to do with the print mode.
    2.  The book in question was 'Digitized by Microsoft' ... don't know if that makes any difference, but thought it would help to under stand that it was not created by the normal Adobe Acrobat method.
    3.  Now, when I go to the Print mode, from where I just viewed the 2-side-by-side pages, the initial view there, for 'page', is just 1 page ... not the 2 page view I just came from ... and it will print out this view in a full sheet version.
    4.  But, not wanting to print out 1130 pages, want to print multi-page as allowed under Acrobat options.
    5.  So choose multi-page and 2 pages and "Print to printable area"..
    6.  When this option appears in the print viewing window, the 'images' (presuming that to be the correct reference) are small, over the normal (roughly) 5 x 7 inch (each) for a 2-page print option.
    7.  With the 2-page print option, the images are only 3.5 x 5.25 inches ... rather than something like 5 x 7 inch ... which is difficult to read without a magnifier.  [Note:  This 3.5 x 5.25 is as indicated in Properties that the original 'Digitizing' did.
    8.  So, in essence, how can one change the default individual image size from 3.5 x 5.25 inch size, to something closer to 5 x 7 inch size ... so that each image fills in more of it's half of the 8.5 x 11 inch page being printed ... rather than the small size reflected in the attached jpg ?
    I've attached a jpg of the print screen, and one of the 2 page side-by-side 'default' view in Acrobat.
    Thanks

  • How to transfer Painter 12 with my custom brushes from old iMac to a new iMac both running Mavericks

    Hi,
    I just purchased a new iMac. Have Painter 12 on my older iMac and want to be able to transfer Painter 12, with my custom brushes to my new iMac. Tried Airdrop but got a message that it was damaged and that I should trash it. Does any know how to get  Painter 12 with all my custom brushes to my new machine? Both are running Mavericks.
    Thank you,
    Jim

    etresoft,
    Thank you for your response. I did try to use Migration Assistant and I got as far as the two machines trying to communicate with each other. So I guess the answer to your question would be I tried, I failed and it worked until a certain point. I understand that there are other ways to connect the machines, I would have to see if I have the proper cables to do so. Airdrop did get data to my new machine and that tells me that they do see each other on the network. I do not know why they did not see each other via Migration Assistant. I assume that I could go to Corel's site and download Painter 12 to my new machine, ( my new machine does not have a disk drive ), but I will not have my custom brushes etc. and would have to totally make them up in the fresh install version and I am trying to avoid that.
    You are probably correct in saying that Painter 12 probably needs a full reinstallation to work properly. Am I to assume that Migration Assistant will do a full reinstallation, including my custom brushes? I guess I am a little confused here.
    Jim

  • Confused about how to use paint()

    Hi, I have been working really hard to try to get the following program to work but I am really confused on how to use paint(). I do not have anyone to ask so I thought this forum could help. Anyways, here is my problem...
    I am trying to recursively figure out the Sierpinski fractal. I cannot figure out if my math works or not because I do not know how to call the paint() recursively to draw my triangles.
    Please have a look at the following code. Thank you!
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    public class DrawTriangle extends Frame {
      Point a = new Point(20,480),
            b = new Point(350,40),
            c = new Point(680,480),
            halfB,
            halfC,
            halfB2,
            halfC2,
            halfC3;
      int width;
      public DrawTriangle() {
        super("Sierpinski Fractal");
        addWindowListener( new WindowAdapter() {
          public void windowClosing( WindowEvent we ) {
            dispose();
            System.exit( 0 );
        setBackground( Color.white );
        setSize(700, 500);
        setVisible(true);
      public void paint(Graphics g, Point a, Point b, Point c) {
        width = c.x - a.x;
        if (width < 6){return;}
        g.setColor( Color.GREEN );
        g.drawPolygon( new int[] { a.x, b.x, c.x }, new int[] { a.y, b.y, c.y }, 3 );
        halfC.x = c.x/2;
        halfC.y = c.y;
        halfB.y = b.y/2;
        halfB.x = b.x;
        halfB2.y = halfB.y + a.y;
        halfB2.x = a.x;
        halfC2.x = halfC.x + a.x;
        halfC2.y = a.y;
        halfC3.x = halfC.x/2 + a.x;
        halfC3.y = halfB2.y;
        paint(g, a, halfC, halfB);
        paint(g, halfC3, halfC, halfB);
        paint(g, halfC2, halfC, halfB);
      public static void main(String[] args) {
         new DrawTriangle();

    thanks jsalonen, your tip let me start working on the math to correct it.
    I have a new problem now. My math is correct but I am having problems with the recursion. I can draw only the top , left , or right triangles. I cannot get them all to work together. See code and comments below.
    Any ideas why I cant call all three of the paint()s toegther and have them work?
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    public class DrawTriangle extends Frame {
      Point a = new Point(20,480),
            b = new Point(350,40),
            c = new Point(680,480),
            halfA,
            halfB,
            halfC;
      int width;
      public DrawTriangle() {
        super("Sierpinski Fractal");
        addWindowListener( new WindowAdapter() {
          public void windowClosing( WindowEvent we ) {
            dispose();
            System.exit( 0 );
        setBackground( Color.white );
        setSize(700, 500);
        setVisible(true);
      public void paint(Graphics g)
      paint(g, a, b, c);
      public void paint(Graphics g, Point a, Point b, Point c) {
        width = c.x - a.x;
        if (width < 6){return;}
        halfA = new Point((a.x+b.x)/2, (a.y+b.y)/2);
        halfB = new Point((a.x+c.x)/2, (a.y+c.y)/2);
        halfC = new Point((b.x+c.x)/2, (b.y+c.y)/2);
        g.setColor( Color.GREEN ); //draw left triangle in green
        g.drawPolygon( new int[] { a.x, halfA.x, halfB.x }, new int[] { a.y, halfA.y, halfB.y }, 3 );
        g.setColor( Color.RED ); //draw top triangle in red
        g.drawPolygon( new int[] { b.x, halfA.x, halfC.x }, new int[] { b.y, halfA.y, halfC.y }, 3 );
        g.setColor( Color.BLUE ); //draw right triangle in blue
        g.drawPolygon( new int[] { c.x, halfB.x, halfC.x }, new int[] { c.y, halfB.y, halfC.y }, 3 );
        /*If you were to comment our two of these paint() calls the one will work correctly alone.
         *But my problem is that they do not work together! */
        //g, left point, top point, right point
        paint(g, halfA, b, halfC); //top triangle
        paint(g, halfC, halfB, c); //right triangle
        paint(g, a, halfA, halfB); //left triangle
      public static void main(String[] args) {
         new DrawTriangle();
    }

Maybe you are looking for

  • Problem with threads and graphics

    I have a thread that chooses paths for a Travelling salesman problem, it then calls a TSPdraw class and passes it the path, which the class then draws. the problem is when i have two threads it creates two windows but only draws a path in one of them

  • STARTSAP_NBAS DDIC password locking out

    Guys, We are doing 4.6c upgrade to ERP6 and during STARTSAP_NBAS phase DDIC locking out and cant start SAP original system. We tried to unlock the password and also did the reset using SAPup reset DDICpwd. But its still locking out. When we tried to

  • Difference between Public Void and Public Int

    I was wondering what the difference was between 'public void' and 'public int'?

  • In F110 the payment document is calculating discount even after the

    Hi,     I am executing F110 and in the proposal list the documents are calculating discount although the payment date is much beyond the discount allowable period. For example - We are having a payment term which says if payment is made withing 14 da

  • BDC failing as a Background Job

    Hi all, My BDC  for MIGO transaction is failing as a background job. Kindly advise. Dev