Need help with advanced JTable

The application I am converting to Java has a string grid (table) with special behavior that I need to be able to bring to the Java version. It let's users filter the column data (that I know how to do) using a locked first row (just below the column header) that always stays in place and that shows what filter is applied to each column (by showing a combo box).
I usually write server apps and have only been trying to grasp Swing for about a week, and I find myself stuck :(
Is this at all possible in Java? If not, can I make the header respond to mouse events and show a popup menu for each column? If so how?
Please help!

I have made an attempt as follows (to show where I am stuck).
I have two TableModels that contain rows and data;
a) the grid data that's coming from our EJB session facade
b) the filter settings (a String[] with initially empty strings) which show what filter is used for each column.
The two table models are shown in two tables that share a common TableColumnModel so that whenever i move or resize a column both tables are updated.
The filter table shows it's header and the row of empty cells. The Table Model I've used for it is ripped from the Sorted Table example from Sun, so that I can capture mouse events, set the sort order for each column and notify the grid table that it needs to update accordingly.
I attempted to use the filter table as a header view in a JScrollPane, which would keep it in place all the time while the user would be able to scroll and resize the grid table.
This is where I fail - I can't even get it to show up in the header. And if I only put the two tables on a JPanel it seems impossible to get them to stick together when the pane is resized (aside from the fact that I no longer can capture the mouse events).
I'd be happy to send someone the code fragments if you think you have a solution to this - that will allow users to resize, edit and move columns in a table where you initially have no clue as to how many columns it will contain.
Please please continue to help me :)

Similar Messages

  • Need help with advanced applet

    I need help with designing an applet as follows. Can someone give me a basic layout of code and material so i can fill in the rest or at leats give me some hints so i can get started since i am like no good at applets.
    Design and implement an applet that graphically displays the processing
    of a selection sort. Use bars of various heights to represent
    the values being sorted. Display the set of bars after each swap. Put
    a delay in the processing of the sort to give the human observer a
    chance to see how the order of the values changes.
    heres a website that does something similar
    http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html

    elasolova wrote:
    i will not help you this time. but if you buy me a candy maybe i can reconsider the issue. :PI suggest an all-day sucker.

  • Need Help with Advanced Button Actions

    I am a brand new Captivate 5 user and I have created a image button that I want to have a double action. When the user clicks on the image button, I want it to SHOW a new button AND SHOW another image. I used the Advanced Actions but it does not work when I preview project.  Help!

    Hello and welcome to the forum,
    Did you assign the advanced action to the image button as Success action? And the new button + the image have to be on the same slide, but with the status Invisible. You can not show hidden objects that are sitting on another slide then the slide with the advanced action.
    If you want to have more information about advanced actions, I do blog a lot about them. Here is the link to my blog:
    http://lilybiri.posterous.com
    Lilybiri

  • Need help with Advanced Selection in MSA

    Hi,
    Has anyone managed to identify how to create additional
    advanced selection criteria using links to existing combo engines ? Documentation on Mobile system maint is limited so looking for some additional help. Some criteria you can run the check against but not all why ? What should go in the hierachy fields and how do you select the choice list values ?
    Thanks in advance
    M

    Hi,
    Thanks,my issue is I want to use the combo box so the user can select from the drop down the relevant code from the choice list. Not rocket science really.
    Example of sql generated for profession whch is kna1 field.
    select  KNA1.TITLE,KNA1.SFAKNA2,KNA1.SFAKNA1,KNA1.PROFRESSION as PROFESSION,KNA1.PAFKT,KNA1.NAME2,KNA1.NAME1,KNA1.KVTGRP,KNA1.KVCPPOS,KNA1.KUNNR,KNA1.KTOKD,KNA1.BPACT,KNA1.ANRED,KNA1.ABTNR,ADRC.TELNR_LONG,ADRC.STREET,ADRC.POST_CODE1,ADRC.CITY1,ADRC.ADRCDFLT,ADDR.SFAKNBP , (KNA1.PROFESSION ='MIC') as ReturnValue1 from SMOKNA1 KNA1,SMOADRC ADRC,CDBD_ADDREXT ADDR where kna1.deleted='0' and KNA1.Source='CON' and ADRC.deleted='0' and ADDR.deleted = '0' and (ADRC.ADRCDFLT='S' or ADRC.ADRCDFLT='P') and (1=1) and kna1.sfakna1=adrc.sfakna1 and adrc.sfaadrc = addr.sfaadrc order by kna1.name1
    Code fails !
    I have set VAR1 as a free Combo with Bdoc as Choice, segment as Choice List with fields chkey/Textx so hiearchy fields looks like this //*/Profession hiearchy params being mandt/spras/list
    It will not check is this because there is an error in this definition ?
    Regards
    MM

  • Need help with advanced Query

    I am stuck on a query and hope someone can help me out with
    it. Basically I am trying to get the average score by team who has
    competed in four or more events.
    So far I have my query doing a join to pull in the teams name
    and their category. What I want to do is be able to count the
    unique locations and do an average of the four highest scores on a
    field called overall.
    I have tried putting a couple different COUNT in my query's
    WHERE statement but it errors out.
    Any ideas? Some how I have a feeling I need to create a new
    table.
    Thanks

    chieffan wrote:
    > I am stuck on a query and hope someone can help me out
    with it. Basically I am
    > trying to get the average score by team who has competed
    in four or more events.
    >
    > So far I have my query doing a join to pull in the teams
    name and their
    > category. What I want to do is be able to count the
    unique locations and do an
    > average of the four highest scores on a field called
    overall.
    >
    > I have tried putting a couple different COUNT in my
    query's WHERE statement
    > but it errors out.
    >
    > Any ideas? Some how I have a feeling I need to create a
    new table.
    >
    > Thanks
    You need to use GROUP BY. Will need to know more specifics
    about the
    table construction along with sample data, and an example of
    the
    expected results.
    Dooza

  • Need Help with Advanced Filters

    I hope someone can please help A.S.A.P. my current project
    depends on getting the searches to function correctly I have found
    the Multiple Filters very useful all it needs is a little tweaking,
    I have tried but failed
    1st Main Problem
    The problem with the multiple filter it only work
    alphabetical, I need to be able to filter facilities
    for example a restaurant has up to 10 facilities I would like
    to tick the facility to show the live result
    in the DB there is either a 1 or 0 in the field, so I tried
    the following code
    this is what I am trying to achieve but with the Live
    Searches
    http://www.dinewithus.co.uk/dining/shropshiresearch.php
    var dsCounties = new
    Spry.Data.XMLDataSet("http://www.dinewithus.co.uk/new/xml/county.xml",
    "/counties/county");
    var dsLocation = new Spry.Data.XMLDataSet("
    http://www.dinewithus.co.uk/new/xml/{dsCounties::url2}",
    "export/row");
    var gEffectInProgress = null;
    var gPendingSetRowIDRequest = -1;
    function ffAH(ds, row, index){ var c =
    row.smoking_al_fresco.charAt(0); return c = '1' ? null : row; };
    function ffIP(ds, row, index){ var c =
    row.disabled_access_facilities_fac.charAt(0); return c = '1' ? null
    : row; };
    function ffQZ(ds, row, index){ var c =
    row.real_ales_fac.charAt(0); return c = '1' ? null : row; };
    function ToggleFilter(enable, f)
    if (enable)
    pvLocation.addFilter(f, true);
    else
    pvLocation.removeFilter(f, true);
    function RemoveAllFilters()
    document.forms[0]["fAH"].checked = false;
    document.forms[0]["fIP"].checked = false;
    document.forms[0]["fQZ"].checked = false;
    pvLocation.removeAllFilters(true);
    2nd Issue (not sure if possible?)
    currently using the paging example I am able to show all the
    records in different regions, the only problem is the filter Area
    is a text box I need this to be a dropdown search, fetching
    DISTINCT results from the towns filed in the DB, I managed to do
    this creating another dynamic data set DISTINCT town which showed
    all the towns but once selecting an option did not change the
    results below ideally I need something similar my county search but
    for towns the town are dynamically showing from DB but the counties
    are showing from 1 XML file
    http://www.dinewithus.co.uk/new/xml/county.xml

    That's just it. I select Library or Filters from the Window dropdown menu and neither window opens up. Could it be my 15.4" MacBook Pro screen isn't big enough to see the interface?

  • Hi, i need help with a jtable

    hi, iam new here, i try to read an excel file, and put the rows and columns in a jtable, i dont have the code exactly but maybe someone can help me.

    You can use this
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    //String myDB ="myExcel";
    String myDB =  "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=c:/book.xls;"
        + "DriverID=22;READONLY=false";
    //con=DriverManager.getConnection("jdbc:odbc:myExcel");
    con=DriverManager.getConnection(myDB,"","");
    dbmd=con.getMetaData();
    stat=con.createStatement();
    rs=stat.executeQuery("Select * from `Sheet1$`");//[Sheet1$]
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    while (rs.next()) {
    for (int i = 1; i <= numberOfColumns; i++) {
    if (i > 1) System.out.print(", ");
    String columnValue = rs.getString(i);
    System.out.print(columnValue);
    System.out.println("");
    for (int j = 1; j <= numberOfColumns; j++)
      System.out.println(rsmd.getColumnName(j));
    rsTable=dbmd.getTables(null,null,"%",null);
    while (rsTable.next())
    //String tableCatalog = rsTable.getString(1);
    //String tableSchema = rsTable.getString(2);
    System.out.println("Table Name "+rsTable.getString(3)+" Table catalog "+rsTable.getString(1)+" Table Schema "+rsTable.getString(2));
    rsTable.close();You can store Column Names,data in the String Array.
    To generate a JTable with this check this
    http://www.codetoad.com/java_JTable.asp.
    There at method createBlankElement()
    put values from the data array or if you want, from the database.
    For the Columns, pass columnNames array to addColumns method.

  • Need Help with Advanced SQL Query

    It's advanced for me, at least. I have three tables that I
    need to use:
    Product (product_id and product_title are the fields)
    shipRegion (shipRegion_ID)
    product_shipRegion_shipCharge (product_id, shipRegion_ID,
    primaryShipCharge, secondaryShipCharge)
    What I am trying to do is create a query that will look for
    two things:
    1. Any product that is listed in the
    product_shipRegion_shipCharge table that has a primary or secondary
    ship charge of $0.00 or is NULL.
    That part is easy:
    SELECT DISTINCT p.product_id, p.product_title
    FROM product p
    INNER JOIN product_shipRegion_shipCharge pss ON p.product_id
    = pss.product_id AND (pss.primaryShipCharge IS NULL OR
    pss.primaryShipCharge = 0 OR pss.secondaryShipCharge IS NULL OR
    pss.secondaryShipCharge = 0)
    WHERE p.display = 1
    AND p.price > 0
    It's this next part that's tricky for me:
    2. Get the product_id and product_title (from the product
    table) that does NOT have any entry in the
    product_shipRegion_shipCharge table.
    I'm guessing that I need to include some kind of LEFT JOIN in
    the above query to find out what all of the regions are (from the
    shipRegion table) and then see what's missing for each product in
    the product_shipRegion_shipCharge table, but I have no idea how to
    do it.
    Anyone?
    Josh

    This should be what the query would look like using the left
    join:
    SELECT product_table.product_id, product_table.product_title
    FROM product_table
    LEFT OUTER JOIN product_shipRegion_shipCharge
    ON product_shipRegion_shipCharge.product_id =
    product_table.product_id
    WHERE product_shipRegion_shipCharge. product_id IS NULL
    SQL Server's query optimizer will probably turn the '...IN
    (subquery)' or '...exists (subquery)' into this kind of execution
    plan on its own - depending on your table structures.

  • Need help with advanced color adjustments

    Hello people,
    A costumer asked me to design a sofa brochure. All product images have the same yellowish lighting and I will have to adjust them of course. But I'm struggling with it.
    What is the best way to have 100% correct colors?

    Once you get a sample, you most likely will have to use curves to correct the color crossover of the color difference between the highlights (too yellow-red) and the shadows too cyan.  Depending upon your other images,  there are several ways to do this.  You can try just using straight curves to adjust the color difference between the highlights and the shadows, you can use color range to select the colors that are off and make a mask to balance those colors with either curves or hue/saturation, or if the other images have a solid color like this one, you can use a solid color adjustment layer set to color blend mode and tweak the blend if sliders to not have the deep shadows return them to a more neutral color.  The left half of the attached image uses the solid color fill layer, and the right half uses color range and curves.

  • Need help with Template - unbalanced #EndEditable tag

    I am unable to use this template to create a new page and get the "unbalanced #EndEditable tag" error.
    If I open the file independently it looks great - otherwise I get the error.
    Code for internal_students.dwt
    There is an error at line 45, column 79 (absolute position 2188)
    <div id="metanav"><!-- #BeginLibraryItem "/Library/metaNav.lbi" -->
    <p><a href="../Library/contact/index.html">Contact Us</a></p>
    <!-- #EndLibraryItem --></div>
            <div id="navigation">
                <div id="navigation_l">
                    <div id="navigation_r"><!-- #BeginLibraryItem "/Library/mainNav.lbi" --> <ul>
                            <li><a href="../index.html" class="first"><img src="../images/spacer.gif" alt="CAITE Homepage" width="75" height="20" border="0" /></a></li>
                            <li><a href="../about/index.html">About</a></li>
      <li><a href="../news/index.html">News And Events</a></li>
      <li><a href="../educators/index.html">For Educators</a></li>
      <li><a href="../students/index.html">For Students</a></li>
      <li><a href="../industry/index.html" class="last">For Industry</a></li>
                        </ul>
    <!-- #EndLibraryItem --></div>
    I need help with this as the site and templates were created 2/3 years before I arrived on the job.
    Thank you
    Cheryl

    Okay
    - This is on-line page  http://caite.cs.umass.edu/students/index.html
    If you want code from template here it is:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/internal_about.dwt" codeOutsideHTMLIsLocked="false" -->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>CAITE - Commonwealth Alliance for Information Technology Education</title>
    <!-- InstanceEndEditable -->
    <!-- InstanceBeginEditable name="head" -->
    <meta name="Description" content="Commonwealth Alliance for Information Technology Education (CAITE) to design and carry out comprehensive programs that address under representation in information technology (IT) education and the workforce. CAITE will focus on women and minorities in groups that are underrepresented in the Massachusetts innovation economy" />
    <meta name="Keywords" content="Commonwealth Alliance for Information Technology Education CAITE Massachusetts women minorities information technology IT" />
    <meta name="robots" content="all, index, follow" />
    <meta name="revisit-after" content="14 days" />
    <meta name="author" content="Outreach Web Team" />
    <!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable --><!-- InstanceEndEditable -->
    <link rel="shortcut icon" href="/images/favicon.ico" />
    <script type="text/javascript" src="../scripts/jquery.js"></script>
    <script type="text/javascript" src="../scripts/jquery.easing.js"></script>
    <script type="text/javascript" src="../scripts/jquery.pngfix.js"></script>
    <script language="JavaScript" type="text/JavaScript">
        <!--
        $(document).ready(function() {
            $("img[@src$=png], div#wrapper_l, div#wrapper_r, div#whatsnew").pngfix();
        //-->
    </script>
    <link href="../css/screenstyle.css" rel="stylesheet" type="text/css" media="screen" />
    <link href="../css/printstyle.css" rel="stylesheet" type="text/css" media="print" />
    </head>
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <body>  
        <div id="wrapper">
            <div id="metanav"><!-- #BeginLibraryItem "/Library/metaNav.lbi" -->
    <p><a href="../Library/contact/index.html">Contact Us</a></p>
    <!-- #EndLibraryItem --></div>
            <div id="navigation">
                <div id="navigation_l">
                    <div id="navigation_r"><!-- #BeginLibraryItem "/Library/mainNav.lbi" --> <ul>
                            <li><a href="../index.html" class="first"><img src="../images/spacer.gif" alt="CAITE Homepage" width="75" height="20" border="0" /></a></li>
                            <li><a href="../about/index.html">About</a></li>
      <li><a href="../news/index.html">News And Events</a></li>
      <li><a href="../educators/index.html">For Educators</a></li>
      <li><a href="../students/index.html">For Students</a></li>
      <li><a href="../industry/index.html" class="last">For Industry</a></li>
                        </ul>
    <!-- #EndLibraryItem --></div>
                    <!-- end navigation right -->
                </div><!-- end navigation left -->
           </div><!-- end navigation -->
            <div id="wrapper_l">
                <div id="wrapper_r">
                      <div id="innerwrapper">
                        <div id="internalBanner-print"> <h1>Commonwealth Alliance for Information Technology Education (CAITE)</h1></div>
                        <div id="internalBanner"><!-- InstanceBeginEditable name="internalBanner" -->
                          <div class="students-banner">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="125" height="188" align="left" valign="top" id="homeImage"><img src="../images/logo_vertical_small.png" alt="CAITE" width="105" height="188" /></td>
                                <td align="left" valign="top" id="internal-banner-quote"><div id="internalQuote">
                                    <div id="internalQuote-inner">
                                      <p>CAITE designs and carrys out comprehensive programs that address under-representation in information technology (IT).</p>
                                  </div>
                                </div></td>
                              </tr>
                            </table>
                        </div>
                        <!-- InstanceEndEditable --></div> <!-- end banner -->
                        <div id="internalContent">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr>
                                <td width="317" align="left" valign="top" id="secondary-content">
                                  <!-- InstanceBeginEditable name="SecondaryNav" --><!-- #BeginLibraryItem "/Library/studentNav.lbi" -->
                                  <h3><a href="../students/index.html">For Students</a></h3>
                                  <div id="secondaryNav">
                                    <ul>
                                      <li><a href="http://www.takeITgoanywhere.org" target="_blank">TakeITgoanywhere.org</a></li>
                                    </ul>
    </div><!-- #EndLibraryItem --><!-- InstanceEndEditable -->
                                </td>
                                <td align="left" valign="top" id="contentCell"><!-- InstanceBeginEditable name="mainContent" -->
                                  <h1>For Students</h1>
                                  <p>The University of Massachusetts Amherst is leading a Commonwealth Alliance for Information Technology Education (CAITE) to design and carry out comprehensive programs that address under representation in information technology (IT) education and the workforce. CAITE will focus on women and minorities in groups that are underrepresented in the Massachusetts innovation economy; that is, economically, academically, and socially disadvantaged residents.</p>
                                  <p>The project will pilot a series of outreach programs supported by educational pathways in three regions (one rural, one suburban, and one urban). The project will include work with high school teachers, staff, and counselors. CAITE will identify best practices and disseminate, deploy, extend and institutionalize these best practices statewide and nationally.</p>
                                  <p>Community colleges are the centerpiece of CAITE because of the central role they play in reaching out to underserved populations and in serving as a gateway to careers and further higher education.</p>
                                  <p>This project will build a broad alliance built on its leadership in and partnership with the Commonwealth Information Technology Initiative (CITI), the Boston Area Advanced Technological Education Center (BATEC), regional Louis Stokes Alliances and NSF EGEP programs, and other partnerships and initiatives focused on information technology education and STEM pipeline issues</p>
                                  <p> </p>
                                <!-- InstanceEndEditable --></td>
                              </tr>
                          </table>
                        </div>
                        <div id="alliances">
                              <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                  <td height="30"  align="left" valign="top"><h2><a href="../about/alliances.html">Alliances</a></h2></td>
                                </tr>
                                <tr>
                                  <td  align="center" valign="middle"><!-- #BeginLibraryItem "/Library/AllianceTable.lbi" --><p>
    <table border="0" cellpadding="2" cellspacing="0">
                                    <tr>
                                      <td width="35"  align="center" valign="middle"> </td>
                                      <td  align="center" valign="middle"><a href="http://www.citi.mass.edu/" target="_blank"><img src="../images/logo_citi.jpg" alt="Citi" width="65" height="50"  border="0 /"></a></td>
                                      <td align="center" valign="middle"><a href="http://www.batec.org/index.php" target="_blank"><img src="../images/logo_batec.jpg" alt="BATEC" width="69" height="46" border="0" /></a></td>
                                      <td  align="center" valign="middle"><a href="http://www.nsf.gov/index.jsp" target="_blank"><img src="../images/nsflogo.gif" alt="NSF" width="64" height="65" border="0" ></a></td>
                                      <td  align="center" valign="middle"><a href="http://www.nelsamp.neu.edu/" target="_blank"><img src="../images/nelsamplogo.gif" width="100" border="0"></a></td>
                                      <td  align="center" valign="middle"><p><a href="http://mysite.verizon.net/milnerm/" target="_blank"><img src="../images/umlsamp.png" width="85" height="63" border="0"></a></p>                                  </td>
                                      <td  align="center" valign="middle"><a href="http://www.neagep.org/index.asp" target="_blank"><img src="../images/nealogo.gif" border="0" ></a></td>
      </tr>
                                  </table>
    <!-- #EndLibraryItem --></td>
                                </tr>
                          </table>
                        </div>
                    </div> <!-- end inner wrapper -->
                </div><!-- end wrapper right -->
            </div><!-- end wrapper left -->
            <div id="bottom">
                <div id="bottom_l">
                    <div id="bottom_r"> </div><!-- end bottom right -->
                </div><!-- end bottom left -->
            </div>  <!-- end bottom -->
        </div><!-- end wrapper -->
        <div id="copyright"><!-- #BeginLibraryItem "/Library/copyright.lbi" -->
    <p>Sponsored by CAITE an NSF CISE Broadening Participation in Computing Alliance<br />
    &copy; copyright 2008 <a href="http://www.umass.edu/" target="_blank">University of Massachusetts, Amherst</a></p>
    <font color="#666666"><br>
    </font>
    <p><font color="#666666" size=2>  This material is based upon work supported by the National Science Foundation under Grant No.s NSF-0634412 and NSF-0837739. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.</font> </p>
    <!-- #EndLibraryItem --></div>    
    <!-- end copyright -->
    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("UA-7435501-1");
    pageTracker._trackPageview();
    } catch(err) {}</script>
        </body>
    <!-- InstanceEnd --></html>

  • Need help with my graphic calculator!!!

    Hello everybody!! I need help with my little program I made.... The problem is that I am unable to use to calculate but it is possible to compile the code!! What should I do?? Thanks in advance.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Aritmetik extends JFrame implements ActionListener{
         private JLabel l1 = new JLabel("Tal1: ", JLabel.LEFT);
         private JLabel l2 = new JLabel("Tal2: ", JLabel.LEFT);
         private JLabel l3 = new JLabel("Resultat",JLabel.LEFT);
         private JLabel l4 = new JLabel(" ", JLabel.RIGHT);
         private JTextField t1 = new JTextField(" ",10);
         private JTextField t2 = new JTextField(" ",10);
         private JButton b1 = new JButton("+");
         private JButton b2 = new JButton("-");
         private JButton b3 = new JButton("*");
         private JButton b4 = new JButton("/");
         public Aritmetik(){
              Container v = getContentPane();
              v.setLayout(new GridLayout(5,2));
              v.add(l1);
              v.add(t1);
              v.add(l2);
              v.add(t2);
              v.add(b1);
              v.add(b2);
              v.add(b3);
              v.add(b4);
              v.add(l3);
              v.add(l4);
              b1.addActionListener(this);
              b2.addActionListener(this);
              b3.addActionListener(this);
              b4.addActionListener(this);
              pack();
              setVisible(true);
              setDefaultCloseOperation(EXIT_ON_CLOSE);
         public void actionPerformed(ActionEvent e){
              int tal1 = Integer.parseInt(t1.getText());
              int tal2 = Integer.parseInt(t2.getText());
                   if(e.getSource() == b1){
              if(t1.getText().equals("") || t2.getText().equals(""))
                                       JOptionPane.showMessageDialog(null, "Mata in tal!");
                   else{
                        l3.setText("Resultat ");
                   l4.setText(" " + (tal1+tal2));
                   else if(e.getSource() == b2){
                        int sub = tal1-tal2;
                        l4.setText(" " + (sub));
                   else if(e.getSource() == b3){
                        int multi = tal1*tal2;
                        l4.setText(" " + (multi));
                   else if(e.getSource() == b4){
                        int div = tal1/tal2;
                        l4.setText(" " + (div));
                   public static void main(String[] arg){
                   Aritmetik A =new Aritmetik();

    Here is your problem:
    public void actionPerformed(ActionEvent e){
      int tal1 = Integer.parseInt(t1.getText().trim());  // add the trim()
      int tal2 = Integer.parseInt(t2.getText().trim());  // add the trim()
      if(e.getSource() == b1){
        if(t1.getText().equals("") || t2.getText().equals(""))
          JOptionPane.showMessageDialog(null, "Mata in tal!");
        else{
          l3.setText("Resultat ");
          l4.setText(" " + (tal1+tal2));
      }... Better ...
    public void actionPerformed(ActionEvent e)  throws NumberFormatException {
      String tala = t1.getText().trim();
      String talb = t2.getText().trim();
      if ( tala == null  ||  "".equals(tala)  ||  talb == null  ||  "".equals(talb) ) {
        JOptionPane.showMessageDialog(null, "Mata in tal!");
        return();
      int tal1 = Integer.parseInt(tala);
      int tal2 = Integer.parseInt(talb);
      if(e.getSource() == b1){
        l3.setText("Resultat ");
        l4.setText(" " + (tal1+tal2));
      else if(e.getSource() == b2){
        int sub = tal1-tal2;
        l4.setText(" " + (sub));
      else if(e.getSource() == b3){
        int multi = tal1*tal2;
        l4.setText(" " + (multi));
      else if(e.getSource() == b4){
        int div = tal1/tal2;
        l4.setText(" " + (div));
    }Message was edited by:
    abillconsl

  • Need help with my addressbook program

    hi,
    i need help with my program here. this one should works as:
    - saves user input into a txt file
    - displays name of the saved person on the jlist whenever i run the program
    - displays info about the person when clicked via textboxes given by reading the txt file where the user inputs are
    - should scroll when the list exceeds the listbox
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.JList;
    import java.awt.event.ActionListener;
    import java.io.*;
    import javax.swing.event.*;
    import java.io.FilterInputStream;
    public class AddressList extends JPanel implements ActionListener
         JTextField txt1 = new JTextField();
         JTextField txt2 = new JTextField();
         JTextField txt3 = new JTextField();
         DefaultListModel mdl = new DefaultListModel();
         JList list = new JList();
         JScrollPane listScroller = new JScrollPane(list);
         ListSelectionModel listSelectionModel;
         File fob = new File("Address3.txt");
         String name;
         char[] chars;     
         public void ListDisplay()
              try
                   RandomAccessFile rand = new RandomAccessFile(fob,"rw");
                   BufferedReader br = new BufferedReader(new FileReader("Address3.txt"));
                   if(fob.exists())
                         while((name = rand.readLine()) != null)
                              chars = name.toCharArray();
                              if(chars[0] == '*')
                                   mdl.addElement(name);
                                   list.setModel(mdl);
                              if(chars[0] == '#')
                                   continue;
                    else
                        System.out.println("No such file..");
              catch(IOException a)
                         System.out.println(a.getMessage());
         public AddressList()
              this.setLayout(null);
              listSelectionModel = list.getSelectionModel();
            listSelectionModel.addListSelectionListener(new ListInfo());
              list.setBounds(10,40,330,270);
              listScroller.setBounds(320,40,20,100);
              add(list);
              add(listScroller);
              JLabel lbl4 = new JLabel("Name: ");
              lbl4.setBounds(400,10,80,30);
              add(lbl4);
              JLabel lbl5 = new JLabel("Cellphone #: ");
              lbl5.setBounds(400,50,80,30);
              add(lbl5);
              JLabel lbl6 = new JLabel("Address: ");
              lbl6.setBounds(400,90,80,30);
              add(lbl6);
              JLabel lbl7 = new JLabel("List ");
              lbl7.setBounds(10,10,100,30);
              add(lbl7);
              txt1.setBounds(480,10,200,30);
              add(txt1);
              txt2.setBounds(480,50,200,30);
              add(txt2);
              txt3.setBounds(480,90,200,30);
              add(txt3);
              JButton btn1 = new JButton("Add");
              btn1.setBounds(480,130,100,30);
              btn1.addActionListener(this);
              btn1.setActionCommand("Add");
              add(btn1);
              JButton btn2 = new JButton("Save");
              btn2.setBounds(480,170,100,30);
              btn2.addActionListener(this);
              btn2.setActionCommand("Save");
              add(btn2);
              JButton btn3 = new JButton("Cancel");
              btn3.setBounds(480,210,100,30);
              btn3.addActionListener(this);
              btn3.setActionCommand("Cancel");
              add(btn3);
              JButton btn4 = new JButton("Close");
              btn4.setBounds(480,250,100,30);
              btn4.addActionListener(this);
              btn4.setActionCommand("Close");
              add(btn4);
         public static void main(String[]args)
              JFrame frm = new JFrame("Address List");
              AddressList panel = new AddressList();
              frm.getContentPane().add(panel,"Center");
              frm.setSize(700,350);
              frm.setVisible(true);
              panel.ListDisplay();
         public void actionPerformed(ActionEvent e)
              String cmd;
              cmd = e.getActionCommand();
              if(cmd.equals("Add"))
                   txt1.setText("");
                   txt2.setText("");
                   txt3.setText("");
              else if(cmd.equals("Save"))
                   mdl.addElement(txt1.getText());
                   list.setModel(mdl);
                   try
                   RandomAccessFile rand = new RandomAccessFile(fob,"rw");
                   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                   LineNumberReader line = new LineNumberReader(br);
                    if(fob.exists())
                              rand.seek(fob.length());
                              rand.writeBytes("* " + txt1.getText());
                              rand.writeBytes("\r\n" + "# " + txt2.getText());
                              rand.writeBytes("\r\n" + "# " + txt3.getText() + "\r\n");
                    else
                         System.out.println("No such file..");
                        txt1.setText("");
                        txt2.setText("");
                        txt3.setText("");
                    catch(IOException a)
                         System.out.println(a.getMessage());
              else if(cmd.equals("Cancel"))
                   txt1.setText("");
                   txt2.setText("");
                   txt3.setText("");
              else if(cmd.equals("Close"))
                   System.exit(0);
    class ListInfo implements ListSelectionListener
         public void valueChanged(ListSelectionEvent e)
              ListSelectionModel lsm = (ListSelectionModel)e.getSource();
              int minIndex = lsm.getMinSelectionIndex();
            int maxIndex = lsm.getMaxSelectionIndex();
              try //*this one should display the info of the person whenever i click the person's name at the list box via textbox.. but i cant seem to get it right since it always display the info of the first person inputed.. i tried to get the program to display them whenever it reads lines with * on them....
                   File fob = new File("Address3.txt");
                   RandomAccessFile rand = new RandomAccessFile(fob,"rw");
                   BufferedReader br = new BufferedReader(new FileReader("Address3.txt"));
                   LineNumberReader line = new LineNumberReader(br);
                   if(fob.exists())
                              for(int i = minIndex; i<=maxIndex; i++)
                                   if(lsm.isSelectedIndex(i))
                                        while((name = rand.readLine()) != null)
                                             chars = name.toCharArray();
                                             if(chars[0] == '#')
                                                  continue;
                                             if(chars[0] == '*')
                                                  txt1.setText(rand.readLine());
                                                 txt2.setText(rand.readLine());
                                                 txt3.setText(rand.readLine());
                    else
                              System.out.println("No such file..");
              catch(IOException a)
                         System.out.println(a.getMessage());
    }the only problem now is about how it should display the right info about the person whenever i click its name on the list.. something about file reading or something, i just cant figure it out.
    and also about how to make it scroll once it exceeds the list.. i cant make it work, maybe something about wrong declaration..
    thanks in advance..
    Edited by: syder on Mar 14, 2008 2:26 AM

    Like said before, do one thing at a time. At startup, something like:
    //put all the content in a list
    ArrayList<String> lines = new ArrayList<String>();
    while(String line=rand.readLine()!=null) {
        lines.add(line);
    }If you follow the good advice to create a class to encapsulate the entries, you could populate a list of such entries like this:
    static final int ENTRY_SIZE = 3;//you have 3 fields now, better to have a constant if that changes
    ArrayList<Entry> entries = new ArrayList<Entry>();
    for(int i=0; i<lines.size(); i+=ENTRY_SIZE) {
        Entry entry = new Entry(lines.get(i), lines.get(i+1), lines.get(i+2);
        entries.add(newEntry);
    }You could also do both of the above in one run, but I think you will understand better what's happening if you do one thing at a time.
    If you don't want to put the entries in an encapsulating class, you can still access this without looping:
    int listStartIdx = <desired_entry_index>*ENTRY_SIZE;
    String att1 = lines.get(listStartIdx).substring(1);
    String att2 = lines.get(listStartIdx+1).substring(1);
    String att3 = lines.get(listStartIdx+2).substring(1);

  • Need help with Installing Canon LBP 2900B on Macbook Pro OSX 10.6.8

    I know this is going to sound silly, but really need help with this, URGENTLY!!!
    Bought a Canon LBP2900B printer more than a year ago, and was using it on my MacBook Pro with OSX Snow Leopard (10.6.8) very well. My hard disk recently crashed and now I cannot reinstall the printer, nor can I find the driver for it anywhere for the Mac.
    Have searched all the forums and followed all discussion threads on the Apple Communities as well, but none of the solutions seem to work. Even went back to @Dexter's solution with trying to download the file from the link http://boolet.free.fr/CAPT.zip (this is what I had done when I bought the printer, and it worked perfectly) but the link doesn't exist anymore.
    Extremely grateful if anyone can put up a solution to this, or alternatively, IF ANYONE HAS THE OLD CAPT.ZIP FILE AND CAN UPLOAD IT.
    Thanks in advance. Look forward to your solutions.
    Cheers

    Depends on how the partitons are arranged. If they're exactly as quoted, then yes.
    Open Disk Utility and select the partition tab.
    In the diagram, the top partition needs to be the one you're booted from, and partition 2 the middle one.
    Select Partiton 2 so that it's highlighted, and click the '-' button below the diagram.
    Drag the bottom right corner of partition 1 down to meet partition 3.

  • I need help with event structure. I am trying to feed the index of the array, the index can vary from 0 to 7. Based on the logic ouput of a comparison, the index buffer should increment ?

    I need help with event structure.
    I am trying to feed the index of the array, the index number can vary from 0 to 7.
    Based on the logic ouput of a comparison, the index buffer should increment
    or decrement every time the output of comparsion changes(event change). I guess I need to use event structure?
    (My event code doesn't execute when there is an  event at its input /comparator changes its boolean state.
    Anyone coded on similar lines? Any ideas appreciated.
    Thanks in advance!

    You don't need an Event Structure, a simple State Machine would be more appropriate.
    There are many examples of State Machines within this forum.
    RayR

  • Need Help with Address Display

    I need help with APEX.
    Here's my situation:
    I have a report that displays brief employee information. Among the information displayed is the Address. Right now, it's display as:
    Mr X
    Employee Id
    Accounting Department
    Address 1
    Mr X
    Employee Id
    Accounting Department
    Address 2
    I would like it to display
    Mr X
    Employee Id
    Accounting Department
    Address 1
    Address 2
    1) I have thought of using the Break functionality; however, the function only allows break at column 1, 2, 3. As you can see Address starts at column 4. Also, Address has a few columns; Address Line 1, Address Line 2, City, State, Zipcode.
    2) Stragg functions - I'm not sure how to implement it since it has more than 1 columns.
    Any ideas?
    Thanks in advance
    Andrew

    The example I gave you, using analytic functions is a simple one.
    Now, you are saying:
    1. some of the employees may have two adresses?
    2. if this is the case, your employee appears in the report twice?
    3. you don't want his name, employee id and accounting department to appear twice?
    4. only his address has to be displayed?
    If the answer to all the questions is yes, this kind of query will help you. I repeat:
    SELECT CASE
              WHEN LAG (employee_id) OVER (ORDER BY employee_id) =
                                                        employee_id
                 THEN NULL
              ELSE employee_name
           END employee_name,
           CASE
              WHEN LAG (employee_id) OVER (ORDER BY employee_id) =
                                                          employee_id
                 THEN NULL
              ELSE employee_id
           END employee_id,
           CASE
              WHEN LAG (employee_id) OVER (ORDER BY employee_id) =
                                                employee_id
                 THEN NULL
              ELSE accounting_department
           END accounting_department,
           street, postal_code, city, state, country
      FROM your_employees_table;Give it a try.
    Denes Kubicek

Maybe you are looking for