JPanel vs. JComponent


I'm going to create a custom 'widget', and I was going to extend JPanel. The more I read though, the more I'm curious, what's the difference between JComponent and JPanel Is there any advantage to using JPanel or is it just convention

Posted On: Tuesday 23rd of October 2012 11:36:35 PM Total Views:  292
View Complete with Replies

RELATED TOPICS OF Swing / AWT / SWT PROGRAMMING LANGUAGE




easiest way to create & setting jpanels?

I am try to creating 21 jpanels with different ways... 1. drag & drop from eclipse windowsbuilder 21 times so each time its code like with settings also JPanel panel_example = new JPanel(); panel_example.setBackground(new Color(245, 245, 245)); panel_example.setFont(new Font("Trebuchet MS", Font.PLAIN, 12)); panel_example.setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); panel_example.setBounds(78, 68, 86, 82); panel_example.setLayout(new BorderLayout(0, 0));
VIEWS ON THIS POST

250

Posted on:

Saturday 22nd September 2012
View Replies!

arranging components in jpanel in a vertical manner...?

Hi , I'm just starting in java... or coming back to using it again... I'm not that good so I was wondering after reading on my old java book, how to arrange components such as labels and buttons in a panel in a vertical position, much like a webpage link panel on the left side where the user chooses which page he wants to go to... the default layout of a jpanel is a flowlayout I think and all the components I add to it just automatically arranges itself horizontally which is really far from what I want to do... Hope any help would be ok... it would be easier if it was html where I just add a in order to skip a line and then just add each separate link... is there some sort of absolute positioning for components in a panel or contentpane where I can use to store jlabels/jbuttons so I can arrange the components in a way that can be more user friendly...
VIEWS ON THIS POST

236

Posted on:

Saturday 22nd September 2012
View Replies!

jlabel.setbounds() in jpanel

, I m trying to work with the following code in order to change the location of jlabel at runtime , but when i minimize the frame, the jlabels get set back to their original positions . Could any one help please i have a frame , a jpanel on it and a jlable on jpanel which i want to position on mouse drag.
VIEWS ON THIS POST

156

Posted on:

Monday 24th September 2012
View Replies!

overlapping problem of jpanels

As i got reply from Wendy Gibbons in JDBC section's topic which i created worry about other considerations when you have the simplest version working. Here i try simplest version as per my thought. I make simple swing program (Just swing no jdbc or hibernate & db), Name simpleExample.java Contains 1 JFrame, Array of jpanels.(only 3 jpanels i create by array). Major code is here., but i modified it as i try in 2-3 days after last post in that question. If you want to see how it developed, 1. 3 questions regarding JPanel. Creation of problem:- When program runs 3 panels we can see, 0,1,2. If we drag & drop panel 0 on panel 2, it will locate beside it because code goes to check_overlap_panel(); & run for loop & check if condition & set as below. simpledm.comp_panel.setLocation(simpledm.comp_panel.getX()+25, simpledm.comp_panel.getY()+25); but when we drag & drop panel 1 on panel 2,it will do same for checking ovelaping against panel 2, & setlocation as per above quote,but it forget already that location occupy by panel 0. Problem panel 1 not try to cross check overlap against panel 0. If i increase myindex = any number, then it should be try to setlocation of panel as avoid overlap against another panel. I try my best & then post question...I also try sscce for code What i do:- Here i try to create 13 boolean flags to check many if-else conditions & for easiness i create 5 functions Conditions like 1. In check_resolutionboundries() function i check panel should not move beyond systems resolution, so if program run on any monitor which has any resolution, then it will run without trouble. This function i called in mousedragged event. 2. When program runs all integers are 0 so 1st condition is check integer against 0 in function check_int_zero(). 3. When function check_int_zero() calls in chek_flags(), to check probability of flags true & false. 4. check_overlap_panel() function contain code for checking panels overlap or not. private void check_overlap_panel() { for (Counter= 0; Counter < panels.length; Counter++) { if (simpledm.comp_panel.getBounds().intersects(simpleExample.panels[Counter].getBounds())) { if (Integer.parseInt(simpledm.comp_panel.getName()) != Integer.parseInt(panels[Counter].getName())) { Flag_over= false; }else { Flag_over = true; }}}}
VIEWS ON THIS POST

306

Posted on:

Monday 24th September 2012
View Replies!

Array of jpanels within JScrollPane

I try to create Array of jpanels within JScrollPane... I partially done same but instead of JScrollPane i created jpanel....you can see code here. Here i write simple code for JScrollPane import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.GraphicsEnvironment; import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.SwingUtilities; public class scp { static int Array_counter = 11; static int counter,j,k = 0; static JPanel[] panels = new JPanel[Array_counter]; static JLabel[] labels = new JLabel[Array_counter]; JFrame myframe = new JFrame(); sp bgp = new sp(); int sys_want_w, sys_want_h; Point locations; Point locations1; public void mygui() { GraphicsEnvironment env = GraphicsEnvironment .getLocalGraphicsEnvironment(); System.out.println(env.getMaximumWindowBounds()); sys_want_w = env.getMaximumWindowBounds().width; sys_want_h = env.getMaximumWindowBounds().height; JScrollPane myjScrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); myjScrollPane.setViewportBorder(BorderFactory.createLineBorder(Color.black, 1)); myframe.setSize(800, 600); myframe.setLocationRelativeTo(null); myframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); myframe.setVisible(true); myframe.setResizable(true); bgp.setLayout(null); bgp.setSize(new Dimension(364, 96)); bgp.setOpaque(true); bgp.setBorder(BorderFactory.createLineBorder(Color.black, 1)); Rectangle r1 = new Rectangle(myjScrollPane.getX(), myjScrollPane.getY(),myjScrollPane.getWidth(), myjScrollPane.getHeight()); bgp.setBounds(r1); myjScrollPane.add(bgp); myjScrollPane.computeVisibleRect(r1); myjScrollPane.setBounds(myframe.getX(),myframe.getY(),myframe.getWidth(),myframe.getHeight()); myjScrollPane.setViewportView(bgp); myjScrollPane.computeVisibleRect(bgp.getBounds()); myframe.getContentPane().add(myjScrollPane); for (counter = 0; counter < panels.length; counter++) { panels[counter] = new JPanel(); panels[counter].setLayout(new FlowLayout()); panels[counter].setBackground(new Color(255, 255, 204)); panels[counter].setSize(25, 25); panels[counter].setBorder(BorderFactory.createLineBorder(Color.black,1)); panels[counter].setName(String.valueOf(counter)); labels[counter] = new JLabel(); labels[counter].setText(String.valueOf(counter)); panels[counter].add(labels[counter], null); panels[counter].setOpaque(true); Point locations = new Point((0 + (26 * k)), ((j))); k++; panels[counter].setLocation(locations); bgp.add(panels[counter]); } } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new scp().mygui(); } }); } class sp extends JPanel { private static final long serialVersionUID = 1L; Image image; public sp() { try { image = javax.imageio.ImageIO.read(new java.net.URL(getClass().getResource("bg.jpg"), "bg.jpg")); } catch (Exception e) { /* handled in paintComponent() */ } } @Override protected void paintComponent(Graphics gr) { super.paintComponent(gr); if (image != null) gr.drawImage(image, 0, 0, sys_want_w - 8, sys_want_h - 35, this); } } }
VIEWS ON THIS POST

258

Posted on:

Tuesday 25th September 2012
View Replies!

help me how to move image ( jpanel)

i choose image ( jfilechooser) and draw it in jpanel ,but how to move image with mouse \t my code: import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGImageEncoder; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Container; import java.awt.Desktop; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsEnvironment; import java.awt.GridLayout; import java.awt.Image; import java.awt.Point; import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionAdapter; import java.awt.event.MouseMotionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Scanner; import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.Action; import javax.swing.text.Element; import javax.swing.text.AttributeSet; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JColorChooser; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JEditorPane; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.JSeparator; import javax.swing.JSplitPane; import javax.swing.JTextArea; import javax.swing.JTextPane; import javax.swing.JToolBar; import javax.swing.JTree; import javax.swing.KeyStroke; import javax.swing.ScrollPaneConstants; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.text.MutableAttributeSet; import javax.swing.text.SimpleAttributeSet; import javax.swing.text.StyleConstants; import javax.swing.text.StyledDocument; import javax.swing.text.StyledEditorKit; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; class Paint extends JFrame implements ActionListener { protected File dossier = null; public JTree jtree; public JMenuBar menuBar = new JMenuBar(); public JMenu Fichier,Edition,dessiner,aide; public JMenuItem change, style, size, couper, copier, coller, Save, New, Ouvrir, coleur, vider, deplacer, Quitter, ligne, rectangle, cercle, ellipse, main, polygone, triangle, remplir, gomme, annuler, repeter, apropos, doc; public JToolBar toolbar1,toolbar2,toolbar3; public JButton cut, print, txt, color, nouveau, open, draw, Sauvgarde, Main, Ligne, Rectang, Cercle, Ellipse, Triangle, Triangle_draw, Triangle_fill, Deplacer, img, Polygone, Remplir, Gomme, rect_fill, rect_draw, rd_rect_fill, rd_rect_draw, vide1, vide2, taille1, taille2, taille3, taille4, tligne1, tligne2, tligne3, tligne4, ellipse_fill, ellipse_draw, cercle_d, cercle_f, premier_p, arriere_p, color_r; public Container contenu=getContentPane(); public JSplitPane pane,pane1; public String nomm,nommm; public int numm; public String g="java"; public JFileChooser fc=new JFileChooser(); public Point offset = new Point(); public Color rr; public String name=""; public BufferedImage immg; public JComponent p1; public txtstyle ts = new txtstyle(); public Figures figures = new Figures(); public Dessin ds = new Dessin(); public JPanel pp = new JPanel(); public JComponent c1; public JTextArea info = new JTextArea (); public File na; public String nom_image,path,frfr; public Image im; public Color c=Color.black; public Fenetre fen; public Vector vc = new Vector(); public JPopupMenu jpopup = new JPopupMenu(); private int clicX=0; private int clicY=0; private int xx; private int yy; public int ii=0,jj=0; public size siz = new size(); private int mouseX=100; private int mouseY=200; private boolean drag=false; final Toolkit toolkit = Toolkit.getDefaultToolkit(); final Clipboard clipboard = toolkit.getSystemClipboard(); private ImageIcon ic ; private JLabel jb ; public void siize( int width, int height){ xx=width; yy=height; System.out.println("val xx:"+xx); } public Paint(size s){ // A propos de la fentre principale setSize(600,400); setTitle("ZAKI-SOFT App I.S.I by ABDELKAFI ZAKARIA -U.S.T.O"); // siz= new size(); this.siz=s; //this.fen=fe; this.ii=100; this.jj=100; //xx=Paint.this.siz.width(); //yy=Paint.this.siz.height(); /*ic=new ImageIcon(image()); jb=new JLabel(ic,JLabel.CENTER); jb.addMouseMotionListener(new moveIconHandler()); jb.setBounds(ii,jj,ic.getIconWidth(), ic.getIconHeight()); pp.add(jb);*/ // Barre de menu Fichier = new JMenu("Fichier"); Edition = new JMenu("Edition"); dessiner = new JMenu("Dessiner"); aide = new JMenu("Aide"); Ouvrir = new JMenuItem("Ouvrir une image"); Save = new JMenuItem("Sauvgarder as.."); New = new JMenuItem("Nouveau dessin"); deplacer=new JMenuItem("Dplacer un objet"); Quitter=new JMenuItem("Quitter"); coleur = new JMenuItem("Couleur"); annuler = new JMenuItem("Annuler"); couper = new JMenuItem("cut"); copier = new JMenuItem("copy"); coller = new JMenuItem("past"); size = new JMenuItem("resize image"); change = new JMenuItem("change"); style = new JMenuItem("Editeur Text"); repeter = new JMenuItem("Rpter"); vider = new JMenuItem("Effacer tous"); main=new JMenuItem("dessin libre"); ligne=new JMenuItem("Ligne"); gomme=new JMenuItem("Gomme"); triangle=new JMenuItem("Triangle"); polygone=new JMenuItem("Polygone"); remplir=new JMenuItem("Remplir"); rectangle= new JMenuItem("Rectangle"); cercle= new JMenuItem("Cercle"); ellipse= new JMenuItem("Ellipse"); doc= new JMenuItem("Documentation"); apropos= new JMenuItem("A propos"); Action boldAction = new BoldAction(); boldAction.putValue(Action.NAME, "Bold"); Edition.add(boldAction); Action italicAction = new ItalicAction(); italicAction.putValue(Action.NAME, "Italic"); Edition.add(italicAction); Action foregroundAction = new ForegroundAction(); foregroundAction.putValue(Action.NAME, "Color"); Edition.add(foregroundAction); Action formatTextAction = new FontAndSizeAction(); formatTextAction.putValue(Action.NAME, "Font and Size"); Edition.add(formatTextAction); Action action=new StyledEditorKit.UnderlineAction(); action.putValue(Action.NAME, "Underline"); Edition.add(action); Fichier.add(New); Fichier.add(Ouvrir); Fichier.add(Save); Fichier.add(Quitter); Edition.add(copier); Edition.add(couper); Edition.add(coller); Edition.add(size); Edition.add(change); Edition.add(style); Edition.add(annuler); Edition.add(repeter); Edition.add(new JSeparator()); Edition.add(coleur); Edition.add(vider); Edition.add(deplacer); aide.add(doc); aide.add(apropos); dessiner.add(main); dessiner.add(ligne); dessiner.add(rectangle); dessiner.add(cercle); dessiner.add(ellipse); dessiner.add(polygone); dessiner.add(triangle); dessiner.add(new JSeparator()); dessiner.add(deplacer); dessiner.add(gomme); dessiner.add(remplir); annuler.setEnabled(false); repeter.setEnabled(false); menuBar.add(Fichier); menuBar.add(Edition); menuBar.add(dessiner); menuBar.add(aide); setJMenuBar(menuBar); // Barre d'outil toolbar1 = new JToolBar("Barre d'outil"); toolbar2 = new JToolBar("Barre d'outil2",1); toolbar3 = new JToolBar("Barre d'outil3",1); Main = new JButton(new ImageIcon("Image\\drw1.png")); Main.setToolTipText("main libre"); Main.addActionListener(this); cut = new JButton(new ImageIcon("Image\\cut.png")); cut.setToolTipText("couper"); cut.addActionListener(this); txt = new JButton(new ImageIcon("Image\\txxt.png")); txt.setToolTipText("zone de texte"); txt.addActionListener(this); color = new JButton(new ImageIcon("Image\\color1.png")); color.setToolTipText("main libre"); color.addActionListener(this); draw = new JButton(new ImageIcon("Image\\dr.png")); draw.setToolTipText("draw"); draw.addActionListener(this); open = new JButton(new ImageIcon("Image\\open1.png")); open.setToolTipText("open image"); open.addActionListener(this); nouveau = new JButton(new ImageIcon("Image\\new.png")); nouveau.setToolTipText("draw"); nouveau.addActionListener(this); vide1 = new JButton(new ImageIcon("Image\\vide.gif")); vide2 = new JButton(new ImageIcon("Image\\vide.gif")); vide1.setEnabled(false); vide2.setEnabled(false); rect_fill = new JButton(new ImageIcon("Image\\rect1.gif")); rect_fill.setToolTipText("dessiner un rectangle plein"); rect_fill.addActionListener(this); rect_draw = new JButton(new ImageIcon("Image\\rect_draw.gif")); rect_draw.setToolTipText("dessiner un Rectangle vide"); rect_draw.addActionListener(this); rd_rect_fill = new JButton(new ImageIcon("Image\\roundrec_fill.gif")); rd_rect_fill .setToolTipText("dessiner un roundrectangle plein"); rd_rect_fill .addActionListener(this); rd_rect_draw = new JButton(new ImageIcon("Image\\roundrec_draw.gif")); rd_rect_draw .setToolTipText("dessiner un roundrectangle vide"); rd_rect_draw .addActionListener(this); Ligne = new JButton(new ImageIcon("Image\\lin1.png")); Ligne.setToolTipText("Une ligne"); Ligne.addActionListener(this); Sauvgarde = new JButton(new ImageIcon("Image\\save1.png")); Sauvgarde.setToolTipText("Save"); Sauvgarde.addActionListener(this); Rectang = new JButton(new ImageIcon("Image\\rect1.png")); Rectang.setToolTipText("Un Rectangle"); Rectang.addActionListener(this); Cercle = new JButton(new ImageIcon("Image\\cerc.png")); Cercle.setToolTipText("Un Cercle"); Cercle.addActionListener(this); Ellipse = new JButton(new ImageIcon("Image\\elli.png")); Ellipse.setToolTipText("Un Ellipse"); Ellipse.addActionListener(this); print = new JButton(new ImageIcon("Image\\prt.png")); print.setToolTipText("Imprimer"); print.addActionListener(this); Polygone = new JButton(new ImageIcon("Image\\polygone.png")); Polygone.setToolTipText("Un Polygone"); Polygone.addActionListener(this); color_r = new JButton(new ImageIcon("Image\\vide.gif")); color_r.setBackground(c); color_r.setSize(17, 17); color_r.setToolTipText("les Couleurs"); color_r.addActionListener(this); Remplir = new JButton(new ImageIcon("Image\\fill.png")); Remplir.setToolTipText("Remplir le fond"); Remplir.addActionListener(this); Gomme = new JButton(new ImageIcon("Image\\gom.png")); Gomme.setToolTipText("Gomme"); Gomme.addActionListener(this); Triangle = new JButton(new ImageIcon("Image\\triangle1_draw.gif")); Triangle.setToolTipText("Triangle"); Triangle.addActionListener(this); Triangle_draw = new JButton(new ImageIcon("Image\\triangle1_draw.gif")); Triangle_draw.setToolTipText("Triangle"); Triangle_draw.addActionListener(this); Triangle_fill = new JButton(new ImageIcon("Image\\triangle1_fill.gif")); Triangle_fill.setToolTipText("Triangle"); Triangle_fill.addActionListener(this); Deplacer = new JButton(new ImageIcon("Image\\dp.png")); Deplacer.setToolTipText("Deplacer"); Deplacer.addActionListener(this); img = new JButton(new ImageIcon("Image\\img.gif")); img.setToolTipText("Selectionner une image"); img.addActionListener(this); taille1 = new JButton(new ImageIcon("Image\\taille1.gif")); taille1.setToolTipText("changer la taille1"); taille1.addActionListener(this); taille2 = new JButton(new ImageIcon("Image\\taille2.gif")); taille2.setToolTipText("changer la taille2"); taille2.addActionListener(this); taille3 = new JButton(new ImageIcon("Image\\taille3.gif")); taille3.setToolTipText("changer la taille3"); taille3.addActionListener(this); taille4 = new JButton(new ImageIcon("Image\\taille4.gif")); taille4.setToolTipText("changer la taille4"); taille4.addActionListener(this); tligne1 = new JButton(new ImageIcon("Image\\taille1.gif")); tligne1.setToolTipText("changer la taille1"); tligne1.addActionListener(this); tligne2 = new JButton(new ImageIcon("Image\\taille2.gif")); tligne2.setToolTipText("changer la taille2"); tligne2.addActionListener(this); tligne3 = new JButton(new ImageIcon("Image\\taille3.gif")); tligne3.setToolTipText("changer la taille3"); tligne3.addActionListener(this); tligne4 = new JButton(new ImageIcon("Image\\taille4.gif")); tligne4.setToolTipText("changer la taille4"); tligne4.addActionListener(this); ellipse_fill = new JButton(new ImageIcon("Image\\ellipse_fill.gif")); ellipse_fill.setToolTipText("Ellipse plein"); ellipse_fill.addActionListener(this); ellipse_draw= new JButton(new ImageIcon("Image\\ellipse_draw.gif")); ellipse_draw.setToolTipText("Ellipse vide"); ellipse_draw.addActionListener(this); cercle_d = new JButton(new ImageIcon("Image\\cercle_draw.gif")); cercle_d.setToolTipText("Cercle vide"); cercle_d.addActionListener(this); cercle_f = new JButton(new ImageIcon("Image\\cercle_fill.gif")); cercle_f.setToolTipText("Cercle plein"); cercle_f.addActionListener(this); Quitter.setToolTipText("Quitter l'application"); Quitter.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4,KeyEvent.ALT_MASK)); Quitter.addActionListener(this); New.setToolTipText("Quitter l'application"); New.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,KeyEvent.CTRL_MASK)); New.addActionListener(this); Ouvrir.setToolTipText("Quitter l'application"); Ouvrir.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,KeyEvent.CTRL_MASK)); Ouvrir.addActionListener(this); Save.setToolTipText("Sauvegarder"); Save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,KeyEvent.CTRL_MASK)); Save.addActionListener(this); coleur.setToolTipText("Choi coleur"); coleur.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P,KeyEvent.CTRL_MASK)); coleur.addActionListener(this); annuler.setToolTipText("Annuler la dernire action"); annuler.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z,KeyEvent.CTRL_MASK)); annuler.addActionListener(this); repeter.setToolTipText("Rpter la dernire action"); repeter.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y,KeyEvent.CTRL_MASK)); repeter.addActionListener(this); vider.setToolTipText("Vider l'espace de travail"); vider.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,KeyEvent.CTRL_MASK)); vider.addActionListener(this); deplacer.setToolTipText("Dplacer un objet"); deplacer.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D,KeyEvent.CTRL_MASK)); deplacer.addActionListener(this); ligne.setToolTipText("Dessiner une ligne"); ligne.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_L,KeyEvent.CTRL_MASK)); ligne.addActionListener(this); main.setToolTipText("Dessin libre"); main.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M,KeyEvent.CTRL_MASK)); main.addActionListener(this); triangle.setToolTipText("Dessiner un triangle"); triangle.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T,KeyEvent.CTRL_MASK)); triangle.addActionListener(this); gomme.setToolTipText("utiliser la Gomme"); gomme.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G,KeyEvent.CTRL_MASK)); gomme.addActionListener(this); remplir.setToolTipText("remplir le dessin"); remplir.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,KeyEvent.CTRL_MASK)); remplir.addActionListener(this); rectangle.setToolTipText("Dessiner un rectangle"); rectangle.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R,KeyEvent.CTRL_MASK)); rectangle.addActionListener(this); polygone.setToolTipText("Dessiner un rectangle"); polygone.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P,KeyEvent.CTRL_MASK)); polygone.addActionListener(this); cercle.setToolTipText("Desssiner un cercle"); cercle.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,KeyEvent.CTRL_MASK)); cercle.addActionListener(this); ellipse.setToolTipText("Desssiner un ellipse"); ellipse.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E,KeyEvent.CTRL_MASK)); ellipse.addActionListener(this); apropos.setToolTipText("A propos de l'application"); apropos.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1,KeyEvent.CTRL_MASK)); apropos.addActionListener(this); doc.setToolTipText("La documentation de l'application"); doc.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F2,KeyEvent.CTRL_MASK)); doc.addActionListener(this); couper.setToolTipText("couper le text"); couper.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J,KeyEvent.CTRL_MASK)); couper.addActionListener(this); copier.setToolTipText("copier le text"); copier.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M,KeyEvent.CTRL_MASK)); copier.addActionListener(this); coller.setToolTipText("coller le text"); coller.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,KeyEvent.CTRL_MASK)); coller.addActionListener(this); size.setToolTipText("changer la taille de l'image"); size.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,KeyEvent.CTRL_MASK)); size.addActionListener(this); style.setToolTipText("Editeur Text"); style.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,KeyEvent.CTRL_MASK)); style.addActionListener(this); change.setToolTipText("change"); change.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_6,KeyEvent.CTRL_MASK)); change.addActionListener(this); premier_p = new JButton(new ImageIcon("Image\\img.gif")); premier_p.setToolTipText("Mettre l'objet en premiere plan"); premier_p.addActionListener(this); arriere_p = new JButton(new ImageIcon("Image\\img.gif")); arriere_p.setToolTipText("Mettre l'objet en arrire plan"); arriere_p.addActionListener(this); // ImageIcon ic = new ImageIcon(immg); //jb= new JLabel(ic); toolbar1.add(nouveau); toolbar1.add(open); toolbar1.add(Sauvgarde); toolbar1.add(print); toolbar1.add(color); toolbar1.add(txt); toolbar1.add(cut); toolbar1.add(draw); toolbar1.setToolTipText("Barre d'outil"); toolbar2.add(vide1); toolbar2.add(vide2); toolbar2.setToolTipText("Toolbar"); toolbar3.add(vide1); toolbar3.add(vide2); toolbar3.setToolTipText("Toolbar"); toolbar2.setBackground(Color.GRAY); toolbar1.setBackground(Color.GRAY); JScrollPane scroller = new JScrollPane(ds, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); pp.setBackground(Color.white); BorderLayout bord = new BorderLayout(); pp.setLayout(bord); DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root"); DefaultMutableTreeNode operation; DefaultMutableTreeNode grandChild; for(int childIndex=1; childIndex
VIEWS ON THIS POST

189

Posted on:

Tuesday 25th September 2012
View Replies!

how to calculate cpu/memory utilizing by jcomponents/jpanels/Jframe?

I create 1 Jframe in that 1 big jpanel fitted to that JFrame. In that jpanel i create array of jpanels(small) say n numbers...n=5,6,7,,9...up to...99. size (25,25) Now i want print statement which shows cpu/memory utilized by each panel/component...
VIEWS ON THIS POST

277

Posted on:

Tuesday 25th 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

312

Posted on:

Tuesday 25th September 2012
View Replies!

how to add images dynamically to jpanel?

hello, i added some images to jpanel, with some animation. i put some images in a folder, and i m display/moving them on jpanel simultaneously. my question is can i add images dynamically\t i mean what i want is, i want to add a button on that panel, and when i click on that button, one more image (randomly) should added to my jpanel from that folder. how can i do this\t
VIEWS ON THIS POST

193

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

143

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

258

Posted on:

Sunday 30th September 2012
View Replies!

linking two jpanels

i am working a desktop application,in which i am having a jpanel which is a login page,what i want is to move to other jpanel on successful login .
VIEWS ON THIS POST

187

Posted on:

Wednesday 17th October 2012
View Replies!

how to add scrollpane for a jpanel with null layout manager.

I include a JPanel with a null layout in a JScrollPane, and it doesn't display the scrollbars. Why but its working with layout manager public static void main(String[] args) { JFrame frame = new JFrame(); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); for(int i = 0; i < 20; i++) { panel.add(new JButton("Button " + i)); } //Creating JScrollPane with JPanel JScrollPane scrollPane = new JScrollPane(panel); JPanel otherPanel = new JPanel(); otherPanel.setLayout(new BorderLayout()); //Adding scrollPane to panel otherPanel.add(scrollPane); frame.add(otherPanel); frame.setSize(200,200); frame.setVisible(true); }
VIEWS ON THIS POST

213

Posted on:

Wednesday 17th October 2012
View Replies!

frame vs. JFrame

Is there a difference between using frame or JFrame as in the following As, when I ran the program it operated the same. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
VIEWS ON THIS POST

161

Posted on:

Wednesday 17th October 2012
View Replies!

set size of jpanel

Hi I am designing a form using swing components in my applet. I want to have a strip on top of my form with a title in it. I am using jpanel and color bachground for it. My problem is that I cannot decrease height of the jpanel more than a minimum size. It covers one fourth part of my form. below code: JPanel jpRow0 = new JPanel(new FlowLayout(FlowLayout.RIGHT, hgap, vgap)); jpRow0.computeVisibleRect(); jpRow0.setPreferredSize(new Dimension(695, 1)); // does not work !!! jpRow0.setBackground(new Color(0,0,128)); JLabel lblFormTitle = new JLabel(TitlePersian.REPORT + " " + TitlePersian.INVOICES_ + " " + TitlePersian.CONTRACT); lblFormTitle.setFont(Global.font); lblFormTitle.setForeground(new Color(255,255,255)); jpRow0.add(lblFormTitle); getContentPane().add(jpRow0); does anyone has experienced my problem and has a solution I would be
VIEWS ON THIS POST

134

Posted on:

Wednesday 17th October 2012
View Replies!

Removing a jtable from a jpanel/Changing the table

.. I've written this code, which creates a table with a scrollpane, and loads the results of a search, when a button is pressed. The problem is that each time i press the button a new jtable is created. How can i make it either: a) refill the same table b) remove the table and make another one which displays the new results. My code: searchBt.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { pd.contains(qTxt1.getText(),true); System.out.println(pd.dictSearchStore.size()); if (pd.toObject()!= null && pd.toObject().length!=0) { JTable resTable = new JTable(pd.toObject(),tableTitles); JScrollPane scrollPane = new JScrollPane(resTable); resTable.setPreferredScrollableViewportSize(new Dimension(170, 160)); panel.add(scrollPane); panel.validate(); } } });
VIEWS ON THIS POST

250

Posted on:

Thursday 18th October 2012
View Replies!

Spring vs. Gridbag

I was wondering if someone could supply a very brief summary of Spring layout. The only description I've seen so far is that it is an attempt to make Gridbaglayout simpler. Also what would be a good use of Spring.
VIEWS ON THIS POST

69

Posted on:

Thursday 18th October 2012
View Replies!

jpanel into jframe

i have jframe1. jframe having menu bar and i have 5 jpanel. now i want a result like, when i select one menu item it will show me a panel (i.e. - jpanel1) when i click on other menu item then it has to show other jpanel (i.e. - jpanel2) and jpanel1 get hide.
VIEWS ON THIS POST

125

Posted on:

Monday 22nd October 2012
View Replies!

Listening frames vs. listening buttons

I'm used to write listeners in this way : JButton button = new JButton("I'm a button!"); button.addActionListener(new InnerClassWhichImplementsActionListener()) That's because when I started programming in java I used jbuilder and it creates code in that way when you draw the GUI. I've seen some examples using this style : public class MyFrame extends JFrame implements ActionListener { public void actionPerformed(ActionEvent e){ switch actions based on e.getSource() ... It seems to me a better way, less lines of code, class attributes are directly visible. Since I'm still quite a newbie, before I start rewriting my old code, there's something I'm missing in the "Inner class method" making it preferable
VIEWS ON THIS POST

65

Posted on:

Monday 22nd October 2012
View Replies!

inherited vs. implements Listeners

I'm working with a sample class that extends JFrame. I noticed that I had to add "implements KeyListener" and declare the appropriate methods as required. That's not too surprising, but then I added a method on the WindownListener interface to listen for the window close event. It struck me as odd that I didn't need to implement the other methods. A little digging and I see that this is because one of the ancestors of JFrame implements WindowsListener (I think it was Component). So far, so good. Interestingly enough, if I add "implements WindowListener" to my class, I now have to provide an implementation for each of the methods required in the interface, even though those methods already exist higher in the tree and would therefore be inherited in my JFrame subclass. Why is that
VIEWS ON THIS POST

70

Posted on:

Tuesday 23rd October 2012
View Replies!