Implementing frozen rows/columns in a JTable layout like MS Excel

I am trying to develop a complex application in which I have a JTable defined, the column names are Name, Admin status , slot id , ipaddress
as per the query to the database this JTable is populated with the data, now I have a button called freeze pane on this panel (let say it admin panel) , I need to implement a feature where if I select a row from JTable and click on the freeze pane button then all the rows above this selected row should be locked , and when I do scrolling only the rows below this selected row should scroll, the upper rows should be fix, this implementation is similar to that of feature " freeze pane " in microsoft excel. Kindly let me know if it's possible and if yes can you provide me with a sample of code.
Thanx in advance.

Even I was searching for some help on implementing the freeze/unfreeze functionality in the JTable. If you have come across any solution, pls provide me with the approach.

Similar Messages

  • How can I add new row/column into existing jTable?

    Hi add!
    Can you help me how can I add new row/column into existing jTable?
    Tnx in adv!

    e.g
    Create two buttons inside the Table ( "Add New Row" ) and ("Add new Column")
    their handlers are:
    add new row:
    //i supose u already have
    DefaultTabelModel tablemodel = new DefaultTableModel(rowdata, columnNames);
    //and   
       JTabel jtable = new JTable(tablemodel);
    // Handler (row)
    jbtAddRow.addActionListener(new ActionListener(){
       public void actionPerformed(ActionEvent e) {
          if(jtable.getSelectedRow() >= 0 )
              tablemodel.insertRow(jtable.getSelectedRow(), new java.util.Vector());  
           else  
                tablemodel.addRow(new java.util.Vector());
        });to add new columns its the same but inside actionPerformed method:
    ask for e.g "Whats the name for the new column"
    then,
       tablemodel.addColumn(nameOfColumn, new java.util.Vector());   Joao
    Message was edited by:
    Java__Estudante

  • How to insert rows & columns into a jTable???

    helloo there...
    How to insert rows & columns into a jtable???
    your reply is greatly appreciated....
    -=samer=-

    Yes!thanks...
    But what i want is how to set the number of rows and the number of columns...and i don't know how to setColumns and rows....any idea?
    the user will input number of rows and columns in a jtextfield....
    Please rply...

  • Can we adjust ROW height in ALV report as like of Excel ?

    Dear all,
    Can we adjust ROW height in ALV report as like of Excel sheet ?
    Can we increase/decrease the row height in the output display ?
    How ?

    kps204020 wrote:
    Thanks a lot for your response.
    I've tried your proposal, but it has no affect. The report cells show all their content using as much lines as necessary for this.This is the default behaviour for HTML table data (tables and cells expand to fit their content).
    So I still have rows with lots of lines and rows with only a few lines mixed in my IR dependant on the cell content. Because some rows filling nearly the whole screen, it is difficult to get an overview with regard to adjacent rows.
    I'm using Application Express 4.1.1.00.23. with Theme 21. Scarlet and Firefox 17.0.1.Are all users using Firefox?
    Actually I'm working on my first APEX Solution for usage in my company and the customers demanding a solution for this topic . So I'm very keen to find a solution.
    I'm very much looking forward to your response.I've been involved with similar issues in the past. My first response is simple: Does this data have to be shown in the report? Can the offending column(s) be removed from the primary report? They will still be visible in the single row view, and the detail view if there is one.
    The second option is to create a detail view for the report with a structure that is better suited to the data involved, and make this the default view. (For an example of this, see the treatment of the PRODUCT_DESCRIPTION column in the detail view of the Products report in the Sample Database Application: click on the View Detail button on the Products page.)
    The third possibility is some kind of customization of the presentation of the data. This will involve using some combination of HTML/CSS/Dynamic Actions/Plug-ins/JavaScript that you may not be familiar with: do you have experience of these? To go down that route you need to describe in detail how you want to present the data, or what behaviour is required when the data is too long, and share an example of the report on apex.oracle.com that we can work with.

  • Create spreadsheet template without shading or frozen rows/columns?

    I created a blank speadsheet that doesn't have the first row and column shaded and frozen and saved it as a template. But when I create a new spreadsheet using it, Numbers insists on adding back those shaded and frozen rows and columns when I add an additional sheet. How can I prevent Numbers from doing this?

    Hi Andreas,
    When you add a sheet with "+" you are going to get a sheet with a standard table. Use the little triangle in the sheet tab to duplicate your sheet with the plain table before you start work and you should be set.
    quinn

  • Include Row/Column Headers in Pivot Table Export to Excel

    I am using JDeveloper version 11.1.2.3
    I am trying to export my pivot table to excel using dvt:exportPivotTableData. I'd like to include column/row headers in the export, but can't seem to find a way to do that. Is there a way to do this in my jdeveloper version?

    I am using JDeveloper version 11.1.2.3
    I am trying to export my pivot table to excel using dvt:exportPivotTableData. I'd like to include column/row headers in the export, but can't seem to find a way to do that. Is there a way to do this in my jdeveloper version?

  • Updating the particular row and column in a JTable

    Hi,
    I have a JTable which is having fixed number of columns. When i am trying to update a particular cell in the table
    during programm execution i am not able to do it.
    I am getting the row number and column number correctly. But when i am going to set the data it is not setting at the same row. It is setting some other row according to the m_index (according to the sorting).
    i am doing :
    JTableModel model = (JTableModel) m_TablePan.getTableModel();
    model.setValueAt(savedData, row, column);

    See the convertXxxIndexToView and convertXxxIndexToModel methods.
    db
    Edited by: Darryl.Burke -- wrong methods suggested
    Edit2: Evidently lipumama doesn't follow up on many questions posted.
    One for the blacklist.

  • Looking for component: flexible rows like columns in a JTable

    Hello,
    I need a swing component to display several rows which can be moved up and down, the height resized, interchanged with the mouse like the columns in a JTable. But there is no need for columns. I think there is no standard swing component.
    Any ideas, resource hints?
    Thanks, Ulrich

    One more piece of advice. It is not very easy to get "pre-written custom components". Most developers do things to meet their own needs and these may not be exactly what you are looking for. The best thing to do is to try to develop this yourself. It will give you loads of experience and in later programmes you may write, based on the experience you obtained from the "pain-staking" development process you'll know how to go round these problems quicker and may be able to help others also.
    So just start writing some stuff. You may end up finishing sooner than you think. And remember forum members are always ready to help with problems (accompanied by minimal code examples of the actual problem).
    ICE

  • Can I make auto layout of Matrix Chart after setting fixed rows/columns ?

    Can I make auto layout of Matrix Chart after setting fixed rows/columns ?
    I want to make Matrix Chart to auto layout to zooming out a chart of filter.
    Matrix Chart's layout is AUTO layout at creating.
    Matrix Chart layout can fix specfic rows / columns from layout toolbar.
    BUT fixed layout's Matrix Chart does not zoom a chart of filter.
    Regards,
    Yoshihiro Kawabata
     

    Hi Yoshihiro - at the moment if a specific number of row/columns has been set for small multiples the chart will maintain these proportions even after filtering.
    If the chart hasn't had a set row/column dimensions set it will automatically be re-laid out when filtered however.

  • JTable cell Render on the last row column one help please

    Hi All
    I am hoping that someone will be able to help me with this....
    I want to render the last row and column one of the table with this render
    thanks for any help
    Craig
        public class MyRenderer2 extends DefaultTableCellRenderer {
            public Component getTableCellRendererComponent(JTable table,
                    Object value,
                    boolean isSelected, boolean hasFocus,
                    int row, int column) {
                ImageIcon icon = new ImageIcon(image_pics.SMALL_BLUE);
                setIcon(icon);
                return this;
        }

    it still renders every row
    any Ideas ??
    I just want the last row column 0 to be rendered
    I a call a method set table
    then I call for the data
    //TableModel
        public void setClientTableModel() {
            clientModel = new DefaultTableModel(coloumHeaderObject, 0) {
                public boolean isCellEditable(int row, int column) {
                    return false;
            TableSorter sorter = new TableSorter(clientModel); //ADDED THIS
            sorter.setTableHeader(phoneList.getTableHeader()); //ADDED THIS
            phoneList.setModel(sorter);
           // phoneList.setTableHeader(null);
            setTable();
            revalidate();
        public void setTable() {
          // phoneList.getColumnModel().getColumn(0).setCellRenderer(new MyRenderer());
            phoneList.getColumnModel().getColumn(1).setCellRenderer(new MyRenderer1());
            phoneList.getColumnModel().getColumn(4).setCellRenderer(new MyRenderer2());
            phoneList.getColumnModel().getColumn(0).setMinWidth(20);
            phoneList.getColumnModel().getColumn(0).setMaxWidth(20);
            phoneList.getColumnModel().getColumn(0).setPreferredWidth(20);
            phoneList.getColumnModel().getColumn(1).setMinWidth(20);
            phoneList.getColumnModel().getColumn(1).setMaxWidth(20);
            phoneList.getColumnModel().getColumn(1).setPreferredWidth(20);
            phoneList.getColumnModel().getColumn(2).setMinWidth(80);
            phoneList.getColumnModel().getColumn(2).setMaxWidth(80);
            phoneList.getColumnModel().getColumn(2).setPreferredWidth(80);
            phoneList.getColumnModel().getColumn(3).setMinWidth(150);
            phoneList.getColumnModel().getColumn(3).setMaxWidth(150);
            phoneList.getColumnModel().getColumn(3).setPreferredWidth(150);
            phoneList.getColumnModel().getColumn(4).setMinWidth(20);
            phoneList.getColumnModel().getColumn(4).setMaxWidth(20);
            phoneList.getColumnModel().getColumn(4).setPreferredWidth(20);
            phoneList.setOpaque(false);
            phoneList.setGridColor(Color.lightGray);
            phoneList.setRowHeight(18);
            phoneList.setShowVerticalLines(false);
            phoneList.setIntercellSpacing(new Dimension(0, 0));
            phoneList.setFont(new java.awt.Font("Lucida Grande", 0, 11));
            phoneList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            if (ALLOW_COLUMN_SELECTION) { // false by default
                if (ALLOW_ROW_SELECTION) {
                    phoneList.setCellSelectionEnabled(true);
                phoneList.setColumnSelectionAllowed(true);
                ListSelectionModel colSM = phoneList.getColumnModel().getSelectionModel();
                colSM.addListSelectionListener(new ListSelectionListener() {
                    public void valueChanged(ListSelectionEvent e) {
                        if (e.getValueIsAdjusting())return;
                        ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                        int row = phoneList.getSelectedRow(), col = 3;
                        int rowID = phoneList.getSelectedRow(), colID = 5;
                        if (lsm.isSelectionEmpty()) {
                        } else {
                            int selectedCol = lsm.getMinSelectionIndex();
                            if (selectedCol == 4) {
                                phoneNumber = (String) phoneList.getValueAt(row, col).toString();
                                main.setPhoneNumber(phoneNumber);
                                main.openLargePhone();
                                lsm.clearSelection();
                            if (selectedCol == 5) {
                                ID = (String) phoneList.getValueAt(row, col).toString();
                             //   main.setID(ID);
                              //  main.deleteContact();
                                lsm.clearSelection();
    //set table data
        public void setTest() {
            setClientTableModel();
            Object[] data = {" ", " ", "Work", "03 9841-8247", " "};
            clientModel.addRow(data);
            Object[] data1 = {" ", " ", "Fax", "03 9842-0360", " "};
            clientModel.addRow(data1);
            phoneList.getColumnModel().getColumn(0).setCellRenderer(new MyRenderer());
        }

  • JTable: is it possible to remove row/column borders

    Hi,
    I want my JTable to be displayed without any lines between
    rows/columns. I tried to use the border settings but cannot get rid of
    the lines. I assume because these small lines belongs to the
    column/row properties?
    How can I get rid of them?

    table.setIntercellSpacing(...);

  • How to select rows in the inner JTable rendered in an outer JTable cell

    I have wrriten the following code for creating cell specific renderer - JTable rendered in a cell of a JTable.
    table=new JTable(data,columnNames)
    public TableCellRenderer getCellRenderer(int row, int column)
    if ((row == 0) && (column == 0))
    return new ColorRenderer();
    else if((row == 1) && (column == 0))
    return new ColorRenderer1();
    else
    return super.getCellRenderer(row, column);
    ColorRenderer and ColorRenderer1 are two inner classes, which implement TableCellRenderer to draw inner JTable on the outer JTable cell, having 2 rows and 1 column each.
    Now what is happening the above code keeps executing continously, that is the classes are being initialised continously, inner JTables are rendered (drawn) continously, and this makes the application slow after some time. It throws java.lang.OutOfMemoryException.
    WHY IS IT SO??? I can't understand where's the bug..
    Any advice please???
    Moreover i want selections in inner tables and not on outer table, how can this be possible.
    I am working on this since a long time but have not yet found a way out...

    With your help i have overcome the problem of continous repeatition.
    The major problem which I am facing is, in selecting rows in the inner rendered JTables.
    I have added listener on outer JTable which select rows on the outer JTable, hence the complete inner JTable which being treated as a row, gets selected.
    The thing is i need to select the rows of inner rendered JTables,not the outer JTable.
    How to go about it??
    I have even added listener to inner rendered JTables, but only first row of every table gets selected.
    Please help....
    Thanks in advance.

  • Help for adjusting columns of a JTAble in a Table Model

    Hello community,
    In order to have a good display of by DataBase in a JTable, I've wrote some code to adjust columns in function of datas. Those datas are displayed with a TableModel ( which I've declared in a class JDBCAdapter ).
    When I start my application, I call adjustColumns(), and all is great but when I add information to my DB and display it, the columns of my JTable return to default width...
    So I want to incorporate my function adjustColumns in my TableModel, and I need help...
         void adjustColumns()
         // Ajuste les colonnes aux donnes pour que tout soit visible
         int nbRow,nbCol;
         nbRow = JTable1.getRowCount();
         nbCol = test.getColumnCount();
         for ( int i = 0; i < nbCol; i++ )
         com.sun.java.swing.table.TableColumn column = null;
         column = JTable1.getColumnModel().getColumn(i);
         int dataLength = 0;
         for ( int j = 0; j< nbRow; j++ )
         FontMetrics fm;
         int dataLengthTmp;
         String valueTable;
         fm = JTable1.getFontMetrics(JTable1.getFont());
         if ( test.getValueAt(j, i) == null )
         System.out.println("Valeur nulle...");
         dataLengthTmp = 0;
         else
         valueTable = test.getValueAt(j, i).toString();
         dataLengthTmp = fm.stringWidth(valueTable);
         System.out.println(valueTable + " = " + dataLengthTmp);
         if ( dataLengthTmp > dataLength )
         dataLength = dataLengthTmp;
         if ( dataLength != 0 )
    column.setWidth(dataLength + 5);
    else
    column.sizeWidthToFit();
    JTable1.setModel(test);
    JTable1.repaint();
    import java.util.Vector;
    import java.sql.*;
    import com.sun.java.swing.table.AbstractTableModel;
    import com.sun.java.swing.event.TableModelEvent;
    public class JDBCAdapter extends AbstractTableModel {
    Connection connection;
    Statement statement;
    ResultSet resultSet;
    String[] columnNames = {};
    Vector rows = new Vector();
    ResultSetMetaData metaData;
    public JDBCAdapter(String url, String driverName,
    String user, String passwd) {
    try {
    Class.forName(driverName);
    System.out.println("Ouverture de la connexion a la base de donnee...");
    connection = DriverManager.getConnection(url, user, passwd);
    statement = connection.createStatement();
    catch (ClassNotFoundException ex) {
    System.err.println("Cannot find the database driver classes.");
    System.err.println(ex);
    catch (SQLException ex) {
    System.err.println("Cannot connect to this database.");
    System.err.println(ex);
    public void executeQuery(String query) {
    if (connection == null || statement == null) {
    System.err.println("There is no database to execute the query.");
    return;
    try {
    resultSet = statement.executeQuery(query);
    metaData = resultSet.getMetaData();
    int numberOfColumns = metaData.getColumnCount();
    columnNames = new String[numberOfColumns];
    // Get the column names and cache them.
    // Then we can close the connection.
    for(int column = 0; column < numberOfColumns; column++) {
    columnNames[column] = metaData.getColumnLabel(column+1);
    // Get all rows.
    rows = new Vector();
    while (resultSet.next()) {
    Vector newRow = new Vector();
    for (int i = 1; i <= getColumnCount(); i++) {
    newRow.addElement(resultSet.getObject(i));
    rows.addElement(newRow);
    // close(); Need to copy the metaData, bug in jdbc:odbc driver.
    fireTableChanged(null); // Tell the listeners a new table has arrived.
    catch (SQLException ex) {
    System.err.println(ex+" query = "+query);
    public void executeUpdate(String query) {
    if (connection == null || statement == null) {
    System.err.println("There is no database to execute the query.");
    return;
    try {
    statement.executeUpdate(query);
    // close(); Need to copy the metaData, bug in jdbc:odbc driver.
    fireTableChanged(null); // Tell the listeners a new table has arrived.
    catch (SQLException ex) {
    System.err.println(ex+" query = "+query);
    public void close() throws SQLException {
    System.out.println("Fermeture de la connection a la base de donnee... Bye !");
    resultSet.close();
    statement.close();
    connection.close();
    protected void finalize() throws Throwable {
    close();
    super.finalize();
    // Implementation of the TableModel Interface
    // MetaData
    public String getColumnName(int column) {
    if (columnNames[column] != null) {
    return columnNames[column];
    } else {
    return "";
    public Class getColumnClass(int column) {
    int type;
    try {
    type = metaData.getColumnType(column+1);
    catch (SQLException e) {
    return super.getColumnClass(column);
    switch(type) {
    case Types.CHAR:
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
    return String.class;
    case Types.BIT:
    return Boolean.class;
    case Types.TINYINT:
    case Types.SMALLINT:
    case Types.INTEGER:
    return Integer.class;
    case Types.BIGINT:
    return Long.class;
    case Types.FLOAT:
    case Types.DOUBLE:
    return Double.class;
    case Types.DATE:
    return java.sql.Date.class;
    default:
    return Object.class;
    public boolean isCellEditable(int row, int column) {
    try {
    return metaData.isWritable(column+1);
    catch (SQLException e) {
    return false;
    public int getColumnCount() {
    return columnNames.length;
    // Data methods
    public int getRowCount() {
    return rows.size();
    public Object getValueAt(int aRow, int aColumn) {
    Vector row = (Vector)rows.elementAt(aRow);
    return row.elementAt(aColumn);
    public String dbRepresentation(int column, Object value) {
    int type;
    if (value == null) {
    return "null";
    try {
    type = metaData.getColumnType(column+1);
    catch (SQLException e) {
    return value.toString();
    switch(type) {
    case Types.INTEGER:
    case Types.DOUBLE:
    case Types.FLOAT:
    return value.toString();
    case Types.BIT:
    return ((Boolean)value).booleanValue() ? "1" : "0";
    case Types.DATE:
    return value.toString(); // This will need some conversion.
    default:
    return "\""+value.toString()+"\"";
    public void setValueAt(Object value, int row, int column) {
    try {
    String tableName = metaData.getTableName(column+1);
    // Some of the drivers seem buggy, tableName should not be null.
    if (tableName == null) {
    System.out.println("Table name returned null.");
    String columnName = getColumnName(column);
    String query =
    "update "+tableName+
    " set "+columnName+" = "+dbRepresentation(column, value)+
    " where ";
    // We don't have a model of the schema so we don't know the
    // primary keys or which columns to lock on. To demonstrate
    // that editing is possible, we'll just lock on everything.
    for(int col = 0; col<getColumnCount(); col++) {
    String colName = getColumnName(col);
    if (colName.equals("")) {
    continue;
    if (col != 0) {
    query = query + " and ";
    query = query + colName +" = "+
    dbRepresentation(col, getValueAt(row, col));
    System.out.println(query);
    System.out.println("Not sending update to database");
    // statement.executeQuery(query);
    catch (SQLException e) {
    // e.printStackTrace();
    System.err.println("Update failed");
    Vector dataRow = (Vector)rows.elementAt(row);
    dataRow.setElementAt(value, column);
    Thanks to help me.

    Hi,
    OK. I have read your code sample again. It looks like the JDBCAdapter class is reloading table data in the executeQuery method. Why not call adjustColumns at the end of this method after the new rows and columns are loaded? Perhaps it also should be called at the end of executeUpdate. Have you tried doing that?
    I would still set
    JTable1.setAutoCreateColumnsFromModel (false); to prevent Java from readjusting the size automatically at some other time.
    regards,
    Terry

  • How can I use a column header to select columns in a JTable?

    Hello,
    I've been working for ages on this, but I still can't come up with a suitable solution. What I want to be able to do is select a column header from a JTable, which in turn would select the corresponding column in my JTable. I cant seem to do this with a mouse listener, and I can't see how to toggle the buttons of the header either.
    Any help would be gratefully appreciated.
    Mike

    I have both row and columns selected depending on what you do in the JTable. Here's my code:
    where you init your JTable add:
    addressTable = new JTable(addressTableModel, addressTableColumnModel);
    JTableHeader th = addressTable.getTableHeader();
    th.addMouseListener(new tableHeaderMouseAdapter(addressTable));
    addressTable.getSelectionModel().addListSelectionListener(new selectionListener(addressTable));
    addressTable.setColumnSelectionAllowed(true);
    tableHeaderMouseAdapter looks like this (it should look familiar):
    private class tableMouseAdapter extends MouseAdapter
         private JTable tableView;
         public tableMouseAdapter(JTable newTableView)
              tableView = newTableView;
         public void mouseClicked(MouseEvent e)
              int selectedRow = tableView.getSelectedRow();
              if ((e.getClickCount() == 1) && (selectedRow != -1))
                   tableView.clearSelection();
                   tableView.setRowSelectionInterval(selectedRow, selectedRow);
                   tableView.setColumnSelectionInterval(0, tableView.getColumnModel().getColumnCount() - 1);
    selectionListener looks like this:
    private class selectionListener implements ListSelectionListener
         private JTable tableView;
         private boolean changingSelection;
         public selectionListener(JTable newTableView)
              tableView = newTableView;
              changingSelection = false;
         public void valueChanged(ListSelectionEvent e)
              if ((!changingSelection) && (tableView.getSelectedColumnCount() < tableView.getColumnCount()) && (tableView.getSelectedRowCount() < tableView.getRowCount()))
                   changingSelection = true;
                   int selectedRow = tableView.getSelectedRow();
                   if (selectedRow >= 0)
                        tableView.clearSelection();
                        tableView.setRowSelectionInterval(selectedRow, selectedRow);
                   tableView.setColumnSelectionInterval(0, tableView.getColumnModel().getColumnCount() - 1);
                   changingSelection = false;
    I'm sure there is a better way to do this, but it's the first thing I could get to work.
    disclamer:
    Use this code at your own risk. I make no claims about this code whatsoever.

  • Selective reordering of columns in a Jtable

    Hi
    I have this problem where I need to allow the first 8 columns to be reordered but not the remaining columns in a Jtable.
    I have tried a few approaches by adding listeners to the jtable header and identifying the column which is clicked for reordering and accordingly setting the rearrange policy / feature of the jtable to true/false.
    This works fine in almost all scenarios except for one where the user selects a column which can be reordered and drags it to a position beyond the allowed 8 columns, and now that column is frozen since it is beyond the permissible index of 8.
    I was wondering if there was a 'cleaner'/ better way to go about implementing this.

    Thanks for the link...
    I went through it but seems like a big change for the functionality I want to achieve.
    I am thinking about allowing the user to reorder the column and then if he has chosen an invalid column (one which cannot be rearranged) just undo that action using the moveColumn method.
    I tried overriding the columMoved method to inform me about a column reorder evernt but that method keeps getting fired while the user is rearranging.
    Is there anyway to get a notification once the user is done rearranging the column.
    Thanks

Maybe you are looking for

  • GR Block

    Hi We have different Scheduling Agreement's raised against a particular vendor with schedule lines for every order. Is there any way to restrict a particular agreement from being Goods Receipted? It might not serve the purpose if we just put a block

  • Controlling Auditing database (Datawise)

    Hi, I am using BOXI R3.0, we have configured the auditing. Is there a way we can control amount of data write in Audit database? We need to configure such that it should keep only last 3 months data and it should remove prior data from Audit database

  • Cant get nexus to charge

    I bought a nexus cant get it to charge? it has 4 sm sencers on side does it hav a docking station to help charge it?

  • If I needed Fibre

    An Xserve and Xserve RAID are in our future and I have a couple of questions. We are currently planning on the clients accessing the server via gigabit ethernet, and I understand that the Xserve would connect to the RAID via Fibre then the network wo

  • Sound output, comes out headphones AND internal speakers

    I've had my refurbished PBG4 1.33 GHz for a few months and when I plug in headphones, the sound comes out the headphones AND the internal speakers of the laptop. I've tried messing w/ the System Prefs/Output with no luck whatsoever. Any suggestions,