Can anyone help me, please

Hello again:
Please run my coding first, and get some view from my coding.
I want to add a table(it is from TableRenderDemo) to a JFrame when I click on the button(from DrawCalendar) of the numer 20, and I want the table disply under the buttons(from DrawCalendar), and the table & buttons all appear on the frame. I added some code for this problem(in the EventHander of the DrawCalendar class), but I do
not known why it can not work.Please help me to solve this problem.
Can anyone help me, please.
Thanks.
*This program for add some buttons to JPanel
*and add listeners to each button
*I want to display myTable under the buttons,
*when I click on number 20, but why it doesn't
*work, The coding for these part are indicated by ??????????????
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.GridLayout;
public class DrawCalendar extends JPanel {
     private static DrawCalendar dC;
     private static TestMain tM;
     private static TableRenderDemo myTable;
     private static GridLayout gL;
     private static final int nlen = 35;
    private static String names[] = new String[nlen];
    private static JButton buttons[] = new JButton[nlen];
     public DrawCalendar(){
          gL=new GridLayout(5,7,0,0);
           setLayout(gL);
           assignValues();
           addJButton();
           registerListener();
    //assign values to each button
       private void assignValues(){
          names = new String[35];
         for(int i = 0; i < names.length; i++)
            names[i] = Integer.toString(i + 1);
     //create buttons and add them to Jpanel
     private void addJButton(){
          buttons=new JButton[names.length];
          for (int i=0; i<names.length; i++){
               buttons=new JButton(names[i]);
     buttons[i].setBorder(null);
     buttons[i].setBackground(Color.white);
     buttons[i].setFont(new Font ("Palatino", 0,8));
add(buttons[i]);
//add listeners to each button
private void registerListener(){
     for(int i=0; i<35; i++)
          buttons[i].addActionListener(new EventHandler());          
//I want to display myTable under the buttons,
//when I click on number 20, but why it doesn't
//work
private class EventHandler implements ActionListener{
     public void actionPerformed(ActionEvent e){
     for(int i=0; i<35; i++){
//I want to display myTable under the buttons,
//when I click on number 20, but why it doesn't
//work
     if(i==20){  //???????????               
          tM=new TestMain(); //???????
          tM.c.removeAll(); //??????
          tM.c.add(dC); //???????
          tM.c.add(myTable); //????
          tM.validate();
     if(e.getSource()==buttons[i]){
     System.out.println("testing " + names[i]);
     break;
*This program create a table with some data
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumn;
import javax.swing.DefaultCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TableRenderDemo extends JScrollPane {
private boolean DEBUG = true;
public TableRenderDemo() {
// super("TableRenderDemo");
MyTableModel myModel = new MyTableModel();
JTable table = new JTable(myModel);
table.setPreferredScrollableViewportSize(new Dimension(700, 70));//500,70
//Create the scroll pane and add the table to it.
setViewportView(table);
//Set up column sizes.
initColumnSizes(table, myModel);
//Fiddle with the Sport column's cell editors/renderers.
setUpSportColumn(table.getColumnModel().getColumn(2));
* This method picks good column sizes.
* If all column heads are wider than the column's cells'
* contents, then you can just use column.sizeWidthToFit().
private void initColumnSizes(JTable table, MyTableModel model) {
TableColumn column = null;
Component comp = null;
int headerWidth = 0;
int cellWidth = 0;
Object[] longValues = model.longValues;
for (int i = 0; i < 5; i++) {
column = table.getColumnModel().getColumn(i);
try {
comp = column.getHeaderRenderer().
getTableCellRendererComponent(
null, column.getHeaderValue(),
false, false, 0, 0);
headerWidth = comp.getPreferredSize().width;
} catch (NullPointerException e) {
System.err.println("Null pointer exception!");
System.err.println(" getHeaderRenderer returns null in 1.3.");
System.err.println(" The replacement is getDefaultRenderer.");
comp = table.getDefaultRenderer(model.getColumnClass(i)).
getTableCellRendererComponent(
table, longValues[i],
false, false, 0, i);
cellWidth = comp.getPreferredSize().width;
if (DEBUG) {
System.out.println("Initializing width of column "
+ i + ". "
+ "headerWidth = " + headerWidth
+ "; cellWidth = " + cellWidth);
//XXX: Before Swing 1.1 Beta 2, use setMinWidth instead.
column.setPreferredWidth(Math.max(headerWidth, cellWidth));
public void setUpSportColumn(TableColumn sportColumn) {
//Set up the editor for the sport cells.
JComboBox comboBox = new JComboBox();
comboBox.addItem("Snowboarding");
comboBox.addItem("Rowing");
comboBox.addItem("Chasing toddlers");
comboBox.addItem("Speed reading");
comboBox.addItem("Teaching high school");
comboBox.addItem("None");
sportColumn.setCellEditor(new DefaultCellEditor(comboBox));
//Set up tool tips for the sport cells.
DefaultTableCellRenderer renderer =
new DefaultTableCellRenderer();
renderer.setToolTipText("Click for combo box");
sportColumn.setCellRenderer(renderer);
//Set up tool tip for the sport column header.
TableCellRenderer headerRenderer = sportColumn.getHeaderRenderer();
if (headerRenderer instanceof DefaultTableCellRenderer) {
((DefaultTableCellRenderer)headerRenderer).setToolTipText(
"Click the sport to see a list of choices");
class MyTableModel extends AbstractTableModel {
final String[] columnNames = {"First Name",
"Last Name",
"Sport",
"# of Years",
"Vegetarian"};
final Object[][] data = {
{"Mary ", "Campione",
"Snowboarding", new Integer(5), new Boolean(false)},
{"Alison", "Huml",
"Rowing", new Integer(3), new Boolean(true)},
{"Kathy", "Walrath",
"Chasing toddlers", new Integer(2), new Boolean(false)},
{"Sharon", "Zakhour",
"Speed reading", new Integer(20), new Boolean(true)},
{"Angela", "Lih",
"Teaching high school", new Integer(4), new Boolean(false)}
public final Object[] longValues = {"Angela", "Andrews",
"Teaching high school",
new Integer(20), Boolean.TRUE};
public int getColumnCount() {
return columnNames.length;
public int getRowCount() {
return data.length;
public String getColumnName(int col) {
return columnNames[col];
public Object getValueAt(int row, int col) {
return data[row][col];
* JTable uses this method to determine the default renderer/
* editor for each cell. If we didn't implement this method,
* then the last column would contain text ("true"/"false"),
* rather than a check box.
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
* Don't need to implement this method unless your table's
* editable.
public boolean isCellEditable(int row, int col) {
//Note that the data/cell address is constant,
//no matter where the cell appears onscreen.
if (col < 2) {
return false;
} else {
return true;
* Don't need to implement this method unless your table's
* data can change.
public void setValueAt(Object value, int row, int col) {
if (DEBUG) {
System.out.println("Setting value at " + row + "," + col
+ " to " + value
+ " (an instance of "
+ value.getClass() + ")");
if (data[0][col] instanceof Integer
&& !(value instanceof Integer)) {
//With JFC/Swing 1.1 and JDK 1.2, we need to create
//an Integer from the value; otherwise, the column
//switches to contain Strings. Starting with v 1.3,
//the table automatically converts value to an Integer,
//so you only need the code in the 'else' part of this
//'if' block.
try {
data[row][col] = new Integer(value.toString());
fireTableCellUpdated(row, col);
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(TableRenderDemo.this,
"The \"" + getColumnName(col)
+ "\" column accepts only integer values.");
} else {
data[row][col] = value;
fireTableCellUpdated(row, col);
if (DEBUG) {
System.out.println("New value of data:");
printDebugData();
private void printDebugData() {
int numRows = getRowCount();
int numCols = getColumnCount();
for (int i=0; i < numRows; i++) {
System.out.print(" row " + i + ":");
for (int j=0; j < numCols; j++) {
System.out.print(" " + data[i][j]);
System.out.println();
System.out.println("--------------------------");
*This program for add some buttons and a table on JFrame
import java.awt.*;
import javax.swing.*;
public class TestMain extends JFrame{
private static TableRenderDemo tRD;
     private static TestMain tM;
protected static Container c;
private static DrawCalendar dC;
     public static void main(String[] args){
     tM = new TestMain();
     tM.setVisible(true);
     public TestMain(){
     super(" Test");
     setSize(800,600);
//set up layoutManager
c=getContentPane();
c.setLayout ( new GridLayout(3,1));
tRD=new TableRenderDemo();
dC=new DrawCalendar();
addItems();//add Buttons to JFrame
private void addItems(){
     c.add(dC); //add Buttons to JFrame
     //c.add(tRD); //add Table to JFrame     

Click Here and follow the steps to configure your Linksys Router with Version FIOS.

Similar Messages

  • Apple iPad 3. BT email not working. Cannot send emails from btconnect SMTP after iOS upgrade. This is the only difference I am aware of. Can anyone help me please.

    BT email not working. Cannot send emails from btconnect SMTP after iOS upgrade. This is the only difference I am aware of. Apple iPad 3. Can anyone help me please.

    All resolved at last
    Deleted the SMTP setting
    Recreated the SMTP using the same settings
    Able to send emails now
    No logic - as usual - just a bug!

  • My iphone 4s wont turn on,it wont even charge,when it does eventually start to charge the apple icon on the screen will appear for a few seconds then itll disappear, i have tried to do the soft/hard reset but nothing happens, can anyone help me please?

    My iphone 4s wont turn on,it wont even charge,when it does eventually start to charge the apple icon on the screen will appear for a few seconds then itll disappear, i have tried to do the soft/hard reset but nothing happens, can anyone help me please? do i have a dead iphone on my hands? isit worth me going into the apple store and seeing what they can do or isit pointless? please help!!!

    Try to backup and restore you device in itunes...restoring the device is like removing the iOS software off the device and re-add in a newer software, after you have restore you device, MAKE SURE YOU SET UP YOUR DEVICE LIKE A NEW DEVICE, DONT NOT RESTORE FROM BACKUP!!... give the device a chance to use the newer software and see if the issue still persisting, if the issue still on going then its would be a hardware issue.
    Call Apple Care and see if your device is still under warranty to get it replace

  • My iPhone 5 rear camera was not working, now the rear camera is also not working. I have procured the phone in 2012 from San Fransico. USA Can anyone help me, please?

    My iPhone 5 rear camera was not working, now the rear camera is also not working. I have procured the phone in 2012 from San Fransico. USA Can anyone help me, please?

    No one here can help you. If your phone is no longer under warranty, a third-party repair shop will most likely be your best bet. You can't mail the phone to Apple, in the US, as Apple does not accept international shipments. You could mail it to a friend/relative, in the US, & they could take it to an Apple store for you. Some Apple stores repair iPhones. Otherwise, you're looking at an out of warranty replacement.
    Good luck.

  • I have a business and I use iCal for all my appointments, how can I print receipts from my MacBook to a receipt printer? I want my clients to have a receipt of the services that they have paid for, can anyone HELP ME PLEASE?

    I have a business and I use iCal for all my appointments, how can I print receipts from my MacBook to a receipt printer?
    I want my clients to have a receipt of the services that they have paid for, can anyone HELP ME PLEASE?

    Well...I went to the modem (Westell, WireSpeed), found the NAT settings, once again, I'm WAY over my head, I am assuming this is a TCP connection (as opposed to a UDP) and per Lorex my mobile devices will use port 1025.  So I gave it a "global port range" of 1-10 and I indicated that the "base host port" was 80, 1025, & 9000 (ports 1,2,3).  When I selected the 'enable' it asked for a "host devise" my choices are my IPhone, IMac and the IP address for the dvr, so I choose the dvr.  I still cannot connect and canyouseeme still can NOT find these open ports.  This is taking up my whole day! I don't know how people figure this stuff out.

  • I would like to get siri working on my 3G iphone 4s and since upgrading to ios 7 my speakers work intermittently can anyone help me please

    I upraded my 3G iphone 4s to the ios7 and have had trouble with the speakers  working on and off  and I would like to know how to get siri  and would like to know how to do that so that I may use it in my hands free  equipped vehicles can anyone help me please ?

    First, this is the Photoshop (full version) forum - you may be able to get more pertinent and specific help down at the Photoshop Elements forum:
    http://forums.adobe.com/community/photoshop_elements
    Generally speaking, one edits image files then saves the results on one's hard drive, so the photos don't "go into" Photoshop, but rather they are just files on the disk.  However, I'm not sure whether you used a feature of Elements I may not be familiar with.  You may be best off asking Elements experts.
    -Noel

  • TS1363 IPOD classic not baing recognised in itunes, can anyone help me please?

    i habve an ipod classic when i first used it it was fine but then it started stopping syncing half way through saying there was an error and my songs would cut off half way through or just not play now when i connect it to the computer it dosent show up in itunes but does in my computer. i messege in my itunes pops up saying i need to restore my ipod yet my ipod dosent show up in itunes to do this. i have tried uninstalling intunes and reinstalling it again i have tried using a different laptop but nothing works can anyone help me please?

    See my response to your other post.
    B-rock

  • When I try to set up Icloud control panel in Windows Vista, I get "your setup couldn't be started because the Icloud server stopped responding. I've tried loads of fixes suggested on the net but none worked. Can anyone help me please?

    When I try to set up Icloud control panel in Windows Vista, I get "your setup couldn't be started because the Icloud server stopped responding. I've tried loads of fixes suggested on the net but none worked. Can anyone help me please?

    Hello, ksb2. 
    Thank you for visiting Apple Support Communities.
    We are investigating this issue. This article will be updated as more information becomes available.
    iCloud: iCloud Control Panel setup cannot be started
    http://support.apple.com/kb/TS5178
    Cheers,
    Jason H.

  • Hello sir        i have mac os x lion and A fter upgrading to Lion  i can't instal the face time app its type ( FaceTime can't be installed on "Mac" because the version of Mac OS X is too new. )   can anyone help me please .   notes : on snow leopard the

    hello sir
           i have mac os x lion and A
    fter upgrading to Lion  i can't instal the face time app its type ( FaceTime can’t be installed on “Mac” because the version of Mac OS X is too new. )   can anyone help me please .
    notes : on snow leopard the face time was work normally but i delete it the app i thought it will work after i reinstall it

    Lion comes with FaceTime. Look in your dock or in the Applications folder.

  • Flash swf that runs on every browser except in Firefox. Can anyone help me please?

    Hello.
    I have an flash swf in a site that runs on every browser except in Firefox. I get an warning telling me that the page requires a newer version of flash player but i already have the 10,0,32,18 and the swf was published for flash player 9.
    Can anyone help me please?

    The figures you mention only make sense on your intranet.  Are you still using the same wireless router.  The verizon one is somewhat limited as far as max wireless-n performace.  For one thing it only has a 2.4 radio.   I like many people who wanted wireless-n performance before they even added a wireless-n gigabit router, have my own handling my wireless-n network.

  • Hi there, I want to change the background-color of the browser, when a popup-picture is shown. This picture pops up by clicking a hyperlink in the text...can anyone help me please...thanks a lot

    Hi there, I want to change the background-color of the browser, when a popup-picture is shown. This picture pops up by clicking a hyperlink in the text...can anyone help me please...thanks a lot

    Hi,
    CSS is interpreted by your browser, so server cache seems unlikely in htis case. There is however some hierarchy in CSS, so parts of the APEX CSS, theme CSS or page CSS might overwright or block yours.
    Does changing the CSS on runtime affect your page? Eg, run the following in your browser console and see if your page turns black: $('#uBodyContainer').css("background-color","black")
    Also try moving up your css in the hierarchy labeling it as important:
    div#uBodyContainer { 
      background-color:#000000 !important;  
    See:Assigning property values, Cascading, and Inheritance
    Regards,
    Vincent
    http://vincentdeelen.blogspot.com

  • My imessages are gone. i cant activate them now. When i go into send and recieve its only my e-mail address thats ticked and not my phone number ticked also. When i sign in with my apple ID it is ticked there. can anyone help me please.

    my imessages are gone. i cant activate them now. When i go into send and recieve its only my e-mail address thats ticked and not my phone number ticked also. When i sign in with my apple ID it is ticked there. can anyone help me please.

    Hi,
    Go to the iPhone
    GO to Settings > Messages
    Is the iPhone Number ticked to be enabled (It will be greyed out and not editable but should be On)
    If it is Off (Unticked remove the Apple ID)
    Place the iPhone in Airplane mode for a few minutes.
    Go back to Settings Messages and make sure the Message app Is Enabled overall.
    Check the iPhone Number is verifying.
    When Completed test by sending an iMessage to your Apple ID (Mac)
    If that works add back the Apple ID to the iPhone's Settings.
    Restart the Mac App and Accept the op ups that appear as to what the iPhone is using.
    9:52 pm      Friday; April 4, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • I deleted aperture and now my sistem is acting crazy. I desperately need help fixing it.Can anyone help me please?

    I deleted aperture and now my sistem is acting crazy.The dock disappeared and almost all icons are gone except for their names.I have an important project for tomorrow and I desperately need help fixing it.Can anyone help me please?

    Well it all started with Aperture 3 trying to import some photos from my iphone.It took ages to import those photos and like I was in a hurry to finish my work in Illustrator so I tryied to force quit on A3 and it didn´t, so I shut down the computer and started over.it was all ok but I uninstalled the A3 and the I realized the icons were back to original form and a few fonts changed.so I Installed the trial version of A3.I did a restart of the system and then there was.aperture lauching but no dock and a 80% of the icons disappeared, but the names of the files and folder remained.and I cand acces the apps from the apple sign on the left corner.I tried also restarting a few time but it´s always the same.I am a recent user of a mac , and please excuse my bad english.If this is in any way useful please help me!

  • I have lost my alternate layout, I was working on it yesterday - today it is not there gone, can anyone help me please:?

    I have been creating an Alernate layout (tablet) from my desktop version. Today when I open it the Tablet Plan is not there! Can anyone help me please. I am using windows 7. I have not had any problems like this before. Could it be a clitch or a muse error.
    Deborah
    [email protected]

    Maybe a silly question: You switched to the "tablet" button on top of the "plan" window?

  • I have just got a Nikon D810 but CC wont open my raw file, can anyone help me please?

    I have just got a Nikon D810 but CC wont open my raw file, can anyone help me please?

    Ah ok shall try that now, thank you very much for your help

Maybe you are looking for

  • Is this the product I need to create PDF from a form online?

    Hello, I need to develop an application where the user fills out an online form and a pdf is automatically created and emailed to them, a copy is also archived. Am I looking in the corect place by exploring LiveCycle PDF Generator or am I looking for

  • PAYR table not getting updated....

    Dear all, We have created one Z program for manual check creation. Z program automatically created manual checks in the system and its working fine. In some cases system is not updated GL account in PAYR table for checks generated. In normal GL accou

  • N95 gets restart automatically while video recordi...

    Whenever I try to record video more than 4-5 min, my N95 gets restarted automatically while recording and doesnt even save the video. But when I record smaller video say 1-2 min everything is fine. I have Phone from O2 germany and Nokia website says

  • IDOC: Vendor & Customer Error

    Hi Experts, I am getting error massage at supplier client when I run t code WE05 Vendor number A-V6701 has not been saved for customer A-6701 Message no. V4076 I have checked customer master data Confi settings at Sales level unable to resolve this p

  • Use a Secondary CE in actual Periodic Repostings cycle

    Hi, I need your help to figure out how to move on with this process. May you help me out? I want to settle a CE group for a CC group to some WBS "dummy" with different percentage on the receiver tracing factor. Afterwards I would like to settle each