A scroll bar/scrollPane
I'm having some buttons populated in to a mc (using a mysql db). At the moment there are abut 700 buttons. But I don't know how to get it into a scrollPane or some other way so has a scroll bar beside this mc.
I initially had the patHolder on the swf stage (not exported to actionscript) and then after the buttons are populated i tried to use the refresh() to make the scroll pane work. After reading your post I tried the following, but I'm a bit lost here.
//content path (Componant inspector): patHolder
var myContent:MovieClip= scrollerGS.content
var senderLoad:LoadVars = new LoadVars();
var receiveLoad:LoadVars = new LoadVars();
senderLoad.sendAndLoad("http://www.web.com/the.php",receiveLoad,"POST");
receiveLoad.onData = function(src) {
var messageA:Array = src.split(",,,");
messageA.pop();
var xPosition:Number = 0;
var yPosition:Number = 0;
for(var i:Number=0; i<messageA.length; i++){
var msgA:Array = messageA[i].split(",,");
//_root.patHolder.attachMovie("XBtn1","btn"+i,_root.patHolder.getNextHig hestDepth());
var currentButton:MovieClip=myContent.attachMovie("XBtn1","btn"+i,1000+i) ;
//_root.patHolder["btn"+i]._x = xPosition;
//_root.patHolder["btn"+i]._y = yPosition;
currentButton._x=xPosition;
currentButton._y=yPosition;
yPosition = yPosition + 31.0;
_root.patHolder["btn"+i].textBlack.text = msgA[0];
scrollerGS.invalidate();
Similar Messages
-
Question about ScrollPane scroll bar
Hello Everyone,
Currently I am working in Flash Professional 8. I need to
customize the scroll bar in the ScrollPane. I figured out how to
customize the graphics.
Instead of the lil grey scroll bar that you can drag I want
it to be an arrow. I made it into an arrow but there appears to be
some sort of size restriction on it and the arrow I created appears
distorted. Is there some way I can change this size restriction and
have the scroll bar be 100 pixels high if I wanted it to be?
Thanks in advance for any help!anybody?
-
ScrollPane vertical scroll bar positioning
I have a ScrollPane that holds a number of number of sprites. The sprites are like rows and I would like them to fill the width of the ScrollPane.
My problem is that if there are not enough sprites to fill the vertical space of the ScrollPane, then no Scrollbar appears and there is a narrow gap left on the right side of the ScrollPane. If I make the sprites wider, when the vertical scroll bar does appear some of the sprite is cut off and the horizontal scroll bar appears (I never want the horizontal one to appear).
Is there a way to move the scrollBars? or perhaps another way to solve my issue?assign your sp's horizontalScrollPolicy (and/or verticalScrollPolicy) to "off".
-
Flash mx -ScrollPane - scroll bar issue
If we create some dynamic content and display it using
scrollPane and if the width and height of the clip( the clip
displayed in ScrollPane) changes dynamically by clicking on a
button then refreshPane method does not work properly. We have to
set original position of the clip to (0, 0) when scroll bar
(vertical/ horizontal) disappears. I think this is not a good idea
to work around with scrollPane.
Let me know if there are any efficient methods with which we
can handle dynamic data in scrollPane to display it properly.
Thanks in advance,
ShreeramHi,
Thanks for your co-operation. Please let me know if
Macromedia Team fixes this bugs. Till then please let know about
any methods or any solutions if you know.
thanks
Shreeram -
Scroll bars not coming in a scrollpane
Hi,
I have a splitpane on which i have added a scrollpane. On the scrollpane i have added a panel on whcih i have added an image.
now when i run the program, and i decrease the resolution, the size of the image gets bigger and it gets truncated by the toolbar of the frame. whereas what i expected was that the scrollbar shuld have come and i shuld have been able to see the image by using hte scroll bars
anyideas on what went wrong?
thanx
deepak sainiHi,
the thing is confusing me actually.. Now i am running the applicaiton at a lower resolution and trying to fit the things.
everything comes fine but when i raise the splitpnae on which i have the scrollpane, the scrollpane completely covers the whole frame and the toolbar disappears.
I have copied the lines of code ....have a look and do tell me if u see somethiing wrong!!!
panelTop = new JPanel();
panelTop.setLayout(new BorderLayout());
textArea = new JTextArea(300, 100);
textArea.setCaretPosition(textArea.getDocument().getLength());
scrollPane = new JScrollPane(textArea);
scrollPaneTop = new JScrollPane(panelTop);
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPaneTop, scrollPane);
splitPane.setOneTouchExpandable(true);
splitPane.setDividerLocation(480);
Dimension minimumSize = new Dimension(200,200);
//panelTop.setMinimumSize(minimumSize);
Dimension minimumSize2 = new Dimension(50,150);
scrollPaneTop.setMinimumSize(minimumSize2);
panelTop.setPreferredSize(minimumSize);
panelTop.setBounds(20,250, 200, 200);
//Provide a preferred size for the split pane
splitPane.setBounds(10,250, 200, 400);
panelTop.setVisible(true);
JPanel toolBarPanel = new JPanel();
toolBarPanel.setBounds(1,1,750,50);
toolBar = new JToolBar();
toolBarPanel.add(toolBar);
toolBarPanel.setVisible(true);
getContentPane().add(toolBarPanel);
toolBar.setBackground(Color.red); -
Reskinning scrollPane scroll bar
Hey. I'm trying to resking the scroll bars of the scrollPane
component
in Flash 8 and haven't quite figure it out using the standard
/ limited
Flash Help provided. I've been able to use the Help to reskin
a
standard UIScrollBar component by duplicating / altering the
desired
states. This is the simple code placed on the scrollBar
instance on
the timeline that can redirect it to use a new instance:
onClipEvent(initialize){
downArrowDownName = "ScrollDownArrowDown2";
ScrollDownArrowDown2 obviously being the new movie clip.
However, even
though Flash Help tells me that the scrollPane component
utilizes the
UIScollBar elements and to refer to that section to alter the
ScrollPane, I cannot simply use the code above on the
scrollPane
component. It sounds like this should be fairrly easy to
figure out,
but I'm out of options. Thoughts?anybody?
-
Remove/Hide scroll bars in scroll panes.
Hi all,
I am pretty new to action script. I am building a photo gallery and I am loading the thumbnails from an XML file into a scroll pane dynamically. As the scroll pane fills up, it gets wider to accomodate the thumbnails. There is one row, and eventually, I want to have the user be able to mouse left or right and have the scroll pane scroll, versus clicking on the bar or the left/right arrows. However, in order to accomplish this, I need the scroll bars to disappear!
Is there anyway to either remove or hide both the x and y scroll bars on a scroll pane? My scroll pane is called: thumbPane.
Thanks in advance!
-RobHello friend,
first select scrollpane.Then open parameters panel (if dont know go to window > properties > paramiters ) turn to OFF HorizontalScrollPolicy and verticalScrollPoliy then left and right scroll Bar will not display.
THANKS. -
How do i add a Scroll Bar to a JList Component using absolute positioning?
I've got a applet whose content pane is set to null. I've create a jlist component on this applet and using absolute positioning set the bounds at
ListBox1.setBounds(380,10, 500, 500);.
My problem is creating add a scroll bar to the list box.
JScrollPane scrollPane = new JScrollPane(ListBox1);
C.add(scrollPane);
The above code is what i use and when i run this applet i don't see the list box at all. How do i add a scrollbar to this list box or JList component. Please help.You need to setBounds() on the JScrollPane, not the JList.
The JScrollPane is the component that is being added to the panel. -
JTextArea w/Scroll bar wont scroll AND code drops through if statements
Hi, I'm still having trouble with the text area in the following code. When you run the code, you get the top arrow on the scroll bar, but the bottom is cut off. Also, a big problem is that no matter what choice is selected from the combo box, the code drops through to the last available value each time. Someone on the forums suggested using an array list for the values in the combo box, but I have not been able to figure out how to do that. A quick example would be apprciated.
Thank you in advance for any help
//Import required libraries
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.text.*;
import java.math.*;
import java.util.*;
//Create the class
public class Week3Assignment407B extends JFrame implements ActionListener
//Panels used in container
private JPanel jPanelRateAndTermSelection;
//Variables for Menu items
private JMenuBar menuBar;
private JMenuItem exitMenuItem;
private JMenu fileMenu;
//Variables for user instruction and Entry
private JLabel jLabelPrincipal;
private JPanel jPanelEnterPrincipal;
private JLabel jLabelChooseRateAndTerm;
private JTextField jTextFieldMortgageAmt;
//Variables for combo box and buttons
private JComboBox TermAndRate;
private JButton buttonCompute;
private JButton buttonNew;
private JButton buttonClose;
//Variables display output
private JPanel jPanelPaymentOutput;
private JLabel jLabelPaymentOutput;
private JPanel jPanelErrorOutput;
private JLabel jLabelErrorOutput;
private JPanel jPanelAmoritizationSchedule;
private JTextArea jTextAreaAmoritization;
// Constructor
public Week3Assignment407B() {
super("Mortgage Application");
initComponents();
// create a method that will initialize the main frame for the GUI
private void initComponents()
setSize(700,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container pane = getContentPane();
GridLayout grid = new GridLayout(15, 1);
pane.setLayout(grid);
//declare all of the panels that will go inside the main frame
// Set up the menu Bar
menuBar = new JMenuBar();
fileMenu = new JMenu();
fileMenu.setText("File");
exitMenuItem = new JMenuItem();
exitMenuItem.setText("Exit");
fileMenu.add(exitMenuItem);
menuBar.add(fileMenu);
pane.add(menuBar);
//*******************TOP PANEL ENTER PRINCIPAL*****************************//
// Create a label that will advise user to enter a principle amount
jPanelEnterPrincipal = new JPanel();
jLabelPrincipal = new JLabel("Amt to borrow in whole numbers");
jTextFieldMortgageAmt = new JTextField(10);
GridLayout Principal = new GridLayout(1,2);
jPanelEnterPrincipal.setLayout(Principal);
jPanelEnterPrincipal.add(jLabelPrincipal);
jPanelEnterPrincipal.add(jTextFieldMortgageAmt);
pane.add(jPanelEnterPrincipal);
//****************MIDDLE PANEL CHOOSE INTEREST RATE AND TERM*****************//
// Create a label that will advise user to choose an Int rate and term combination
// from the combo box
jPanelRateAndTermSelection = new JPanel();
jLabelChooseRateAndTerm = new JLabel("Choose the Rate and Term");
buttonCompute = new JButton("Compute Mortgage");
buttonNew = new JButton("New Mortgage");
buttonClose = new JButton("Close");
GridLayout RateAndTerm = new GridLayout(1,5);
//FlowLayout RateAndTerm = new FlowLayout(FlowLayout.LEFT);
jPanelRateAndTermSelection.setLayout(RateAndTerm);
jPanelRateAndTermSelection.add(jLabelChooseRateAndTerm);
TermAndRate = new JComboBox();
jPanelRateAndTermSelection.add(TermAndRate);
TermAndRate.addItem("7 years at 5.35%");
TermAndRate.addItem("15 years at 5.5%");
TermAndRate.addItem("30 years at 5.75%");
jPanelRateAndTermSelection.add(buttonCompute);
jPanelRateAndTermSelection.add(buttonNew);
jPanelRateAndTermSelection.add(buttonClose);
pane.add(jPanelRateAndTermSelection);
//**************BOTTOM PANEL TEXT AREA FOR AMORITIZATION SCHEDULE***************//
jPanelAmoritizationSchedule = new JPanel();
jTextAreaAmoritization = new JTextArea(26,50);
// add scroll pane to output text area
JScrollPane scrollBar = new JScrollPane(jTextAreaAmoritization,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
jPanelAmoritizationSchedule.add(scrollBar);
pane.add(jPanelAmoritizationSchedule);
//***************ADD THE ACTION LISTENERS TO THE GUI COMPONENTS*****************//
// Add ActionListener to the buttons and menu item
exitMenuItem.addActionListener(this);
buttonCompute.addActionListener(this);
buttonNew.addActionListener(this);
buttonClose.addActionListener(this);
TermAndRate.addActionListener(this);
jTextFieldMortgageAmt.addActionListener(this);
//*************** Set up the Error output area*****************//
jPanelErrorOutput = new JPanel();
jLabelErrorOutput = new JLabel();
FlowLayout error = new FlowLayout();
jPanelErrorOutput.setLayout(error);
pane.add(jLabelErrorOutput);
setContentPane(pane);
pack();
setVisible(true);
//Display error messages
private void OutputError(String ErrorMsg){
jLabelErrorOutput.setText(ErrorMsg);
jPanelErrorOutput.setVisible(true);
//create a method that will clear all fields when the New Mortgage button is chosen
private void clearFields()
jTextAreaAmoritization.setText("");
jTextFieldMortgageAmt.setText("");
//**************CREATE THE CLASS THAT ACTUALLY DOES SOMETHING WITH THE EVENT*****//
//This is the section that receives the action source and directs what to do with it
public void actionPerformed(ActionEvent e)
Object source = e.getSource();
String ErrorMsg;
double principal;
double IntRate;
int Term;
double monthlypymt;
double TermInYears = 0 ;
if(source == buttonClose)
System.exit(0);
if (source == exitMenuItem) {
System.exit(0);
if (source == buttonNew)
clearFields();
if (source == buttonCompute)
//Make sure the user entered valid numbers
try
principal = Double.parseDouble(jTextFieldMortgageAmt.getText());
catch(NumberFormatException nfe)
ErrorMsg = (" You Entered an invalid Mortgage amount"
+ " Please try again. Please do not use commas or decimals");
jTextAreaAmoritization.setText(ErrorMsg);
principal = Double.parseDouble(jTextFieldMortgageAmt.getText());
if (TermAndRate.getSelectedItem() == "7 years at 5.35%") ;
Term = 7;
IntRate = 5.35;
if (TermAndRate.getSelectedItem() == "15 years at 5.5%") ;
Term = 15;
IntRate = 5.5;
if (TermAndRate.getSelectedItem() == "30 years at 5.75%") ;
Term = 30;
IntRate = 5.75;
//Variables have been checked for valid input, now calculate the monthly payment
NumberFormat formatter = new DecimalFormat ("$###,###.00");
double intdecimal = intdecimal = IntRate/(12 * 100);
int months = Term * 12;
double monthlypayment = principal *(intdecimal / (1- Math.pow((1 + intdecimal),-months)));
//Display the Amoritization schedule
jTextAreaAmoritization.setText(" Loan amount of " + formatter.format(principal)
+ "\n"
+ " Interest Rate is " + IntRate + "%"
+ "\n"
+ " Term in Years " + Term
+ " Monthly payment "+ formatter.format(monthlypayment)
+ "\n"
+ " Amoritization is as follows: "
+ "------------------------------------------------------------------------");
public Insets getInsets()
Insets around = new Insets(35,20,20,35);
return around;
//Main program
public static void main(String[]args) {
Week3Assignment407B frame = new Week3Assignment407B();
}here's your initComponents with a couple of changes, the problem was the Gridlayout(15,1)
also, the scrollpane needed a setPreferredSize()
private void initComponents()
setSize(700,400);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Container pane = getContentPane();
JPanel pane = new JPanel();
//GridLayout grid = new GridLayout(15, 1);
GridLayout grid = new GridLayout(2, 1);
pane.setLayout(grid);
menuBar = new JMenuBar();
fileMenu = new JMenu();
fileMenu.setText("File");
exitMenuItem = new JMenuItem();
exitMenuItem.setText("Exit");
fileMenu.add(exitMenuItem);
menuBar.add(fileMenu);
//pane.add(menuBar);
setJMenuBar(menuBar);
jPanelEnterPrincipal = new JPanel();
jLabelPrincipal = new JLabel("Amt to borrow in whole numbers");
jTextFieldMortgageAmt = new JTextField(10);
GridLayout Principal = new GridLayout(1,2);
jPanelEnterPrincipal.setLayout(Principal);
jPanelEnterPrincipal.add(jLabelPrincipal);
jPanelEnterPrincipal.add(jTextFieldMortgageAmt);
pane.add(jPanelEnterPrincipal);
jPanelRateAndTermSelection = new JPanel();
jLabelChooseRateAndTerm = new JLabel("Choose the Rate and Term");
buttonCompute = new JButton("Compute Mortgage");
buttonNew = new JButton("New Mortgage");
buttonClose = new JButton("Close");
GridLayout RateAndTerm = new GridLayout(1,5);
jPanelRateAndTermSelection.setLayout(RateAndTerm);
jPanelRateAndTermSelection.add(jLabelChooseRateAndTerm);
TermAndRate = new JComboBox();
jPanelRateAndTermSelection.add(TermAndRate);
TermAndRate.addItem("7 years at 5.35%");
TermAndRate.addItem("15 years at 5.5%");
TermAndRate.addItem("30 years at 5.75%");
jPanelRateAndTermSelection.add(buttonCompute);
jPanelRateAndTermSelection.add(buttonNew);
jPanelRateAndTermSelection.add(buttonClose);
pane.add(jPanelRateAndTermSelection);
jPanelAmoritizationSchedule = new JPanel();
jTextAreaAmoritization = new JTextArea(26,50);
JScrollPane scrollBar = new JScrollPane(jTextAreaAmoritization,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
scrollBar.setPreferredSize(new Dimension(500,100));//<------------------------
jPanelAmoritizationSchedule.add(scrollBar);
getContentPane().add(pane,BorderLayout.NORTH);
getContentPane().add(jPanelAmoritizationSchedule,BorderLayout.CENTER);
exitMenuItem.addActionListener(this);
buttonCompute.addActionListener(this);
buttonNew.addActionListener(this);
buttonClose.addActionListener(this);
TermAndRate.addActionListener(this);
jTextFieldMortgageAmt.addActionListener(this);
jPanelErrorOutput = new JPanel();
jLabelErrorOutput = new JLabel();
FlowLayout error = new FlowLayout();
jPanelErrorOutput.setLayout(error);
//pane.add(jLabelErrorOutput);not worrying about this one
//setContentPane(pane);
pack();
setVisible(true);
}instead of
if (TermAndRate.getSelectedItem() == "7 years at 5.35%") ;
Term = 7;
IntRate = 5.35;
you would be better off setting up arrays
int[] term = {7,15,30};
double[] rate = {5.35,5.50,5.75};
then using getSelectedIndex()
int loan = TermAndRate.getSelectedIndex()
Term = term[loan];
IntRate = rate[loan]; -
Horizontal scroll bar at top in JScrollPane
Hi,
How can i get the horizontal scroll bar to be on the top instead of bottom
here is my code
TableModel tableModel = new TableModel(totalData,
columnHeader);
JTable table = new JTable(tableModel);
JScrollPane scrollPane = new JScrollPane(table);
AshishHi Ash
I dont know whether this is feasible please sorry if i am wrong.
Create a JPanel and add scroll bar to the left and top.
I have posted a Q in the subject JDialog Esc Key. please answer the Q for me.
Lakshmi. -
Scroll Bar code in Awt Required Plz Help me
Hi,
My requirment is to add Vertical Scrollbar to the table.There are 12 rows in a table like from January to December.
I am able to see data of rows as jan,feb,mar,apr only .
i want to see the data of rows of next months by adding vertical scroll bar using Awt code.
I added vertical scroll bar using awt code. When i click on that Vertical scroll bar event is going to below method.
public void adjustmentValueChanged(AdjustmentEvent e) {
I tried with some logic inside above method but it is not working.what is the code i have to write inside the above method inorder to scroll the next months.
Plz Help me.
Thanks In Advance.........But i want to do this code In Using Awt only......Well, a JTable is a Swing component so I have no idea what you are talking about.
To control the size of the table you can use:
table.setPreferredScrollableViewportSize(???);
JScrollPane scrollPane = new JScrollPane( table ); -
Scroll bar does not retain its position after or before pack
Hi
My Scroll bar does not retain its position after pack in my application.
But i need to retain its state.
My code snippet is :
System.out.println("VAlue--->" + getHXValue());
scrollPane.getHorizontalScrollBar().setValue(getHXValue());
pack();
My VAlue printed is 100.
But my positon of scroll bar is at 0 th location.
Can any one help me.....Swing related questions should be posted in the Swing forum.
My code snippet is :Snippets don't help.
If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)",
see http://homepage1.nifty.com/algafield/sscce.html,
that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
Don't forget to use the "Code Formatting Tags",
see http://forum.java.sun.com/help.jspa?sec=formatting,
so the posted code retains its original formatting. -
Ok what I have is a site I am building for school. I have some textfields loaded from a outside file. Some of the fields have more text then will show in the size of the box, and you can sroll it down to read it all but unless you try to scroll there is really now way to tell you can do it just buy looking at the text box. So I want to add a scroll bar and we have not covered that in class.
Note everything has to be added using AS3 we can have no content on the timeline. I have look to try to find something so show me how to dod this but all I can find are videos on doing it using the stage and adding items to it.Can you make it a little more plane please. I am working on so much other sruff along with this I am drawing a blank. I tried a couple things but get this arroa code.
TypeError: Error #1034: Type Coercion failed: cannot convert fl.containers::ScrollPane@311540b1 to flash.display.MovieClip.
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at beta_fla::MainTimeline() -
JTable can't display column names and scroll bar in JDialog !!
Dear All ,
My flow of program is JFrame call JDialog.
dialogCopy = new dialogCopyBay(frame, "Bay Name Define", true, Integer.parseInt(txtSourceBay.getText()) ,proVsl ,300 ,300);
dialogCopy.setBounds(0, 0, 300, 300);
dialogCopy.setVisible(true); Then,I set the datasource of JTable is from a TableModel.
It's wild that JTable can diplay the data without column names and scroll bar.
I have no idea what's going wrong.Cause I follow the Sun Tutorial to code.
Here with the code of my JDialog.
Thanks & Best Regards
package com.whl.panel;
import com.whl.vslEditor.vslDefine;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Frame;
import javax.swing.JDialog;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
public class dialogCopyBay extends JDialog {
vslDefine glbVslDefine;
int lvCnt = -1;
JTable tableCopyBay;
int bgnX = 0;
int bgnY = 30;
int tableWidth = 100;
int tableHeight = 100;
public dialogCopyBay(Frame frame, String title, boolean modal, int sourceBay,
vslDefine pVslDefine, int ttlWidth, int ttlHeight) {
super(frame, title, true);
Container contentPane = getContentPane();
System.out.println("dialogCopyBay Constructor");
glbVslDefine = null;
glbVslDefine = pVslDefine;
copyBayModel copyBay = new copyBayModel((glbVslDefine.getVslBayStructure().length - 1),sourceBay);
tableCopyBay = new JTable(copyBay);
tableCopyBay.setPreferredScrollableViewportSize(new Dimension(tableWidth, tableHeight));
JScrollPane scrollPane = new JScrollPane(tableCopyBay);
scrollPane.setViewportView(tableCopyBay) ;
tableCopyBay.setFillsViewportHeight(true);
tableCopyBay.setBounds(bgnX, bgnY, tableWidth, tableHeight);
tableCopyBay.setBounds(10, 10, 100, 200) ;
contentPane.setLayout(null);
contentPane.add(scrollPane);
contentPane.add(tableCopyBay);
class copyBayModel extends AbstractTableModel {
String[] columnNames;
Object[][] dataTarget;
public copyBayModel(int rowNum ,int pSourceBay) {
columnNames = new String[]{"Choose", "Bay Name"};
dataTarget = new Object[rowNum][2];
for (int i = 0; i <= glbVslDefine.getVslBayStructure().length - 1; i++) {
if (pSourceBay != glbVslDefine.getVslBayStructure().getBayName() &&
glbVslDefine.getVslBayStructure()[i].getIsSuperStructure() == 'N') {
lvCnt = lvCnt + 1;
dataTarget[lvCnt][0] = false;
dataTarget[lvCnt][1] = glbVslDefine.getVslBayStructure()[i].getBayName();
System.out.println("lvCnt=" + lvCnt + ",BayName=" + glbVslDefine.getVslBayStructure()[i].getBayName());
public int getRowCount() {
return dataTarget.length;
public int getColumnCount() {
return columnNames.length;
public String getColumnName(int col) {
return columnNames[col];
public Object getValueAt(int rowIndex, int columnIndex) {
return dataTarget[rowIndex][columnIndex];
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
public boolean isCellEditable(int row, int col) {
if (col == 1) {
// Bay Name Not Allow To modify
return false;
} else {
return true;
public void setValueAt(Object value, int row, int col) {
dataTarget[row][col] = value;
fireTableCellUpdated(row, col);Dear DB ,
I am not sure what you mean.
Currently,I don't undestand which code is error.
And I also saw some example is add JTable and JScrollPane in JDialog.
Like Below examle in Sun tutorial
public class ListDialog extends JDialog implements MouseListener, MouseMotionListener{
private static ListDialog dialog;
private static String value = "";
private JList list;
public static void initialize(Component comp,
String[] possibleValues,
String title,
String labelText) {
Frame frame = JOptionPane.getFrameForComponent(comp);
dialog = new ListDialog(frame, possibleValues,
title, labelText);
* Show the initialized dialog. The first argument should
* be null if you want the dialog to come up in the center
* of the screen. Otherwise, the argument should be the
* component on top of which the dialog should appear.
public static String showDialog(Component comp, String initialValue) {
if (dialog != null) {
dialog.setValue(initialValue);
dialog.setLocationRelativeTo(comp);
dialog.setVisible(true);
} else {
System.err.println("ListDialog requires you to call initialize " + "before calling showDialog.");
return value;
private void setValue(String newValue) {
value = newValue;
list.setSelectedValue(value, true);
private ListDialog(Frame frame, Object[] data, String title,
String labelText) {
super(frame, title, true);
//buttons
JButton cancelButton = new JButton("Cancel");
final JButton setButton = new JButton("Set");
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ListDialog.dialog.setVisible(false);
setButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ListDialog.value = (String) (list.getSelectedValue());
ListDialog.dialog.setVisible(false);
getRootPane().setDefaultButton(setButton);
//main part of the dialog
list = new JList(data);
list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
list.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
setButton.doClick();
JScrollPane listScroller = new JScrollPane(list);
listScroller.setPreferredSize(new Dimension(250, 80));
//XXX: Must do the following, too, or else the scroller thinks
//XXX: it's taller than it is:
listScroller.setMinimumSize(new Dimension(250, 80));
listScroller.setAlignmentX(LEFT_ALIGNMENT);
//Create a container so that we can add a title around
//the scroll pane. Can't add a title directly to the
//scroll pane because its background would be white.
//Lay out the label and scroll pane from top to button.
JPanel listPane = new JPanel();
listPane.setLayout(new BoxLayout(listPane, BoxLayout.Y_AXIS));
JLabel label = new JLabel(labelText);
label.setLabelFor(list);
listPane.add(label);
listPane.add(Box.createRigidArea(new Dimension(0, 5)));
listPane.add(listScroller);
listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
//Lay out the buttons from left to right.
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS));
buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
buttonPane.add(Box.createHorizontalGlue());
buttonPane.add(cancelButton);
buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
buttonPane.add(setButton);
//Put everything together, using the content pane's BorderLayout.
Container contentPane = getContentPane();
contentPane.add(listPane, BorderLayout.CENTER);
contentPane.add(buttonPane, BorderLayout.SOUTH);
pack();
public void mouseClicked(MouseEvent e) {
System.out.println("Mouse Click");
public void mousePressed(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
public void mouseReleased(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
public void mouseEntered(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
public void mouseExited(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
public void mouseDragged(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
public void mouseMoved(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
* This is here so that you can view ListDialog even if you
* haven't written the code to include it in a program.
} -
JScrollPane's scroll bar alignment
I tried all the suggested methods, and yet I still get the vertical scroll bar aligned somewhere in the middle when the JFrame opens, when top alignment would be preferable... Any suggestion on this is more than welcome. My code is structured with nested components like this:
JScrollPane scroll
---JPanel allJPanels
------JPanel a
---------JPanel a_1
---------JLabel a_2
---------JEditorPane a_3
------JPanel b
---------JPanel b_1
---------JLabel b_2
---------JEditorPane b_3
scroll.setViewportView( allJPanels );
Methods attempted:
scroll.getVerticalScrollBar().setValue( scroll.getVerticalScrollBar().getMinimum() );
OR
scroll.getViewport().setViewPosition( new java.awt.Point( 0, 0 ) );
OR
scroll.getVerticalScrollBar().getModel().setValue( 0 );
OR
allJPanels.scrollRectToVisible( new java.awt.Rectangle( 1, 1, allJPanels.getWidth(), allJPanels.getHeight() ) );
Thanks for any suggestionCould you please explain your exact requirement. If you just want whether you have to show the scrollpane or not then there is a policy in JScrollpane in which you can set the vertical scrollbar policy as required.
Maybe you are looking for
-
I want to include some video in my iphone app, which will be embedded into the .ipa file. What is the best format of video to use, and should it be embedded in Flash or external? Regards Simon
-
Recovered files folder in trash on startup?
Hi um.. howcome when I turn my mac on theres sometimes a folder called Recovered files in my trash bin? is my Laptop not holding onto data?
-
Hi, Here i require the indicator tick on in case of Import PO for the sake of convience for report purpose.Can i do this? Pl give the suggestion.
-
9i - calling reports from menu
Hi, Could somebody tell me if it's possible to call a report using the run_report_object facility from a menu. There isn't the reports node that there is on a form to define the report. Many thanks, Sean Dwyer
-
32bit browser on 64bit Windows 2008 Server
We're running 32-bit IE 7.0 on a 64-bit installation of Windows 2008 Server. When attempting to download Adobe Flash Player from adobe.com, we receive the message that our platform is not supported. This article mentions it is possible to use a 32-bi