Scroll panel problems


I am having alot of problems getting this scroll panel to work. Specifically I have the [panel on my GUI, but I cant figure out how to get the text area to populate it. Can someone please tell me what I a,m doing wrong here.

These are the code portions that pertain to the scroll panel only.

private JTextArea jtextarea1;//define textarea private JScrollPane scrollpane1;
Posted On: Wednesday 17th of October 2012 06:14:45 AM Total Views:  198
View Complete with Replies

RELATED TOPICS OF Swing / AWT / SWT PROGRAMMING LANGUAGE




SWT Canvas.scroll() removing invisible controls

I observed that while scrolling with scrollbars SWT Canvas removes the control which is not in the visible area. //horizontal scroll canvas.scroll(calculatedDistanceX , 0, 0, 0, screen.getSize().x,screen.getSize().y , true );
VIEWS ON THIS POST

121

Posted on:

Friday 21st September 2012
View Replies!

JTextArea disable scroll on select all

Every time I select all (Ctrl+A) text on a text area, it scrolls to the bottom. Is there anyway to maintain the position or the visible rectangle while still selecting all the contents
VIEWS ON THIS POST

91

Posted on:

Saturday 22nd September 2012
View Replies!

How do I add text to a scrollable JTextPane without scrolling the JScrollPane?

I am using a JTextPane within a JScrollPane to display more text than the area provides. The controls live on a custom JDialog box and everything is fully initialized in the dialog's constructor. The scroll bars work and allow me to scroll around and view all of the text, but the problem is that the scrollbar is initialized at the lowest position. In other words, when my dialog appears the text field is scrolled down and displays the bottom of the block of text instead of the top. The first thing I tried to do was set the vertical scrollbar's value to 0 after setting up the dialog, but the request is ignored. I thought this might be the result of the dialog being resized with "pack()" so I called this after pack() and it is still ignored. As far as I can tell something happens after the dialog's constructor that changes this setting and wipes out mind, but I don't know what it is. // This is the code I call to move the scrollbar: scrollPane.getVerticalScrollBar().setValue(0);
VIEWS ON THIS POST

149

Posted on:

Saturday 22nd September 2012
View Replies!

How to make scrolling area bigger. i.e. increase window size?

I know that you use either the JPanel revalidate() or the JScrollPane revalidate(). Which one I don't know. However, I did both and still it's not resizing. I know that there's some other line of code I needed but can't recall what it was. I thought it might be the JFrame pack() method, but that didn't do it either.
VIEWS ON THIS POST

238

Posted on:

Saturday 22nd September 2012
View Replies!

increase size of scrollpane at run time

hi, How can i increase size of scrollpane at run time i have try scrollpane.setMaximumSize(new Dimension(nw,nh)); but its not working for me....
VIEWS ON THIS POST

155

Posted on:

Saturday 22nd September 2012
View Replies!

resizable Canvas or panel in scrollpane

Hi , I want to create java applet having Canvas or Panel. Now when i start entering data using drawstring(), height of Canvas or Panel should increase dynamically and scroll bar should be visible. How can I implement such applet Please let me know even this can be achieved by using control other then Canvas or Panel. Thank you in advance. [Note: Cross-posted at http://stackoverflow.com/questions/11207552/resizable-canvas-or-panel-in-scrollpane ].
VIEWS ON THIS POST

69

Posted on:

Saturday 22nd September 2012
View Replies!

scrollPane.getHorizontalScrollBar().setValue Problem

hi, i want setValue to the end of the scrollBar. but fail. here is the code, result is picture1 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 300); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.X_AXIS)); scrollPane = new JScrollPane(); contentPane.add(scrollPane); table = new JTable(); table.setModel(new DefaultTableModel(6,72)); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); scrollPane.setViewportView(table); // here scrollPane.getHorizontalScrollBar().setValue(scrollPane.getHorizontalScrollBar().getMaximum());
VIEWS ON THIS POST

174

Posted on:

Monday 24th September 2012
View Replies!

gridlayout not working with custom jpanel and jscrollpane; my jpanels get cut off

I'm trying to add my own implementation of jpanel to another jpanel, in a scrollpane, so that as it adds more it will make a list of them down the screen. Unfortunately I can't seem to put space between my jpanels; when I set the second two gridlayout parameters, parts of them get cut off (so that they appear shorter vertically). Any idea why this is happening or how to get around it (called from a method in a jframe class) miniPanel = new JPanel(); miniPanel.setLayout(new java.awt.GridLayout(100, 4,0,60)); for(int i=0;i
VIEWS ON THIS POST

285

Posted on:

Tuesday 25th September 2012
View Replies!

Getting the TwoButtons to add the gradient circle to the panel

Thank you, that did the trick... Java Greenhorn needs help, I created this based on some other code I found when I searched for TwoButtons in some of the forums. It compiles OK and does not throw any exceptions a run time, but does not draw a gradient circle either. Line 21 & 24 is not working, I'm obviously missing something. Can some one please give me some guidence, please other than my issue I like this code better than the Head First Java book example with inner classes... ------ TwoButtons.java ------- 1 import java.awt.*; 2 import java.awt.event.*; 3 import javax.swing.*; 4 public class TwoButtons extends JFrame implements ActionListener 5 { 6 JButton colorButton ; 7 JButton labelButton ; 8 JLabel label; 9 String x = "flip"; 10 11 // constructor for TwoButtons 12 public TwoButtons() 13 { 14 colorButton = new JButton("Change Circle Color"); 15 labelButton = new JButton("Change Label Text"); 16 17 colorButton.setActionCommand( "circle" ); // set the command 18 labelButton.setActionCommand( "label" ); // set the command 19 label = new JLabel("I'm a Label"); 20 label.setPreferredSize(new Dimension(100, 70)); 21 MyCircleG drawcircle = new MyCircleG(); 22 23 getContentPane().setLayout( new FlowLayout() ); 24 getContentPane().add( drawcircle ); 25 getContentPane().add( labelButton ); 26 getContentPane().add( label ); 27 getContentPane().add( colorButton ); 28 // register the buttonDemo frame 29 // as the listener for both Buttons. 30 colorButton.addActionListener( this ); 31 labelButton.addActionListener( this ); 32 //getContentPane().setBackground( Color.yellow ); 33 } 34 public void actionPerformed( ActionEvent evt) 35 { 36 // check which command has been sent 37 if ( evt.getActionCommand().equals( "circle" ) ) { 38 // getContentPane().setBackground( Color.red ); 39 repaint(); } 40 if ( evt.getActionCommand().equals( "label" ) ) { 41 if (x == "flip") { 42 label.setText("Label Changed!"); 43 x = "flop"; 44 }else { 45 x = "flip"; 46 label.setText("I'm a Label"); 47 } } 48 } 49 public static void main ( String[] args ) 50 { 51 TwoButtons demo = new TwoButtons() ; 52 WindowQuitter wquit = new WindowQuitter(); 53 demo.addWindowListener( wquit ); 54 demo.setSize( 500, 500 ); 55 demo.setVisible( true ); 56 } 57 } 58 class WindowQuitter extends WindowAdapter 59 { 60 public void windowClosing( WindowEvent e ) 61 { 62 System.exit( 0 ); 63 } 64 } -------- MyCircleG.java ------ 1 import java.awt.*; 2 import javax.swing.*; 3 4 class MyCircleG extends JPanel { 5 6 public void paintComponent(Graphics g) { 7 8 Graphics2D g2d = (Graphics2D) g; 9 10 int red = (int) (Math.random() * 256); 11 int green = (int) (Math.random() * 256); 12 int blue = (int) (Math.random() * 256); 13 Color startColor = new Color(red, green, blue); 14 15 red = (int) (Math.random() * 256); 16 green = (int) (Math.random() * 256); 17 blue = (int) (Math.random() * 256); 18 Color endColor = new Color(red, green, blue); 19 20 GradientPaint gradient= new GradientPaint(70,70,startColor, 150, 150, endColor); 21 g2d.setPaint(gradient); 22 g2d.fillOval(70,70,100,100); 23 24 } // End method 25 26 } // End class
VIEWS ON THIS POST

80

Posted on:

Wednesday 26th September 2012
View Replies!

JTooltip with a vertical scrollbar?

I have a JTextField that listens to mouseevents and fetches information from a database and displays it nicely in a JToolTip (By using html). The problem is this: If I have many entries comming back from the database the tootip keeps going outside the screen. I would like it to add a scrollbar (similar to IntelliJ's ctrl+Q feature) so the user can scroll throught the entries.... Could be that I am using the wrong technique here... Any suggestions
VIEWS ON THIS POST

69

Posted on:

Wednesday 26th September 2012
View Replies!

Want to add Horizontal and vertical scroll bar in my code

Here is my code : /* * To change this template, choose Tools | Templates * and open the template in the editor. */ //package prina_tiger; /** * * @author Parth * long start = System.currentTimeMillis(); long end = start + 60*1000; // 60 seconds * 1000 ms/sec while (System.currentTimeMillis() < end) { // run } */ import java.applet.*; import java.awt.*; import java.awt.event.*; import java.applet.Applet; import java.awt.Button; import java.awt.Color; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.*; import java.util.StringTokenizer; /** * Example applet which uses hexagonal grid. It's a hexagonal version of the * "lights out" puzzle game: http://en.wikipedia.org/wiki/Lights_Out_(game) */ public class HexLightsOut extends Applet implements ActionListener { Button okButton; Graphics g; @Override public void init() { okButton = new Button("Start"); okButton.setActionCommand("start"); g = this.getGraphics(); okButton.addActionListener(this); // add the button to the layout add(okButton); } public void actionPerformed(ActionEvent e) { try { if (e.getActionCommand().equalsIgnoreCase("start")) { String file_veh = "vehicle.txt"; String[][] flow_ids = null; String line_veh = ""; int line_cnt = 0, i = 0; BufferedReader br_veh = new BufferedReader(new FileReader(file_veh)); while ((line_veh = br_veh.readLine()) != null) { line_cnt++; } flow_ids = new String[line_cnt][2]; br_veh = new BufferedReader(new FileReader(file_veh)); while ((line_veh = br_veh.readLine()) != null) { flow_ids[i][0] = line_veh; flow_ids[i][1] = null; i++; } DrawHexagon drawHexagon = new DrawHexagon(g, flow_ids); new Thread(drawHexagon).start(); } } catch (Exception ex) { ex.printStackTrace(); } } @Override public void paint(Graphics g) { try { } catch (Exception e) { e.printStackTrace(); } } } class DrawHexagon implements Runnable { Graphics g; long serialVersionUID = 1L; int BOARD_WIDTH = 5; int BOARD_HEIGHT = 4; int L_ON = 1; int L_OFF = 2; int NUM_HEX_CORNERS = 6; int CELL_RADIUS = 60; int[][] mCells = {{0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}}; int[][] mCellsCnt = {{0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0}}; int[] mCornersX = new int[NUM_HEX_CORNERS]; int[] mCornersY = new int[NUM_HEX_CORNERS]; HexGridCell mCellMetrics = new HexGridCell(CELL_RADIUS); String[][] flow_ids = null; DrawHexagon(Graphics g, String[][] flow_ids) { this.g = g; this.flow_ids = flow_ids; } public void plotHex() { for (int j = 0; j < mCellsCnt.length; j++) { for (int i = 0; i < mCellsCnt[j].length; i++) { mCellsCnt[j][i] = 0; } } for (int j = 0; j < mCells.length; j++) { for (int i = 0; i < mCells[0].length; i++) { mCellMetrics.setCellIndex(i, j); mCellMetrics.computeCorners(mCornersX, mCornersY); g.setColor((mCells[j][i] == L_ON) Color.ORANGE : Color.GRAY); g.fillPolygon(mCornersX, mCornersY, NUM_HEX_CORNERS); g.setColor(Color.BLACK); g.drawPolygon(mCornersX, mCornersY, NUM_HEX_CORNERS); } } } public void StartProcedure() { try { plotHex(); BufferedReader br = new BufferedReader(new FileReader("out.txt")); String strLine = "", vechId = "", hexID = "", hexChgMsg = "", LogStr = ""; String timestep = "", x = "", y = "", co_or = ""; int[] x_curr, y_curr = null; int cnt = 0; StringTokenizer st_line, st_coor, main_token; int loop = 0; while ((strLine = br.readLine()) != null) { LogStr = ""; plotHex(); //ploting hexagons again /* Some programming part based value I draw points and lines in applet */ } System.out.println("DONE"); } catch (Exception e) { e.printStackTrace(); } } public void run() { StartProcedure(); } }
VIEWS ON THIS POST

92

Posted on:

Wednesday 26th September 2012
View Replies!

Getting scrollbars to scroll

I figured out how to setup scroll bars so that they appear on the proper components. I have a frame that the scrollpane is being added to that is 500x500. My panel that is the component for the scrollpane is an image that is 640x640. When i run my program, it makes the image in a 500x500 frame and generates the image at its 640x640. It adds in the scrollbars, but they dont do anything. What piece of this puzzle am i missing
VIEWS ON THIS POST

92

Posted on:

Saturday 29th 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

129

Posted on:

Saturday 29th September 2012
View Replies!

problem in setting background image of jpanel

i m not able to set a background image of my JPanel, can anyone tell me how do i set JPanel Background image\t here is my code, in which i m setting the background color of my JPanel but i want to set an image instead: import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.Random; class Test { public static void main(String args[]) { JFrame frame = new JFrame(); Cpoint point = new Cpoint(); Cdynamic d = new Cdynamic(point); Cair ca= new Cair(); d.panel.setBackground(Color.ORANGE); point.setBackground(new Color(0,0,255)); JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, d.panel, point); Container c = frame.getContentPane(); c.add(sp, BorderLayout.CENTER); ca.setPreferredSize(new Dimension(200,0)); c.add(ca, BorderLayout.EAST); frame.setVisible(true); frame.setSize(1280,750); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } class Dynamic extends JPanel { JPanel panel; JButton button; JLabel label; Cpoint cp; Dynamic(Cpoint c) { cp = c; System.out.println("Inside Dynamic class"); panel = new JPanel(); panel.setBackground(Color.yellow); button = new JButton("Fish Die"); label = new JLabel("Label to test"); panel.add(button); panel.add(label); button.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ cp.fishAlive = false; if(cp.timer != null && cp.timer.isRunning()) { cp.timer.stop(); cp.repaint(); } } }); } } class Cpoint extends JPanel implements ActionListener{ Cfish1 ball,ball2,ball3,ball4,ball5,ball6; Cbubble1 bull,bull2,bull3,bull4,bull5,bull6,bull7,bull8,bull9,bull10; int newx, newy, midx,midy,getradius, newwidth, newheight; Timer timer; int count; boolean fishAlive = true; int counter = 0; Cpoint() { timer = new Timer(26, this); timer.start(); ball = new Cfish1(500,100, new ImageIcon("g:\\fish\\fish1.jpg").getImage()); bull = new Cbubble1(20,400); } public void paintComponent(Graphics g) { super.paintComponent(g); if(fishAlive) { ball.DisplayFish(g); bull.DisplayBubble(g); } } public void actionPerformed(ActionEvent e) { ball.movementFish(this); bull.movement_bubble(this); try { repaint(); } catch (Exception ex) { ex.printStackTrace(); } System.out.println("timer "+(counter++)); } } class Cfish1 { int x = 2; int y = 5; int dx = 2; int dy = 1; int radius = 9; Image fishImg; public Cfish1() {} public Cfish1(int x, int y,Image img) { fishImg = img; this.x = x; this.y = y; radius = fishImg.getWidth(null)/2; } public int getRadius() { return radius; } public void movementFish(Cpoint sp) { if(x+dx>sp.getWidth()-radius-4) { x = sp.getWidth()-radius-2; dx = -dx; } else if(x+dxsp.getHeight()-radius-4) { y = sp.getHeight()-radius-4; dy = -dy; } else if(y+dysp.getHeight()-bulradius-4) { buly = sp.getHeight()-bulradius-4; bulradius++; if(bulradius==6) bulradius=1; } else if(buly+buldy
VIEWS ON THIS POST

225

Posted on:

Sunday 30th September 2012
View Replies!

Absolute layout on nested panel

I have a GUI in which I want absolute positioning within a subpanel. I'm using GridBagLayout elsewhere, including the parent. When I set the layout manager to null on a top level panel, everything works as I'm expecting. But, when trying to do the same on a subpanel, I get a blank panel (no visible controls). I've reduced this down to a code fragment (based on examples from the web) that can demonstrate this both ways by setting an (obviously named) boolean variable. Here's the code fragment: public static void addComponentsToContainer( JPanel panel ) { panel.setLayout( null ); JButton b1 = new JButton( "1" ); JButton b2 = new JButton( "2" ); JButton b3 = new JButton( "3" ); panel.add( b1 ); panel.add( b2 ); panel.add( b3 ); b1.setBounds( 10, 5, 60, 25 ); b2.setBounds( 30, 40, 60, 25 ); b3.setBounds( 50, 75, 60, 25 ); } public static void main( String[] args ) { JFrame frame = new JFrame(); JPanel parent = new JPanel(); JPanel panel = parent; boolean iWantItToFail = true; if ( iWantItToFail ) { JPanel child = new JPanel(); parent.add( child ); panel = child; } addComponentsToContainer( panel ); frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); frame.setContentPane( parent ); frame.setSize( 150, 150 ); frame.setVisible( true ); }
VIEWS ON THIS POST

75

Posted on:

Sunday 30th September 2012
View Replies!

how to add panel dynamically

I want to develop application like a goggle talk...after lo gin i want to display online members on my panel...so i have taken list of members and wants to display it on to panel...so i want add online people's information to another separate panel..In short i want to dynamically add panels to single panel...
VIEWS ON THIS POST

111

Posted on:

Monday 1st October 2012
View Replies!

scrollpane problem

i m making an editor, which has one panel , which inturn has labels which contains the line number and the editor is with frame the problem is when i reachs end of the line surely editor goes up (similar when you type at the end and scrollpane allows you to view the text at the bottom of your editor) my problem is line numbers label doesnt go in upward (though it is in scrollpane) for eg line number max goes to 35 then the screen finishes after that when i press enter editor scrolls down but this number panel doesnt scrolls down i guess this will give you a better idea...what is going wrong public class LineNumberOnEditor { /** * @param args the command line arguments */ private static JEditorPane editor; private JPanel panel; private JFrame frame; private int counter; private PrintWriter tempOut,htmlOut; private BufferedReader reader; private File tempFileLocation, htmlFileLocation; private JLabel numberLabel; private int lineNoInt = 0; private Integer lineNO = lineNoInt; private JPanel lineNumberPanel ; private JScrollPane scrollpane , lineNoScrollpane; private Font font ; public void startEditor() { frame = new JFrame("Editor"); panel = new JPanel(); editor = new JEditorPane(); editor.setPreferredSize(new Dimension(1350,850)); scrollpane = new JScrollPane(editor); numberLabel = new JLabel(lineNO.toString(),JLabel.RIGHT); settingCommonFont(); settingLineNo(); settingKeyAdapter(); numberLabel.setFont(font); editor.setFont(font); editor.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); frame.add(scrollpane,BorderLayout.CENTER); frame.add(lineNoScrollpane,BorderLayout.WEST); frame.pack(); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); } public static void main(String[] args) { // TODO code application logic here new LineNumberOnEditor().startEditor(); } private void settingKeyAdapter() { class KeyListener extends KeyAdapter { @Override public void keyPressed(KeyEvent e) { if(e.getKeyCode() == KeyEvent.VK_ENTER) { incrementingLNumber(); } } private void incrementingLNumber() { lineNoInt++; lineNO = lineNoInt; JLabel numberLabel = new JLabel(lineNO.toString()); lineNumberPanel.add(numberLabel); lineNumberPanel.updateUI(); numberLabel.setFont(font); System.out.println(lineNoInt); } } editor.addKeyListener(new KeyListener()); } private void settingLineNo() { lineNumberPanel = new JPanel(); lineNumberPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0)); lineNumberPanel.setPreferredSize(new Dimension(60,5)); BoxLayout box = new BoxLayout(lineNumberPanel, BoxLayout.Y_AXIS); lineNumberPanel.setLayout(box); lineNumberPanel.add(numberLabel); lineNoScrollpane = new JScrollPane(lineNumberPanel,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); } private void settingCommonFont() { font = new Font("Times New Roman",Font.BOLD,18); } }
VIEWS ON THIS POST

154

Posted on:

Wednesday 3rd October 2012
View Replies!

problem in erasing panel

hey i am new in java n getting this problem i want to create a program in which i am retrieving data from database and showing in gui frame but i want when submit pressed old frame's data should be get erased but instead of that it appends in that thank you for your help package javaapplication48; import java.awt.BorderLayout; import java.io.*; import java.sql.*; import javax.swing.*; import java.awt.event.*; public class JavaApplication48 implements ActionListener { private JFrame f1,f2; ResultSet rs; private JPanel p1,p2,p3,p4,p5; private JLabel l1,l2; private JRadioButton r1,r2,r3,r4; private JButton b1; public int id,i=1; private String ques,a,b,c,d,cor; Box b2=Box.createVerticalBox(); public JavaApplication48() { f1=new JFrame("eww"); f2=new JFrame("result"); b1=new JButton("Submit"); } public void launch() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:cone"); try { Statement st=con.createStatement(); String str="SELECT * FROM quizcontest where id="+i; rs=st.executeQuery(str); while(rs.next()) { id=rs.getInt("id"); ques=rs.getString("ques"); a=rs.getString("a"); b=rs.getString("b"); c=rs.getString("c"); d=rs.getString("d"); cor=rs.getString("cor"); } con.close(); } catch(SQLException e) { System.out.println("Table creation process denied");} } catch(Exception e) { e.printStackTrace(); } p1=new JPanel(); p2=new JPanel(); p3=new JPanel(); p4=new JPanel(); p5=new JPanel(); l1=new JLabel(ques); r1=new JRadioButton(a); r2=new JRadioButton(b); r3=new JRadioButton(c); r4=new JRadioButton(d); p1.add(l1); b2.add(p1); p2.add(r1); p2.add(r2); b2.add(p2); p3.add(r3); p3.add(r4); b2.add(p3); p4.add(b1); b2.add(p4); f1.add(b2,BorderLayout.CENTER); f1.setSize(400,400); //f1.pack(); f1.setVisible(true); b1.addActionListener(this); } // @Override public void actionPerformed(ActionEvent e) { f1.dispose(); i++; launch(); } public static void main(String[] args) { JavaApplication48 ob=new JavaApplication48(); ob.launch(); } }
VIEWS ON THIS POST

147

Posted on:

Wednesday 3rd October 2012
View Replies!

printing JTables - concatenating? what about the panels?

I am printing a JTable in this manner: StringBuffer sb = new StringBuffer(); PrintRequestAttributeSet attribs = new HashPrintRequestAttributeSet(); attribs.add(new Copies(1)); attribs.add(OrientationRequested.PORTRAIT); int xx = 1; //left and right margin int yy = 1; //top and bottom margin. Note that bottom margin cannot be less than 15 mm int ww = 845; //Width int hh = 599; //Height int units = MediaPrintableArea.MM; attribs.add(new MediaPrintableArea(xx, yy, ww, hh, units)); String title = "My Table"; sb.append(title); MessageFormat footer = new MessageFormat("Page {0}"); getPayrollHeadcountList().getTable().setPreferredSize(new Dimension(500, 500)); getPayrollHeadcountTotalList().getTable().setPreferredSize(new Dimension(500, 100)); try { getPayrollHeadcountList().getTable().print(PrintMode.FIT_WIDTH, header, footer, true, attribs, false); //getPayrollHeadcountTotalList().getTable().print(PrintMode.FIT_WIDTH, header, footer, true, attribs, false); } catch (PrinterException pe) { Debug.trace(pe); }
VIEWS ON THIS POST

546

Posted on:

Wednesday 17th October 2012
View Replies!

JScrollPane adding JPanels at the top and keeping current scroll view

I have a JScrollPane that contains a vertical Box. I'm inserting new JPanel's at the top of Box. If I use the scrollbar to scroll down I'd like for the current view to remain where I scrolled down to. For example, if I have 50 panels in the box and use the scrollbar to view panel 20, I'd like the view to remain on box 20 even though other boxes are added on top. Additionally, if I use the scrollbar to scroll back up to the top I'd like the view to display new panels as they are added. Any idea how to do this BTW, it isn't necessary to use a JScrollPane or a Box. The example code is just to help explain what I am trying to do. Example code: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TestScrollPane extends JFrame { JScrollPane scrollPane; Box box; private static int panelCount = 0; public TestScrollPane() { setPreferredSize(new Dimension(200, 400)); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); scrollPane = new JScrollPane(); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.getVerticalScrollBar().setUnitIncrement(15); box = Box.createVerticalBox(); scrollPane.getViewport().add(box); this.add(scrollPane); this.pack(); this.setLocationRelativeTo(null); this.setVisible(true); Timer t = new Timer(500, new ActionListener() { public void actionPerformed(ActionEvent ae) { box.add(new TestPanel(), 0); scrollPane.validate(); } }); t.setRepeats(true); t.start(); } public class TestPanel extends JPanel { int myId = panelCount++; public TestPanel() { this.setLayout(new GridBagLayout()); this.setBorder(BorderFactory.createBevelBorder(1)); JLabel label = new JLabel("" + myId); label.setHorizontalAlignment(JLabel.CENTER); label.setVerticalAlignment(JLabel.CENTER); this.setMaximumSize(new Dimension(100, 100)); this.setPreferredSize(new Dimension(100, 100)); this.add(label); } } public static void main(String[] args) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { TestScrollPane testScrollPane = new TestScrollPane(); } }); } }
VIEWS ON THIS POST

106

Posted on:

Wednesday 17th October 2012
View Replies!