Help with JTable needed
Hi guys. How to update a JTable? What am I doing wrong? When I press buttons nothing happend d:(
public void init() {
this.setSize(640,420);
//this.setLayout ( null );
panel = new JPanel();
//Builder.buildInsertGui();
//Builder.buildInfoGui();
//Builder.buildSettingsGui();
Builder.table=Database.getOperations();
ActionListener ladd = new ActionListener() {
public void actionPerformed(ActionEvent e) {
Builder.table=new JTable();
System.out.println("free");
Application.panel.repaint();
JButton badd = new JButton("Free");
badd.addActionListener(ladd);
ActionListener ldel = new ActionListener() {
public void actionPerformed(ActionEvent e) {
Builder.table=Database.getOperations();
System.out.println("fill");
Application.panel.repaint();
JButton bdel = new JButton("Fill");
badd.addActionListener(ldel);
this.panel.add(Builder.table);
this.panel.add(bdel);
this.panel.add(badd);
this.add(panel);
}
Hi,
first create the table once in the init method
second you don't need to call the repaint on the JPanel each time you do the action
third you need to update your table via the table Model by extending the AbstractTableModel
The table Model is the part which hold the data for the table to be presented
fourth get the table Model; then populate it again with different values
Fifth call table.repaint;
ex:
public class MyStocksTable extends JFrame {
protected JTable m_table;
protected StockTableData m_data;
protected JLabel m_title;
protected JButton m_btn;
public MyStocksTable() {
super("Stocks Table");
setSize(600, 300);
UIManager.put("Table.focusCellHighlightBorder",
new LineBorder(Color.black, 0));
m_data = new StockTableData();
m_title = new JLabel(m_data.getTitle(),
new ImageIcon("money.gif"), SwingConstants.CENTER);
m_title.setFont(new Font("Helvetica",Font.PLAIN,24));
getContentPane().add(m_title, BorderLayout.NORTH);
m_table = new JTable();
m_table.setAutoCreateColumnsFromModel(false);
m_table.setModel(m_data);
m_btn = new JButton("UPDATE ME");
getContentPane().add(m_btn,BorderLayout.SOUTH);
m_btn.addActionListener(new MyActionListener(m_table));
for (int k = 0; k < m_data.getColumnCount(); k++) {
DefaultTableCellRenderer renderer = new
DefaultTableCellRenderer();
renderer.setHorizontalAlignment(
StockTableData.m_columns[k].m_alignment);
TableColumn column = new TableColumn(k,
StockTableData.m_columns[k].m_width, renderer, null);
m_table.addColumn(column);
JTableHeader header = m_table.getTableHeader();
header.setUpdateTableInRealTime(false);
JScrollPane ps = new JScrollPane();
ps.getViewport().setBackground(m_table.getBackground());
ps.getViewport().add(m_table);
getContentPane().add(ps, BorderLayout.CENTER);
public static void main(String argv[]) {
MyStocksTable frame = new MyStocksTable();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
class MyActionListener implements ActionListener {
private JTable table;
public MyActionListener(JTable table){
this.table = table;
public void actionPerformed(ActionEvent e) {
StockTableData dataModel = (StockTableData)table.getModel();
dataModel.setDefaultData2();
table.setModel(dataModel);
table.repaint();
class StockData {
public String m_symbol;
public String m_name;
public Double m_last;
public Double m_open;
public Double m_change;
public Double m_changePr;
public Long m_volume;
public StockData(String symbol, String name, double last,
double open, double change, double changePr, long volume) {
m_symbol = symbol;
m_name = name;
m_last = new Double(last);
m_open = new Double(open);
m_change = new Double(change);
m_changePr = new Double(changePr);
m_volume = new Long(volume);
class ColumnData {
public String m_title;
public int m_width;
public int m_alignment;
public ColumnData(String title, int width, int alignment) {
m_title = title;
m_width = width;
m_alignment = alignment;
class StockTableData extends AbstractTableModel {
static final public ColumnData m_columns[] = {
new ColumnData( "Symbol", 100, JLabel.LEFT ),
new ColumnData( "Name", 160, JLabel.LEFT ),
new ColumnData( "Last", 100, JLabel.RIGHT ),
new ColumnData( "Open", 100, JLabel.RIGHT ),
new ColumnData( "Change", 100, JLabel.RIGHT ),
new ColumnData( "Change %", 100, JLabel.RIGHT ),
new ColumnData( "Volume", 100, JLabel.RIGHT )
protected SimpleDateFormat m_frm;
protected Vector m_vector;
protected Date m_date;
public StockTableData() {
m_frm = new SimpleDateFormat("MM/dd/yyyy");
m_vector = new Vector();
setDefaultData();
public void setDefaultData() {
try {
m_date = m_frm.parse("12/18/2004");
catch (java.text.ParseException ex) {
m_date = null;
m_vector.removeAllElements();
m_vector.addElement(new StockData("ORCL", "Oracle Corp.",
23.6875, 25.375, -1.6875, -6.42, 24976600));
m_vector.addElement(new StockData("EGGS", "Egghead.com",
17.25, 17.4375, -0.1875, -1.43, 2146400));
m_vector.addElement(new StockData("T", "AT&T",
65.1875, 66, -0.8125, -0.10, 554000));
m_vector.addElement(new StockData("LU", "Lucent Technology",
64.625, 59.9375, 4.6875, 9.65, 29856300));
m_vector.addElement(new StockData("FON", "Sprint",
104.5625, 106.375, -1.8125, -1.82, 1135100));
m_vector.addElement(new StockData("ENML", "Enamelon Inc.",
4.875, 5, -0.125, 0, 35900));
m_vector.addElement(new StockData("CPQ", "Compaq Computers",
30.875, 31.25, -0.375, -2.18, 11853900));
m_vector.addElement(new StockData("MSFT", "Microsoft Corp.",
94.0625, 95.1875, -1.125, -0.92, 19836900));
m_vector.addElement(new StockData("DELL", "Dell Computers",
46.1875, 44.5, 1.6875, 6.24, 47310000));
m_vector.addElement(new StockData("SUNW", "Sun Microsystems",
140.625, 130.9375, 10, 10.625, 17734600));
m_vector.addElement(new StockData("IBM", "Intl. Bus. Machines",
183, 183.125, -0.125, -0.51, 4371400));
m_vector.addElement(new StockData("HWP", "Hewlett-Packard",
70, 71.0625, -1.4375, -2.01, 2410700));
m_vector.addElement(new StockData("UIS", "Unisys Corp.",
28.25, 29, -0.75, -2.59, 2576200));
m_vector.addElement(new StockData("SNE", "Sony Corp.",
96.1875, 95.625, 1.125, 1.18, 330600));
m_vector.addElement(new StockData("NOVL", "Novell Inc.",
24.0625, 24.375, -0.3125, -3.02, 6047900));
m_vector.addElement(new StockData("HIT", "Hitachi, Ltd.",
78.5, 77.625, 0.875, 1.12, 49400));
public void setDefaultData2() {
try {
m_date = m_frm.parse("12/18/2004");
catch (java.text.ParseException ex) {
m_date = null;
m_vector.removeAllElements();
m_vector.addElement(new StockData("ORCLAlan", "Oracle Corp.",
23.6875, 25.375, -1.6875, -6.42, 24976600));
m_vector.addElement(new StockData("EGGSAlan", "Egghead.com",
17.25, 17.4375, -0.1875, -1.43, 2146400));
m_vector.addElement(new StockData("TAlan", "AT&T",
65.1875, 66, -0.8125, -0.10, 554000));
m_vector.addElement(new StockData("LU", "Lucent Technology",
64.625, 59.9375, 4.6875, 9.65, 29856300));
public int getRowCount() {
return m_vector==null ? 0 : m_vector.size();
public int getColumnCount() {
return m_columns.length;
public String getColumnName(int column) {
return m_columns[column].m_title;
public boolean isCellEditable(int nRow, int nCol) {
return false;
public Object getValueAt(int nRow, int nCol) {
if (nRow < 0 || nRow>=getRowCount())
return "";
StockData row = (StockData)m_vector.elementAt(nRow);
switch (nCol) {
case 0: return row.m_symbol;
case 1: return row.m_name;
case 2: return row.m_last;
case 3: return row.m_open;
case 4: return row.m_change;
case 5: return row.m_changePr;
case 6: return row.m_volume;
return "";
public String getTitle() {
if (m_date==null)
return "Stock Quotes";
return "Stock Quotes at "+m_frm.format(m_date);
}I hope this could help
Regard,
Alan Mehio
London,UK
Similar Messages
-
Help with JTable - content of cell disappears when selected
Hello,
I have a jTable and I have created a custom cell renderer. It does what it's supposed to do (which is set the background color of all cells with null or "" value to red - as an indication to the user that b4 proceeding he/she has to fill in this cells). The problem is that when I select a red cell, it becomes white and the text value it contains disappears. When I double click I can start typing in a new value.
I would appreciate any hint why this happens? Ideally I would like the cell to keep its color when clicked or double-clicked and its value, and only when i'm done editing its content and it's not null or empty string to become white.
I'm including majority of my code (some automatically generated code from Netbeans is not included).
Thank you very much,
Laura
public class DataNormalisation extends javax.swing.JFrame {
JTextArea txt=new JTextArea();
public Object[][] DataSummary;
public Vector<String> colName;
MainF p;
String[] ExpNames;
/** Creates new form DataNormalisation */
public DataNormalisation(String[] EN, MainF parent) {
p=parent;
ExpNames=EN;
colName= new Vector<String>();
colName.add("Sample Name");
colName.add("Replicate Group");
DataSummary=new Object[ExpNames.length][2];
for (int i=0;i<ExpNames.length;i++){
DataSummary[0]=ExpNames[i];
initComponents();
this.jTable1.getTableHeader().setReorderingAllowed(false);
TableColumn column = jTable1.getColumnModel().getColumn(1);
column.setCellRenderer(new CustomTableCellRenderer());
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new JTable (new DataModel());
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Data Normalisation");
jTable1.setAutoCreateRowSorter(true);
jTable1.setCellSelectionEnabled(true);
jScrollPane1.setViewportView(jTable1);
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
// End of variables declaration
class DataModel extends AbstractTableModel {
class TML implements TableModelListener{
public void tableChanged (TableModelEvent e){
txt.setText(""); // Clear it
for (int i=0;i<DataSummary.length; i++){
for (int j=0; j<DataSummary[0].length;j++){
txt.append(DataSummary[i][j] + " ");
txt.append("\n");
public DataModel(){
addTableModelListener(new TML());
@Override
public void setValueAt(Object val, int row, int col){
DataSummary[row][col]=val;
fireTableDataChanged();
@Override
public boolean isCellEditable(int row, int col){
return (col != 0);
public int getRowCount(){
return DataSummary.length;
public int getColumnCount(){
return colName.size();
public Object getValueAt(int row, int column){
return DataSummary[row][column];
public String getColumnName(int col) {
return colName.get(col);
class CustomTableCellRenderer extends DefaultTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value == null || value.equals("")) {
cell.setBackground(Color.red);
} else cell.setBackground(Color.white);
return cell;Ideally I would like the cell to keep its color when clicked or double-clicked Not sure why is changes color when you click on the cell.
But when you double click the editor is invoked, which is a JTextField and its background is white by default.
The code you posted doesn't help because its not executable.
If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
And don't post NetBeans generated code, because we don't use IDE to write GUI code.
Also, why did you create a custom TableModel. The DefaultTableModel will store your data for you. -
Need help with iPhoto, Need help with iPhoto
Hey there!!!
When I plug in my iPhone I go to iPhoto and can choose to import the pictures. I also tried Image Capture as it seemed easier to organise my pictures, making folders, sub-folders, etc. The problem with this is everytime I plug my iPhone into the computer click on Import the system automatically makes second, third, fourth, etc copies of each picture. This also means that there is a copy of my pictures on iPhoto and on Image Capture - which I do not really need.
I have tried to make Albums and Folders on iPhoto. Sometimes when I delete a picture as it has been saved in two albums it gets deleted from both albums. Why is this? How can I make Albums or Folders to organise my pictures. If my pictures are transferred directly onto iPhoto, can I find them anywhere else in my computer? If I wanted to burn pictures from various albums on a disc how could I do that on iPhoto? Also I dont want events to create themselves. How can I avoid this?
I would like help with either using iPhoto or know how the stop the duplicating of pictures on Image Capture.
Maybe there is a better way I can transfer the pictures onto my MacBook??
Thanks a mil!!!Are you running a "referenced" or "managed' library?
Image Capture does not store phortos in it. It's an application for uploading photos to wherever you tell it to, either a folder on the hard drive or into iPhoto. If you want to use only Image Capture to upload your photos to iPhoto then set iPhoto's General preferences to the following:
Deleting Photos from an iPhoto Library:
1 - from an Event or the Photos mode: select the photo(s) and use the Delete key to move the photos to the trash bin. Then empty the iPhoto Trash bin as follows:
2 - from an album, smart album, book, slideshow, card, etc.: select the photo(s) and use the key combination of Command+Option+Delete to move the photos to the trash bin. Then empty the trash bin as above.
NOTE: deleting a photo from an album, slideshow, book, etc., with only the Delete key only deletes that photo from that item. Deleting a photo from an Event deletes ALL occurances of that photo in the library.
OT -
Need help with JTable data selection.
Hi,
I have a table with multiple rows and each row has a checkbox.user might select checkbox for any row. i want to capture data of all those rows where checkbox is checked. i need to capture data on the click event of my Jbutton.kindly suggest how to proceed.
Thankshii,
1/ capture = PrintScreen
2/ capture = New Window
3/ capture = somehow to save selected row(s)
... kopik -
Hi i have a form with a combo box and a jtable
Each item in the combo box is associated with a set of values with need to be displayed in the row/column format using the JTable.So for each value selected in the combo box the contents of the table should change.Could anyone help me out with this.Thanks
Krishnawhat do you have so far?
-
Hello there,
I am trying to present the database search results of
3 fields
First Name | Last name | Phone Number
of 8 entries into a JTable in a Jframe.
But I just could not make it work. Can any body send me some sample codes, or provide some information to do this job?
Let Duke be with you!!
Many thanks!Assuming you expect to have the user update the values you display.
You will need to have an abstract table model to drive your Jtable.
It in effect caches the data you return in the resultset and
drives the table display.
You also should put your table in a Jscrollpane
Below are some code snippets from a program
Some resources
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
http://developer.java.sun.com/developer/onlineTraining/GUI/Swing2/shortcourse.html#JFCTableDataModel
I user below to help me
http://developer.java.sun.com/developer/technicalArticles/Database/dukesbakery/
http://developer.java.sun.com/developer/technicalArticles/Database/dukesbakery2/
http://developer.java.sun.com/developer/codesamples/jdbc.html
First some information and methods that are used.
String SQLDriver = "com.mysql.jdbc.Driver"; // SQL jdbc driver
String SQLConnectionString = "jdbc:mysql://localhost/passport?user=root&password="; // SQL connection string
public static Connection openSQLConnection(String connectionDriver, String connectionString) {
errMsg = "Unable to open SQL connection.";
Connection sqlconn = null; // Connection reference
try {
Class.forName(connectionDriver); // Load database driver
sqlconn = DriverManager.getConnection(connectionString); // Make connection
// Get SQL warnings issued
SQLWarning warning = null;
try {
warning = sqlconn.getWarnings();
if (warning == null) {logIt("openSQLConnection - No warnings issued.");} // my logging
else {
while (warning != null) {
logIt("openSQLConnection - Warning: " + warning); // my logging
warning = warning.getNextWarning();
catch (Exception wex) {showSystemError("Unable to process SQL connection warnings.","openSQLConnection - SQL warning exception", wex, false);}
return null; // my error system kills progran so never here
catch (ClassNotFoundException cnfex) {showSystemError(errMsg,"openSQLConnection - Class not found exception", cnfex, true);}
catch (SQLException sqlex) {showSystemError(errMsg,"openSQLConnection - SQL exception", sqlex, true);}
catch (Exception excp) {showSystemError(errMsg,"openSQLConnection - Remaining exceptions", excp, true);} // Process all remaining exceptions here
return sqlconn;
public static void closeSQLConnection(Connection SQLConnection) {
if (SQLConnection != null) {
try {
SQLConnection.close();
logIt("SQL connection successfully closed"); // my logging
catch (SQLException sqlEx) {logIt("SQL connection close failed: " + sqlEx);}
}1) Make a connection to the database
try {
Connection modelConnection = null;
Statement selectData = null;
ResultSet rs = null;
modelConnection = openSQLConnection(SQLDriver, SQLConnectionString); // Open a SQL connection
selectData = modelConnection.createStatement(); // Setup for query
rs = selectData.executeQuery(YOUR SELECT STATEMENT); // Perform query
catch (Exception showException) {Passport.showSystemError("Unable to load table Data.", "SQL load of table data failed: "+modelSelectStatement, showException, false);}2) Cache the resultset to a vector in the abstract table
Vector data = new Vector(); // m/b public to model
Vector row;
String cStr = "";
while(rs.next()) { // Create data rows
row = new Vector();
// do for each field - note can treat as correct data types
cStr = new String(rs.getString(1));
if( null == cStr ) cStr = "";
row.addElement(cStr);
data.addElement(row); // add row to vector
rs.close();
closeSQLConnection(modelConnection);3) display table on form
Dam I don't know if this is going to be any help but I hope so.
It is not trivial.
rykk -
Help with scripting: need to import Excel files into PS type layers
Howdy all,
I have a series of TV commercials provided to me as layered PS files. I work in CS3 and export to Avid for editing.
For customization, I need to import their Excel list of phone numbers and duplicate each one into a type layer with existing efx and placement.
There are 30-60 #s, which appear in 2 locations, so automation is key (just finished a 45 # series, and they have more!)
I dont know how to script this, and would appreciate any guidance. I am not asking for someone to do it for me, just help me learn what I have to do.
Dave KoslowFrom Excel save your file out as either CSV or TDT from the drop down 'save as' options. Once you have a plain text file script will be able to read the text file using which ever delimiter best suits you and create an array of string variables that you can use within photoshop to assign to the contents of a text layer…
-
Help with constuctor, need to rewrite program with this constructor
i need to use this constructor for my Scholar class:
public Scholar(String fullName, double gradePointAverage, int essayScore, boolean scienceMajor){here is the project that i'm doing:
http://www.cs.utsa.edu/~javalab/cs17.../project1.html
here's my code for the Scholar class:package project1;
import java.util.*;
public class Scholar implements Comparable {
private static Random rand;
private String fullName;
private double gradePointAverage;
private int essayScore;
private int creditHours;
private boolean scienceMajor;
private String lastName;
private String firstName;
private double totalScore;
/** Creates a new instance of Scholar */
public Scholar(String lastName, String firstName){
this.fullName = lastName + ", " + firstName;
this.gradePointAverage = gradePointAverage;
this.essayScore = essayScore;
this.creditHours = creditHours;
this.scienceMajor = scienceMajor;
this.rand = new Random();
public String getFullName(){
return fullName;
public double getGradePointAverage(){
return gradePointAverage;
public int getEssayScore(){
return essayScore;
public int getCreditHours(){
return creditHours;
public boolean getScienceMajor(){
return scienceMajor;
public String setFullName(String lastName, String firstName){
fullName = lastName + ", " + firstName;
return fullName;
public double setGradePointAverage(double a){
gradePointAverage = a;
return gradePointAverage;
public int setEssayScore(int a){
essayScore = a;
return essayScore;
public int setCreditHours(int a){
creditHours = a;
return creditHours;
public boolean setScienceMajor(boolean a){
scienceMajor = a;
return scienceMajor;
public void scholarship(){
Random doubleGrade = new Random ();
Random intGrade = new Random ();
gradePointAverage = doubleGrade.nextDouble() + intGrade.nextInt(4);
Random score = new Random();
essayScore = score.nextInt(6);
Random hours = new Random();
creditHours = hours.nextInt(137);
Random major = new Random();
int num1 = major.nextInt(3);
if (num1 == 0)
scienceMajor = true;
else
scienceMajor = false;
public double getScore(){
totalScore = (gradePointAverage*5) + essayScore;
if (scienceMajor == true)
totalScore += .5;
if (creditHours >= 60 && creditHours <90)
totalScore += .5;
else if (creditHours >= 90)
totalScore += .75;
return totalScore;
public int compareTo(Object obj){
Scholar otherObj = (Scholar)obj;
double result = getScore() - otherObj.getScore();
if (result > 0)
return 1;
else if (result < 0)
return -1;
return 0;
public static Scholar max(Scholar s1, Scholar s2){
if (s1.getScore() > s2.getScore())
System.out.println(s1.getFullName() + " scored higher than " +
s2.getFullName() + ".\n");
else
System.out.println(s2.getFullName() + " scored higher than " +
s1.getFullName() + ".\n");
return null;
public static Scholar max(Scholar s1, Scholar s2, Scholar s3){
if (s1.getScore() > s2.getScore() && s1.getScore() > s3.getScore())
System.out.println(s1.getFullName() + " scored the highest" +
" out of all three students.");
else if (s2.getScore() > s1.getScore() && s2.getScore() > s3.getScore())
System.out.println(s2.getFullName() + " scored the highest" +
" out of all three students.");
else if (s3.getScore() > s2.getScore() && s3.getScore() > s1.getScore())
System.out.println(s3.getFullName() + " scored the highest" +
" out of all three students.");
return null;
public String toString(){
return "Student name: " + fullName + " -" + " Grade Point Average: "
+ gradePointAverage + ". " + "Essay Score: " + essayScore + "."
+ " Credit Hours: " + creditHours + ". " + " Science major: "
+ scienceMajor + ".";
}here's my code for the ScholarTester class:package project1;
import java.util.*;
public class ScholarTester {
public static void main(String [] args){
System.out.println("This program was written by Kevin Brown. \n");
System.out.println("--------Part 1--------\n");
Scholar abraham = new Scholar("Lincoln", "Abraham");
abraham.scholarship();
System.out.println(abraham);
/*kevin.setEssayScore(5);
kevin.setGradePointAverage(4.0);
kevin.setCreditHours(100);
kevin.setFullName("Brown", "Kevin J");
kevin.setScienceMajor(true);
System.out.println(kevin);*/
Scholar george = new Scholar("Bush", "George");
george.scholarship();
System.out.println(george + "\n");
System.out.println("--------Part 2--------\n");
System.out.println(abraham.getFullName() + abraham.getScore() + ".");
System.out.println(george.getFullName() + george.getScore() + ".\n");
System.out.println("--------Part 3--------\n");
if(abraham.compareTo(george) == 1)
System.out.println(abraham.getFullName() + " scored higher than " +
abraham.getFullName() + ".\n");
else
System.out.println(abraham.getFullName() + " scored higher than " +
abraham.getFullName() + ".\n");
System.out.println("--------Part 4--------\n");
Scholar.max(abraham, george);
Scholar thomas = new Scholar("Jefferson", "Thomas");
thomas.scholarship();
System.out.println("New student added - " + thomas + "\n");
System.out.println(abraham.getFullName() + " scored " +
abraham.getScore() + ".");
System.out.println(george.getFullName() + " scored " +
george.getScore() + ".");
System.out.println(thomas.getFullName() + " scored " +
thomas.getScore() + ".\n");
Scholar.max(abraham, george, thomas);
}everything runs like it should and the program is doing fine, i just need to change the format of the Scholar constructor and probably other things. Can someone please give me an idea how to fix this.
Thanks for taking your time reading this.then don't reply if you're not going to read it, i
just gave the url, Don't get snitty. I'm just informing you that most people here don't want to click a link and read your whole bloody assignment. If you want help, the burden is on you to make it as easy as possible for people to help you. I was only trying to inform you about what's more likely to get you help. If doing things your way is more important to you than increasing your chances of being helped, that's your prerogative.
so you can get an idea on what
it's about, and yeah i know how to add a constructor,
that's very obvious, That's what I thought, but you seemed to be saying, "How do I add this c'tor?" That's why I was asking for clarification about what specific trouble you're having.
i just want to know how to
implement everything correctly, so don't start
flaming people. I wasn't flaming you in the least. I was informing you of how to improve your chances of getting helped, and asking for clarification about what you're having trouble with. -
I have been attempting to create some nested styles.
So far, I am getting the hang of it.
I have created a grep style that will make all text after the word "NOTE: " into italic. Also, I have grep style that makes all text that is "FIGURE +\d+\d" into bold text.
The problem I have is that if the word "FIGURE " etc. is in the italicized note text, then it will not become bold.
For example: "Operate the switch to begin the process (FIGURE 3-3). Make sure guards are closed (refer to FIGURE 3-1)."
That works fine, and "FIGURE " is bold. However, when I change the sentence by adding "NOTE: Make sure guards... " it all becomes italic, and I loose the bold on "FIGURE 3-1"
So, is there a way to augment my italic grep with some kind of inclusion... as if I were saying "if "FIGURE +\d+\d" make that is bold italic"
sorry for the long-winded attempt to describe what I want to do.
Thanks in advance for help.
RPPRPP,
The trouble is that in GREP style you can find text but not formatting, so you can't say something like "find FIGURE only when it's italic". In the Find/Change dialog you can, but in GREP styles you can't.
You also can't say "look for FIGURE if it's preceded by NOTE: and any characters in between". Unfortunately, lookbehind can't cope with variable-length text. So if you always have "NOTE: Refer to FIGURE ...", then you can use lookbehind and you set-up would be this:
apply italic to FIGURE [-\d]+
apply bold to NOTE:.+
apply bold-italic to (?<=NOTE: Refer to )FIGURE [-\d]+
The first parenthetical is a lookbehind: in this case, FIGURE looks behind, meaning you find FIGURE only when it's preceded by "Note: Refer to", which is not matched itself. So bold italics would be applied only to FIGURE [-\d]+, and only when preceded by ...
But you're not likely to have such fixed text. When you have just a few alternatives, you can list them as alternatives, so if you always have "Note: Refer to " or "NOTE: See " you could salvage your set-up, but with more than let's say three alternatives it gets messy.
(?<=NOTE:.+? )FIGURE [-\d]+ , which you would hope would match any text from NOTE: to FIGURE, doesn't work as a lookbehind.
Peter -
[JS] CS3 Help with groups needed
Hi.
I am formatting a page of text frames, and images, and trying to group the selected objects together.
While formatting the pageI am gathering an array of variables:
myGroupArray = new Array();
myGroupCounter = 0;
myGroupArray[myGroupCounter]="myTextFrame";
myGroupCounter++;
etc...
when I am finished a section, I want to group the contents of the vaiable 'myGroupArray'
I am using this line:
myGroup = myDoc.groups.add(myGroupArray);
but getting an error 'Invalid value for parameter 'groupitems' of event 'add'. Expected Array o...t received("myTextFrame","myCorrectPic","myPriceFrame","mtQtyFrame").
Can someone help me on this?
Cheers
Roy(Without actually trying it in ID)
myGroupArray[myGroupCounter]="myTextFrame";
That adds a string to the array, not the frame. If "myTextFrame" is a variable pointing to a text frame, simply use
myGroupArray[myGroupCounter]=myTextFrame;
By the way, have you been programming in other languages in the past? I have, and used
myGroupCounter++;
as well until finding out that for arrays, this built-in array function works equally well:
myGroupArray.push(myTextFrame);
Types much faster, and if you need the number of elements, you can always use myGroupArray.length. -
Hello could someone possibly help me.
My page layout has a top banner ("banner"), then main content
below in the middle (middletext), and a fotter ("footer") below the
"middletext" div
I want place a div of say 100px directly to the right of the
"middletext" div. The layout is fluid so I want the right div to
move with the rest of the page when resized in an IE window. Here
is the code for the css -
body {
background-color: #666666;
background-repeat: repeat-x;
#background {
background-color: #999999;
background-repeat: repeat-x;
width: 80%;
#content {
background-color: #CCCCCC;
background-repeat: repeat-x;
height: 300px;
#middletext {
background-color: #FFFFFF;
background-repeat: repeat-x;
margin-left: 200px;
margin-right: 200px;
height: 300px;
#footer {
background-color: #9999FF;
background-repeat: repeat-x;
height: 100px;
#rightcontent {
background-repeat: repeat-x;
width: 100px;
background-color: #CCCC66;
height: 100px;
position: absolute;
left: 1052px;
top: 135px;
#banner {
background-color: #996633;
background-repeat: repeat-x;
height: 100px;
And the code for the html page -
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<link href="test.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4
resized
if (init==true) with (navigator) {if
((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW ||
innerHeight!=document.MM_pgH) location.reload();
MM_reloadPage(true);
//-->
</script>
</head>
<body>
<div id="background">
<div id="banner">Content for id "banner" Goes
Here</div>
Content for id "background" Goes Here
<div id="content">
<div id="middletext">Content for id "middletext" Goes
Here</div>
id content </div>
<div id="footer">Content for id "footer" Goes
Here</div>
</div>
</body>
</html>
I also have the width of the page set to 80%, just to give a
small border, but how can I center the entire page?
Many thanks in advance!!
Billy.Add the 'right' <div> before the 'middletext'
<div> and float it right
with a width of 100px. See code and css below.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN"
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<link href="test.css" rel="stylesheet"
type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4
resized
if (init==true) with (navigator) {if
((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight;
onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW ||
innerHeight!=document.MM_pgH)
location.reload();
MM_reloadPage(true);
//-->
</script>
<style>
body {
background-color: #666666;
background-repeat: repeat-x;
#background {
background-color: #999999;
background-repeat: repeat-x;
width: 80%;
#content {
background-color: #CCCCCC;
background-repeat: repeat-x;
height: 300px;
#middletext {
background-color: #FFFFFF;
background-repeat: repeat-x;
margin-left: 200px;
margin-right: 200px;
height: 300px;
#footer {
background-color: #9999FF;
background-repeat: repeat-x;
height: 100px;
#rightcontent {
background-repeat: repeat-x;
width: 100px;
background-color: #CCCC66;
height: 100px;
position: absolute;
left: 1052px;
top: 135px;
#banner {
background-color: #996633;
background-repeat: repeat-x;
height: 100px;
#right {
float: right;
width: 100px;
background-color:#FFFFFF;
</style>
</head>
<body>
<div id="background">
<div id="banner">Content for id "banner" Goes
Here</div>
Content for id "background" Goes Here
<div id="content">
<div id="right">right</div>
<div id="middletext">Content for id "middletext" Goes
Here</div>
<div id="footer">Content for id "footer" Goes
Here</div>
</div>
</div>
</body>
</html> -
NEED HELP WITH QUERY, NEED NEWEST RECORD ONLY
Hi all,
Here goes,
I have an assingment in which i need to find the agents who allow the footballers to break the rules.
So far i have 41 results, in which there is 4 agents and 24 footballers, and the same footballer has broken more than one rule or the rule more than once.
What i now need is to arrange so that each footballer on shows up once no matter how many times they have broken the rules.
i have
SELECT
t.transfer_time || ' ' || a.first_name || ' ' || a.last_name || ' ' || f.first_name || ' ' || f.last_name || ' ' || f.footballer_id || ' ' || t.transfer_id
FROM
agents a, transfers t, footballers f, footballers_fees fo
WHERE
a.agent_id = t.broker_id
AND
t.footballer_id = f.footballer_id
AND
f.footballer_id = fo.footballer_id
AND
(RULE 1 BROKEN AND RULE 2 BROKEN
OR
RULE 1 BROKEN AND RULE 2 NOT BROKEN
OR
RULE 1 NOT BROKEN AND RULE 2 BROKEN)
GROUP BY
t.transfer_time || ' ' || a.first_name || ' ' || a.last_name || ' ' || f.first_name || ' ' || f.last_name || ' ' || f.footballer_id || ' ' || t.transfer_id
ORDER BY
t.transfer_time || ' ' || a.first_name || ' ' || a.last_name || ' ' || f.first_name || ' ' || f.last_name || ' ' || f.footballer_id || ' ' || t.transfer_id
(I havent typed out the SQL for the rules 1 and 2 but i know it works)
Now i need to show only each footballer once whether they have broken either rule and more than once or not.
I have been staring at the screen for near enough 10 hours and any help or ideas would be greatly appreciated
Thanks all :)884080 wrote:
Hi all,
Here goes,
I have an assingment in which i need to find the agents who allow the footballers to break the rules.
So far i have 41 results, in which there is 4 agents and 24 footballers, and the same footballer has broken more than one rule or the rule more than once.
What i now need is to arrange so that each footballer on shows up once no matter how many times they have broken the rules.
i have
SELECT
t.transfer_time || ' ' || a.first_name || ' ' || a.last_name || ' ' || f.first_name || ' ' || f.last_name || ' ' || f.footballer_id || ' ' || t.transfer_id
FROM
agents a, transfers t, footballers f, footballers_fees fo
WHERE
a.agent_id = t.broker_id
AND
t.footballer_id = f.footballer_id
AND
f.footballer_id = fo.footballer_id
AND
(RULE 1 BROKEN AND RULE 2 BROKEN
OR
RULE 1 BROKEN AND RULE 2 NOT BROKEN
OR
RULE 1 NOT BROKEN AND RULE 2 BROKEN)
GROUP BY
t.transfer_time || ' ' || a.first_name || ' ' || a.last_name || ' ' || f.first_name || ' ' || f.last_name || ' ' || f.footballer_id || ' ' || t.transfer_id
ORDER BY
t.transfer_time || ' ' || a.first_name || ' ' || a.last_name || ' ' || f.first_name || ' ' || f.last_name || ' ' || f.footballer_id || ' ' || t.transfer_id
(I havent typed out the SQL for the rules 1 and 2 but i know it works)
Now i need to show only each footballer once whether they have broken either rule and more than once or not.
I have been staring at the screen for near enough 10 hours and any help or ideas would be greatly appreciated
Thanks all :)Realize that we don't have your tables or data, so we can't run, test, or improve your SQL.
so what exactly do you expect from us? -
Hi,
I'm trying to resize my JTable columns with this code, but it's not working. What I am doing wrong?
for (int i = 0; i < table.getColumnModel().getColumnCount(); i++) {
TableColumn tc = table.getColumnModel().getColumn(i);
int width = (i == 0)? 10 : table.getWidth()/2 - 10; // three columns
tc.setPreferredWidth(width);
Thanks,
Andr�Now my problem is that using either of these methods
is they don't carry the user's selected column width
through updates.It sounds like the change event your table model is firing is causing the entire table to be rebuilt. I would guess that you are firing fireTableStructureChanged() which would cause the entire table to be rebuilt (columns, cell values, etc.) Just fire a change event for the minimum necessary. If you can't identify what data in your table has changed (to fire cell or row change events), but the structure (columns) of the table hasn't changed, just fire fireTableDataChanged(). This will cause the cells to be redrawn with the new values, but shouldn't cause the columns to be rebuilt and resized. -
Help with WRVS4400N - Need to find a replacement AC Adapter
Hello, I have a Cisco WRVS4400N V2. I need to find a replacement AC adapter and the stands if possble. Can anyone direct me to the right place? Thanks.
Mike,
unfortunately we do not stock or have product numbers for the AC adapter or the stands. Any universal AC adapter should work provided that it provides the following power requirements:
Power
12V 1A
Hope this helps,
Blake Wright
Cisco SBSC Network Engineer -
Help with Launchpad Needed please.
Please can some one tell how to stop getting all these updates in my Launchpad, I downloaded some code which got rid of the icons,(Happy) I started to organise them all, then Microsoft update put 20 icons on it, and they cannot be trashed. Hate This! Its a waist of time using the code to delete if everytime there is an update on something or other, loads of icons appear. Why can I not have control over my own Mac!
I think Ive worked out my own problem...
After I attach the model to the parent with addChild, i then
set its transform to transform(). ie.
theChildModel.transform = transform()
Which solves the problem of the child being offset from the
parent.
(below is a seperate problem, I'm using a sphere primitive,
so theres no issue with possibly the sphere having an popsitional
offset when i attach it as a child. My previous question was in
relation to when I attach the actual head object, which did have an
offset)
But Now, I have a problem with the parent being positioned
incorrectly when I try to use boneplayer to animate it.
I tried to get down to basics, to work out where the position
was first going wrong, and its when i add the bonesPlayer modifier.
These are the simple steps I take...
I copy the Torso model into the 3D world. (this has a bone
structure and a dummy Model in the correct position for head,
hands, feet)
Then I create a sphere primitive.
Then I add the sphere as a child of the Torso's child[1]
dummy Model, which I know is the 'head's dummy Model.
That works fine, the sphere is in the correct 'head'
position.
But then when I add the bonesPlayer modifier to the Torso
Model, the sphere jumps to an incorrect position(about in the
middle of the torso model).
Anyone experienced something like this before? Should I be
doing something first before I add the bonesPlayer modifier?
I have a very trimmed down demo of what Im talking about, if
anyone would like to see the code.
Any help greatly appreciated.
Glen
Maybe you are looking for
-
Consuming PI Webservice from Webdynpro Java Not working
Hello SAP, Environment: CE 7.2. Resolution expected immediately, Helpful answer is highly appreciated. Is the namespace should not exceed 60char for PI Webservice, for executing the webservice from Webdynpro Java. I tried with all the options in exec
-
Set sleep time for multiple hard drives
I have 2 internal hard drives on my mac, one SSD boot drive and an HDD for media. I would like to have the HDD go to sleep when it is not in use (i.e. when I am not using itunes) which is most of the time. I have energy saver set to sleep drives when
-
Problems working with Japanese characters found in filenames to determine invalid shortcuts
Hi, I have written a script that uses test-path to query whether or not *.LNK shortcut files have valid Target Paths to determine whether or not the LNK files should be kept if invalid or contain temporary locations. This works perfectly for most sho
-
Is it possible to add a region to a pop up , knowing that this region is representing a task flow which communicates with a database ?
-
How do I connect model a1355 to 2011 imac?
Install window says components are incompatible. Any help?