Which design pattern can be appied here?


Somthing like this TableModel --> dataFilter --> table1 table2 table 3

In a word, when set different condition in the dataFilter, it will have differnet tables. I think there is some design pattern can be appied here to make the design easily.

Posted On: Tuesday 23rd of October 2012 09:17:14 PM Total Views:  41
View Complete with Replies

RELATED TOPICS OF Swing / AWT / SWT PROGRAMMING LANGUAGE




create a jtable which can combine and split and the image change also

hi newbie here and would like to know how to create a jtable with default images and with specific column and rows that if you combine the cells the image enlarge and when split the image decreases.
VIEWS ON THIS POST

195

Posted on:

Wednesday 19th September 2012
View Replies!

Sinple GUI Program which uses the BorderLayout.

I need to write a Java program to display a screen like the following screen, which uses the BorderLayout. This is what my output is supposed to be: or View Here: https://www.dropbox.com/s/u1pqz588b8cofxo/Untitled1.png I tried writing the code for this program. But I am not able to do so. Following is my code: import java.awt.BorderLayout; import javax.swing.JButton; import javax.swing.JFrame; public class GUI extends JFrame { public GUI() { setLayout(new BorderLayout(1000,2000)); add(new JButton("Java"), BorderLayout.NORTH); add(new JButton("Programming"), BorderLayout.CENTER); add(new JButton("Is Not So Easy"), BorderLayout.NORTH); add(new JButton("Linear Data Structers!"), BorderLayout.SOUTH); } public static void main(String[] args) { GUI frame = new GUI(); frame.setTitle("EECS 1570"); frame.setSize(600,400); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
VIEWS ON THIS POST

81

Posted on:

Thursday 20th September 2012
View Replies!

can we display images in sequence which will gives perception of motion in frame's contentPane ?

can we display images in frame which can give perception of motion very similar to videos ....i short can we display sequence of images so that it is played like a video i have tried but ..the images where over lapping other and GUI gets hanged does any one has done that before
VIEWS ON THIS POST

148

Posted on:

Saturday 22nd September 2012
View Replies!

How to create the Jtable in which one column contain the check box or String

Hi , i want to create the Jtable in which one column contain the check box (which is a boolean value) or String i created the Check box as public Class getColumnClass(int column) { return getValueAt(0, column).getClass(); } This function return me boolean value "True" or "False" my problem is that, in the 1st column and 5 row i need to display the "check box" and next row from 6 to 10 of the same column i need to display string. .
VIEWS ON THIS POST

119

Posted on:

Saturday 22nd September 2012
View Replies!

How to set Focus to the first row in a JTable which is inside a JScrollPane

I have a JTable inside a JScrollPane. I have put this inside a panel. As soon the panel loads i want the first row in the JTable to get the focus BUT by default the focus goes to the JScrollPane and on pressing tab the focus enters into table's first row. I dont want to use setRowSelectionInterval(0,0) and setColumnSelectionInterval(0,0) as my requirement is different from that. Kindly help me.
VIEWS ON THIS POST

155

Posted on:

Saturday 22nd September 2012
View Replies!

how to display text on image which keeps on getting changed ?

I have successfully manage to display a text on JLabel but when ever i m changing that text , the other text is displayed on the same image to try to rub the orignally writen text with graphics2d.drawString("",210,50);
VIEWS ON THIS POST

174

Posted on:

Saturday 22nd September 2012
View Replies!

which layout manager to use for this purpose?

, I'am currently trying to create a simple 2column layout. I want the right column to have a fixed width whereas the left column should resize according to the whole Frame.
VIEWS ON THIS POST

65

Posted on:

Wednesday 26th September 2012
View Replies!

Checking which jpanel is active in tabs

I was wondering if there's a built-in way to do this. Otherwise, I was thinking of simply setting an Int to 1-3 on a mouse click event when selecting my tabs. In case anyone wants to see the chaos that is my code... /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package switchoverlay; import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * * @author anthony.schmitt */ public class OverlayGUI extends javax.swing.JFrame { /** Creates new form OverlayGUI */ public OverlayGUI() { initComponents(); setTitle("SwitchGate Beta - Anthony Schmitt"); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // private void initComponents() { SwitchTypeRadioGroup = new javax.swing.ButtonGroup(); ALLTabs = new javax.swing.JTabbedPane(); ExamPanel = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); ExamTNButton = new javax.swing.JButton(); ExamCOEButton = new javax.swing.JButton(); AddButton = new javax.swing.JButton(); DeleteButton = new javax.swing.JButton(); COETypeEADBox = new javax.swing.JComboBox(); jLabel3 = new javax.swing.JLabel(); TNField = new javax.swing.JFormattedTextField(); COEField = new javax.swing.JFormattedTextField(); ChangeTab = new javax.swing.JPanel(); TNCOEChangePanel = new javax.swing.JPanel(); ChangeTNButton = new javax.swing.JButton(); ChangeCOEButton = new javax.swing.JButton(); OriginatingPanel = new javax.swing.JPanel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); COETypeCHANGEBox1 = new javax.swing.JComboBox(); jLabel4 = new javax.swing.JLabel(); OriginatingTNField = new javax.swing.JFormattedTextField(); OriginatingCOEField = new javax.swing.JFormattedTextField(); NewPanel = new javax.swing.JPanel(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); COETypeCHANGEBox2 = new javax.swing.JComboBox(); NewTNField = new javax.swing.JFormattedTextField(); NewCOEField = new javax.swing.JFormattedTextField(); FeatureChangePanel = new javax.swing.JPanel(); FeatureTNField = new javax.swing.JFormattedTextField(); jLabel13 = new javax.swing.JLabel(); PICField = new javax.swing.JFormattedTextField(); PICLabel = new javax.swing.JLabel(); LPICField = new javax.swing.JFormattedTextField(); PICLabel1 = new javax.swing.JLabel(); GETPICButton = new javax.swing.JButton(); GTD5RadioButton = new javax.swing.JRadioButton(); DMS10RadioButton = new javax.swing.JRadioButton(); DMS100RadioButton = new javax.swing.JRadioButton(); ESSRadioButton = new javax.swing.JRadioButton(); DCORadioButton = new javax.swing.JRadioButton(); BottomPanel = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); ResultField = new javax.swing.JTextArea(); jLabel12 = new javax.swing.JLabel(); CopyButton = new javax.swing.JButton(); ClearButton = new javax.swing.JButton(); ClearCodeButton = new javax.swing.JButton(); SearchButton = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); ExamPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jLabel1.setText("TEN DIGIT TN:"); jLabel2.setText("COE TYPE:"); ExamTNButton.setText("Exam TN"); ExamTNButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ExamTNButtonActionPerformed(evt); } }); ExamCOEButton.setText("Exam COE"); ExamCOEButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ExamCOEButtonActionPerformed(evt); } }); AddButton.setText("Add"); AddButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { AddButtonActionPerformed(evt); } }); DeleteButton.setText("Delete"); DeleteButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DeleteButtonActionPerformed(evt); } }); COETypeEADBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "TCU", "RSU", "RLU", "MXU", "RALT.RLU" })); jLabel3.setText("COE:"); try { TNField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)###-####"))); } catch (java.text.ParseException ex) { ex.printStackTrace(); } javax.swing.GroupLayout ExamPanelLayout = new javax.swing.GroupLayout(ExamPanel); ExamPanel.setLayout(ExamPanelLayout); ExamPanelLayout.setHorizontalGroup( ExamPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ExamPanelLayout.createSequentialGroup() .addGap(24, 24, 24) .addGroup(ExamPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(ExamPanelLayout.createSequentialGroup() .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(TNField, javax.swing.GroupLayout.PREFERRED_SIZE, 305, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(ExamPanelLayout.createSequentialGroup() .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(COETypeEADBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(24, 24, 24) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(COEField, javax.swing.GroupLayout.PREFERRED_SIZE, 212, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(31, 31, 31) .addGroup(ExamPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(DeleteButton) .addComponent(AddButton) .addComponent(ExamCOEButton) .addComponent(ExamTNButton)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); ExamPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {AddButton, DeleteButton, ExamCOEButton, ExamTNButton}); ExamPanelLayout.setVerticalGroup( ExamPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ExamPanelLayout.createSequentialGroup() .addGap(22, 22, 22) .addGroup(ExamPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ExamPanelLayout.createSequentialGroup() .addComponent(ExamTNButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(ExamCOEButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(AddButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(DeleteButton)) .addGroup(ExamPanelLayout.createSequentialGroup() .addGroup(ExamPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(TNField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(ExamPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(COETypeEADBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3) .addComponent(COEField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(155, Short.MAX_VALUE)) ); ALLTabs.addTab("Exam/Add/Delete", ExamPanel); TNCOEChangePanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); ChangeTNButton.setText("Change TN"); ChangeTNButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ChangeTNButtonActionPerformed(evt); } }); ChangeCOEButton.setText("Change COE"); ChangeCOEButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ChangeCOEButtonActionPerformed(evt); } }); OriginatingPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("ORIGINATING")); jLabel5.setText("10 DIGIT TN:"); jLabel6.setText("COE:"); COETypeCHANGEBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "TCU", "RSU", "RLU", "MXU", "RALT.RLU" })); COETypeCHANGEBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { COETypeCHANGEBox1ActionPerformed(evt); } }); jLabel4.setText("COE TYPE:"); try { OriginatingTNField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)###-####"))); } catch (java.text.ParseException ex) { ex.printStackTrace(); } javax.swing.GroupLayout OriginatingPanelLayout = new javax.swing.GroupLayout(OriginatingPanel); OriginatingPanel.setLayout(OriginatingPanelLayout); OriginatingPanelLayout.setHorizontalGroup( OriginatingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(OriginatingPanelLayout.createSequentialGroup() .addGap(8, 8, 8) .addComponent(jLabel5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(OriginatingTNField)) .addGroup(OriginatingPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(COETypeCHANGEBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(24, 24, 24) .addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(OriginatingCOEField, javax.swing.GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)) ); OriginatingPanelLayout.setVerticalGroup( OriginatingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, OriginatingPanelLayout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(OriginatingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(OriginatingTNField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(OriginatingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6) .addComponent(jLabel4) .addComponent(COETypeCHANGEBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(OriginatingCOEField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(126, 126, 126)) ); NewPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("NEW")); jLabel7.setText("COE:"); jLabel8.setText("10 DIGIT TN:"); jLabel9.setText("COE TYPE:"); COETypeCHANGEBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "TCU", "RSU", "RLU", "MXU", "RALT.RLU" })); try { NewTNField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)###-####"))); } catch (java.text.ParseException ex) { ex.printStackTrace(); } NewTNField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { NewTNFieldActionPerformed(evt); } }); javax.swing.GroupLayout NewPanelLayout = new javax.swing.GroupLayout(NewPanel); NewPanel.setLayout(NewPanelLayout); NewPanelLayout.setHorizontalGroup( NewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(NewPanelLayout.createSequentialGroup() .addGap(8, 8, 8) .addComponent(jLabel8) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 7, Short.MAX_VALUE) .addComponent(NewTNField, javax.swing.GroupLayout.PREFERRED_SIZE, 317, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, NewPanelLayout.createSequentialGroup() .addGap(0, 8, Short.MAX_VALUE) .addComponent(jLabel9) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(COETypeCHANGEBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(20, 20, 20) .addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(NewCOEField, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE)) ); NewPanelLayout.setVerticalGroup( NewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(NewPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(NewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel8) .addComponent(NewTNField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(NewPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel9) .addComponent(COETypeCHANGEBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel7) .addComponent(NewCOEField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(46, Short.MAX_VALUE)) ); javax.swing.GroupLayout TNCOEChangePanelLayout = new javax.swing.GroupLayout(TNCOEChangePanel); TNCOEChangePanel.setLayout(TNCOEChangePanelLayout); TNCOEChangePanelLayout.setHorizontalGroup( TNCOEChangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(TNCOEChangePanelLayout.createSequentialGroup() .addContainerGap() .addGroup(TNCOEChangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(TNCOEChangePanelLayout.createSequentialGroup() .addComponent(OriginatingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(TNCOEChangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(ChangeCOEButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(ChangeTNButton, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(TNCOEChangePanelLayout.createSequentialGroup() .addComponent(NewPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap()) ); TNCOEChangePanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {NewPanel, OriginatingPanel}); TNCOEChangePanelLayout.setVerticalGroup( TNCOEChangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(TNCOEChangePanelLayout.createSequentialGroup() .addGroup(TNCOEChangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(TNCOEChangePanelLayout.createSequentialGroup() .addGap(36, 36, 36) .addComponent(ChangeTNButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(ChangeCOEButton) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(TNCOEChangePanelLayout.createSequentialGroup() .addComponent(OriginatingPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE) .addComponent(NewPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); TNCOEChangePanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {NewPanel, OriginatingPanel}); javax.swing.GroupLayout ChangeTabLayout = new javax.swing.GroupLayout(ChangeTab); ChangeTab.setLayout(ChangeTabLayout); ChangeTabLayout.setHorizontalGroup( ChangeTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(TNCOEChangePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); ChangeTabLayout.setVerticalGroup( ChangeTabLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(ChangeTabLayout.createSequentialGroup() .addComponent(TNCOEChangePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) ); ALLTabs.addTab("TN/COE Changes", ChangeTab); FeatureChangePanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); try { FeatureTNField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(###)###-####"))); } catch (java.text.ParseException ex) { ex.printStackTrace(); } jLabel13.setText("10 DIGIT TN:"); try { PICField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####"))); } catch (java.text.ParseException ex) { ex.printStackTrace(); } PICLabel.setText("PIC:"); try { LPICField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####"))); } catch (java.text.ParseException ex) { ex.printStackTrace(); } PICLabel1.setText("LPIC:"); GETPICButton.setText("Get New PIC(S)"); GETPICButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { GETPICButtonActionPerformed(evt); } }); javax.swing.GroupLayout FeatureChangePanelLayout = new javax.swing.GroupLayout(FeatureChangePanel); FeatureChangePanel.setLayout(FeatureChangePanelLayout); FeatureChangePanelLayout.setHorizontalGroup( FeatureChangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(FeatureChangePanelLayout.createSequentialGroup() .addContainerGap() .addComponent(jLabel13) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(FeatureTNField, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(PICLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(PICField, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(PICLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(LPICField, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE) .addComponent(GETPICButton) .addContainerGap()) ); FeatureChangePanelLayout.setVerticalGroup( FeatureChangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(FeatureChangePanelLayout.createSequentialGroup() .addContainerGap() .addGroup(FeatureChangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(FeatureChangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(LPICField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(PICLabel1) .addComponent(GETPICButton)) .addGroup(FeatureChangePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(FeatureTNField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel13) .addComponent(PICField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(PICLabel))) .addContainerGap(253, Short.MAX_VALUE)) ); ALLTabs.addTab("Feature Changes", FeatureChangePanel); SwitchTypeRadioGroup.add(GTD5RadioButton); GTD5RadioButton.setSelected(true); GTD5RadioButton.setText("GTD5"); GTD5RadioButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { GTD5RadioButtonActionPerformed(evt); } }); SwitchTypeRadioGroup.add(DMS10RadioButton); DMS10RadioButton.setText("DMS10"); DMS10RadioButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DMS10RadioButtonActionPerformed(evt); } }); SwitchTypeRadioGroup.add(DMS100RadioButton); DMS100RadioButton.setText("DMS100"); SwitchTypeRadioGroup.add(ESSRadioButton); ESSRadioButton.setText("5ESS"); SwitchTypeRadioGroup.add(DCORadioButton); DCORadioButton.setText("DCO"); BottomPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Code Generation")); ResultField.setColumns(20); ResultField.setRows(5); jScrollPane1.setViewportView(ResultField); jLabel12.setText("TIP: Highlight text and press CTRL+C to copy specific lines of code!"); javax.swing.GroupLayout BottomPanelLayout = new javax.swing.GroupLayout(BottomPanel); BottomPanel.setLayout(BottomPanelLayout); BottomPanelLayout.setHorizontalGroup( BottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(BottomPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(BottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, BottomPanelLayout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(jLabel12) .addGap(105, 105, 105))) .addContainerGap()) ); BottomPanelLayout.setVerticalGroup( BottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(BottomPanelLayout.createSequentialGroup() .addGap(8, 8, 8) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel12)) ); CopyButton.setText("Copy Resulting Code"); CopyButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { CopyButtonActionPerformed(evt); } }); ClearButton.setText("Clear Fields"); ClearButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ClearButtonActionPerformed(evt); ClearButtonActionPerformed1(evt); } }); ClearCodeButton.setText("Clear Code"); ClearCodeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ClearCodeButtonActionPerformed(evt); ClearCodeButtonActionPerformed1(evt); } }); SearchButton.setText("Search code for TN/COE"); SearchButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SearchButtonActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(BottomPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(ALLTabs, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(GTD5RadioButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(DMS10RadioButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(DMS100RadioButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(ESSRadioButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(DCORadioButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createSequentialGroup() .addComponent(ClearButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(CopyButton)) .addGroup(layout.createSequentialGroup() .addComponent(ClearCodeButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(SearchButton))))) .addContainerGap()) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {CopyButton, SearchButton}); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {ClearButton, ClearCodeButton}); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(ALLTabs) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(DMS10RadioButton) .addComponent(DMS100RadioButton) .addComponent(ESSRadioButton) .addComponent(DCORadioButton) .addComponent(GTD5RadioButton) .addComponent(CopyButton) .addComponent(ClearButton)) .addGap(2, 2, 2) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(ClearCodeButton) .addComponent(SearchButton)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(BottomPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); pack(); }// private void DMS10RadioButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void GTD5RadioButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void CopyButtonActionPerformed(java.awt.event.ActionEvent evt) { Clipboard system = Toolkit.getDefaultToolkit().getSystemClipboard(); StringSelection sel = new StringSelection(ResultField.getText()); system.setContents(sel, sel); } private void NewTNFieldActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void COETypeCHANGEBox1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void ChangeCOEButtonActionPerformed(java.awt.event.ActionEvent evt) { String origtn = OriginatingTNField.getText(); // Get TN from TNField String orignpa = origtn.substring(1, 4); //Get first three digits from tn String orignxx = origtn.substring(5, 8); //Get first three digits from tn String origxxxx = origtn.substring(9, 13); //Get last four digits from tn String newtn = NewTNField.getText(); // Get TN from TNField String newnpa = newtn.substring(1, 4); //Get first three digits from tn String newnxx = newtn.substring(5, 8); //Get first three digits from tn String newxxxx = newtn.substring(9, 13); //Get last four digits from tn String origcoe = OriginatingCOEField.getText(); // Get TN from TNField String newcoe = NewCOEField.getText(); // Get TN from TNField Object origcoeobject = COETypeCHANGEBox1.getSelectedItem(); // Turn selected combobox option into an object String origcoestring = origcoeobject.toString(); // Turn that object into a string Object newcoeobject = COETypeCHANGEBox2.getSelectedItem(); // Turn selected combobox option into an object String newcoestring = newcoeobject.toString(); // Turn that object into a string /* * //5ESS RADIO BUTTON CODE PLACED BEFORE OTHER IF TESTS FOR SPECIAL COE FIELD EXCEPTIONS */ if (ESSRadioButton.isSelected() && (origtn.startsWith("( )") && (newtn.startsWith("( )")) && (newcoe.isEmpty()) )) { ResultField.setText("Both TN fields are empty and no COE is entered. " + "\nPlease enter a TN in either field and supply a COE in the NEW COE field."); } else if (ESSRadioButton.isSelected() && (origtn.startsWith("( )") && (newtn.startsWith("( )")) )) { ResultField.setText("Both TN fields are empty, please enter a TN in either field."); } else if (ESSRadioButton.isSelected() && (origtn.startsWith("( )")) ) { String coecode = newcoe.substring(0, 1); //Get starting letter from 5ESS COE code String coedigits = newcoe.substring(1); //Get remaining numbers for 5ESS COE code ResultField.setText("RCV:APPTEXT:DATA,FORM=1V6&CHG,TN="+newnpa+newnxx+newxxxx +",SET=\"CHNGOE.ENTYPE\"&\""+coecode+"\",SET=\"CHNGOE.LEN\"&\""+coedigits+"\",CHG!"); } else if (ESSRadioButton.isSelected() && (newtn.startsWith("( )")) ) { String coecode = newcoe.substring(0, 1); //Get starting letter from 5ESS COE code String coedigits = newcoe.substring(1); //Get remaining numbers for 5ESS COE code ResultField.setText("RCV:APPTEXT:DATA,FORM=1V6&CHG,TN="+orignpa+orignxx+origxxxx +",SET=\"CHNGOE.ENTYPE\"&\""+coecode+"\",SET=\"CHNGOE.LEN\"&\""+coedigits+"\",CHG!"); } else if (ESSRadioButton.isSelected() ) { String coecode = newcoe.substring(0, 1); //Get starting letter from 5ESS COE code String coedigits = newcoe.substring(1); //Get remaining numbers for 5ESS COE code ResultField.setText("RCV:APPTEXT:DATA,FORM=1V6&CHG,TN="+orignpa+orignxx+origxxxx +",SET=\"CHNGOE.ENTYPE\"&\""+coecode+"\",SET=\"CHNGOE.LEN\"&\""+coedigits+"\",CHG!"); } else if (origcoe.isEmpty() && (newcoe.isEmpty()) ) { ResultField.setText("Both COE fields are empty."); } else if (origcoe.isEmpty()) { ResultField.setText("Originating COE field is empty."); } else if (newcoe.isEmpty()) { ResultField.setText("New COE field is empty."); } else if (GTD5RadioButton.isSelected()) { String origset1 = origcoe.substring(1, 3); //Get first two digits from COE String origset2 = origcoe.substring(3, 4); //Get third digit from COE String origset3 = origcoe.substring(4, 6); //Get fourth and fifth digits from COE String origset4 = origcoe.substring(6, 8); //Get sixth and seventh digits from COE String origset5 = origcoe.substring(8, 9); //Get eighth digit from COE String newset1 = newcoe.substring(1, 3); //Get first two digits from COE String newset2 = newcoe.substring(3, 4); //Get third digit from COE String newset3 = newcoe.substring(4, 6); //Get fourth and fifth digits from COE String newset4 = newcoe.substring(6, 8); //Get sixth and seventh digits from COE String newset5 = newcoe.substring(8, 9); //Get eighth digit from COE ResultField.setText("BEGI SRVC\n\nCHAN EN." + origcoestring + origset1 + "." + origset2 + "." + origset3 + "." + origset4 + "." + origset5 + " TO." + newcoestring + newset1 + "." + newset2 + "." + newset3 + "." + newset4 + "." + newset5); } else if (DMS10RadioButton.isSelected()) { String origset1 = origcoe.substring(0, 2); //Get first two digits from COE String origset2 = origcoe.substring(2, 3); //Get third digit from COE String origset3 = origcoe.substring(3, 5); //Get fourth and fifth digits from COE String origset4 = origcoe.substring(5, 7); //Get sixth and seventh digits from COE String newset1 = newcoe.substring(0, 2); //Get first two digits from COE String newset2 = newcoe.substring(2, 3); //Get third digit from COE String newset3 = newcoe.substring(3, 5); //Get fourth and fifth digits from COE String newset4 = newcoe.substring(5, 7); //Get sixth and seventh digits from COE ResultField.setText("MOV STN "+orignxx+" "+origxxxx +"\n(CILLI) "+newcoestring+" "+newset1+" "+newset2+" "+newset3+" "+newset4 + "\n\n**MOV might not work in all switches. " + "\nAt the REQ prompt, type a if MOV is not in the list, it will not work." + "\n\nIf the LEN youre changing from or to is not an LCE, or if MOV is not a valid function in the switch," + "\nit is necessary to take the # out of the switch then put it back in." +"\n\nREQ: QUE STN XXX XXXX (Query it first so you know what to put back on the line)" +"\nREQ: QACT STN XXX XXXX (Query the fwding so you know what to add back on)." +"\nREQ: DEL STN XXX XXXX" +"\nREQ: NEW STN XXX XXXX (put them back in with their new LEN) (features, pics, ppu)" +"\nREQ: ACT STN XXX XXXX (only do this if you need to re-activate the forwarding)"); } else if (DMS100RadioButton.isSelected()) { String origset1 = origcoe.substring(0, 2); //Get first two digits from COE String origset2 = origcoe.substring(2, 3); //Get third digit from COE String origset3 = origcoe.substring(3, 5); //Get fourth and fifth digits from COE String origset4 = origcoe.substring(5, 7); //Get sixth and seventh digits from COE String newset1 = newcoe.substring(0, 2); //Get first two digits from COE String newset2 = newcoe.substring(2, 3); //Get third digit from COE String newset3 = newcoe.substring(3, 5); //Get fourth and fifth digits from COE String newset4 = newcoe.substring(5, 7); //Get sixth and seventh digits from COE ResultField.setText("SERVORD\n\nCLN $ " + origcoestring+" " + origset1 + origset2 + origset3 + origset4 + " " + newcoestring+" " + newset1 + newset2 + newset3 + newset4 + " Y"); } else if (DCORadioButton.isSelected()) { String origset1 = origcoe.substring(0, 3); //Get first three digits from COE String origset2 = origcoe.substring(3, 5); //Get fourth and fifth digit from COE String origset3 = origcoe.substring(5, 7); //Get sixth and seventh digits from COE String newset1 = newcoe.substring(0, 3); //Get first three digits from COE String newset2 = newcoe.substring(3, 5); //Get fourth and fifth digit from COE String newset3 = newcoe.substring(5, 7); //Get sixth and seventh digits from COE ResultField.setText("$ADMIN LINE\n\n" + "CH EN " + origset1 + "-" + origset2 + "-" + origset3 + " EN " + newset1 + "-" + newset2 + "-" + newset3 + " DO"); } else { ResultField.setText("Something went wrong with your fields, please verify."); } } private void ChangeTNButtonActionPerformed(java.awt.event.ActionEvent evt) { String origtn = OriginatingTNField.getText(); // Get TN from TNField String orignpa = origtn.substring(1, 4); //Get first three digits from tn String orignxx = origtn.substring(5, 8); //Get first three digits from tn String origxxxx = origtn.substring(9, 13); //Get last four digits from tn String newtn = NewTNField.getText(); // Get TN from TNField String newnpa = newtn.substring(1, 4); //Get first three digits from tn String newnxx = newtn.substring(5, 8); //Get first three digits from tn String newxxxx = newtn.substring(9, 13); //Get last four digits from tn if (origtn.startsWith("( )") && (newtn.startsWith("( )")) ) { ResultField.setText("Both TN fields are empty."); } else if (origtn.startsWith("( )")) { ResultField.setText("Originating TN field is empty."); } else if (newtn.startsWith("( )")) { ResultField.setText("New TN field is empty."); } else if (GTD5RadioButton.isSelected()) { ResultField.setText("BEGI SRVC\n\nCHAN DN " + orignxx + "-" + origxxxx + " TO " + newnxx + "-" + newxxxx); } else if (DMS10RadioButton.isSelected()) { ResultField.setText("OVLY DN\n\nCHDN STN " + orignxx + " " + origxxxx + " " + newnxx + " " + newxxxx); } else if (DMS100RadioButton.isSelected()) { ResultField.setText("SERVORD\n\nCDN $ " + orignxx + origxxxx + " " + newnxx + newxxxx + " BLDN Y"); } else if (ESSRadioButton.isSelected()) { ResultField.setText("RCV:APPTEXT:DATA,FORM=1V6&CHG,TN="+orignpa+orignxx+origxxxx+",CHNGTN="+newnpa+newnxx+newxxxx+",CHG!"); } else if (DCORadioButton.isSelected()) { ResultField.setText("$ADMIN LINE\n\nCH DN " + orignxx + origxxxx + " DN " + newnxx + newxxxx + " DO"); } else { ResultField.setText("Something went wrong with your TN settings."); } } private void DeleteButtonActionPerformed(java.awt.event.ActionEvent evt) { String tn = TNField.getText(); // Get TN from TNField String npa = tn.substring(1, 4); //Get first three digits from tn String nxx = tn.substring(5, 8); //Get first three digits from tn String xxxx = tn.substring(9, 13); //Get last four digits from tn if (tn.startsWith("( )")) { ResultField.setText("TN field is empty."); } else if (GTD5RadioButton.isSelected()) { ResultField.setText("BEGI SRVC\n\nDELE DN " + nxx + "-" + xxxx + " DL VN"); } else if (DMS10RadioButton.isSelected()) { ResultField.setText("OVLY DN\n\nDEL STN " + nxx + "" + xxxx); } else if (DMS100RadioButton.isSelected()) { ResultField.setText("SERVORD\n\nOUT $ " + nxx + xxxx + " (Office ID & LEN) BLDN Y/n"); } else if (ESSRadioButton.isSelected()) { ResultField.setText("RCV:APPTEXT:DATA,FORM=1V6&OUT,TN="+npa+nxx+xxxx+",OUT!"); } else if (DCORadioButton.isSelected()) { ResultField.setText("$ADMIN LINE\n\nDE DN " + nxx + xxxx); } else { ResultField.setText("Something went wrong with your TN settings."); } } private void AddButtonActionPerformed(java.awt.event.ActionEvent evt) { String tn = TNField.getText(); // Get TN from TNField String npa = tn.substring(1, 4); //Get first three digits from tn String nxx = tn.substring(5, 8); //Get first three digits from tn String xxxx = tn.substring(9, 13); //Get last four digits from tn String coe = COEField.getText(); // Get COE from COEField Object coeobject = COETypeEADBox.getSelectedItem(); // Turn selected combobox option into an object String coestring = coeobject.toString(); // Turn that object into a string if (tn.startsWith("( )") && (coe.isEmpty()) ) { ResultField.setText("TN and COE fields are empty."); } else if (tn.isEmpty() ) { ResultField.setText("TN field is empty."); } else if (GTD5RadioButton.isSelected() && (coe.isEmpty())) { ResultField.setText("Please add a COE."); } else if (GTD5RadioButton.isSelected()) { String set1 = coe.substring(1, 3); //Get first two digits from COE String set2 = coe.substring(3, 4); //Get third digit from COE String set3 = coe.substring(4, 6); //Get fourth and fifth digits from COE String set4 = coe.substring(6, 8); //Get sixth and seventh digits from COE String set5 = coe.substring(8, 9); //Get eighth digit from COE ResultField.setText("BEGI SRVC\n\nADD DN " + nxx + "-" + xxxx + " LINE." + coestring + set1 + "." + set2 + "." + set3 + "." + set4 + "." + set5 + " SPTC S500 HCMK0 FLAS" + "\n" + "**May need to adjust Sx00 and FAR (HCMK)**" + "\n" + "Check http://rcmac.northcentralnetworks.com/in/in.php"); } else if (DMS10RadioButton.isSelected() && (coe.isEmpty())) { ResultField.setText("Please add a COE."); } else if (DMS10RadioButton.isSelected()) { String set1 = coe.substring(0, 2); //Get first two digits from COE String set2 = coe.substring(2, 3); //Get third digit from COE String set3 = coe.substring(3, 5); //Get fourth and fifth digits from COE String set4 = coe.substring(5, 7); //Get sixth and seventh digits from COE ResultField.setText("OVLY DN\n\nNEW STN " + nxx + "" + xxxx + "\n(CILLI) " + coestring +" "+set1 + " " + set2 + " " + set3 + " " + set4); } else if (DMS100RadioButton.isSelected()) { ResultField.setText("SERVORD\n\nNEW $ " + nxx + xxxx +"\n\nCheck http://rcmac.northcentralnetworks.com/ for correct codes."); } else if (ESSRadioButton.isSelected() && tn.startsWith("( )")) { ResultField.setText("Please enter a TN."); } else if (ESSRadioButton.isSelected()) { ResultField.setText("FORM=1V8&NEW,TN="+npa+nxx+xxxx+ ",SET=\"CHNGOE.ENTYPE\"&\"L\",SET=\"CHNGOE.LEN\"&\"YYYYYYYYYY\"" + ",RAX=X,LCC=XXX,CHNGPTY=I,MFRI=N,TTC=Y,CIDIAL=ALLOW,PIC=XXXX,SUST=N,PTC=XXXX,NEW!" +"\n\n If you are uncertain of some of these values," + "\nuse RCV:MENU:APPRC in the switch to login using the built-in menus."); } else if (DCORadioButton.isSelected() && (coe.isEmpty())) { ResultField.setText("Please add a COE."); } else if (DCORadioButton.isSelected()) { String set1 = coe.substring(0, 3); //Get first three digits from COE String set2 = coe.substring(3, 5); //Get fourth and fifth digit from COE String set3 = coe.substring(5, 7); //Get sixth and seventh digits from COE ResultField.setText("$ADMIN LINE\n\n" + "A " + set1 + "-" + set2 + "-" + set3 + " (LCC) " + nxx + xxxx + " TONE USCOT DO"); } else { ResultField.setText("Something went wrong with your TN"); } } private void ExamCOEButtonActionPerformed(java.awt.event.ActionEvent evt) { String tn = TNField.getText(); // Get TN from TNField String npa = tn.substring(1, 4); //Get first three digits from tn String nxx = tn.substring(5, 8); //Get first three digits from tn String xxxx = tn.substring(9, 13); //Get last four digits from tn String coe = COEField.getText(); // Get COE from COEField Object coeobject = COETypeEADBox.getSelectedItem(); // Turn selected combobox option into an object String coestring = coeobject.toString(); // Turn that object into a string if (coe.isEmpty()) { ResultField.setText("COE field is empty."); } else if (GTD5RadioButton.isSelected()) { String set1 = coe.substring(1, 3); //Get first two digits from COE String set2 = coe.substring(3, 4); //Get third digit from COE String set3 = coe.substring(4, 6); //Get fourth and fifth digits from COE String set4 = coe.substring(6, 8); //Get sixth and seventh digits from COE String set5 = coe.substring(8, 9); //Get eighth digit from COE ResultField.setText("EXAM EN." + coestring + set1 + "." + set2 + "." + set3 + "." + set4 + "." + set5); } else if (DMS10RadioButton.isSelected()) { String set1 = coe.substring(0, 2); //Get first two digits from COE String set2 = coe.substring(2, 3); //Get third digit from COE String set3 = coe.substring(3, 5); //Get fourth and fifth digits from COE String set4 = coe.substring(5, 7); //Get sixth and seventh digits from COE ResultField.setText("OVLY DN\n\nLIST LINE UNIT " + coestring +" "+ set1 + " " + set2 + " " + set3 + " " + set4); } else if (DMS100RadioButton.isSelected()) { String set1 = coe.substring(0, 2); //Get first two digits from COE String set2 = coe.substring(2, 3); //Get third digit from COE String set3 = coe.substring(3, 5); //Get fourth and fifth digits from COE String set4 = coe.substring(5, 7); //Get sixth and seventh digits from COE ResultField.setText("SERVORD\n\nQLEN " + coestring + " " + set1 + " " + set2 + " " + set3 + " " + set4); } else if (ESSRadioButton.isSelected() && tn.startsWith("( )")) { ResultField.setText("Please enter a TN."); } else if (ESSRadioButton.isSelected()) { ResultField.setText("RCV:APPTEXT:DATA,FORM=1V6&VFY,TN="+npa+nxx+xxxx+",VFY,END"); } else if (DCORadioButton.isSelected()) { String set1 = coe.substring(0, 3); //Get first three digits from COE String set2 = coe.substring(3, 5); //Get fourth and fifth digit from COE String set3 = coe.substring(5, 7); //Get sixth and seventh digits from COE ResultField.setText("$ADMIN LINE\n\nDI EN " + set1 + "-" + set2 + "-" + set3); } else { ResultField.setText("Something went wrong with your COE"); } } private void ExamTNButtonActionPerformed(java.awt.event.ActionEvent evt) { String tn = TNField.getText(); // Get TN from TNField String npa = tn.substring(1, 4); //Get first three digits from tn String nxx = tn.substring(5, 8); //Get first three digits from tn String xxxx = tn.substring(9, 13); //Get last four digits from tn if (tn.startsWith("( )") ) { ResultField.setText("TN field is empty."); } else if (GTD5RadioButton.isSelected()) { ResultField.setText("EXAM DN " + nxx + "-" + xxxx + " NZO"); } else if (DMS10RadioButton.isSelected()) { ResultField.setText("OVLY DN\n\nQUE STN " + nxx + " " + xxxx); } else if (DMS100RadioButton.isSelected()) { ResultField.setText("SERVORD\n\nQDN " + nxx + xxxx); } else if (ESSRadioButton.isSelected()) { ResultField.setText("1.6 For COE, LCC, PICS:" + "\nrcv:apptext:data,form=1v6&vfy,tn=" + tn + ",vfy,end" + "\n\n1.8 For MOST other features:" + "\nrcv:apptext:data,form=1v8&vfy,tn=" + tn + ",vfy,end" + "\n\nNOTE: These commands will print all of the form pages at once."); } else if (DCORadioButton.isSelected()) { ResultField.setText("$ADMIN LINE\n\nEXDI DN " + nxx + xxxx); } else { ResultField.setText("Something went wrong with your TN."); } } private void GETPICButtonActionPerformed(java.awt.event.ActionEvent evt) { String tn = FeatureTNField.getText(); // Get TN from TNField String npa = tn.substring(1, 4); //Get first three digits from tn String nxx = tn.substring(5, 8); //Get first three digits from tn String xxxx = tn.substring(9, 13); //Get last four digits from tn String pic = PICField.getText(); // Get PIC String lpic = LPICField.getText(); // Get LPIC String bothpics = PICField.getText() + LPICField.getText(); // Get both PICs if (tn.startsWith("( )") && (bothpics.startsWith(" ")) ) { ResultField.setText("TN and both PIC fields are empty."); } else if (tn.startsWith("( )") && (pic.startsWith(" ")) ) { ResultField.setText("TN field is empty."); } else if (tn.startsWith("( )") && (lpic.startsWith(" ")) ) { ResultField.setText("TN field is empty."); } else if (bothpics.startsWith(" ")) { ResultField.setText("Both PIC fields are empty."); } else if (GTD5RadioButton.isSelected() && (pic.startsWith(" ")) ) { ResultField.setText("BEGI SRVC\n\nCHAN DN "+nxx+xxxx+" ICID "+lpic); } else if (GTD5RadioButton.isSelected() && (lpic.startsWith(" ")) ) { ResultField.setText("BEGI SRVC\n\nCHAN DN "+nxx+xxxx+" CID "+pic); } else if (GTD5RadioButton.isSelected()) { ResultField.setText("BEGI SRVC\n\nCHAN DN "+nxx+xxxx+" CID "+pic+" ICID "+lpic); } else if (DMS10RadioButton.isSelected() && (pic.startsWith(" ")) ) { ResultField.setText("OVLY DN\n\nADO STN "+nxx+xxxx+" PRES2 "+lpic); } else if (DMS10RadioButton.isSelected() && (lpic.startsWith(" ")) ) { ResultField.setText("OVLY DN\n\nADO STN "+nxx+xxxx+" PRES "+pic); } else if (DMS10RadioButton.isSelected()) { ResultField.setText("OVLY DN\n\nADO STN "+nxx+xxxx+" PRES "+pic+" PRES2 "+lpic); } else if (DMS100RadioButton.isSelected() && (pic.startsWith(" ")) ) { ResultField.setText("SERVORD\n\nCHF $ "+nxx+xxxx+" LPIC "+lpic+" Y $ Y"); } else if (DMS100RadioButton.isSelected() && (lpic.startsWith(" ")) ) { ResultField.setText("SERVORD\n\nCHF $ "+nxx+xxxx+" PIC "+pic+" Y $ Y"); } else if (DMS100RadioButton.isSelected()) { ResultField.setText("SERVORD\n\nCHF $ "+nxx+xxxx+" PIC "+pic+" Y LPIC "+lpic+" Y $ Y"); } else if (ESSRadioButton.isSelected() && (pic.startsWith(" ")) ) { ResultField.setText("RCV:APPTEXT:DATA,FORM=1V6&CHG,TN="+tn+",PTC="+lpic+",CHG!"); } else if (ESSRadioButton.isSelected() && (lpic.startsWith(" ")) ) { ResultField.setText("RCV:APPTEXT:DATA,FORM=1V6&CHG,TN="+tn+",PIC="+pic+",CHG!"); } else if (ESSRadioButton.isSelected()) { ResultField.setText("RCV:APPTEXT:DATA,FORM=1V6&CHG,TN="+tn+",PIC="+pic+",PTC="+lpic+",CHG!"); } else if (DCORadioButton.isSelected() && (pic.startsWith(" ")) ) { ResultField.setText("$ADMIN LINE\n\nCH DN "+nxx+xxxx+" 0+INTER "+lpic+" 1+INTER "+lpic+" DO"); } else if (DCORadioButton.isSelected() && (lpic.startsWith(" ")) ) { ResultField.setText("$ADMIN LINE\n\nCH DN "+nxx+xxxx+" 0+INTRA "+pic+" 1+INTRA "+pic+" DO"); } else if (DCORadioButton.isSelected()) { ResultField.setText("$ADMIN LINE\n\nCH DN "+nxx+xxxx+" 0+INTRA "+pic+" 1+INTRA "+pic+ " 0+INTER "+lpic+" 1+INTER "+lpic+" DO"); } else { ResultField.setText("Something went wrong with your TN."); } } private void ClearButtonActionPerformed(java.awt.event.ActionEvent evt) { TNField.setValue(""); //AED TAB FIELDS COEField.setValue(""); OriginatingTNField.setValue(""); //TN/COE CHANGE TAB FIELDS OriginatingCOEField.setValue(""); NewTNField.setValue(""); NewCOEField.setValue(""); FeatureTNField.setValue(""); //FEATURE CHANGE TAB FIELDS PICField.setValue(""); LPICField.setValue(""); } private void ClearButtonActionPerformed1(java.awt.event.ActionEvent evt) { } private void ClearCodeButtonActionPerformed(java.awt.event.ActionEvent evt) { ResultField.setText(""); } private void ClearCodeButtonActionPerformed1(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void SearchButtonActionPerformed(java.awt.event.ActionEvent evt) { try { String findtn = ResultField.getText(); // Get text from result field for scanning // String findtn = ("fnuef483/3764537..fiybybybvyeuby44testuneincui");
VIEWS ON THIS POST

122

Posted on:

Saturday 29th September 2012
View Replies!

some event in swing which is similar to mouse events, sensed throu touch screen

hi, Actually i am using the touch screen in my application, front end. But the problem is ,on particular button i have added the event, mouse pressed and mouse released. ie. in state of mouse pressed some task is performed and ,on release of mouse some other task gets executed. all the task takes place when operations are performed throu mouse, but while using fingers on touch screen, task don't get perform . So please let me know any event which could work similar to mouse press and mouse release on touch screen.
VIEWS ON THIS POST

88

Posted on:

Monday 1st October 2012
View Replies!

Changes which we made in JTree are not reflecting in our file

Hi Friends, I'm a newbie in Java and we are creating one application where we fetch the data from the file and created the tree structure (JTree) and we are able to change the data in JTree but the changes which we made in JTree are not reflecting in our file. Please help me out with this how to push back the data to the same file with changes we made in JTree.
VIEWS ON THIS POST

61

Posted on:

Monday 1st October 2012
View Replies!

isSelected not recognizing which radiobutton is selected.

My program needs to determine to rate to apply for the movie tickets based on the radiobuttons. No matter the radiobutton selected it always uses the senior rate, any ideas //import packages import java.util.*; import javax.swing.*; import javax.swing.border.*; import java.awt.*; import java.awt.event.*; import java.text.NumberFormat; public class EncoreMoviesMenuValidationApp { public static void main(String[] args) { JFrame frame = new EncoreFrame(); frame.setVisible(true); }//end main() }//end EncoreMoviesMenuValidationApp class class EncoreFrame extends JFrame { public EncoreFrame() { setTitle("Encore Movies"); setSize(325, 450); setLocationRelativeTo(null); setResizable(false); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); JPanel panel = new EncorePanel(this); add(panel); }//end of EncoreFrame() constructor }//end of EncoreFrame class EncorePanel extends JPanel implements ActionListener { //Declare variables private JLabel movieNameLabel; private JRadioButton child, adult, senior, empty; private JMenuBar menuBar; private JMenu menuFile, menuHelp; private JMenuItem menuFileCommands,menuFileExit,menuFileCommandsReset, menuFileCommandsCalculate, menuHelpAbout; private JButton calculateButton, resetButton, ExitButton; private JComboBox movieNameComboBox, ticketsComboBox; private JCheckBox Matinee; private JTextArea output; String[] movies = {"","The Fighter","127 Hours","Restrepo","The King's Speech"}; //passing in frame so that you can set the JMenuBar public EncorePanel(JFrame frame) { //construct menubar menuBar = new JMenuBar(); //construct the menus menuFile = new JMenu("File"); menuFile.setMnemonic(KeyEvent.VK_F); menuHelp = new JMenu("Help"); menuHelp.setMnemonic(KeyEvent.VK_H); //add menu to the menuBar menuBar.add(menuFile); menuBar.add(menuHelp); //create and show submenus menuFileCommands = new JMenu("Commands"); menuFileExit = new JMenuItem("Exit"); menuFileExit.setMnemonic(KeyEvent.VK_X); menuFileExit.setAccelerator(KeyStroke.getKeyStroke("ctrl Q")); menuFileExit.addActionListener(this); menuFileCommandsCalculate = new JMenuItem("Calculate"); menuFileCommandsCalculate.setAccelerator(KeyStroke.getKeyStroke("ctrl L")); menuFileCommandsCalculate.addActionListener(this); menuFileCommandsReset = new JMenuItem("Reset"); menuFileCommandsReset.setAccelerator(KeyStroke.getKeyStroke("ctrl R")); menuFileCommandsReset.addActionListener(this); menuHelpAbout = new JMenuItem("About"); menuHelpAbout.setMnemonic(KeyEvent.VK_A); menuHelpAbout.setAccelerator(KeyStroke.getKeyStroke("F1")); menuHelpAbout.addActionListener(this); menuFile.add(menuFileCommands); menuFileCommands.add(menuFileCommandsCalculate); menuFileCommands.add(menuFileCommandsReset); //add file and help menus menuFile.add(menuFileExit); menuHelp.add(menuHelpAbout); //add menuBar to the frame frame.setJMenuBar(menuBar); //declare JPanels JPanel containerPane = new JPanel(); JPanel movieNamePanel = new JPanel(); JPanel ticketPanel = new JPanel(); JPanel displayPanelRadio = new JPanel(); JPanel outputPanel = new JPanel(); JPanel buttonPanel = new JPanel(); //Set panel layout movieNamePanel.setLayout(new FlowLayout(FlowLayout.LEFT)); ticketPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); displayPanelRadio.setLayout(new FlowLayout(FlowLayout.CENTER)); outputPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); containerPane.setLayout(new BoxLayout(containerPane, BoxLayout.PAGE_AXIS)); //create and label combobox JLabel movieNameLabel = new JLabel("Movie Name: "); movieNameComboBox = new JComboBox(movies); movieNamePanel.add(movieNameLabel); movieNamePanel.add(movieNameComboBox); //declare radiobuttons child = new JRadioButton("Child", false); adult = new JRadioButton("Adult", false); senior = new JRadioButton("Senior", false); empty = new JRadioButton("",true); empty.setVisible(false); ButtonGroup radioGroup = new ButtonGroup(); //add radiobuttons to group radioGroup.add(child); radioGroup.add(adult); radioGroup.add(senior); radioGroup.add(empty); //add buttons to panel displayPanelRadio.add(child); displayPanelRadio.add(adult); displayPanelRadio.add(senior); //create border around radiobuttons Border etchedBdr = BorderFactory.createEtchedBorder(); Border titledBdr = BorderFactory.createTitledBorder(etchedBdr, "Ticket Type"); Border emptyBdr = BorderFactory.createEmptyBorder(10, 10, 10, 10); Border compoundBdr=BorderFactory.createCompoundBorder(titledBdr, emptyBdr); displayPanelRadio.setBorder(compoundBdr); //create tickets string String[] tickets = {"","1","2","3","4","5","6","7","8","9","10"}; //construct ticket combobox, and matinee checkbox JLabel numberOfTicketsLabel = new JLabel("Number of Tickets: "); ticketsComboBox = new JComboBox(tickets); Matinee = new JCheckBox("Matinee"); ticketPanel.add(numberOfTicketsLabel); ticketPanel.add(ticketsComboBox); ticketPanel.add(Matinee); //textarea output declaration and add to outputPanel output = new JTextArea(11,25); outputPanel.add(output); output.setBorder(BorderFactory.createEtchedBorder()); output.setEditable(false); output.setFocusable(false); //construct JButtons calculateButton = new JButton("Calculate Price"); resetButton = new JButton("Reset"); ExitButton = new JButton("Exit"); //addActionListener to 3 buttons in buttonPanel calculateButton.addActionListener(this); resetButton.addActionListener(this); ExitButton.addActionListener(this); //add buttons and panels buttonPanel.add(calculateButton); buttonPanel.add(resetButton); buttonPanel.add(ExitButton); containerPane.add(movieNamePanel); containerPane.add(displayPanelRadio); containerPane.add(ticketPanel); containerPane.add(outputPanel); containerPane.add(buttonPanel); add(containerPane); }//end of encorePanel constructor //Determine date for about message Date now = new Date(); public void actionPerformed(ActionEvent e) { Object source = e.getSource(); boolean validData = true; //calculate buttons if(source == calculateButton || source == menuFileCommandsCalculate ) { double cost = 0.0; String type = ""; //check to make sure form is filled out correctly try { if(movieNameComboBox.getSelectedIndex() == 0) { JOptionPane.showMessageDialog(null, "Please select a Movie.", "Error", JOptionPane.ERROR_MESSAGE); movieNameComboBox.requestFocus(); validData = false; }//end movie if else if(empty.isSelected()) { JOptionPane.showMessageDialog(null, "Please select a Ticket Type.", "Error", JOptionPane.ERROR_MESSAGE); empty.requestFocus(); validData = false; }//end movie if else if(ticketsComboBox.getSelectedIndex() == 0) { JOptionPane.showMessageDialog( null, "Please select the number of tickets you wish to purchase.", "Error", JOptionPane.ERROR_MESSAGE); ticketsComboBox.requestFocus(); validData = false; } //if statement for matinee prices if(Matinee.isSelected()) { if(child.isSelected()) { cost = Double.parseDouble((String)ticketsComboBox.getSelectedItem()) * 2.5; type = child.getText(); } else if(adult.isSelected()) { cost = Double.parseDouble((String)ticketsComboBox.getSelectedItem()) * 5; type = adult.getText(); } else if(senior.isSelected()); { cost = Double.parseDouble((String)ticketsComboBox.getSelectedItem()) * 3; type = senior.getText(); } }//end of if statements //normal price calculations else { if(child.isSelected()) { cost = Double.parseDouble((String)ticketsComboBox.getSelectedItem()) * 5; type = child.getText(); } else if(adult.isSelected()) { cost = Double.parseDouble((String)ticketsComboBox.getSelectedItem()) * 7.5; type = adult.getText(); } else if(senior.isSelected()); { cost = Double.parseDouble((String)ticketsComboBox.getSelectedItem()) * 6; type = senior.getText(); } }//end else //currency output and change calculatebutton text NumberFormat currency = NumberFormat.getCurrencyInstance(); calculateButton.setText("Additional Tickets"); output.append((String)ticketsComboBox.getSelectedItem() + " " + type + " tickets for " + (String)movieNameComboBox.getSelectedItem() + " will cost " + currency.format(cost) + ".\n" ); }//end try catch(NumberFormatException err) { }//end catch }//end if //set form to beginning look when reset is pressed else if(source == resetButton || source == menuFileCommandsReset) { movieNameComboBox.setSelectedIndex(0); empty.setSelected(true); ticketsComboBox.setSelectedIndex(0); output.setText(null); calculateButton.setText("Calculate Price"); Matinee.setSelected(false); } //code exit buttons, ask if user wants to exit else if(source == ExitButton || source == menuFileExit) { if (JOptionPane.showConfirmDialog(null, "Are you sure you want to exit", "Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) { System.exit(0); }//end if JOptionPane }//end else if exitButton else if(source == menuHelpAbout) { JOptionPane.showMessageDialog( null, "Brennan Wilde\n" + now + "\nCMIS230-092", "About Encore Movies", JOptionPane.INFORMATION_MESSAGE); }//end elseif About }//and of actionPerformed(); }// end of EncorePanel class
VIEWS ON THIS POST

43

Posted on:

Wednesday 17th October 2012
View Replies!

Dragging ftp-link to windows explorer - which dataflavor?

I need to drag a file link (ftp://localhost/foo.zip) to the windows explorer, making it download the file. I'm using: new DataFlavor("text/uri-list;class=java.lang.String");
VIEWS ON THIS POST

108

Posted on:

Wednesday 17th October 2012
View Replies!

PropertyChangeListener - FocusListener - which one do I use

Dear Ranchers, I have two questions. They are related I think , but I am not sure so I put the other question as a separate topic I have an application which can open and save files. However, when I open up a second file in a new Window and even if I click on the first Window it is only the second file that is saved. How do I make sure the right file is saved. Kind regards, Kieran
VIEWS ON THIS POST

47

Posted on:

Wednesday 17th October 2012
View Replies!

General design question

Might be a stupid question but... I've build a few sortable test table applets for a page that I am programming. The tables are rather long-about 500 lines of code because they are sortable. The tables seem to be doing everything I want. Now I have built the rest of the page and I am thinking that it might be best to tweak the table applets into a class that has a function which will return the sortable tables. The I should only have to instantiate the class and add the tables to the main page. I wanted to do this for readability sake. Is this a good idea
VIEWS ON THIS POST

67

Posted on:

Thursday 18th October 2012
View Replies!

How to separate the design from event handling in swing

Hi , I am using eclipse with windows builder plugin to develop my desktop application. The plugin used is generating the entire code into a single java file for gui.Now, I want to have the separate file for event handling. For example, Lets say we have one button and one textfield (code generated in file-Main.java),on click of button, the textfield should be filled with "" . For that we need to add actionListener to button and need to create an anonymous class and add method actionPerformed(),I want to have this class implementing ActionListener in separate java file(to separate the code we need to have the reference of the button and textfield in event handling class).How to get that reference.
VIEWS ON THIS POST

44

Posted on:

Sunday 21st October 2012
View Replies!

Reacting to events outside of the class in which an event occurs

Hi I'm trying to understand how to structure a simple application. It seems it must be a really common scenario but so far I can't work it out. Lets say I have a class A with the main method. My expectation is that it will co-ordinate activities. The application has a JFrame with several panels in it, each with some GUI control. Each of these panels will be a class, say named B1, B2 B3... etc. Each class B has a listener for the control that is shown on its panel. Question: How do I make the main class A aware when events have occurred in the panel classes B1, B2 etc. I can think of three approaches, none of which seems that attractive: a) I have a get method in each B class relating to some class field affected by the GUI. This method would then be called periodically from A to determine if an event has been handled. This seems to be a really poor solution, one comparable to not using event listeners at all in the B classes. b) making each B class inherit a property that i) is altered by the GUI component's action listener in that B class and ii) can itself be listened to by the A class. This seems to be quite an elegant solution, except I have found no reference to it (in this terminology) in any of the documentation that I have read. c) Start again with a different architecture completely and put all listeners in class A, together with their panels and GUI controls. This seems to be a poor solution not taking advantage of any properties of object orientation. So, I'm sure I have missed something simple, I just can't see where to go from here. Any clues
VIEWS ON THIS POST

44

Posted on:

Monday 22nd October 2012
View Replies!

Apply CheckBox in Each Node in a JTree which fetches system file(JCheckbox and Jtree)

Hi , I have the requirement like this. I have to fetch syatem files and have to choose files and folders accordingly. I have made a program which fetches the system files. I have to put checkboxes beside each and every files and folders. I am giving the code ..Please see any body can help.. Any help will be greatly appreciated..
VIEWS ON THIS POST

52

Posted on:

Monday 22nd October 2012
View Replies!

How to get this attached design using Layout Managers - sans GroupLayout

Hi I would like to get the attached swing layout but I'm unable to. I was trying the below code. JLabel imglabel; JTextArea imgarea; JButton imgload; ImageIcon myimage; ImageD(String s) { setTitle(s); setSize(800,800); setLayout(new BorderLayout()); imgload = new JButton("Load ImG"); imgload.setMaximumSize(new Dimension(10,20)); imgload.addActionListener(this); imglabel = new JLabel(); imgarea = new JTextArea("uneditable",40,50); imgarea.setEditable(false); add(imgload, BorderLayout.NORTH); add(imglabel, BorderLayout.EAST); add(imgarea, BorderLayout.SOUTH); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); }
VIEWS ON THIS POST

34

Posted on:

Monday 22nd October 2012
View Replies!

How to know which button being clicked?

I also post my problem in dreamincode.net and stackoverflow but haven't get my problem solved. I'm trying to make N x N grid of JButton with one JTextField in the below where we can input character there then clicked on any of the white button to make the input show up on the button that being clicked. Is there a way to make it like that ( to make it recognize which button being clicked and get the input show up on it) Thank's... Because what i have achieved now is any button i clicked, the input will show in the last button being created not in the button that being clicked. import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Lat1 extends JFrame implements ActionListener { final int ROWS = 12; final int COLS = 12; final static int topLeftNum[][]= { {-1, 1, 0, 2, 0, 0, 3, -1, 4, 0, 5, 0}, {6, 0, 0, 0, -1, -1, 0, -1, -1, -1, 0, -1}, {-1, 0, -1, 0, -1, 7, 0, 0, 8, -1, 0, -1}, {9, 0, 0, 0, 10, -1, -1, -1, 11, 0, 0, -1}, {0, -1, -1, 12, 0, 0, 13, -1, 0, -1, -1, -1}, {0, -1, 14, -1, 0, -1, 0, -1, 15, 0, 0, 16}, {17, 0, 0, 18, 0, -1, 19, 20, 0, -1, -1, 0}, {0, -1, 0, 0, -1, 21, 0, 0, 0, -1, -1, 0}, {22, 23, 0, 0, -1, 0, -1, 0, -1,24, 0, 0}, {-1, 0, -1, 25, 0, 0, -1, 0, -1, 0, -1, -1}, {26, 0, 0, -1, -1, 0, -1, 27, 0, 0, 0, -1}, {-1, -1, -1, -1, -1, 0, -1, 0, -1, 0, -1, -1} }; Box b; JTextField t; char answer; public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run(){ new Lat1(); } }); } /*--------------------------------------------------------*/ public Lat1() { this.setSize(1000,1000); this.setVisible(true); JPanel p1 = new JPanel(); p1.setLayout(new GridLayout(ROWS,COLS)); for (int j=0; j
VIEWS ON THIS POST

38

Posted on:

Monday 22nd October 2012
View Replies!

which layouts to chose ( begging stuff )?

hello all im new to swing and gui programming and im trying to get as much information and tips as i can for example , if i like to build my application as : tree in the right panel in the right and footer and header , also i like that the window vertical border between the tree and the panel will be resistible . what i choose what layers should i adopt
VIEWS ON THIS POST

34

Posted on:

Monday 22nd October 2012
View Replies!