Ctrl PgUp / CtrlPgDown in JTables vs JTabbedPanes

Hi there, another wee JTable problem.
I want Ctrl PageUp and Ctrl PageDown to move between JTabbedPanes. This normally works, except when the focus is currently in a JTable. I want it to also work if the focus is in a JTable.
I have tried to stop the JTable from handling the keys by setting the inputmap to "none" but this has no effect (you can see my code for this below).
Here is a test program that shows the bad behaviourimport java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.InputMap;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
public class TestTable extends JTable {
     public TestTable(Object[][] data, Object[] headings) {
          super(data, headings);
          setFocusTraversalPolicyProvider(true);
          // Turn off Ctrl PgUp and Ctrl PgDown handling so tab navigation works.
          InputMap inputs = getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
          KeyStroke ctrlPgUpKey = KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, InputEvent.CTRL_DOWN_MASK);
          inputs.put(ctrlPgUpKey, "None");
          KeyStroke ctrlPgDownKey = KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, InputEvent.CTRL_DOWN_MASK);
          inputs.put(ctrlPgDownKey, "None");
     public boolean isCellEditable(int row, int column) {
          return false;
     public static void main(String[] args) {
          JFrame frame = new JFrame("Test table");
          JTabbedPane pane = new JTabbedPane();
          frame.add(pane);
          JPanel panel = new JPanel();
          JTextField field = new JTextField("Key Ctrl PgDown or Ctrl PgUp");
          panel.add(field);
          pane.add("test1", panel);
          pane.add("test2", new JScrollPane(new TestTable(new String[][] {{"hello", "me"}}, new String[]{"H1", "H2"})));
          pane.add("test3", new JPanel());
          frame.setBounds(100, 100, 300, 300);
          frame.setVisible(true);
}Thanks,
Tim

i had a similiar problem, had some UIs that had a Tabbed pane and
ScrollBars, and some tabs had JTables in them, anyhow, I just wanted
Control-Page_up/Down to work for the JTabbedPane all the the time so
I did this in my windows look and feel applications and all was well, just posting so maybe this will help someone down the road
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
UIDefaults uiDefaults = UIManager.getDefaults();
// ginny wants Control-Page-Up and Control-Page-Down to work for tabbed
// panes, which it does by default, however, it also works for JTable
// and JScrollPane, and those components grab the keystroke 1st if they are
// all in the same screen, so disabling it for JTable and JScrollPane
// see WindowsLookAndFeel.java
uiDefaults.remove("ScrollPane.ancestorInputMap");
uiDefaults.put("ScrollPane.ancestorInputMap",
new UIDefaults.LazyInputMap(new Object[] {
"RIGHT", "unitScrollRight",
"KP_RIGHT", "unitScrollRight",
"DOWN", "unitScrollDown",
"KP_DOWN", "unitScrollDown",
"LEFT", "unitScrollLeft",
"KP_LEFT", "unitScrollLeft",
"UP", "unitScrollUp",
"KP_UP", "unitScrollUp",
"PAGE_UP", "scrollUp",
"PAGE_DOWN", "scrollDown",
"ctrl PAGE_UP", "None", //"scrollLeft",
"ctrl PAGE_DOWN", "None",//"scrollRight",
"ctrl HOME", "scrollHome",
"ctrl END", "scrollEnd"
uiDefaults.remove("Table.ancestorInputMap");
uiDefaults.put("Table.ancestorInputMap",
new UIDefaults.LazyInputMap(new Object[] {
"ctrl C", "copy",
"ctrl V", "paste",
"ctrl X", "cut",
"COPY", "copy",
"PASTE", "paste",
"CUT", "cut",
"RIGHT", "selectNextColumn",
"KP_RIGHT", "selectNextColumn",
"LEFT", "selectPreviousColumn",
"KP_LEFT", "selectPreviousColumn",
"DOWN", "selectNextRow",
"KP_DOWN", "selectNextRow",
"UP", "selectPreviousRow",
"KP_UP", "selectPreviousRow",
"shift RIGHT", "selectNextColumnExtendSelection",
"shift KP_RIGHT", "selectNextColumnExtendSelection",
"shift LEFT", "selectPreviousColumnExtendSelection",
"shift KP_LEFT", "selectPreviousColumnExtendSelection",
"shift DOWN", "selectNextRowExtendSelection",
"shift KP_DOWN", "selectNextRowExtendSelection",
"shift UP", "selectPreviousRowExtendSelection",
"shift KP_UP", "selectPreviousRowExtendSelection",
"PAGE_UP", "scrollUpChangeSelection",
"PAGE_DOWN", "scrollDownChangeSelection",
"HOME", "selectFirstColumn",
"END", "selectLastColumn",
"shift PAGE_UP", "scrollUpExtendSelection",
"shift PAGE_DOWN", "scrollDownExtendSelection",
"shift HOME", "selectFirstColumnExtendSelection",
"shift END", "selectLastColumnExtendSelection",
"ctrl PAGE_UP", "None", //"scrollLeftChangeSelection",
"ctrl PAGE_DOWN", "None", //"scrollRightChangeSelection",
"ctrl HOME", "selectFirstRow",
"ctrl END", "selectLastRow",
"ctrl shift PAGE_UP", "scrollRightExtendSelection",
"ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
"ctrl shift HOME", "selectFirstRowExtendSelection",
"ctrl shift END", "selectLastRowExtendSelection",
"TAB", "selectNextColumnCell",
"shift TAB", "selectPreviousColumnCell",
"ENTER", "selectNextRowCell",
"shift ENTER", "selectPreviousRowCell",
"ctrl A", "selectAll",
"ESCAPE", "cancel",
"F2", "startEditing"
}));

Similar Messages

  • JTable on JTabbedPane

    Hi,
    I was wondering how you would add a JTable onto a JTabbedPane?
    Thanks

    import javax.swing.*;
    import java.awt.*;
    public class TabTable {
         TabTable(){
              JFrame.setDefaultLookAndFeelDecorated(true);
              JFrame f = new JFrame("JTable in JTabbedPane ...");
              JTabbedPane tab = new JTabbedPane();
              Object table [][] = {{"Singaravelan","21","MALE"},{"Devanderan","19","MALE"}};
              String column [] = {"NAME","AGE","SEX"};
              JTable jtable = new JTable(table,column);
              JPanel panel = new JPanel();
              panel.setLayout(new FlowLayout());
              panel.add(jtable);
              tab.addTab("Table 1",panel);
              tab.addTab("Table 2",new JLabel("Table 2",JLabel.CENTER));
              tab.addTab("Table 3",new JLabel("Table 3",JLabel.CENTER));
              f.getContentPane().add(tab);
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              f.setSize(500,500);
              f.setVisible(true);
         public static void main(String args[]){
              new TabTable();          
    }

  • Resize JTable in JTabbedPane

    Given the FileTableDemo from the Java Foundation Class in a Nutshell book.(O'Reilly) Chapter 3 page 51 in my addition.
    I have modified the example to place the JTable in a JTabbedPane. Now when the window (JFrame) is resized by the user the JTable no longer resizes. How do I passing the "resizing" into the component (JTable) placed in the JTabbedPane?
    Here is the code: My deviation from the example is enclosed in "///////////KBS" and of course the line frame.getContentPane().add(myTP, "Center"); where "pane" has been replaced with "myTP"
    Thanks Brad
    import javax.swing.*;
    import javax.swing.table.*;
    import java.io.File;
    import java.util.Date;
    public class FileTableDemo
    public static void main(String[] args)
    // Figure out what directory to display
    File dir;
    if (args.length > 0)
    dir = new File(args[0]);
    else
    dir = new File(System.getProperty("user.home"));
    // Create a TableModel object to represent the contents of the directory
    FileTableModel model = new FileTableModel(dir);
    // Create a JTable and tell it to display our model
    JTable table = new JTable(model);
    JScrollPane pane = new JScrollPane(table);
    pane.setBorder(BorderFactory.createEmptyBorder(60,20,20,20));
    ////////KBS
    JTabbedPane myTP = new JTabbedPane();
    JPanel myOne = new JPanel();
    JPanel myTwo = new JPanel();
    myOne.add(pane);
    myTP.add("One", myOne);
    myTP.add("Two", myTwo);
    ////////KBS
    // Display it all in a scrolling window and make the window appear
    JFrame frame = new JFrame("FileTableDemo");
    frame.getContentPane().add(myTP, "Center");
    frame.setSize(600, 400);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
    // The methods in this class allow the JTable component to get
    // and display data about the files in a specified directory.
    // It represents a table with six columns: filename, size, modification date,
    // plus three columns for flags: direcotry, readable, writable
    class FileTableModel extends AbstractTableModel
    protected File dir;
    protected String[] filenames;
    protected String[] columnNames = new String[] {
    "name",
    "size",
    "last modified",
    "directory?",
    "readable?",
    "writable?"
    protected Class[] columnClasses = new Class[] {
    String.class,
    Long.class,
    Date.class,
    Boolean.class,
    Boolean.class,
    Boolean.class
    // This table model works for any one given directory
    public FileTableModel(File dir)
    this.dir = dir;
    this.filenames = dir.list();
    // These are easy methods
    public int getColumnCount()
    return 6;
    public int getRowCount()
    return filenames.length;
    // Information about each column
    public String getColumnName(int col)
    return columnNames[col];
    public Class getColumnClass(int col)
    return columnClasses[col];
    // The method that must actually return the value of each cell
    public Object getValueAt(int row, int col)
    File f = new File(dir, filenames[row]);
    switch(col)
    case 0: return filenames[row];
    case 1: return new Long(f.length());
    case 2: return new Date(f.lastModified());
    case 3: return f.isDirectory() ? Boolean.TRUE : Boolean.FALSE;
    case 4: return f.canRead() ? Boolean.TRUE : Boolean.FALSE;
    case 5: return f.canWrite() ? Boolean.TRUE : Boolean.FALSE;
    default: return null;
    }

    Well, I didn't find an answer but I did find a solution.
    The JPanel is the problem. I use it to help with layout which is not obvious in this example.
    As you can see in the code the JTable is placed in a JScrollPane which is place in a JPanel which is placed in a JTabbedPane.
    If I use Box instead of JPanel the JTable in the JScrollPane in the Box in the TabbedPane in the JFrame resizes correclty.
    So although JPanel is resizable with setSize it does not get resized when it's JFrame gets resized.
    I would still like to know why?
    ////////KBS
    JTabbedPane myTP = new JTabbedPane();
    Box myOne = Box.createHorizontalBox();
    Box myTwo = Box.createHorizontalBox();
    myOne.add(pane);
    myTP.add("One", myOne);
    myTP.add("Two", myTwo);
    ////////KBS

  • Issue with re-sizing JTable Headers, JTabbedPane and JSplit pane

    Ok, hopefully I'll explain this well enough.
    In my Swing application I have a split pane, on the left hand side is a JTable and on the right hand is a JTabbedPane. In the tabs of the JTabbedPane there are other JTables.
    In order to make the rows in the JTable on the left and the JTable(s) on the right line up, the Table Header of all the tables is set to the size of the tallest (deepest?) table header.
    Hopefully so far I'm making sense. Now to get to the issue. One of the tables has a number of columns equal to the value on a NumberSpinner (it represents a number of weeks). When this value is changed the table is modified so that it contains the correct number of columns. As the table is re-drawn the table header goes back to its default size so I call my header-resize method to ensure it lines up.
    The problem is this: if I change the number of weeks when selecting a tab other than the one containing my table then everything is fine, the table header is re-sized and everything lines up. If I change the number of weeks with the tab containing the table selected, the column headers stay at their standard size and nothing lines up.
    To make things more complicated, I also put System.out.println's in as every method called in the process to obtain the size of the table header. And every println returned the same height, the height the table header should be.. So I'm really confused.
    Could anyone shed any light on this?
    Thanks.

    Okay I managed to solve the problem by explicitly revalidating and repainting the table header.
    Not sure why it wasnt doing it properly for that table when all the others where fine.
    Oh well...

  • JTable in JTabbedPane

    Hello
    I have a little GUI problem. I created a dialog with a JTabbedPane in the center that contains some JPanel with labels, fields etc. (nothing heavy). The Dialog has a size about 100px*200px.
    Now I put a JTable (with no sizing information) in a JScrollPane and add it to the JTabbedPane and the Dialog gets a size of about 200px*200px.
    Why? I tried a lot, but nothing helped?
    Thankful for every help.

    Oh sorry,
    I want that the JTable (and the JScrollPane) adopts the size of the Dialog (before I added the table). I don't set any size in my code for the dialog and the panels. I set only size for some JFields in the panels and pack() the dialog.
    First everything is wonderfull aligned, but when I add the scrollpane with the table the whole dialog becomes wider.
    Is there a chance that the new tab gets the old size?

  • Ctrl+V on a JTable

    What method is called when I press Ctrl+V after selecting a row on a JTable? I tried using the copy() method which works on a text area/field but it doesn't work on the table. Ctrl+V works, but calling the
    copy() method doesn't.

    I'm not sure if this is what you want, but the ctrl+v action is the paste action. Are you trying to override the paste with the copy action?
    JTable already has the cut, copy, paste and a lot more ready for use. Below is what happens when a key action is executed on a JTable.
    "When the table component has the focus and a key (or combination of keys) is pressed, JTable's processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) method is eventually called. That method starts by executing boolean retVal = super.processKeyBinding (ks, e, condition, pressed); (which is found in JComponent). The method checks to see if ks is located in the component's input map (that is, a set of mappings from Keystroke objects to Action names). If found, the resulting Action name is checked against the component's Action map (that is, a set of mappings from Action names to Action objects) to see if that map contains an Action object that associates with the Action name. If so, SwingUtilities' notifyAction(Action action, KeyStroke ks, KeyEvent event, Object sender, int modifiers) method is called to create an ActionEvent object and call the Action's actionPerformed(ActionEvent e) method. Assuming that the actionPerformed(ActionEvent e) method is called, retVal contains a value that causes processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) to exit. Otherwise, that method automatically starts an editor for the focused cell"
    -- Exploring Swing's Table Component
    -- http://www.informit.com/isapi/product_id~%7BCC10A6C8-9E4A-4FC4-B158-5C8BC41A879E%7D/element_id~%7B236A3815-39EF-4EF9-B2B3-553B3734E763%7D/st~%7B94C03A97-1188-4875-8A06-17743BA224B7%7D/content/articlex.asp
    Hope this helps

  • JTable and JTabbedPane questions

    I have an application which has some JTabbedPanes setup, one of which has a table on it.
    What i'm after is a way of having a user select a row from the table and in doing so this will send them to another tabbedpane.
    So what i need is a way of assigning each row an ID number, then being able to extract this ID, and being able to switch to a new tab without having to click on the tab itself.
    I hope someone can point me in the right direction.
    One more question as well.
    I'm designing a networked bulletinboard application (using javaspaces) and i'm having an implementation issue.
    At the moment I can list all the topics in a table which just contains |the author, topic title and date created|.
    I'm having trouble thinking of a good way of displaying the actuall topic itself (and multiple follow-up posts).
    I was thinking of doing this in another table, but i couldnt find a way of customizing the layout enough to display formatted text. So i thought I would just do a loop of JTextAreas for each topic.
    Something along the lines of:
    while (i < number_of_posts)
    Create_JTextArea(post[i]);
    Do you think this would be a suitable way of implementing this? Or is there a better way that i'm missing?

    So what i need is a way of assigning each row an ID numberStore the ID number in the TableModel. You then just remove the TableColumn from the TableColumnModel and the ID will not be displayed in the table. You then simply use model.getValueAt(...) to reference the ID.

  • JTabbedPane,JTable in JPopupMenu

    Hai,
    In my applet, I have added JTabbedPane and JTable in JPopupmenu just like JPanel using Java 1.3. It works fine. Now when I run this applet using Java 1.5 plugin, if I click on that JTable or JTabbedPane over JPopupmenu it closed automatically. It works fine in Java 1.4 also.
    Any ideas...?

    Hai,
    Finally I got solution for this. If I use
    show(Component invoker, int x, int y) method it gives problem. So
    I have changed my code using setLocation(int x,int x) and then
    setVisible(true). It works fine.
    But Now I have got another problem. If I add JTextField over JPopupMenu, I couldn't edit that textfield.
    Anybody having solution for this?

  • Tab key selects cell for edit in JTable

    Hello,
    I've seen extensive posts on this forum for this problem, but no solution yet.
    I have a Jtable, with custom cellRenders and cellEditors. Some columns are editable, some are not.
    What I want to do, is when someone tabs to an editable cell, that cell immediately goes into edit mode. This means, it acts as if someone double clicked on it, or tabbed then clicked on it. Basically, I want it to ACTUALLY go into edit mode.
    Please do not respond by telling me how to make it look editable (highlighting, etc) and do not respond with mouseEvent solutions. Please do not respond by telling me to do table.editCellAt(row,col) because that does not kick in my custom editor, it uses the defaultCellEditor.
    So basic question:
    How to kick in editing when someone tabs to an editable cell?
    If you need code examples, please request and I will post.

    nmstaat,
    In JTable:
    Look into the processKeyBinding method. It takes a keyevent and matchs it with an InputMap, and the InputMap invokes an Action in the corresponding ActionMap.
    You will have to call yourJTable.getActionMap(), then alter the action that corresponds to the 'tab' key.
    For Further information, check the JTable API, its all there.
    Good Luck,
    Alex
    Here's the current map for the Metal look and feel:
    JTable (Java L&F)
    Navigate out forward | Tab
    Navigate out forward | Ctrl+Tab
    Navigate out backward | Shift+Tab
    Navigate out backward | Ctrl+Shift+Tab
    Move to next cell | Tab
    Move to next cell | Right Arrow
    Move to previous cell | Shift+Tab
    Move to previous cell | Left Arrow
    Wrap to next row | Tab
    Wrap to next row | Right Arrow
    Wrap to previous row | Shift+Tab or Left
    Wrap to previous row | Shift+Tab or Left
    Block move vertical | PgUp, PgDn
    Block move left | Ctrl+PgUp
    Block move right | Ctrl+PgDn
    Block extend vertical | Shift+PgUp/PgDn
    Block extend left | Ctrl+Shift+PgUp
    Block extend right | Ctrl+Shift+PgDn
    Move to first cell in row | Home
    Move to last cell in row | End
    Move to first cell in table | Ctrl+Home
    Move to last cell in table | Ctrl+End
    Select all cells | Ctrl+A
    Deselect current selection | Up/Down Arrow
    Deselect current selection | Ctrl+Up/Down Arrow
    Deselect current selection | Pgup/Pgdn
    Deselect current selection | Ctrl+Pgup/Pgdn
    Deselect current selection | Home/End
    Deselect current selection | Ctrl+Home/End
    Extend selection one row | Shift+Up/Down
    Extend selection one column | Shift+Left/Right
    Extend selection to beginning/end of row | Shift+Home/End
    Extend selection to beginning/end of column | Ctrl+Shift+Home/End
    Edit cell without overriding current contents | F2
    Reset cell content prior to editing | Esc

  • How to override Ctrl-Click behavior in Java L&F

    On the Mac, Ctrl-Click is the popup trigger. While Java L&F designers were obviously aware of this (it is warned about in the Java Look and Feel Design Guidelines, 2nd ed, page 106). However, just two pages later (page 108), they then generically specifify that Ctrl-Click is used in lists and tables to toggle the selection.
    The implementation of the Java L&F does not appear to consider the Mac's use of Ctrl-Click and still toggles selection. If there is an additional mouse listener that shows a menu in response to the popup trigger, it will ALSO open the menu on Ctrl-Click.
    What is the best way to overide the Ctrl-Click behavior in JTable etc. to NOT do the toggle selection? Note that this is a mouse event and not a key event, so it can't be turned off or changed by the getActionMap() mechanism.
    Also, does anyone know what the "Command" modifier on the Mac (Command-Click is supposed to toggle selection on Macs) shows up as in the InputEvent (isMetaDown(), isAltGraphDown()...)?

    Try extending the JList and override the processMouseEvent(MouseEvent evt) method and show your popup menu when the user clicks the mouse while holding the CTRL key down. The code below demonstrates the same.
    import java.awt.BorderLayout;
    import java.awt.event.MouseEvent;
    import java.util.Vector;
    import javax.swing.JFrame;
    import javax.swing.JList;
    import javax.swing.JOptionPane;
    import javax.swing.JScrollPane;
    import javax.swing.ListModel;
    import javax.swing.WindowConstants;
    public class Temp extends JFrame {
         public Temp() {
              super("Temp");
              setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              String [] items = {"One", "Two", "Three", "Four", "Five"};
              JList list = new MyList(items);
              JScrollPane scroller = new JScrollPane(list);
              getContentPane().add(scroller, BorderLayout.CENTER);
              pack();
              setVisible(true);
         class MyList extends JList {
              public MyList() {
                   super();
              public MyList(Object[] listData) {
                   super(listData);
              public MyList(Vector listData) {
                   super(listData);
              public MyList(ListModel dataModel) {
                   super(dataModel);
              protected void processMouseEvent(MouseEvent evt) {
                   System.out.println(evt.isPopupTrigger());
                   int onmask = MouseEvent.CTRL_DOWN_MASK | MouseEvent.BUTTON1_DOWN_MASK;
                   if(evt.getModifiersEx() == onmask) {
                        JOptionPane.showMessageDialog(this, "Control + click");
                   else {
                        super.processMouseEvent(evt);
         public static void main(String[] args) {
              new Temp();
    }Hope this helps
    Sai Pullabhotla

  • Why can I only add up to 7 rows in a table???

    I have written the following programme
    but can only allow 6 addButton clicks....(I want to allow adding unlimited number of rows)
    can anyone run the code and help me out please???
    import javax.swing.border.* ;
    import javax.swing.* ;
    import java.awt.Dimension;
    import java.awt.event.* ;
    import java.util.*;
    import java.awt.*;
    import javax.swing.table.TableColumn;
    import javax.swing.JTable;
    import javax.swing.DefaultCellEditor;
    import javax.swing.table.*;
    public class ReadingListDialog extends javax.swing.JDialog{
    ReadingListDialog me;
    String[] type = {"Text Book", "Online Material","Other"};
    String[] columns;
    JComboBox typeComboBox;
    JButton editButton;
    JButton cancelButton;
    JButton saveButton;
    JButton addButton;
    JButton deleteButton;
    JTable bookTable;
    JTable onlineTable;
    JTable otherTable;
    JTabbedPane tabbedPane;
    Box outerBox;
    Box buttonBox;
    JScrollPane bookScrollPane ;
    JScrollPane onlineScrollPane ;
    JScrollPane otherScrollPane ;
    Vector row;     
    DefaultTableModel bookModel;
    DefaultTableModel onlineModel;
    DefaultTableModel otherModel;
    private boolean DEBUG = true;
    /** Creates a new instance of ReadingListDialog */
    public ReadingListDialog(java.awt.Frame parent, boolean modal, boolean edit) {
    initComponents();
    public void initComponents(){
    me = this ;
    ImageIcon icon = new ImageIcon("middle.gif");
    Object[][] bookData = {
    // {"Altemate Java", "Robert Sedgewick", "Library", "June 30", "p.130-150","No notes","Read"},
    //{"Elementary Algebra","Ian Horthorn","Desk Copy","sep 28","p.111, p.112","important topic!!!True......hello everyone","Not Read"},
    String[] bookColumn = {"Text Title",
    "Author",
    "Location",
    "Read By Date",
    "Page/Chapter",
    "Note",
    "Status"
    DefaultTableModel bookModel = new DefaultTableModel(bookData, bookColumn);          
    bookTable = new JTable(bookModel);
    setUpReadingStatusColumn(bookTable.getColumnModel().getColumn(6));
    bookTable.setPreferredScrollableViewportSize(new Dimension(500, 35));
    Object[][] onlineData = {
    // {"Google", "www.google.com", "June 30", "a search engine","Don't understand"},
    // {"Waikato Uni","www.waikato.ac.nz","Sep 29","important topic!!!True......hello everyone","Half way"},
    String[] onlineColumn = {"Website Name",
    "URL",
    "Read By Date",
    "Note",
    "Status"
    DefaultTableModel onlineModel = new DefaultTableModel(onlineData, onlineColumn);     
    onlineTable = new JTable(onlineModel);
    setUpReadingStatusColumn(onlineTable.getColumnModel().getColumn(4));
    onlineTable.setPreferredScrollableViewportSize(new Dimension(500, 35));
    Object[][] otherData = {
    //{"Lecture slide", "N/A", "June 30", "useful for assignment 2","Read"},
    //{"Notes on Linear Algebra","DeskCopy","Sep 29","important topic!!!True......hello everyone","Not Read"},
    String[] otherColumn = {"Material",
    "Location",
    "Read By Date",
    "Note",
    "Status"
    DefaultTableModel otherModel = new DefaultTableModel(otherData, otherColumn);     
    otherTable = new JTable(otherModel);
    setUpReadingStatusColumn(otherTable.getColumnModel().getColumn(4));
    otherTable.setPreferredScrollableViewportSize(new Dimension(500, 35));
    tabbedPane = new JTabbedPane();
    //create the buttons
    cancelButton = new JButton("Cancel");
    saveButton = new JButton("Save");
    addButton = new JButton( "Add Row" );
    deleteButton = new JButton("Delete Row");
    //add buttons to buttonBox
    buttonBox = new Box(BoxLayout.X_AXIS);
    buttonBox.add(saveButton);
    buttonBox.add(addButton);
    buttonBox.add(deleteButton);
    buttonBox.add(cancelButton);
    addButton.addActionListener( new ActionListener()          {
    public void actionPerformed(ActionEvent e)               {
    DefaultTableModel bookModel = (DefaultTableModel)bookTable.getModel();
    Object[] newRow = new Object[7];
    int row = bookTable.getRowCount() + 1;
    for(int k = 0; k<row; k++)
    newRow[k] = "";
    bookModel.addRow( newRow );
    //Create the scroll pane and add the table to it.
    bookScrollPane= new JScrollPane(bookTable);
    onlineScrollPane = new JScrollPane(onlineTable);
    otherScrollPane = new JScrollPane(otherTable);
    //add the scroll panes to each tab
    tabbedPane.addTab("Text Book Readings", icon, bookScrollPane, "Edit your reading list");
    tabbedPane.setSelectedIndex(0);
    tabbedPane.addTab("Online Readings", icon, onlineScrollPane, "Still does nothing");
    tabbedPane.addTab("Other Materials", icon, otherScrollPane, "Still does nothing");
    //add the tabbedPane to outerBox
    outerBox = new Box(BoxLayout.Y_AXIS);
    //outerBox.setBorder(new EmptyBorder(0,0,20,15));
    outerBox.add(tabbedPane);
    outerBox.add(buttonBox);
    //add the outerBox to the pane
    getContentPane().add(outerBox);
    if (DEBUG) {
    bookTable.addMouseListener(new MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    //printDebugData(bookTable);
    cancelButton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
    me.dispose();
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    public void setUpReadingStatusColumn(TableColumn statusColumn) {
    //Set up the editor for the status cells.
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("");
    comboBox.addItem("Read");
    comboBox.addItem("Just Started");
    comboBox.addItem("Half way");
    comboBox.addItem("Not Read");
    comboBox.addItem("Don't understand");
    statusColumn.setCellEditor(new DefaultCellEditor(comboBox));
    //Set up tool tips for the status cells.
    DefaultTableCellRenderer renderer =
    new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for selecting a status");
    statusColumn.setCellRenderer(renderer);
    //Set up tool tip for the status column header.
    TableCellRenderer headerRenderer = statusColumn.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer) {
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the satus to see a list of choices");
    public static void main(String args[]) {
    ReadingListDialog r = new ReadingListDialog(new javax.swing.JFrame(), true, true);
    r.setSize(new Dimension(600,500));
    r.show();

    Try this
    public void actionPerformed(ActionEvent e) {
    DefaultTableModel bookModel = (DefaultTableModel)bookTable.getModel();
    Object[] newRow = new Object[] {};
    //int row = bookTable.getRowCount() + 1;
    //for(int k = 0; k<row; k++)
    //newRow[k] = "";
    bookModel.addRow( newRow );

  • [SOLVED] Page Up and Page Down keys no longer working correctly

    uname ...
    3.12.9-2-ARCH #1 SMP PREEMPT x86_64
    I use KDE  4.12.2 
    For some reason - applications in KDE are no longer responding to the PgUp and PgDown keys.
    For example previously in firefox PgUp/PgDown would scroll the current web page up or down, but now it doesn't work.
    Firefox DOES change tabd using CTRL + PgUp/CTRL + PgDown as previously.
    Another example Okular ignores PgUp/PgDown - although (again) it does respond to CTRL + PgUp/CTRL + PgDown.
    Previously it responded with the correct move one page up and down.
    If I go to a terminal
    showkey
    keycode 28 release
    # PgDown
    keycode 109 press
    keycode 109 release
    # PgUp
    keycode 104 press
    keycode 104 release
    If I try to set a keyboard sortcut in a KDE app (e.g. change the Previous / Next page keyboard shortcut in Okular) the app recognises the PgUp and PgDown keys, but the application doesn;t respond.
    I've also tried a different keyboard and I get the same behaviour.
    I'm completely baffled, any help?
    What could be causing this strange behaviour?
    Last edited by bhrgunatha (2014-02-22 03:51:02)

    From what I understand - they would have to be global keyboard shortcuts. I've looked in the KDE system settings anmd there are no global shortcuts defined for PgUp and PgDown. I certainly haven't configured anythin to use them.
    I'm not sure if there is anywhere else to look for them.
    EDIT: So after about an hour or so of poking around, it seems I DID set shortcuts for PgUp/PgDown (and promptyl forgot about them.)
    These set global shortcuts that aren't recognised by the KDE system settings shortcuts applet.
    Last edited by bhrgunatha (2014-02-22 03:50:41)

  • PP CS6 PageUp & PageDn shortcut keys not working

    Heads up... This may look like a simple topic that's been covered before, but read on and you'll see it's different.
    I've been using Premiere since v5.5 (Windows 95, not CS 5.5!). I use lots of shortcut keys for all my apps. Premiere has always used PageUp and PageDn to move the cursor to the next edit point (any cut video or audio clip). In PP CS6, I went into change the shortcut keys for those two commands to the same ones I've been using for years. PP CS6 has two sets of options for cursor movements: Selected Track(s) or Any Track. The Any Track is the way it's worked before in earlier versions of PP. I set the Any Tracks Next/Previous to PageDown and PageUp respectively. The actual keystrokes appear in the hot-key window when I press them so I know PP sees the keys and knows what they are.
    When I saved the shortcuts and went to the timeline... nada. PgUp and PgDn do nothing. This has nothing to do with selected video tracks as I'm using the Any Tracks option. To do a further test, I changed the shortcut keys to Ctrl+PgUp and Ctr+PgDn for Any Track. When I  tested that out, it worked perfectly. So this appears to be a bug of some kind. I've been using PgUp and  PgDn for many years. I certainly don't want to have to hold the Ctrl key down while Paging Up and Down to move around the project from clip to clip!
    Does anyone have a solution to this one?
    Thanks for your help...

    "But you can set any shortcut key to suit whatever keys you have available."
    Yeah, I know, but every now and then I have to reinstall and then there's the agony of changing again from the defaults :-( In the end, like 'em or hate 'em, sticking with the defaults usually makes for an easier life. I say that as someone who has been commercially programming since 1967 and forced to use practically every crazy language and stupid machine ever invented ;-)

  • How to skip words using keyboard shortcuts

    Using Ctrl+Rt arrow usually skips words when typing in a free text box but FF uses that keyboard command to move through the open tabs. Is this customizable?
    == This happened ==
    Every time Firefox opened
    == typing in a text field

    on the Keyboard Shortcuts page, under the Windows & Tabs section, it says that CTRL + LEFT ARROW (or RIGHT ARROW) will navigate between tabs. this means that when you are in a text box (e.g. typing an email in a web based email provider like gmail, or in the box i am typing this reply in right now) when you press CTRL + L/R ARROW it changes tabs instead of skipping words. so basically firefox is overriding ability to skip words using CTRL + L/R ARROW. this is rather annoying when typing emails using firefox. i have resorted to typing my emails in a word processor, then pasting into gmail.
    is there a way to disable the CTRL + L/R ARROW shortcut in firefox? it seems redundant to even have that shortcut because CTRL + PGUP/PGDN already does this.
    i did find [http://ubuntuforums.org/showthread.php?t=211030 this page] on the ubuntu forums with a user experiencing the same issue. one user suggested the following (quoted below), but it didnt work for me because the setting was already set to true.
    QUOTE FROM UBUNTU FORUMS:
    In firefox, type about:config in the adress bar and change layout.word_select.stop_at_punctuation to True

  • Scrolling through tabs in Firefox without opening them

    With many tabs open we get two arrows on top of the screen to scroll left and right through tabs by clicking with the mouse. Please see the attached image for an example.
    Is there a keyboard shortcut for those arrows or is it possible to add one?
    Note: I am aware that we can scroll through tabs directly with Alt+[Num], or by using Ctrl+PgUp and Ctrl+PgDown. I have dozens of tabs open, so if I want to go to tab 35 I can't use Alt+[Num], and using Ctrl+PgDn is a problem if I'm say in tab 65. The reason is that with Ctrl+PgDn the tabs from 65 back to 35 would all open while I'm passing through them.

    Image wasn't attached properly and I can't seem to edit the question. Here it is.

Maybe you are looking for

  • Feature Requests - Adobe Reader for Android

    Adobe Reader for Android is a good start, it renders well (and renders 2 pages at a time), and the UI is nice, but there are some missing features. Please can we have the following features added in the next update; # Bookmark support, including the

  • When i return from back up copy contacts, it comes...

    Hei. I have a problem. Our phone/ E75/ went to peaces, but before that we made back up copy to Ovi PS Suite. Computer went broken, but we got everything to hard disk-Mobile Backup- external data storage. I download Noki to computer. I started to move

  • OIM child tables

    Hi Guys A quick question about OIM child tables. I need to send the child table data in a mail whenever a record is inserted or deleted in the child table. This is same as sending notification on addition or removal of an target resource role. I want

  • Adding New Image and Text to an Existing Page Created with Tables

    Working in DW 5.5 I'm trying to add a new image/link and small amount of text to an existing web page that was created with tables and centered.  I am using AP Divs. One for the image and one for the text.  Everything functions fine, but I can't get

  • "Owl Orphanage error" msvcp110.dll ??

    When starting it gives me an "orphan owl error" and says sxvcp110.dll is missing and to reinstall ! ? What's up with that?