Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Use Javascript to freeze an Interactive Report column

indy2005Jul 5 2019 — edited Jul 5 2019

I have a dynamic IR using a Collection.  I need to programmatically set the frozen column, and was wondering if this is possible via javascript or the Oracle side API?


Thanks


Stephen

Comments

camickr
The correct way is probably to override the TabbedPaneUI, but that too complicated for me, so here's a quick hack that might give you some ideas:
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.*;

public class TabbedPaneWithText extends JFrame
{
	public TabbedPaneWithText()
	{
		JTabbedPane tabbedPane = new JTabbedPane()
		{
			public void paintComponent(Graphics g)
			{
				super.paintComponent(g);

				Rectangle lastTab = getUI().getTabBounds(this, getTabCount() - 1);
				int tabEnd = lastTab.x + lastTab.width;

				String text = "Some Text";
				FontMetrics fm = getFontMetrics( getFont() );
				int stringWidth = fm.stringWidth( text ) + 10;
				int x = getSize().width - stringWidth;

				if (x < tabEnd)
					x = tabEnd;

				g.drawString(text, x + 5, 18);
			}
		};
		tabbedPane.add("1", new JTextField("one"));
		tabbedPane.add("2", new JTextField("two"));
		getContentPane().add(tabbedPane);
	}

	public static void main(String args[])
	{
        TabbedPaneWithText frame = new TabbedPaneWithText();
        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
        frame.pack();
        frame.setLocationRelativeTo( null );
        frame.setVisible(true);
	}
}
843804
Thank you, what you posted got me on the right track.

Thanks again!

Brent
843804
The usual solution to this kind of problem is to use a renderer or editor.
camickr has posted a paintComponent method that acts like a tabbed pane renderer, which renders text.

The problem is that you can't add a component to more than one container, so if you have a JPanel you can only put it in one tab. When the user changes tabs, you can remove the component and add it to the next tab. If you use this approach, make sure to use invokeLater() to do the adding/removing of the tab's component.

Or you can override paintComponent and render the tab. This works fine unless you want to edit the text, then you'll need a tabbed pane editor. So basically each tab would contain a tabbed pane editor, and the editor displays a shared JPanel that has text you can edit.
1 - 3

Post Details

Added on Jul 5 2019
3 comments
1,199 views