Swing/AWT/SWT :: Matching Strings To Selected Rows In JTable

Nov 10, 2014

I have a JTable which shows pdf files. In Addition I can check if they have errors, if it so I can generate a "report" by clicking the pdf. But the report gives me errors from all of the pdfs in the table. How can I match the error messages to the pdf which I select?

Here is one of the checking methods:

public static void testAllPagesHaveSameRotation(PDFDocument pdf) throws PDFDocumentException {
if (SettingsGui.testAllPagesHaveSameRotation.isSelected()) {
if (pdf.getPages() == 0) {
rotationError = "";
} else {
rotationError = "";

[Code] ....

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: JTable Not Able To Render Rows In Different Colors

Aug 24, 2014

I have a jtable , a customtablemodel and a customcellrenderer with the NetBeans IDE. I want to have different colors for different rows. But anytime I run the application , the rows are not painted as expected. The code snippets are provided below.

This code is from the jtable :

duesTable = new javax.swing.JTable();
duesTable.setModel(duestableModel);
TableColumn tcol = duesTable.getColumnModel().getColumn(2);
tcol.setCellRenderer(new CustomTableCellRenderer2());
duesTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);

this code is from the TableCellRenderer

public class CustomTableCellRenderer2 extends DefaultTableCellRenderer{
@Override
public Component getTableCellRendererComponent (JTable table,
Object obj, boolean isSelected, boolean hasFocus, int row, int column) {
Component cell = super.getTableCellRendererComponent(
table, obj, isSelected, hasFocus, row, column);

[Code]...

This is from the Table Model.

public class DuesTableModel extends AbstractTableModel implements TableModelListener {
private List<List<Object>> dataList = new ArrayList<>();
private String[] header = { "ID"," PAYMENT YEAR" , "AMOUNT"}; // Payment year is a date
datatype
private int minRowCount = 5;

[Code]....

View Replies View Related

Swing/AWT/SWT :: Copy Selected Data From JTable Cell To Clipboard

Feb 18, 2014

I have a jtable that I would like to copy from a cell that I select to clipboard. How could I do these.

View Replies View Related

Swing/AWT/SWT :: Finding Strings In A JTable

Jan 31, 2015

I am having a problem finding string objects in a jTable. I use setValueAt() to write string variables into a jTable.

I can then use getValueAt() to search to find any of those strings. All works fine until I edit an entry in the table. Then I can never find that string again.

In fact, if I just click in the cell type a character, then delete that character, something changes. The contents of the cell look the same but the search for it doesn't find it.

For example if I have a string "xyz" that was written in a cell. If I set the search value, "a=xyz", and "b=getValueAt(some cell)".

Then at the compare:

if(a==b) I can hover over a and b and I see that;
a = (java.lang.String) xyz

and

b = (java.lang.String) xyz

[note I am using NetBeans to do this]

after the compare, the true path is taken .

If I then click in the cell then click out and try the same compare, everything is exactly the same including what gets reported when I hover. But the false path is taken at the "if".

View Replies View Related

Compare 2 Strings - Generate New String With Matching Characters

Jul 3, 2014

I'm attempting a small program as I'm teaching myself the ropes. In it, I need to compare one string (the base) to another which is just the base string that's had it's characters shuffled.

Java Code:

String base = "ABCDEFG"
String shuffled = "CDAFBEG" mh_sh_highlight_all('java');

What I need to do is run a loop that shuffles the base string each time, but compares and saves any characters that match in the correct location. For example, if shuffled = "CDAFBEG", then the G would be "locked" in place and the rest of the characters shuffled and looped back to the comparison.

I have all the code I need for shuffling the string, but I'm not sure how I would go about comparing each character and then also locking it in place. I get the basics, I think, of needed to use several variables.

View Replies View Related

Multiple Rows Into Database From JTable

Apr 12, 2014

How to insert multiple rows into a database from a jtable and also retrive the same details from database and show it in a jtable.

View Replies View Related

JTable Specific Cell Selected

Jun 6, 2014

I want perform some calculations whenever a specific cell block is focused in JTable, I've tried using focusListener on JTable but looks like my table isn't triggering the event. I don't know why, what to do?

View Replies View Related

Swing/AWT/SWT :: GetSelectedItem Isn't Getting Selected Item

Oct 9, 2014

I was wanting to select an item in a comboBox and display it in a text field but all it's doing at the minute is retrieving the first item in the comboBox and placing that in the txt field

String value = (String) comboBoxEnv.getSelectedItem().toString();
if(comboBoxEnv.getSelectedItem()!= null){
txtTo.setText(value);

View Replies View Related

Swing/AWT/SWT :: Error When Delete Rows With Multiselect

Feb 20, 2014

I have this error when i want delete rows in db... I have this error:

java.lang.String cannot be cast to QueryEliminaMultiSelect

In this class i have write:

class QueryEliminaMultiSelect {
int idNumDel;
String dataDelString;
String nomeDelString;
String emailDelString;
String telDelString;

[Code] .....

where is error???

View Replies View Related

Swing/AWT/SWT :: Refreshing GUI - Display Table With Several Columns And Rows

Jun 6, 2014

I have an application that displays a GUI and this GUI displays a table with several columns and rows. I have a class that extends DefaultTableModel. I wrote the code that displays the GUI. When the database table changes, how would I updated the GUI dynamically? Do you have any sample code that does that?

View Replies View Related

Swing/AWT/SWT :: Rows In JTextArea - Entering More Lines Than Limit

Jan 9, 2014

Here's a snippet of code from a program I'm making:

private void init() {
...
testInfo = new JTextArea("Progress log:
");
testInfo.setEditable(false);
testInfo.setLineWrap(true);
testInfo.setPreferredSize(new Dimension(testInfo.getPreferredSize().width, 200));
scrollPane = new JScrollPane(testInfo);
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
...
add(scrollPane);
}

The problem is, the JTextArea that's created has a "limited" number of rows - it seems you can still enter more lines than the "limit", but they don't show. I thought it was a problem with the JScrollPane but I'm not so sure...

View Replies View Related

Swing/AWT/SWT :: Remove Or Hide Selected JCheckBox From A List In GroupLayout?

Dec 9, 2014

There are 8 JCheckboxes, which are already added to panel and aligned in group layout. From which, I have selected one JCheckbox. Then the resultant GUI should contain only remaining 7 JCheckboxes and selected one should temporarily removed or hide from GUI . Is it possible? If so, how?

View Replies View Related

Swing/AWT/SWT :: Select Different Blocks Of Code When File Selected In JFileChooser?

Nov 12, 2014

I have a program where I have to open a file and then run a piece of code to do something with it. However since there are different files I want to run different pieces of code depending on the file. I have a JFileChooser setup and it works but I would like to have a something like an if else depending on the file extension.

View Replies View Related

Swing/AWT/SWT :: Popup Menu Will Become Invisible Does Not Capture Selected Value / Item

Nov 1, 2014

I have a combobox with this PopupMenuListener. All works fine, except that the popupMenuWillBecomeInvisible method does not capture the selection made and neither does it show the selection.

PopupMenuListener pmlMqMessagePurged = new PopupMenuListener() {
@SuppressWarnings("unchecked")
public void popupMenuWillBecomeVisible(PopupMenuEvent arg0) {
try {
JdbcSqlServerDataSource ds = new JdbcSqlServerDataSource(
DbConnectionURL.UToolDbHostName, 0,

[Code] .....

The popupMenuWillBecomeInvisible does fire but the System.out.println() returns 'nul'l as answer to the value i have selected from the combobox.

View Replies View Related

Swing/AWT/SWT :: How To Code Button That Get Selected Element From JComboBox And Perform Operations

Aug 6, 2014

i've spend an hour or two, pasting fragments from tutorials and nothing changed.

Well - i have GUI, that have JComboBox with two elements:
String[] fedoras = { "Fedora 19", "Fedora 20" };
JComboBox fedora_list = new JComboBox(fedoras);
fedora_list.setSelectedIndex(0);
fedora_list.setBounds(120,170, 170,25);
fedora_list.addActionListener(this);
this.add(fedora_list);

Below i have normal button (named Update) with "update" set as ActionCommand. This button after clicked should check which value from list is selected and perform different operations for that elements. But it's harder than i thought.

Code for update button:

public void actionPerformed(ActionEvent e){
String cmd = e.getActionCommand();
(...)
else if ("update".equals(cmd)){
String selectedFedora = (String) fedora_list.getSelectedItem();
if (selectedFedora.equals("Fedora 19")) {

[code]....

- after user clicked Update button, button should check which value is selected in JComboBox (fedora_list).
- if Fedora 19 is selected and button clicked, then action in Xterm
- if Fedora 20 is selected, this same action in Xterm is performed, but for Fedora Linux 20

The problem is - i don't know hot to code Update button to check which value from fedora_list (JComboBox) is selected and perform other actions for every element on List.

View Replies View Related

Swing/AWT/SWT :: Populate JPanel Based On More Information About Selected JTree Node From A File?

Aug 27, 2014

When you select a node in a JTree can you then populate a JPanel based on more information about that node from a file?

View Replies View Related

Swing/AWT/SWT :: Creating A Combination Lock That Consist Of Three Strings

Oct 23, 2014

I need to use a counter to keep track of user's input. In this class I am trying to create a combination lock that takes three strings. In the tester class the user inserts three strings and both are compared to see if users input matches correct combination. I have no errors only problem is the setPosition method. My output is always false.

public class CombinationLock {
private String first;
private String second;
private String third;
private String firstGuess;
private String secondGuess;
private String thirdGuess;
private boolean open;
private int counter;

[code]....

View Replies View Related

Swing/AWT/SWT :: JTable With Fixed Row

Nov 9, 2008

My JTable has a row, row number 0, which I always want to be at the top.I tried the following two approaches, both without success:

1- Use a custom table cell renderer for the header, and create a header of two rows. the second row is my JTextField.

Problem: I cannot get the JTextField to function properly. (I've seen examples with a checkbox in the header, but that one just reacts to a click somewhere on the header, my textfield must be editable).

2- Use the first row of the table. This works quite nice. However, I must prevent row 0 to be re-ordered when sorting the table.

I was thinking to add a prefix (either something like "___" or "zzz" depending on current sorting mode), but I do not know which methods to adjust for this exaclty.

Another approach would be to have N textfields above the JTable in some layout (or two JTable's on top of each other).

However, Then I would need to react to the re-ordering and re-sizing of all columns as well, which does not seem easy to me.

View Replies View Related

Swing/AWT/SWT :: Using JList Instead Of JTable?

Apr 18, 2014

Can I use Jlist instead of Jtable for showing database table data (select * from employee) in my code?

View Replies View Related

Swing/AWT/SWT :: Can't Select The Very Last Row In A Jtable

Mar 26, 2015

I have encountered a very tricky spot in a project that i am working on. I must have a JTable to programmatically select the very last row in an AbstractTableModel. I have tried every thing but nothing works so far.

The problem is is that the JTable only scrolls down to the second last table row in the model? What am i missing?

//Show the very last row in a tablemodel object using the method updateTableRows
//after an "insert action event" occurred
public void updateViewMode(String name,
java.util.List<NetworkSwitch> list,
boolean flag) {
CableTableModel model = cableTable.getCableModel();

[code]....

What happens is that the only row that gets selected is the second last row of the total rows iny AbstractTableModel object, "CableTableModel"

What am i missing?

View Replies View Related

Swing/AWT/SWT :: JTable Not Getting Updated

Nov 17, 2014

I am preparing a small solution. Below is how the functionality works.

1. Login Screen
2. Successful Login will take to a MDI Form
3. Click the menu, a JInternalFrame will open in the JDestopPane.
4. JInternalFrame has a JTable.
5. JInternalFrame has a JButton available for adding new data.
6. When JButton is clicked, a new JInternalFrame is popped up with some JTextField and JButton to save the data.
7. After saving the data (after insert query), a JDialog is opened to upload Logo (update query for BLOB), There are two buttons in the JDialog, one is for uploading the image, another one is uploading it later.
8. The logo is displayed in the JDialog and if the JButton, for upload is pressed, update the database and reload the JTable in the JInternalFrame is called.

My challenge is in point 8. The function is called properly, but the table is not getting refreshed.

JButton in JDialog for uploading the Logo
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
JOptionPane.showMessageDialog(this, "Image Uploaded Successfully");
companyConfig cc = new companyConfig();
//cc.reloadTable();
cc.updateTable();
this.dispose();

[code]....

View Replies View Related

Swing/AWT/SWT :: JTable Sum Of A Column

Feb 9, 2015

I've been creating a jTable where I can add / edit /delete new entries. Now i have 2 Questions :

1) My column 0 is filled with the row-number. I created a variable and with each "add" it adds +1 to the variable. That works, but as soon as i delete 1 row there is a gap ( 1..2..4..5..).

My question: Is there another way then mine to handle this?

2) The table is/should be working as some kind of database. The user is able to add Information (height, width,...). Now I want to sum the entries of 1 column (length,...). But as they´re objects I didn´t find a way.

My question: How can I sum the entries of 1 column of a table?

View Replies View Related

Swing/AWT/SWT :: JTable Instead Of JTextArea

May 3, 2015

i have this code when i selected a node it display the attribut and value of it in JTextArea but i want it into table :

public void valueChanged( TreeSelectionEvent event )
{
if( event.getSource() == jtree ){
{
FramePrincipale.getExplorePanelll().setText(null);
TreePath path = jtree.getSelectionPath();
String a = changeString(path);
Hashtable env1 = System.getProperties();
env1.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env1.put(Context.PROVIDER_URL, "ldap://localhost:11389/");

[code]....

View Replies View Related

Swing/AWT/SWT :: Keeping Track Of Strings Drawn On JPanel Using Paint

Nov 1, 2014

So, I have this simple program that paints a string on JPanel using g2.drawString("Hello world", 40, 120). Basically, I want to be able to keep track of many strings on the JPanel at once. I'm not sure how to do this. For example, I would want to have an ArrayList of objects that keep track of these strings.

I want to be able to click-and-drag these strings so I will need to know there locations, etc.

Right now, using g2.drawString, it only draws the string. I want something like gw.draw(myStringObject).

import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JFrame;
import javax.swing.JPanel;

[Code] .....

View Replies View Related

Swing/AWT/SWT :: How To Get Data From JTextField Over To JTable

Jun 20, 2014

I am trying to get the data entered in a JTextField into a JTable but not clear on how. The LeftPanel is where the button is located and the RightPanel is where the JTable is. I want the actionPerformed to update the row of the JTable but I can't figure out how. There is another class that controls the GUI but did not think it was necessary to include. Also, I am aware that I am getting an error at the addRow line, can't seem to alleviate it.

public class LeftPanel extends JPanel {

private static final long serialVersionUID = -2311952438693382407L;
private RightPanel rPanel;
public LeftPanel(){
Dimension size = getPreferredSize();
size.width = 250;
setPreferredSize(size);

[code]....

View Replies View Related

Swing/AWT/SWT :: Getting A Row Of Names From The First Column Of JTable?

Feb 9, 2014

I have a JTable with the model " Names " , " Quantity " and " Unit " .

I'm coding a program where you get the ingredients names.

So i need to get the whole row of one column and String it all up together,because i need to store it in mySql and i have already set it all as String.

how i can do this ?

My code are as follows :

JTable Code:

DefaultTableModel model = (DefaultTableModel)table.getModel();
if(!txtQty.getText().trim().equals("")){
model.addRow(new Object[]{ingCB.getSelectedItem().toString(),txtQty.getText(),unitCB.getSelectedItem().toString()});
}else{
JOptionPane.showMessageDialog(null,"*Quantity field left blank");
}

Getting the values and for storing :

for(int i = 1; i<= i ; i++){
ingredients = table.getName();
}

This is for loop is wrong and it does not work because i have a constructor to take in Ingredients but because it is inside the loop, it cannot take it in.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved