Swing bug?: scrolling BLIT_SCROLL_MODE painting JTextArea components hangs

java version "1.5.0_04"
Hello,
When drawing JComponent Text Areas and dynamically scrolling, Java gets confused, gets the shivers and freezes when the viewport cannot get its arms around the canvas. ;)
Possible problem at JViewport.scrollRectToVisible().
When painting non-text area components eg. graphics circles, it is ok.
Have provided example code. This code is based on the ScrollDemo2 example provided in the Sun Java
Tutorial
thanks,
Anil Philip
juwo LLC
Usage: run program and repeatedly click the left mouse button near right boundary to create a new JComponent node each time and to force scrolling area to increase in size to the right.
When the first node crosses the left boundary, then the scroll pane gets confused, gets the shivers and hangs.
The other scroll modes are a bit better - but very slow leaving the toolbar (in the oroginal application) unpainted sometimes.
* to show possible bug when in the default BLIT_SCROLL_MODE and with JTextArea components.
* author: Anil Philip. juwo LLC. http://juwo.com
* Usage: run program and repeatedly click the left mouse button near right boundary to
* create a new JComponent node each time and to force scrolling area to increase in size to the right.
* When the first node crosses the left boundary, then the scroll pane gets confused, gets the shivers
and hangs.
* The other scroll modes are a bit better - but very slow leaving the toolbar (in the oroginal
application)
* unpainted sometimes.
* This code is based on the ScrollDemo2 example provided in the Sun Java Tutorial (written by John
Vella, a tutorial reader).
import javax.swing.*;
import javax.swing.border.EtchedBorder;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
/* ScrollDemo2WithBug.java is a 1.5 application that requires no other files. */
public class ScrollDemo2WithBug extends JPanel {
private Dimension area; //indicates area taken up by graphics
private Vector circles; //coordinates used to draw graphics
private Vector components;
private JPanel drawingPane;
public ScrollDemo2WithBug() {
super(new BorderLayout());
area = new Dimension(0, 0);
circles = new Vector();
components = new Vector();
//Set up the instructions.
JLabel instructionsLeft = new JLabel(
"Click left mouse button to place a circle.");
JLabel instructionsRight = new JLabel(
"Click right mouse button to clear drawing area.");
JPanel instructionPanel = new JPanel(new GridLayout(0, 1));
instructionPanel.add(instructionsLeft);
instructionPanel.add(instructionsRight);
//Set up the drawing area.
drawingPane = new DrawingPane();
drawingPane.setBackground(Color.white);
drawingPane.setPreferredSize(new Dimension(200, 200));
//Put the drawing area in a scroll pane.
JScrollPane scroller = new JScrollPane(drawingPane);
// scroller.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
if(scroller.getViewport().getScrollMode() == JViewport.BACKINGSTORE_SCROLL_MODE)
System.out.println("BACKINGSTORE_SCROLL_MODE");
if(scroller.getViewport().getScrollMode() == JViewport.BLIT_SCROLL_MODE)
System.out.println("BLIT_SCROLL_MODE");
if(scroller.getViewport().getScrollMode() == JViewport.SIMPLE_SCROLL_MODE)
System.out.println("SIMPLE_SCROLL_MODE");
//Lay out this demo.
add(instructionPanel, BorderLayout.PAGE_START);
add(scroller, BorderLayout.CENTER);
/** The component inside the scroll pane. */
public class DrawingPane extends JPanel implements MouseListener {
private class VisualNode {
int x = 0;
int y = 0;
int id = 0;
public VisualNode(int id, int x, int y) {
this.id = id;
this.x = x;
this.y = y;
title.setLineWrap(true);
title.setAlignmentY(Component.TOP_ALIGNMENT);
titlePanel.add(new JButton("Hi!"));
titlePanel.add(title);
nodePanel.add(titlePanel);
nodePanel.setBorder(BorderFactory
.createEtchedBorder(EtchedBorder.RAISED));
box.add(nodePanel);
ScrollDemo2WithBug.this.drawingPane.add(box);
Box box = Box.createVerticalBox();
Box titlePanel = Box.createHorizontalBox();
JTextArea title = new JTextArea(1, 10); // 1 rows x 10 cols
Box nodePanel = Box.createVerticalBox();
public void paintNode(Graphics g) {
int ix = (int) x + ScrollDemo2WithBug.this.getInsets().left;
int iy = (int) y + ScrollDemo2WithBug.this.getInsets().top;
title.setText(id + " (" + ix + "," + iy + ") ");
box.setBounds(ix, iy, box.getPreferredSize().width, box
.getPreferredSize().height);
int n = 0;
DrawingPane() {
this.setLayout(null);
addMouseListener(this);
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.fill3DRect(10, 10, 25, 25, true);
Point point;
for (int i = 0; i < circles.size(); i++) {
point = (Point) circles.elementAt(i);
VisualNode node = (VisualNode) components.get(i);
node.paintNode(g);
//Handle mouse events.
public void mouseReleased(MouseEvent e) {
final int W = 100;
final int H = 100;
boolean changed = false;
if (SwingUtilities.isRightMouseButton(e)) {
//This will clear the graphic objects.
circles.removeAllElements();
area.width = 0;
area.height = 0;
changed = true;
} else {
int x = e.getX() - W / 2;
int y = e.getY() - H / 2;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
Point point = new Point(x, y);
VisualNode node = new VisualNode(circles.size(), point.x,
point.y);
// add(node);
components.add(node);
circles.addElement(point);
drawingPane.scrollRectToVisible(new Rectangle(x, y, W, H));
int this_width = (x + W + 2);
if (this_width > area.width) {
area.width = this_width;
changed = true;
int this_height = (y + H + 2);
if (this_height > area.height) {
area.height = this_height;
changed = true;
if (changed) {
//Update client's preferred size because
//the area taken up by the graphics has
//gotten larger or smaller (if cleared).
drawingPane.setPreferredSize(area);
//Let the scroll pane know to update itself
//and its scrollbars.
drawingPane.revalidate();
drawingPane.repaint();
public void mouseClicked(MouseEvent e) {
public void mouseEntered(MouseEvent e) {
public void mouseExited(MouseEvent e) {
public void mousePressed(MouseEvent e) {
* Create the GUI and show it. For thread safety, this method should be
* invoked from the event-dispatching thread.
private static void createAndShowGUI() {
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated(true);
//Create and set up the window.
JFrame frame = new JFrame("ScrollDemo2");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Create and set up the content pane.
JComponent newContentPane = new ScrollDemo2WithBug();
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
//Display the window.
frame.setSize(800, 600);
frame.pack();
frame.setVisible(true);
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}

I changed the name so you can run this as-is without name clashing. It works okay now.
import javax.swing.*;
import javax.swing.border.EtchedBorder;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class SD2 extends JPanel {
    public SD2() {
        super(new BorderLayout());
        //Set up the instructions.
        JLabel instructionsLeft = new JLabel(
                "Click left mouse button to place a circle.");
        JLabel instructionsRight = new JLabel(
                "Click right mouse button to clear drawing area.");
        JPanel instructionPanel = new JPanel(new GridLayout(0, 1));
        instructionPanel.add(instructionsLeft);
        instructionPanel.add(instructionsRight);
        //Set up the drawing area.
        DrawingPane drawingPane = new DrawingPane(this);
        drawingPane.setBackground(Color.white);
        drawingPane.setPreferredSize(new Dimension(200, 200));
        //Put the drawing area in a scroll pane.
        JScrollPane scroller = new JScrollPane(drawingPane);
        // scroller.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
        if(scroller.getViewport().getScrollMode() == JViewport.BACKINGSTORE_SCROLL_MODE)
            System.out.println("BACKINGSTORE_SCROLL_MODE");
        if(scroller.getViewport().getScrollMode() == JViewport.BLIT_SCROLL_MODE)
            System.out.println("BLIT_SCROLL_MODE");
        if(scroller.getViewport().getScrollMode() == JViewport.SIMPLE_SCROLL_MODE)
            System.out.println("SIMPLE_SCROLL_MODE");
        //Lay out this demo.
        add(instructionPanel, BorderLayout.PAGE_START);
        add(scroller, BorderLayout.CENTER);
     * Create the GUI and show it. For thread safety, this method should be
     * invoked from the event-dispatching thread.
    private static void createAndShowGUI() {
        //Make sure we have nice window decorations.
        JFrame.setDefaultLookAndFeelDecorated(true);
        //Create and set up the window.
        JFrame frame = new JFrame("ScrollDemo2");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //Create and set up the content pane.
        JComponent newContentPane = new SD2();
        newContentPane.setOpaque(true);      //content panes must be opaque
        frame.setContentPane(newContentPane);
        //Display the window.
        frame.setSize(800, 600);
        frame.pack();
        frame.setVisible(true);
    public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
/** The component inside the scroll pane. */
class DrawingPane extends JPanel implements MouseListener {
    SD2 sd2;
    private Dimension area;     //indicates area taken up by graphics
    private Vector circles;     //coordinates used to draw graphics
    private Vector components;
    int n = 0;
    final int
        W = 100,
        H = 100;
    DrawingPane(SD2 sd2) {
        this.sd2 = sd2;
        area = new Dimension(0, 0);
        circles = new Vector();
        components = new Vector();
        this.setLayout(null);
        addMouseListener(this);
     * The 'paint' method is a Container method and it passes its
     * Graphics context, g, to each of its Component children which
     * use it to draw themselves into the parent. JComponent overrides
     * this Container 'paint' method and in it calls this method in
     * addition to others - see api. So the children of DrawingPane will
     * each paint themselves. Here you can do custom painting/rendering.
     * But this is not the place to ask components to paint themselves.
     * That would get swing very confused...
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.fill3DRect(10, 10, 25, 25, true);
        g.setColor(Color.red);
        Point point;
        for (int i = 0; i < circles.size(); i++) {
            point = (Point) circles.elementAt(i);
            g.fillOval(point.x-2, point.y-2, 4, 4);
    //Handle mouse events.
    public void mousePressed(MouseEvent e) {
        if (SwingUtilities.isRightMouseButton(e)) {
            //This will clear the graphic objects.
            circles.removeAllElements();
            components.removeAllElements();
            removeAll();                    // to clear the components
            area.width = 0;
            area.height = 0;
            setPreferredSize(area);
            revalidate();
            repaint();
        } else {
            int x = e.getX() - W / 2;
            int y = e.getY() - H / 2;
            if (x < 0)
                x = 0;
            if (y < 0)
                y = 0;
            Point point = new Point(x, y);
            VisualNode node = new VisualNode(this, circles.size(), point.x, point.y);
            // add(node);
            components.add(node);       // not needed
            circles.addElement(point);
            checkBoundries(x, y, node);
    private void checkBoundries(int x, int y, VisualNode node) {
        boolean changed = false;
        // since we used the setPreferredSize property to set the size
        // of each box we'll have to use it again to let the JScrollPane
        // know what size we need to show all our child components
        int this_width = (x + node.box.getPreferredSize().width + 2);
        if (this_width > area.width) {
            area.width = this_width;
            changed = true;
        int this_height = (y + node.box.getPreferredSize().height + 2);
        if (this_height > area.height) {
            area.height = this_height;
            changed = true;
        if (changed) {
            //Update client's preferred size because
            //the area taken up by the graphics has
            //gotten larger or smaller (if cleared).
            setPreferredSize(area);
            scrollRectToVisible(new Rectangle(x, y, W, H));
            //Let the scroll pane know to update itself
            //and its scrollbars.
            revalidate();
        repaint();
    public void mouseReleased(MouseEvent e) { }
    public void mouseClicked(MouseEvent e)  { }
    public void mouseEntered(MouseEvent e)  { }
    public void mouseExited(MouseEvent e)   { }
* We are adding components to DrawingPanel so there is no need to get
* into the paint methods of DrawingPane. Components are designed to draw
* themseleves when their parent container passes them a Graphics context
* and asks them to paint themselves into the parent.
class VisualNode {
    DrawingPane drawPane;
    int x;
    int y;
    int id;
    Box box;
    public VisualNode(DrawingPane dp, int id, int x, int y) {
        drawPane = dp;
        this.id = id;
        this.x = x;
        this.y = y;
        box = Box.createVerticalBox();
        Box titlePanel = Box.createHorizontalBox();
        JTextArea title = new JTextArea(1, 10);     // 1 rows x 10 cols
        Box nodePanel = Box.createVerticalBox();
        title.setLineWrap(true);
        title.setAlignmentY(Component.TOP_ALIGNMENT);
        titlePanel.add(new JButton("Hi!"));
        titlePanel.add(title);
        nodePanel.add(titlePanel);
        nodePanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
        box.add(nodePanel);
        // here we are adding a component to drawPane so there is really
        // no need to keep this VisualNode in a collection
        drawPane.add(box);
        int ix = (int) x + drawPane.getInsets().left;
        int iy = (int) y + drawPane.getInsets().top;
        title.setText(id + " (" + ix + "," + iy + ") ");
        // since we are using the preferredSize property to setBounds here
        // we'll need access to it (via box) for the scrollPane in DrawPane
        // so we expose box as a member variable
        box.setBounds(ix, iy, box.getPreferredSize().width,
                              box.getPreferredSize().height);
}

Similar Messages

  • Java2D/Swing bug? scrolling with painting JTextArea components hangs app

    Please see
    http://forum.java.sun.com/thread.jspa?threadID=653181

    Please see
    http://forum.java.sun.com/thread.jspa?threadID=653181

  • JTextArea + KeyListener = hangs the VM!

    Ok, I have a weird bug for one of my users.
    In the application when the user presses one of the "���" (swedish) characters on the keyboard in the JTextArea it hangs the VM. Makes the whole vm instance locked on the operating system (and the whole application ofc). The program is a java application running through java web start. JRE 1.5.0_09
    This has been reported to happen randomly on other computers as well.
    If i do not add the key listener to the jtextarea it does not hang! Here is the code for the keylistener I add, which makes the application hang.
    this.addKeyListener(new KeyAdapter(){
         public void keyPressed(KeyEvent e){
              switch (e.getKeyCode()) {
                   case KeyEvent.VK_ENTER :
                        System.out.println("Enter pressed");
                        break;
    });Anyone have any clue what can be causing this?

    >>
    this.addKeyListener(new KeyAdapter(){
         public void keyPressed(KeyEvent e){
              switch (e.getKeyCode()) {
                   case KeyEvent.VK_ENTER :
                        System.out.println("Enter pressed");
                        break;
    >I don't think the problem is in that part of the code.......
    becoz with your code this program is working properly......
    import javax.swing.*;
    import java.awt.event.*;
    public class forJAeon extends JFrame{
        JTextArea jta;
        forJAeon(){
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jta=new JTextArea();
            jta.addKeyListener(new KeyAdapter(){
                 public void keyPressed(KeyEvent e){
                      switch (e.getKeyCode()) {
                           case KeyEvent.VK_ENTER :
                              System.out.println("Enter pressed");
                            break;
            getContentPane().add(jta);
            setSize(200,200);
        public static void main(String args[]){
            new forJAeon().setVisible(true);
    }???????so, the problem might be in some other place is my guess.....!!!
    Tried using keybinding and it gives the same bug. Seems like it bugs on other computers as well. Supports my guess.....?!!??!!

  • Swing bug? cannot set width of JToggleButton

    Hello,
    Just wondered if this was a Swing bug. See also
    bug 6349010.
    The width of the JToggleButton cannot be set.
    However the height can be set.
    The important line is line 135 - and also 140.
    Try changing the width of the button - it does not change.
    thanks,
    Anil
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.util.EventObject;
    import javax.swing.BorderFactory;
    import javax.swing.Box;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTabbedPane;
    import javax.swing.JTextArea;
    import javax.swing.JToggleButton;
    import javax.swing.JTree;
    import javax.swing.UnsupportedLookAndFeelException;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeCellEditor;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreeSelectionModel;
    public class TreeUIFailed extends JPanel {
           AnilTreeCellRenderer3 atcr;
           AnilTreeCellEditor4 atce;
           DefaultTreeModel treeModel;
           JTree tree;
           DefaultMutableTreeNode markedNode = null;
         public TreeUIFailed() {
                super(new BorderLayout());
                   treeModel = new DefaultTreeModel(null);
                   tree = new JTree(treeModel);          
                  tree.setEditable(true);
                   tree.getSelectionModel().setSelectionMode(
                             TreeSelectionModel.SINGLE_TREE_SELECTION);
                   tree.setShowsRootHandles(true);
                  tree.setCellRenderer(atcr = new AnilTreeCellRenderer3());
                  tree.setCellEditor(atce = new AnilTreeCellEditor4(tree, atcr));
                  tree.setRowHeight(0);//TEMP - needed only if setting Win L&F
                   JScrollPane scrollPane = new JScrollPane(tree);
                   add(scrollPane,BorderLayout.CENTER);
         public void setRootNode(DefaultMutableTreeNode node) {
              treeModel.setRoot(node);
              treeModel.reload();
           public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException{
    //            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                TreeUIFailed tb = new TreeUIFailed();
                tb.setPreferredSize(new Dimension(800,600));
                  JFrame frame = new JFrame("Tree Windows UI Failed");
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  frame.setContentPane(tb);
                  frame.setSize(800, 600);
                  frame.pack();
                  frame.setVisible(true);
                  tb.populate();
         private void populate() {
              TextAreaNode3 r = new TextAreaNode3(this);
               setRootNode(r);
                   r.gNode.notes.addTab("0", null/* icon */, new JTextArea(2,25),
                   "no menu!");
                   r.gNode.notes.addTab("1", null/* icon */, new JTextArea(2,25),
                   "no menu!");
                   TextAreaNode3 a = new TextAreaNode3(this);
                   a.gNode.notes.addTab("1", null/* icon */, new JTextArea(2,25),
                   "no menu!");
               treeModel.insertNodeInto(a, r, r.getChildCount());          
    class AnilTreeCellRenderer3 extends DefaultTreeCellRenderer{
         TreeUIFailed panel;
    DefaultMutableTreeNode currentNode;
      public AnilTreeCellRenderer3() {
         super();
    public Component getTreeCellRendererComponent
       (JTree tree, Object value, boolean selected, boolean expanded,
       boolean leaf, int row, boolean hasFocus){
         TextAreaNode3 currentNode = (TextAreaNode3)value;
         NodeGUI4 gNode = (NodeGUI4) currentNode.gNode;
        return gNode.vBox;
    class AnilTreeCellEditor4 extends DefaultTreeCellEditor{
      DefaultTreeCellRenderer rend;
      public AnilTreeCellEditor4(JTree tree, DefaultTreeCellRenderer r){
        super(tree, r);
        rend = r;
      public Component getTreeCellEditorComponent(JTree tree, Object value,
       boolean isSelected, boolean expanded, boolean leaf, int row){
        return rend.getTreeCellRendererComponent(tree, value, isSelected, expanded,
         leaf, row, true);
      public boolean isCellEditable(EventObject event){
        return true;
    * this is done to keep gui separate from model - as in MVC.
    * not necessary.
    * @author juwo
    class NodeGUI4 {
         JPanel notesPanel = new JPanel(new BorderLayout(), true);
         JTabbedPane notes = new JTabbedPane(JTabbedPane.RIGHT);
         final TreeUIFailed view;
         Box vBox = Box.createVerticalBox();
         Box hBox = Box.createHorizontalBox();
         final JTextArea textArea = new JTextArea( 1, 5 );
         JToggleButton toggleButton = new JToggleButton();
         NodeGUI4( TreeUIFailed view_ ) {
              this.view = view_;
              toggleButton.setAlignmentX(Component.CENTER_ALIGNMENT);
    // BEGIN PROBLEM          
              toggleButton.setPreferredSize(new Dimension(200,toggleButton.getPreferredSize().height));
    // END PROBLEM
              vBox.add(toggleButton);
              vBox.add(hBox);
              hBox.add( textArea );
              textArea.setBorder( BorderFactory.createMatteBorder( 0, 0, 1, 0, Color.GREEN ) );
              notesPanel.add(notes);
              hBox.add( notesPanel);
              hBox.setBorder( BorderFactory.createMatteBorder( 5, 5, 5, 5, Color.CYAN ) );
    // THE FOLLOWING DOES NOT WORK EITHER!!!          
              //          halo.setPreferredSize(new Dimension(vBox.getPreferredSize().width,halo.getPreferredSize().height));
    class TextAreaNode3 extends DefaultMutableTreeNode {  
         NodeGUI4 gNode;
         TextAreaNode3(TreeUIFailed view_t) {     
              gNode = new NodeGUI4(view_t);          
    }

    ok, sorry!
    I understood why it does not work.
    Box Layout respects the maximum size of the component.
    By default, a JToggleButton is set to 34.
    Changing the JToggleButton max width to 75, allows the preferred size to be set.
    Thank you camickr!
    Note: in contrast, Flow Layout respects the preferred size and ignores the max size!
    Message was edited by:
    anilp1

  • How to paint over components in JWindow?

    Hi,
    Need to know if its possible to draw some lines over components in a JFrame or JWindow.
    Im writng a GUI for an mp3 player and one of the effects is to create scanlines over the Logo and Components (play, pause, etc)
    Heres what I'm trying to do:
    import java.awt.*;
    import java.awt.geom.RoundRectangle2D;
    import javax.swing.*;
    import java.awt.geom.Line2D;
    public class PLUSGUI extends JWindow {
         public PLUSGUI() {
              //super("+ PLUS-GUI");
              Container c = this.getContentPane();
              c.setBackground(Color.lightGray);
              this.setLayout(new FlowLayout());
              ClassLoader cldr = this.getClass().getClassLoader();
              java.net.URL imageURL   = cldr.getResource("+PLUS_Logo.jpg");
              ImageIcon PLUSLOGO = new ImageIcon(imageURL);
              this.add(new JLabel(PLUSLOGO));
              //this.add(new JButton("test"));
              //this.add(new JCheckBox("test"));
              //this.add(new JRadioButton("test"));
              this.add(new JProgressBar(0, 100));
              this.setSize(new Dimension(300, 300));
              this.setLocationRelativeTo(null);
              //this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              //this.setUndecorated(true);
    public void paint(Graphics g){
       Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    //Draw the logo
    //g2.setPaint(Color.ORANGE);
    //g2.drawString("+ PLUS GUI", 50, 51);
    int x = 0;
    int y = 0;
    int w = 300;
    int h = 0;
    for (int i=0; i<150; i++){
       g2.setColor(Color.GRAY);
       g2.draw(new Line2D.Double(x, y, w, h));
       y=y+2;
       h=h+2;
         public static void main(String[] args) {
              //JFrame.setDefaultLookAndFeelDecorated(true);
              SwingUtilities.invokeLater(new Runnable() {
                   @Override
                   public void run() {
                        Window w = new PLUSGUI();
                        w.setVisible(true);
                        //com.sun.awt.AWTUtilities.setWindowOpacity(w, 0.5f);
                        com.sun.awt.AWTUtilities
                                  .setWindowShape(w, new RoundRectangle2D.Float(0, 0, w.getWidth(), w.getHeight(), 10, 10));
    }

    Custom painting is done by overriding the paintComponent(g) method of a Swing component that is not a top level container.
    You should never override the paint() method of a top level container (like JFrame, JWindow) espcially when you don't invoke super.paint(...).
    So if you want line above the label, then overide the label and add the custom code.
    Also, use proper Java naming convention. Class names and variable name should not be completely capitalized.

  • BUG : JDev 10.1.3 SR2 hangs when opening a java files

    Hi,
    think I've found a bug. I'm using JDev 10.1.3, patched with SR1 & 2, my machine is a Windows XP SP2 box with 1GB mem and Intel Pentium 4 2.60 Ghz with HT.
    When I try to open a file in the Java editor the IDE hangs. Launching jdev.exe I can see that the following output is continuously printed:
    Exception occurred updating RowMap: 16
    startRow: 0
    numRows: 1
    startLine: 0
    numLines: 15
    _rowCount: 15
    lineCount: 15
    Stack trace follows
    java.lang.ArrayIndexOutOfBoundsException: 16
         at oracle.javatools.buffer.ArrayLineMap.getLineEndOffset(ArrayLineMap.java:326)
         at oracle.javatools.editor.BasicView$LineRowMap.recalculateLineWidths(BasicView.java:3576)
         at oracle.javatools.editor.BasicView$LineRowMap.recalculateRows(BasicView.java:3487)
         at oracle.javatools.editor.BasicView$LineRowMap.handleInsert(BasicView.java:3315)
         at oracle.javatools.editor.BasicView$LineRowMap.rebuildRowMap(BasicView.java:3286)
         at oracle.javatools.editor.BasicView$LineRowMap.<init>(BasicView.java:3259)
         at oracle.javatools.editor.BasicView$FoldedRowMap.<init>(BasicView.java:3966)
         at oracle.javatools.editor.BasicView.updateMetrics(BasicView.java:1128)
         at oracle.javatools.editor.BasicView.getPreferredSpan(BasicView.java:1730)
         at javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan(BasicTextUI.java:1257)
         at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:819)
         at oracle.javatools.editor.BasicEditorUI.getPreferredSize(BasicEditorUI.java:158)
         at javax.swing.JComponent.getPreferredSize(JComponent.java:1615)
         at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1227)
         at javax.swing.JViewport.getViewSize(JViewport.java:1003)
         at javax.swing.plaf.basic.BasicScrollPaneUI.syncScrollPaneWithViewport(BasicScrollPaneUI.java:264)
         at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.viewportStateChanged(BasicScrollPaneUI.java:855)
         at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.stateChanged(BasicScrollPaneUI.java:797)
         at javax.swing.JViewport.fireStateChanged(JViewport.java:1357)
         at javax.swing.JViewport.setView(JViewport.java:975)
         at oracle.ideimpl.editor.SplitPane.setEditorComponent(SplitPane.java:343)
         at oracle.ideimpl.editor.SplitPane.attachEditor(SplitPane.java:949)
         at oracle.ideimpl.editor.SplitPane.attachCurrentEditor(SplitPane.java:919)
         at oracle.ideimpl.editor.SplitPane.setCurrentEditorStatePos(SplitPane.java:1138)
         at oracle.ideimpl.editor.SplitPane.setSplitPaneState(SplitPane.java:207)
         at oracle.ideimpl.editor.TabGroup.attachCurrentNode(TabGroup.java:517)
         at oracle.ideimpl.editor.TabGroup.setCurrentTabGroupState(TabGroup.java:1294)
         at oracle.ideimpl.editor.TabGroup.activateEditor(TabGroup.java:639)
         at oracle.ideimpl.editor.EditorManagerImpl.createEditor(EditorManagerImpl.java:1273)
         at oracle.ideimpl.editor.EditorManagerImpl.createEditor(EditorManagerImpl.java:1196)
         at oracle.ideimpl.editor.EditorManagerImpl.openEditor(EditorManagerImpl.java:1131)
         at oracle.ideimpl.editor.EditorManagerImpl.whenOpenEditor(EditorManagerImpl.java:2332)
         at oracle.ideimpl.editor.EditorManagerImpl.handleDefaultAction(EditorManagerImpl.java:1893)
         at oracle.ide.controller.ContextMenu.fireDefaultAction(ContextMenu.java:343)
         at oracle.ideimpl.explorer.BaseTreeExplorer.fireDefaultAction(BaseTreeExplorer.java:1504)
         at oracle.ideimpl.explorer.BaseTreeExplorer.dblClicked(BaseTreeExplorer.java:1841)
         at oracle.ideimpl.explorer.BaseTreeExplorer.mouseReleased(BaseTreeExplorer.java:1862)
         at oracle.ideimpl.explorer.CustomTree.processMouseEvent(CustomTree.java:176)
         at java.awt.Component.processEvent(Component.java:5253)
         at java.awt.Container.processEvent(Container.java:1966)
         at java.awt.Component.dispatchEventImpl(Component.java:3955)
         at java.awt.Container.dispatchEventImpl(Container.java:2024)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
         at java.awt.Container.dispatchEventImpl(Container.java:2010)
         at java.awt.Window.dispatchEventImpl(Window.java:1774)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Forcing RowMap rebuild
    I also disabled ALL extension and removed the jar files in jdev/extension, except the one that was originally included in the 10.1.3 and those that seems related to the service releases.
    The file I'm trying to open is done like this:
    --- start after this line ---
    package com.websiteitalia.jsftest.view.controllers.people.list;
    import com.websiteitalia.jsftest.model.list.people.PeopleListUtil;
    import com.websiteitalia.jsftest.view.controllers.BaseListBacker;
    import com.websiteitalia.weblib.ejb.list.IWSList;
    public class PeopleListBacker extends BaseListBacker {
    public IWSList getListRemote() throws Exception {
    return PeopleListUtil.getList();
    --- end before this line ---
    I include also an HEX encoding of the file:
    00000000h: 70 61 63 6B 61 67 65 20 63 6F 6D 2E 77 65 62 73 ; package com.webs
    00000010h: 69 74 65 69 74 61 6C 69 61 2E 6A 73 66 74 65 73 ; iteitalia.jsftes
    00000020h: 74 2E 76 69 65 77 2E 63 6F 6E 74 72 6F 6C 6C 65 ; t.view.controlle
    00000030h: 72 73 2E 70 65 6F 70 6C 65 2E 6C 69 73 74 3B 0D ; rs.people.list;.
    00000040h: 0A 0D 0A 69 6D 70 6F 72 74 20 63 6F 6D 2E 77 65 ; ...import com.we
    00000050h: 62 73 69 74 65 69 74 61 6C 69 61 2E 6A 73 66 74 ; bsiteitalia.jsft
    00000060h: 65 73 74 2E 6D 6F 64 65 6C 2E 6C 69 73 74 2E 70 ; est.model.list.p
    00000070h: 65 6F 70 6C 65 2E 50 65 6F 70 6C 65 4C 69 73 74 ; eople.PeopleList
    00000080h: 55 74 69 6C 3B 0D 0A 69 6D 70 6F 72 74 20 63 6F ; Util;..import co
    00000090h: 6D 2E 77 65 62 73 69 74 65 69 74 61 6C 69 61 2E ; m.websiteitalia.
    000000a0h: 6A 73 66 74 65 73 74 2E 76 69 65 77 2E 63 6F 6E ; jsftest.view.con
    000000b0h: 74 72 6F 6C 6C 65 72 73 2E 42 61 73 65 4C 69 73 ; trollers.BaseLis
    000000c0h: 74 42 61 63 6B 65 72 3B 0D 0A 69 6D 70 6F 72 74 ; tBacker;..import
    000000d0h: 20 63 6F 6D 2E 77 65 62 73 69 74 65 69 74 61 6C ; com.websiteital
    000000e0h: 69 61 2E 77 65 62 6C 69 62 2E 65 6A 62 2E 6C 69 ; ia.weblib.ejb.li
    000000f0h: 73 74 2E 49 57 53 4C 69 73 74 3B 0D 0A 0D 0A 0D ; st.IWSList;.....
    00000100h: 0A 70 75 62 6C 69 63 20 63 6C 61 73 73 20 50 65 ; .public class Pe
    00000110h: 6F 70 6C 65 4C 69 73 74 42 61 63 6B 65 72 20 65 ; opleListBacker e
    00000120h: 78 74 65 6E 64 73 20 42 61 73 65 4C 69 73 74 42 ; xtends BaseListB
    00000130h: 61 63 6B 65 72 20 7B 0D 0A 20 20 20 20 0D 0A 20 ; acker {..    ..
    00000140h: 20 20 20 70 75 62 6C 69 63 20 49 57 53 4C 69 73 ; public IWSLis
    00000150h: 74 20 67 65 74 4C 69 73 74 52 65 6D 6F 74 65 28 ; t getListRemote(
    00000160h: 29 20 74 68 72 6F 77 73 20 45 78 63 65 70 74 69 ; ) throws Excepti
    00000170h: 6F 6E 20 7B 0D 0A 20 20 20 20 20 20 20 20 72 65 ; on {..        re
    00000180h: 74 75 72 6E 20 50 65 6F 70 6C 65 4C 69 73 74 55 ; turn PeopleListU
    00000190h: 74 69 6C 2E 67 65 74 4C 69 73 74 28 29 3B 0D 0A ; til.getList();..
    000001a0h: 20 20 20 20 7D 0D 0A 20 20 20 20 0D 0A 7D 0D 0A ; }.. ..}..
    Note the last empty line before the end-of-file. If I try to past this code into a Java file and open it in JDev, it hangs as described.
    Moreover, if I remove the last empty line, JDev will open the file in the editor but, as soon as I enter it again (placing the cursor at the end of the file a hitting enter) JDev hangs again.
    A final note: I experienced many hangs also in JSP editor, especially selecting a block of text and pasting something in its place, but don't know if the two behaviours are related.

    Ok, maybe I've tracked down at least one factor that makes JDev hang. I changed my font back to the default "DialogInput" instead of "Lucida Console" and now it opens my file.
    This is the settings that works in system/oracle.jdeveloper.10.1.3.36.73/preferences.xml
    <Item>
    <Key>FontSizeOptions</Key>
    <Value class="oracle.ide.ceditor.options.FontSizeOptions">
    <fontFamily>DialogInput</fontFamily>
    <fontSize>12</fontSize>
    <showOnlyFixedWidth>false</showOnlyFixedWidth>
    </Value>
    </Item>
    With this one it hangs:
    <Item>
    <Key>FontSizeOptions</Key>
    <Value class="oracle.ide.ceditor.options.FontSizeOptions">
    <fontFamily>Lucida Console</fontFamily>
    <fontSize>12</fontSize>
    <showOnlyFixedWidth>false</showOnlyFixedWidth>
    </Value>
    </Item>
    Logging the exception
    Exception occurred updating RowMap: 16
    startRow: 0
    numRows: 1
    startLine: 0
    numLines: 15
    _rowCount: 15
    lineCount: 15
    Stack trace follows
    java.lang.ArrayIndexOutOfBoundsException: 16
         at oracle.javatools.buffer.ArrayLineMap.getLineEndOffset(ArrayLineMap.java:326)
         at oracle.javatools.editor.BasicView$LineRowMap.recalculateLineWidths(BasicView.java:3576)
         at oracle.javatools.editor.BasicView$LineRowMap.recalculateRows(BasicView.java:3487)
         at oracle.javatools.editor.BasicView$LineRowMap.handleInsert(BasicView.java:3315)
         at oracle.javatools.editor.BasicView$LineRowMap.rebuildRowMap(BasicView.java:3286)
         at oracle.javatools.editor.BasicView$LineRowMap.<init>(BasicView.java:3259)
         at oracle.javatools.editor.BasicView$FoldedRowMap.<init>(BasicView.java:3966)
         at oracle.javatools.editor.BasicView.updateMetrics(BasicView.java:1128)
         at oracle.javatools.editor.BasicView.getPreferredSpan(BasicView.java:1730)
         at javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan(BasicTextUI.java:1257)
         at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:819)
         at oracle.javatools.editor.BasicEditorUI.getPreferredSize(BasicEditorUI.java:158)
         at javax.swing.JComponent.getPreferredSize(JComponent.java:1615)
         at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1227)
         at oracle.javatools.editor.gutter.LineGutterPlugin.getRowCount(LineGutterPlugin.java:1485)
         at oracle.javatools.editor.gutter.LineGutterPlugin.getPreferredSize(LineGutterPlugin.java:890)
         at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:690)
         at java.awt.Container.preferredSize(Container.java:1558)
         at java.awt.Container.getPreferredSize(Container.java:1543)
         at javax.swing.JComponent.getPreferredSize(JComponent.java:1617)
         at javax.swing.ViewportLayout.preferredLayoutSize(ViewportLayout.java:78)
         at java.awt.Container.preferredSize(Container.java:1558)
         at java.awt.Container.getPreferredSize(Container.java:1543)
         at javax.swing.JComponent.getPreferredSize(JComponent.java:1617)
         at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:717)
         at java.awt.Container.layout(Container.java:1401)
         at java.awt.Container.doLayout(Container.java:1390)
         at java.awt.Container.validateTree(Container.java:1473)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validate(Container.java:1448)
         at java.awt.Window.show(Window.java:515)
         at oracle.ideimpl.MainWindowImpl.show(MainWindowImpl.java:572)
         at java.awt.Component.show(Component.java:1300)
         at java.awt.Component.setVisible(Component.java:1253)
         at oracle.ideimpl.MainWindowImpl$2.runImpl(MainWindowImpl.java:773)
         at oracle.javatools.util.SwingClosure$1Closure.run(SwingClosure.java:50)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Forcing RowMap rebuild

  • Painting over components

    Hi,
    I have the following panel which displays a series of labels, however when i try and draw a string onto the panel, all of the components disappear when the string is drawn, can someone please help me.
    Thanks
    Cath
    import javax.swing.*;
    import javax.swing.border.*;
    import java.awt.*;
    import java.awt.event.*;
    public class CurrentPlayersPane extends JPanel
         public CurrentPlayersPane()
              setLayout(null);
              red = new ImageIcon("images/red.gif");
              yellow = new ImageIcon("images/yellow.gif");
              green = new ImageIcon("images/green.gif");
              blue = new ImageIcon("images/blue.gif");
              cyan = new ImageIcon("images/cyan.gif");
              magenta = new ImageIcon("images/magenta.gif");
              red_l = new JLabel(red); red_l.setBounds(RIGHT, 10, 14, 14); add(red_l);
              yellow_l = new JLabel(yellow); yellow_l.setBounds(RIGHT, 27, 14, 14); add(yellow_l);
              green_l = new JLabel(green); green_l.setBounds(RIGHT, 44, 14, 14); add(green_l);
              blue_l = new JLabel(blue); blue_l.setBounds(RIGHT, 61, 14, 14); add(blue_l);
              cyan_l = new JLabel(cyan); cyan_l.setBounds(RIGHT, 78, 14, 14); add(cyan_l);
              magenta_l = new JLabel(magenta); magenta_l.setBounds(RIGHT, 95, 14, 14); add(magenta_l);
              player1 = new JLabel(); player1.setBounds(RIGHT+20, 10, 100, 14); add(player1);
              player2 = new JLabel(); player2.setBounds(RIGHT+20, 27, 100, 14); add(player2);
              player3 = new JLabel(); player3.setBounds(RIGHT+20, 44, 100, 14); add(player3);
              player4 = new JLabel(); player4.setBounds(RIGHT+20, 61, 100, 14); add(player4);
              player5 = new JLabel(); player5.setBounds(RIGHT+20, 78, 100, 14); add(player5);
              player6 = new JLabel(); player6.setBounds(RIGHT+20, 95, 100, 14); add(player6);
              arrow = new ImageIcon("images/arrow.gif");
              arrow_l = new JLabel(arrow); add(arrow_l);
         public void paint(Graphics g) {
              g.drawString("Hello World", 75, 50);
         // displayName() - Display the name of a player on the game board
         private void displayName(String name, int playerNo) {
              switch(playerNo)
                   case 1:
                        player1.setText(name);
                        break;
                   case 2:
                        player2.setText(name);
                        break;
                   case 3:
                        player3.setText(name);
                        break;
                   case 4:
                        player4.setText(name);
                        break;
                   case 5:
                        player5.setText(name);
                        break;
                   case 6:
                        player6.setText(name);
                        break;
         // moveArrow() - Move the arrow to point to the current player
         public void moveArrow(int playerNo) {
              arrow_l.setBounds(10, ARROWPOS[playerNo - 1], 29, 15);
         private Icon red, yellow, green, blue, cyan, magenta;
         private JLabel red_l, yellow_l, green_l, blue_l, cyan_l, magenta_l;
         private JLabel player1, player2, player3, player4, player5, player6;
         private ImageIcon arrow;
         private JLabel arrow_l;
         private final static int RIGHT = 45;
         private final static int[] ARROWPOS = {10, 27, 44, 61, 78, 95};
    }

    sorry, one more question, i need a panel which needs to shows some components (e.g. JSlider and labels) only at specific times. So there will be a blank panel most of the time but occasionally i will need to show these components, how can i achieve this?
    Many thanks
    Cath

  • Scrolling of a JTextArea in a JScrollPane

    I have a JTextArea in a JScrollPane.
    It is for a chat and I am constantly appending messages at the bottom of the JTextArea.
    Currently the scrollPanel is scrolling the view so the last line is visible for quite some lines, which is what I want, but from a certain amount of text in the textarea it stops doing that.
    Why does it scroll along at first and then suddenly stops?

    Actually it is a JTextPane instead of JTextArea. My bad.
    And actually it are 2 JTextPanes with a common Document where I am appending the text on (and at the appending I don't have the references to the textpanes).
    Maybe I can add document listeners to the components that have the refs to the textpanes and set the caret position there?

  • Help required building ADF-Swing/ADF-Faces using ADF Business Components

    My question is in regards to how you can go about building a light swing application to an ADF model?
    In particular if I were to say that we were developing a 3-tier project whereby we had a database tier, a series of EJB-ADF façade session beans to the database (middle-tier), and a swing client communicating with the session beans (view-controller tier), how would you go about developing these screens?
    In particular can we develop these screens using ADF-Faces and also ADF-Swing?
    The EJB session façade beans of course are ADF app modules with customised methods. The methods would return back customised DTO objects. These DTO objects are wrappers to row objects ADF would create. This would be mainly due to making these facade beans web service enabled (Oracle state that these methods cannot return oracle.jbo objects if they are to be web service enabled).
    This would be typically deployed to an app server, like Oracle App Server 10G.
    Could you please have a look at this, as I am doing a lot of research into this.
    eg. Taking example from oracle magazine sept/oct 2006
    with slight enhancements
    package oramag.frameworks.example.common;
    import oracle.jbo.ApplicationModule;
    import oramag.frameworks.customdto.EmployeeDTO;
    public interface HRService extends ApplicationModule {
    void deleteCurrentEmpAndCommit();
    EmployeeDTO findEmployee(int employeeId); // new method
    import oramag.frameworks.customdto.EmployeeDTO;
    public class HRServiceImpl extends ApplicationModuleImpl {
    public void deleteCurrentEmpAndCommit() {
    Row empRow = getEmpView().getCurrentRow();
    if (empRow != null) {
    empRow.remove();
    getDBTransaction().commit();
    public EmployeeDTO findEmployee(int employeeId)() {
    EmployeeDTO employeeDTO = null;
    EmployeesImpl employees = getEmployees();
    employees.setNamedWhereClauseParam("EmployeeId", employeeId);
    employees.executeQuery();
    if(employees.hasNext()) {
    EmployeesRowImpl employee = (EmployeesRowImpl)employees.next();
    employeeDTO = new EmployeeDTO(employee);
    return employeeDTO;
    public EmployeesImpl getEmployees() {
    return (EmployeesImpl)findViewObject("Employees");
    Now given the above code snippet, how could you turn this into an ADF-Swing/ADF Faces application so that if a user using the swing application enters an employee id, then the application will execute the query on the app server, the app server in turn returns the results to the client, and the client finally display the results. Typical MVC example.
    Cheers
    Rodney

    The tutorial is for ADF BC used with JavaServer Faces.
    While the tutorial doesn't cover it, we also support drag and drop development for Swing and visual WYSIWYG layout for Swing panels and windows, too. For a very simple example, watch screencast #4 on my blog here:
    http://radio.weblogs.com/0118231/stories/2005/06/24/jdeveloperAdfScreencasts.html
    One thing I have noticed is that when using ADF business components, when the app module returns a custom DTO object like the above example, it returns the data in a element structure according to the data control palette.
    You don't generally ever need to create your own custom DTO's when working with ADF for use by client UI's. The only situation where can be necessary -- until we simplify this in the JDeveloper/ADF 11g release -- is when you desire to expose custom methods that can return sets/arrays of typed row structures through a web service. However, web services are not involved/required in building 3-tier Swing applications.
    When dropping onto a page it does so like a string and doesnt give option to display the data in a read only form etc. Is there anything we need to do, to get the functionality.
    It's more of what you don't need to do :-)
    Just leverage the active data model that the ADF application module provides. You can read more about it in section 4.5 "Understanding the Active Data Model" of the ADF Developer's Guide for Forms/4GL Developers on the ADF Learning Center at http://www.oracle.com/technology/products/adf/learnadf.html). Your UI's bind to view object instances in the data model, and your UI's are automatically kept up to date without needing to write methods that return data. I short article I wrote that preceeded my writing the ADF Developer Guide content on this topis is here:
    http://radio.weblogs.com/0118231/stories/2006/01/26/theAdfBusinessComponentsActiveDataModel.html
    I know that when dropping a view object you get this functionality. Also was wondering if we were to pass an object of thios type back to the model it might not give us the rich functionality like input forms, like what Oracle provides if we were to drop a enitity view object.
    Just use the active data model and everything becomes totally easy, with no changes required to switch between local or three-tier deployment configurations.
    Trying to do everything with hand-coded DTO beans is really going the hard way.
    Could you help us regarding this?

  • Strange Swing bug in Oracle's JDK7

    I have a strange bug with every java app i run with the Java 7 VM. Every frame is limited to a maximum width of 1024 pixels. Doesn't matter if you try to resize it by code or dragging the border with the mouse pointer.
    I have a Macbook with Mac OSX 10.7.5 (1280x800 resolution).
    If i try to run the apps with Apple's Java 6 VM all works as expected.
    Here is a POC:
    import javax.swing.*;
    import java.awt.*;
    public class JDK7Bug {
        public static void main(String[] args) throws InterruptedException {
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
            frame.setSize(800, 400);
            Thread.sleep(100);
            System.out.println("frame.setSize(800, 400); " + frame.getSize());
            frame.setSize(1100, 400);
            Thread.sleep(100);
            System.out.println("frame.setSize(1100, 400); " + frame.getSize());
            frame.setSize(1000, 400);
            Thread.sleep(100);
            System.out.println("frame.setSize(1000, 400); "+frame.getSize());
            System.out.println("ScreenSize: "+Toolkit.getDefaultToolkit().getScreenSize());
    It outputs:
    frame.setSize(800, 400); java.awt.Dimension[width=800,height=400]
    frame.setSize(1100, 400); java.awt.Dimension[width=1024,height=400]
    frame.setSize(1000, 400); java.awt.Dimension[width=1000,height=400]
    ScreenSize: java.awt.Dimension[width=1280,height=800]

    Try wrapping everything inside main in a SwingUtilities.invokeLater. You should not do any Swing stuff outside the EDT and you can remove the Thread.sleep.
    I have tested on my Windows 8.1 with 7u45 and 7u60 and they both work
    I get the following in std.out:
    frame.setSize(800, 400); java.awt.Dimension[width=800,height=400]
    frame.setSize(1100, 400); java.awt.Dimension[width=1100,height=400]
    frame.setSize(1000, 400); java.awt.Dimension[width=1000,height=400]
    ScreenSize: java.awt.Dimension[width=2560,height=1440]

  • Is this really a Swing bug?

    Hi all... :)
    I've just installed J2SDK 1.4.2 and there is something wrong with Swing over here. Not sure if this was already related to Bug DB, so I'm asking here if anyone has seen this problem too.
    You can see a screenshot about the problem at:
    http://www.bcborges.brturbo.com/swingbug.jpg
    The problem doesn't happen with my home pc, which is running Win XP.
    In this screenshot, I'm running Win 2000 with VIA Chipset, onboard display card.

    multiple threads on same subject!
    Dave's right, it's almost certainly a compatibility problem with your JDBC driver

  • Swing (JScrollPane - scroll bar) help

    Hello all..
    I am new user in Swing. Currently I am developing a program using JSCrollPane. I have to draw a kind of chart in it. Therefore as a drawing media, I used the JPanel, in which I put it inside my JScrollPane. Then.. since my graphic is long.. then I set the
    setHorizontalScrollBarPolicy value to ALWAYS. Then I put my JPanel using the following commands :
    this.jScrollPane1.setViewportView(this.jPanel2);
    this.jScrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    Fyi, my JPanel size is set to be wider than the jScrollPane3 size. Nevertheless.. during the run time the horizontal scroll bar is not shown. I am completely loss on how to solve this. Does anyone has any clue or solution for this problem. Thank you very much in advance.
    Kariyage.

    Fyi, my JPanel size is set to be wider than the jScrollPane3 sizeYou should use panel.setPreferredSize(...) not panel.setSize(...);

  • No Scroll bar with JTextArea on unix machine

    hi am using JTextArea with Unix machine... The problem is not enabling scroll bars
    can anyone help me

    JTextArea agreeTxt;
    agreeTxt = new JTextArea(11, 42);
    agreeTxt.setAutoscrolls(true);
    agreeTxt.setLineWrap(true);
    agreeTxt.setEditable(false);
    JScrollPane pane = new JScrollPane( agreeTxt );Now add the JScrollPane object to your JPanel or where ever you have your JTextArea

  • Scroll position and JTextArea

    I hava a JFrame with a JScrollPane/JTextArea in it.
    I frequently update the textarea with a setText(string), but for every update the scrollbar jumps to the bottom. The things is that I want the scrollbar to remember its position and not change its position after an update.
    The string in setText varies in length.
    Any ideas, please.
    Thanks!!

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ScrollingTest {
      static JTextArea textArea;
      static int updateCount = 0;
      static int i;
      public static void main(String[] args) {
        JButton button = new JButton("add data");
        button.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateDisplay();
        JPanel panel = new JPanel();
        panel.add(button);
        textArea = new JTextArea();
        textArea.setMargin(new Insets(10,10,10,10));
        textArea.setLineWrap(true);
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(panel, "North");
        f.getContentPane().add(new JScrollPane(textArea));
        f.setSize(400,300);
        f.setLocation(400,300);
        f.setVisible(true);
      private static void updateDisplay() {
        String text = "";
        for(i = updateCount; i < 40 + updateCount; i++)
          text += String.valueOf(i) + "\n";
        int caretPosition = textArea.getDocument().getLength();
        textArea.setText(textArea.getText() + text);
        updateCount = i;
        textArea.setCaretPosition(caretPosition);
    }

  • Bug : Scrolling in CC app with Mac 10.8

    Hello,
    I have a problem with scrolling : my mousewheel doesn't work anymore, so I use the scrollbar a lot.
    In Mac 10.8, you have a feature that hides the scrollbar by default, considering that everyone has a trackpad, or a working mousewheel (they should have not sold this "magic" mouse with this tiny button, which has a very low lifetime....).
    Anyway, you can uncheck this feature and "always" show the scrollbar.
    But even with this feature unchecked, the scrollbar inside Creative Cloud is hidden by default. The only way to show it is to scroll down a bit. But it is almost impossible for me to scroll down a bit, so it is almost impossible to download apps from the CC app....
    Maybe i've missed something but I don't think so, and the Adobe bug report has no "creative cloud app" in the list of products, so I post it here.

    I'm using the mighty (not magic as I said) mouse from apple : http://en.wikipedia.org/wiki/Apple_Mighty_Mouse
    I'm referring to the Creative Cloud Desktop on Mac.
    You can easily try this bug : Check "always show scroll bars" in system preferences, and try to never use the trackpad to scroll. You'll see that in less than one second, the scroll bar will disappear inside the CC app.

Maybe you are looking for

  • Low File Size/Great Image Quality: H.264, AAC

    1. I created a slideshow in iPhoto, exported it to a QT movie file. The properties of it is as follows: Exibit A: Dimensions: 720x480 Format: MPEG-4 Video, AAC, Stereo, 44.100kHz FPS: 30 Data Rate: 7277.87 kbits/sec Channel Count: 2 Duration: 02'46 S

  • External Mac hard drive to be viewed on Windows OS

    I took the hard drive out of an old Mac 6116 that was in a house fire. I don't think the hard drive suffered smoke or water damage so I want to mount it in an external USB enclosure and look at the contents on a Windows 7 laptop. Is there a program t

  • I cannot automatically synchronize  my iphone to itunes, itunes apparently does not recognize it

    I cannot automatically synchronize  my iphone to itunes, itunes apparently does not recognize it

  • No entry for adapter engine in CPACache

    Hi all, This is a new installation of PI 7.0. Some of the issues we are facing are: 1) ID -> cache notifications -> unable to determine the name of central AE from SLD 2) Integration Builder -> Admin -> cache overview -> refresh objects fails 3) RWB

  • Can't connect to my Mac from a PC

    I need to connect PCs on our company network to folders on my iMac. I've tried everything. Nothing works. I have folders on my Mac set up for sharing. I did manage, yesterday afternoon, to connect to my Mac from my virtual PC that's on this same Mac.