Resizing GUI

I am having trouble writing code to resize components on a GUI after the hit of a button. I have a matrix of jButtons and I want the user to be able to resize the matrix to more or less columns and rows but the only thing I have managed to do is to copy the resized components below the original. Any suggestions would be appreciated?

Are you adding new buttons to the matrix? If so, you may have to remove the original panel from the parent container, add the newly sized one, revalidate the container, and pack it. See if that works.
Container cp = getContentPane();
cp.removeAll();
cp.add(createButtonMatrix());
cp.revalidate();
pack();

Similar Messages

  • Newbie: Java FX Resizable Gui Layout

    Dear all,
    I am trying to create a User Interface for entering address data. The GUI should be resizable so i was experimenting with the jfxtras Grid Layout.
    With the included code a rudimentary Gui is created. My Problem is that i cannot control the initial sizes of my TextBoxes. In my example the Kunden Nr is too large. The Name and Vorname Fields are too small. I tried to manage the sizes using the hspan variable. Defining widths using layoutInfo was not successful.
    Can anyone give me a hint how to set sizes for TextBoxes ?
    Thanks in advance
    import org.jfxtras.scene.layout.*;
    import org.jfxtras.scene.*;
    import javafx.scene.*;
    import javafx.stage.*;
    import ch.bizWare.fx.components.*;
    import javafx.scene.control.TextBox;
    import javafx.scene.text.*;
    import javafx.scene.layout.*;
    import org.jfxtras.scene.shape.*;
    import javafx.scene.paint.*;
    // Container Definition
    var scene : ResizableScene;
    var mainStage : Stage;
    var tbKdNr : TextBox = TextBox{
        layoutInfo: GridLayoutInfo{hgrow: Grow.ALWAYS}
    var lKdNr : Text = Text{
        content: "Kunden Nr"
    var tbAnrede : TextBox = TextBox{
        layoutInfo: GridLayoutInfo{hgrow: Grow.ALWAYS, hspan: 1}
    var lAnrede : Text = Text{
        content: "Anrede"
    var tbName : TextBox = TextBox{
        layoutInfo: GridLayoutInfo{hgrow: Grow.ALWAYS, hspan : 2}
    var lName : Text = Text{
        content: "Name"
    var tbVorname : TextBox = TextBox{
        layoutInfo: GridLayoutInfo{hgrow: Grow.ALWAYS, hspan: 2}
    var lVorname : Text = Text{
        content: "Vorname"
    var tbAdresse : TextBox = TextBox{
        layoutInfo: GridLayoutInfo{hgrow: Grow.ALWAYS, hspan: 4}
    var lAdresse : Text = Text{
        content: "Adresse des Kunden"
    var tbPlzOrt : TextBox = TextBox{
        layoutInfo: GridLayoutInfo{hgrow: Grow.ALWAYS, hspan: 2}
    var lPlzOrt : Text = Text{
        content: "PLZ/Ort"
    var grid : Grid = Grid {
        rows: [ Row{
                     cells : [lKdNr, tbKdNr]
                Row{
                    cells : [lAnrede, tbAnrede, lName, tbName, lVorname, tbVorname]
                Row{
                    cells : [lAdresse, tbAdresse, lPlzOrt, tbPlzOrt]
    scene = ResizableScene {
       width : 600;
       height: 200;
       content:grid    
    // Stage Initialize
    mainStage = Stage {
        title : "Adresse erfassen"
        scene : scene
    }

    Here is my resizable custom EmployeeUI component with address
    package ui.custom;
    import javafx.scene.shape.Rectangle;
    import javafx.stage.Stage;
    import javafx.scene.paint.Color;
    import org.jfxtras.scene.ResizableScene;
    import javafx.scene.text.Text;
    import org.jfxtras.scene.layout.MigLayout;
    import org.jfxtras.scene.layout.MigLayout.*;
    import loans.calc.*;
    import javafx.stage.Stage;
    import javafx.scene.Node;
    import javafx.scene.paint.Color;
    import javafx.scene.control.TextBox;
    import javafx.scene.control.Button;
    import javafx.scene.CustomNode;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.layout.Stack;
    import org.jfxtras.scene.ResizableCustomNode;
    import org.jfxtras.scene.layout.ResizableVBox;
    import org.jfxtras.stage.JFXDialog;
    import javafx.ext.swing.SwingComboBox;
    import javafx.ext.swing.SwingComboBoxItem;
    import javafx.util.Sequences;
    import javafx.scene.paint.LinearGradient;
    import javafx.scene.paint.Stop;
    import javafx.scene.text.Font;
    import javafx.ext.swing.SwingComponent;
    import javax.swing.JTextArea;
    import javax.swing.JScrollPane;
    import javafx.ext.swing.SwingTextField;
    import javafx.scene.shape.Line;
    * @author gusaros
    public class EmployeeUI extends ResizableCustomNode {
    var linearGradient = LinearGradient {
                endY: 1 endX: 0
                stops : [
                    Stop { offset: 0.0 color: Color.web("#eae8e3") },
                    Stop { offset: 1.0 color: Color.WHITE },
    public  var employee:Employee;
    var line1 = Line {
              startX: 10, startY: 10
              endY: 10
              endX: bind width - 10
              // endX: 230, endY: 100
              strokeWidth: 2
              stroke: Color.DARKGRAY
    var header = Text {content:
               "E m p l o y e e   i n f o r m a t i o n"
               font: Font.font("Serif",18)
         var emptyLabel=Label {
             id:"emptyLabel"
             text: ""};
      var firstNameLabel=Label {
             id:"firstNameLabel"
             text: "First Name:"};
    var firstNameField=TextBox {
           id:"firstNameField"
           selectOnFocus: false
           editable:false
           text: bind employee.firstName
       var lastNameLabel=Label {
           id:"lastNameLabel"
            text: "Last Name:" };
        var lastNameField=TextBox {
        id:"lastNameField"
        text: bind employee.lastName
    var dobLabel=Label {
           id:"dobLabel"
            text: "DOB:" };
    var dobField=TextBox {
        id:"dobField" };
    var taxNumberLabel=Label {
           id:"taxNumberLabel"
            text: "Tax number:" };
    var taxNumberField=TextBox {
        id:"taxNumberField" };
    var titleLabel=Label {
           id:"titleLabel"
            text: "Title:" };
    var titleField=TextBox {
        id:"titleField" };
    var planTypeLabel=Label {
           id:"planTypeLabel"
            text: "Plan type:" };
    var planTypeField=TextBox {
        id:"planTypeField" };
    var activeStatusLabel=Label {
           id:"activeStatusLabel"
            text: "Active status:" };
    var activeStatusField=TextBox {
        id:"activeStatusField"
      var serviceLabel=Label {
           id:"servicel"
            text: "Service:" };
    var serviceField=TextBox {
        id:"servicef"  };
    var deductionsLabel=Label {
           id:"deductionsLabel"
            text: "Deductions:" };
    var deductionsField=TextBox {
        id:"deductionsField"
        text:"0"
    var deductionsLabel75=Label {
           id:"deductionsLabel75"
            text: bind if (activeStatusField.text == "B")   " 75% deductions:"  else
            " 90% deductions:"         };
    var deductionsField75=TextBox {
        id:"deductionsField75"
        text: bind if (activeStatusField.text == "B") "{Double.parseDouble(deductionsField.text) * 0.75 }"
                  else  "{Double.parseDouble(deductionsField.text) * 0.9 }"
    var minPaymentLabel=Label {
           id:"minpaymentLabel"
            text: "Minimum payment:" };
    var minPaymentField=TextBox {
           id:"minpaymentfield"
    var reserveLabel=Label {
           id:"reserveLabel"
            text: "Reserve:" };
    var reserveField=TextBox {
        id:"reserveField"
        text:""
    var taxableamtLabel=Label {
           id:"taxableamtLabel"
            text: "Taxable amt:" };
    var taxableamtField=TextBox {
        id:"taxableamtField"
        text:""
    var dcploanLabel=Label {
           id:"ldcploanLabel"
            text: "Current DCP loan :" };
    var dcploanField=TextBox {
        id:"dcploanField"
        text:""
    var addressLabel=Label {
        id:"addressLabel"
        text: "Address:"
    var addressField=TextBox {
        id:"addressField"
    var cityLabel=Label {
        id:"cityLabel"
        text: "City:"
    var cityField=TextBox {
        id:"cityField"
    var stateLabel=Label {
        id:"stateLabel"
        text: "State:"
    var stateField = TextBox {
        id: "statefield"
        columns: 2
    var stateField:SwingComboBox = SwingComboBox {
       id: "stateField"
       items: [
          SwingComboBoxItem{text:"MD"},
          SwingComboBoxItem{text:"CA"},
          SwingComboBoxItem{text:"NY"}
       visible: true
    var zipLabel=Label {
       id:"zipCodeLabel"
       text: "ZIP Code:"
    var zipField=TextBox {
       id:"zipCodeField"
      // Nodes to be laid out
    var nodesToLayout = bind [
        migNode(header, "span,alignx center, wrap" ),
          migNode(emptyLabel,   "wrap" ),
       migNode(firstNameLabel,  "" ),
       migNode(firstNameField,  "" ),
       migNode(lastNameLabel,  "alignx right" ),
       migNode(lastNameField, "" ),
       migNode(dobLabel, "alignx right" ),
       migNode(dobField, "wrap" ),
       migNode(taxNumberLabel, "" ),
       migNode(taxNumberField, "" ),
        migNode(titleLabel, "alignx right" ),
       migNode(titleField, "span, grow,wrap" ),
       migNode(planTypeLabel, "" ),
       migNode(planTypeField, "" ),
       migNode(activeStatusLabel, "alignx right" ),
       migNode(activeStatusField, "" ),
       migNode(serviceLabel, "alignx right" ),
       migNode(serviceField, "wrap" ),
    migNode(Label{ text:"" }, "wrap" ),
    // migNode( line1, "span"  ),
    // migNode(Label{ text:"" }, "wrap" ),
    migNode(addressLabel, "" ),
      migNode(addressField,  "span, grow" ),
       migNode(cityLabel, "" ),
       migNode(cityField, "" ),
       migNode(stateLabel, "alignx right" ),
       migNode(stateField, "", ),
       migNode(zipLabel, "alignx right" ),
       migNode(zipField, "wrap" ),
       migNode(Label{ text:"" }, "wrap" ),
       // ... other nodes are added here ...
      var rowConstraintString:String = "";
    var layoutConstraintString:String = "";
    override function create() {
                MigLayout {
                   constraints: bind layoutConstraintString
                   content:bind  nodesToLayout
                   rows: bind rowConstraintString
    }

  • Swing GUI isn't showing up properly without resizing window

    I am developing a Java GUI with Swing. I have not used any paintComponents or paint commands for anything - all Swing. Every time I run the code, I get the JFrame to come up, but all I can see is the background. Only after I resize the window (manually, with the mouse) do I see the boxes and JComboBox, etc. What is the problem? I've tried googling it, and I can't find a thing. Any ideas?
    Thanks in advance.

    morgalr wrote:
    pack();
    setVisible(true);Without code, that is my general answer.Fixed it. I didn't think it could be something that easy. But it was. Thanks a lot.

  • Rescale GUI-Components on resizeing frame?

    Hello,
    how do I have to implement rescaling GUI-components when a frame (JFrame) is resized by a user on runtime?
    Should I have to use the observer-observable-pattern?
    thanx

    If you've got a layout manager then its automatic otherwise add a WindowListener to capture the resize event then resize them yourself.
    Rob.

  • Resizing image in GUI

    Hey everyone,
    I want to display an iexternal image (ie an image file image.jpg) in a frame, but when the frame is resized by the user ( it should only be resized in set proprtions) it will rezise the image displayed.
    Im new to GUI programming and am not sure how to do this. Can anyone help please ?
    Many Thanks,
    d-_-b.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Without looking at the API, I remember there's something about Image.getScaledInstance(). You need to run that when the frame's size-change listener receives an event.

  • Is there anyway to resize my whole GUI window

    I want to resize my whole gui window without having to go through each controls individually. is there any way to do that

    Hi Dhasan;
    Have you tried option on the VI Properties menu (Menu/File/VI Properties) category Window Size that is called Scale all objects on front panel as the window resizes? It’s a checkbox you just need to activate. Let us know if you find it and if this solves your issue.
    Bye!

  • Gui components don't appear till frame resized

    I am experimenting with gridlayout to create a simple gui.
    The gui has 3 Jlabels and 3 textfields. The problem is that they do not appear until I drag the corner of the frame to resize it.
    Any ideas would be greatly appreciated!

    As one reply sort of pointed out, anytime you add anything to any component, that component needs to be redrawn. If you have a parent component redraw, it will redraw all of its sibling components. Therefore, when you resize the main window it often redraws all of the components within it. However, this may not always occur. If you resize a window to the right/down, the repaint SHOULD only occur in the new area exposed at the bottom/right side. If your panel/component does NOT fall within this "clip rectangle" area, it might still not be redrawn. Because of this, you need to invalidate the parent component that you place a component on so that a render event is put on the swing event queue to indicate it needs to be repainted.
    There are a few ways this can be done. Component.invalidate(), then repaint(). I tend to prefer the component.updateUI() as I think it invalidates AND repaints the component for you. I have seldom, if ever seen any problems with adding things at runtime so long as I called updateUI() or validate() and repaint().
    Keep in mind ALL of these are added as events onto the swing event thread, that does NOT mean they will occur immediately. If another event BEFORE your repaint/validate/etc event is being procssed and is taking up too much time (such as an event listener method), it is possible your component STILL wont be repainted until the event you posted gets consumed by the event thread dispatcher.

  • GUI resizes when calling JLabel.setText()

    Case:
    I have a GUI with a GridbagLayout.
    This is the code for building the GUI.
    Important bits:
    please note the scrollConsole and adding it way at the end, because that's getting bigger:
    NOTE: KwartoButtons are a selfmade class that behaves like a button.
         setSize(600,600);
              Container p1 = getContentPane();
              p1.setLayout(new GridBagLayout());
                        GridBagConstraints c = new GridBagConstraints();
                        c.gridx = 0;
                        c.insets.set(5,8,5,8);
                   p1.setBackground(Color.DARK_GRAY);
                          panelVeld = new JPanel(new GridLayout(4,4));
                          panelStukken = new JPanel(new GridLayout(4,4));
                          labelVeld = new JLabel("Speelveld");
                          labelOngespeeld = new JLabel("Ongespeelde Stukken");
                        buttonStop = new JButton("Stop");
                          buttonConsole = new JButton("Hide/Show Console");
                          buttonStart = new JButton("Start");
                   textAreaConsole = new JTextArea("");
                   buttonPanel = new JPanel(new FlowLayout());
                   textAreaConsole.setFont(new Font("Courier",Font.PLAIN, 12));
                   aanZet = new JLabel("Niemand aan zet");
                          labelVeld.setForeground(Color.LIGHT_GRAY);
                          labelOngespeeld.setForeground(Color.LIGHT_GRAY);   
                       aanZet.setForeground(Color.LIGHT_GRAY);
                       scrollConsole = new JScrollPane(textAreaConsole,                   JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
                      buttonPanel.add(buttonStart);
                      buttonPanel.add(buttonStop);
                      buttonPanel.setBackground(Color.DARK_GRAY);
                     for(int i=0; i < veld.length; i++)
                          veld[i] = new KwartoButton(null, i, true);
                          veld.addMouseListener(this);
                   veld[i].setEnabled(false);
                   panelVeld.add(veld[i]);
              Set<Stuk> stukkenSet = spel.getOngespeeld();
              int i=0;
              for(Stuk stuk: stukkenSet)
                   stukken[i] = new KwartoButton(stuk, i, false);
                   stukken[i].addMouseListener(this);
                   stukken[i].setEnabled(false);
                   panelStukken.add(stukken[i]);
                   i++;
              c.fill = GridBagConstraints.NONE;     
              c.gridx = 0;
                   p1.add(labelVeld, c);
              c.gridx = 1;
                   p1.add(labelOngespeeld, c);
              c.weightx = 0.5;
              c.weighty = 0.9;
              c.fill = GridBagConstraints.BOTH;     
              c.gridx = 0;
                   p1.add(panelVeld, c);
              c.gridx = 1;
                   p1.add(panelStukken, c);
              c.fill = GridBagConstraints.VERTICAL;
              c.gridx=0;
              c.gridwidth=2;
              c.weightx=0;
              c.weighty=0;
              p1.add(aanZet,c);
              c.fill = GridBagConstraints.VERTICAL;     
              c.weighty = 0.0;               
              c.gridy=3;
              c.gridwidth=1;
              c.gridx=0;
                   p1.add(buttonPanel, c);
              c.gridx=1;
                   p1.add(buttonConsole, c);
              c.gridwidth = GridBagConstraints.REMAINDER;     
              c.gridx=0;
              c.gridy=4;
              c.weightx = 1.0;
    c.weighty = 0.1;     
                   c.fill = GridBagConstraints.BOTH;
              p1.add(scrollConsole, c);          
    This is the code I run when the resize happens:
    public void setMessage(String s)  {
    String message =""
    message =s
                  if(!message.equals("")) {
                       addToConsole(message);
                       aanZet.setText(message);
    public void addToConsole(String s)  {
                   // Determine whether the scrollbar is currently at the very bottom position.
                   JScrollBar vbar = scrollConsole.getVerticalScrollBar();
                   boolean autoScroll = ((vbar.getValue() + vbar.getVisibleAmount()) == vbar.getMaximum());
                   // append to the JTextArea (that's wrapped in a JScrollPane named 'scrollPane'
                   textAreaConsole.append(s+"\n");
                   // now scroll if we were already at the bottom.
                   if( autoScroll ) textAreaConsole.setCaretPosition( textAreaConsole.getDocument().getLength() );
         }What my GUI does: When I invoke setMessage(), my scrollConsole grows about one line, until it overpowers the entire GUI (except the buttons).
    If I remove the 'auto-scrolldown' functionality of addToConsole, it still resizes, so I reckon that's not the problem.

    Here you go.
    Thanks in advance.
    import java.awt.*;
    import javax.swing.*;
    * SSCCE Class for my problem.
    * Problem: GUI Resizes after calling the update method.
    public class TestingClass extends JFrame {
                   private JTextArea textAreaConsole;
                   private JLabel aanZet;
                   private JScrollPane scrollConsole;
         public void update(String s) {          //the problematic method
                       addToConsole(s);                         
                       aanZet.setText(s);
       public void addToConsole(String s) { //adds text to console
                   // Determine whether the scrollbar is currently at the very bottom position.
                   JScrollBar vbar = scrollConsole.getVerticalScrollBar();
                   boolean autoScroll = ((vbar.getValue() + vbar.getVisibleAmount()) == vbar.getMaximum());
                   // append to the JTextArea (that's wrapped in a JScrollPane named 'scrollPane'
                   textAreaConsole.append(s+"\n");
                   // now scroll if we were already at the bottom.
                   if( autoScroll ) textAreaConsole.setCaretPosition( textAreaConsole.getDocument().getLength() );
         public TestingClass() {
              super("Test");
              buildGUI();
              setVisible(true);
              update("a");
              update("b");
              update("c");
                   update("d");
                        update("e");
                             update("f");
                                  update("g");
                                       update("h");
                                            update("i");
                                                 update("j");
                                                      update("k");
                                                           update("l");
                                                                update("m");
                                                                     update("n");
                                                                          update("o"); //add more to see more effect, remove to kill problem
         public void buildGUI() { //building the gui
              setSize(600,600);
              Container p1 = getContentPane();
              p1.setLayout(new GridBagLayout());
                        GridBagConstraints c = new GridBagConstraints();
                        c.gridx = 0;
                        c.insets.set(5,8,5,8);
                        JPanel panelVeld = new JPanel(new GridLayout(4,4));
                JPanel panelStukken = new JPanel(new GridLayout(4,4));
                        textAreaConsole = new JTextArea("");
                        textAreaConsole.setFont(new Font("Courier",Font.PLAIN, 12));
                        aanZet = new JLabel("Test!");
                      scrollConsole = new JScrollPane(textAreaConsole, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
                 for(int i=0; i < 16; i++)
                          panelVeld.add(new JButton("x"));
                          panelStukken.add(new JButton("y"));
          c.weightx = 0.5;
          c.weighty = 0.9;
          c.fill = GridBagConstraints.BOTH;     
          c.gridx = 0;
                p1.add(panelVeld, c);
          c.gridx = 1;
                   p1.add(panelStukken, c);
                 c.fill = GridBagConstraints.VERTICAL;
                 c.gridx=0;
                 c.gridwidth=2;
                 c.weightx=0;
                 c.weighty=0;
                      p1.add(aanZet,c);
                 c.gridwidth = GridBagConstraints.REMAINDER;     
                 c.gridx=0;
                 c.gridy=4;
                 c.weightx = 1.0;
          c.weighty = 0.1;                    
                   c.fill = GridBagConstraints.BOTH;            
                      p1.add(scrollConsole, c);
    public static void main(String[] args) { //starting up!
              new TestingClass();
    }

  • Swing GUI resizing

    Hello Users,
    I am writing a swing app for a 12 and 15 inch screen.
    When I create the JButtons for example, they have a
    Panel.add(jButton, new AbsoluteConstraints(10, 80, 70, 30));
    Obviously when the application is run on a 15 inch and I resize the frame the size of the buttons do not adjust.
    So my question is, if I develop a app for a 12 inch and want to show it on 15 inch is there a
    way to automatically resize the swing components?
    Regards,
    Bobby

    Hello Bobby,
    So you are saying set the frame size to the size of the screen?Yes. That's what you wanted to do, having the application frame adapted to the screen size, isn't it?
    But when I create a button don't I have to specify the X, Y length etc...?No, only if you use a null layout (which I guess is close to your Absolute thing).
    Can you provide a quick code example pleaseThere is nothing special. Give a frame a BorderLayout and put one or more buttons into a panel placed at the NORTH or SOUTH edge and see what happens when resizing the frame.
    I'm afraid you are using a GUI builder without having learned the basics.
    And since we have no idea how your GUI shall look like, it's difficult to make precise suggestions.
    Bye
    Jörg

  • The GUI elements are suddenly resizing by clicking/focusing on it ??

    Hello,
    as you can see in the below image i entered Text in the JTextArea so i got scrollbars on the side, suddenly i clicked somewhere on the gui or maybe in the JTextarea and suddenly the JTextArea increases the size of the height??
    How can that happen? I use Substance LooknFeel but it happened also with Swing/ocean LooknFeel although it happened less...
    the code for this application you can find here in the other thread:
    http://forum.java.sun.com/thread.jspa?threadID=5306500&tstart=0
    click this image to see the change:
    http://666kb.com/i/aznduui7no91kxyig.png

    quote:"Write a new small app that has the same UI as the main window of your original program, but none of the back-end functionality."
    There has never been back-end stuff in my code/.jar file ONLY the pure code for the GUI!
    New cleaned...Code without LOOKnFEEL --> runable .JAR file: http://www.sendspace.com/file/ru5xfd
    New cleaned...Code with     LOOKnFEEL --> runable .JAR file: http://www.sendspace.com/file/gjh309
    public class MainWindow extends JFrame
       static final long serialVersionUID = 1L;   
       private JTabbedPane jtp = new JTabbedPane();  
       public MainWindow()
           super("test");        
           final RP rP = new RP();      
          jtp.addTab("test", rP);
          add(jtp);     
          setResizable(false);     
          setSize(400,400);
          setLocationRelativeTo(null);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       
          setVisible(true);               
       public static void main(String []args) throws UnsupportedLookAndFeelException
               EventQueue.invokeLater(new Runnable()
                    public void run()
                             new MainWindow();      
    public class RP extends JPanel
       private static final long serialVersionUID = 1L;
        private JPanel panel = new JPanel();
        private JTextField testNameDirectoryTF   = new JTextField();
        private JComboBox webName = new JComboBox();
        private JButton     testDateLB       = new JButton("test Date");  
        private JSpinner testDateSpinner = new JSpinner();
        private JSpinner forwardDateSpinner = new JSpinner();
        private JButton     forwardDateLB          = new JButton("Date1");
        private JButton     objectFormatLB        = new JButton("Format");
        private JComboBox  objectFormatCB        = new JComboBox();
        private JComboBox  testSpecialCB    = new JComboBox();
        private JButton testSpecialLB = new JButton("test");
        private JTextField favoritesTF = new JTextField();
        private JTextArea  testJTA      = new JTextArea();  
        private JScrollPane testScrollBar  = new JScrollPane(testJTA);
        private JProgressBar testJPB = new JProgressBar(0,100);
        private JButton showBT          = new JButton("show");
        private JButton testBT       = new JButton("save");
        private JButton sendBT          = new JButton("send");
        final   SpinnerDateModel testDateModel = new SpinnerDateModel();
        final   SpinnerDateModel forwardDateModel = new SpinnerDateModel();
        public RP()
            setLayout(new GridBagLayout());          
            addJPanelToJFrame(testNameDirectoryTF   , 0, 0, 4, 1, 1, 1 ,GridBagConstraints.NORTH,GridBagConstraints.BOTH);
            addJPanelToJFrame(webName               , 0, 1, 4, 1, 1, 1 ,GridBagConstraints.NORTH,GridBagConstraints.BOTH);
            addJPanelToJFrame(testDateLB            , 0, 2, 1, 1, 1, 1 ,GridBagConstraints.NORTH,GridBagConstraints.BOTH);
            addJPanelToJFrame(testDateSpinner       , 1, 2, 1, 1, 1, 1 ,GridBagConstraints.NORTH,GridBagConstraints.BOTH);
            addJPanelToJFrame(forwardDateSpinner    , 2, 2, 1, 1, 1, 1 ,GridBagConstraints.NORTH,GridBagConstraints.BOTH);
            addJPanelToJFrame(forwardDateLB         , 3, 2, 1, 1, 1, 1 ,GridBagConstraints.NORTH,GridBagConstraints.BOTH);
            addJPanelToJFrame(objectFormatLB        , 0, 3, 1, 1, 1, 1 ,GridBagConstraints.NORTH,GridBagConstraints.BOTH);
            addJPanelToJFrame(objectFormatCB        , 1, 3, 1, 1, 1, 1 ,GridBagConstraints.CENTER,GridBagConstraints.BOTH);
            addJPanelToJFrame(testSpecialCB         , 2, 3, 1, 1, 1, 1 ,GridBagConstraints.NORTH,GridBagConstraints.BOTH);
            addJPanelToJFrame(testSpecialLB         , 3, 3, 1, 1, 1, 1 ,GridBagConstraints.NORTH,GridBagConstraints.BOTH);
            addJPanelToJFrame(favoritesTF           , 0, 4, 4, 1, 1, 1 ,GridBagConstraints.NORTH,GridBagConstraints.BOTH);
            addJPanelToJFrame(testScrollBar         , 0, 5, 4, 1, 1, 10 ,GridBagConstraints.NORTH,GridBagConstraints.BOTH);
            addJPanelToJFrame(testJPB               , 0, 6, 4, 1, 1, 1 ,GridBagConstraints.NORTH,GridBagConstraints.BOTH);           
           panel.setLayout(new GridBagLayout());          
           addJComponentToJPanel( panel,showBT          ,0 , 7 , 1 , 1 , 1 , 0.25 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
           addJComponentToJPanel( panel,testBT   ,1 , 7 , 1 , 1 , 1 , 0.25 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
           addJComponentToJPanel( panel,sendBT              ,2 , 7 , 1 , 1 , 1 , 0.25 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
           addJPanelToJFrame( panel,0,8,4,1,1,0.25,GridBagConstraints.NORTH,GridBagConstraints.BOTH);  
           testJTA.setLineWrap(true);
           testJTA.setWrapStyleWord(true);       
        public void addJPanelToJFrame(JComponent c, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int anchor, int fill)
           add(c, new GridBagConstraints(gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill, new Insets(0, 0, 0, 0), 0, 0));
        void addJComponentToJPanel(JPanel panel, JComponent c, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int anchor, int fill )
           panel.add(c, new GridBagConstraints(gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill, new Insets(0, 0, 0, 0), 0, 0));      
    }

  • First attempts at a GUI - resizing problem

    Okay, my husband has been teaching me(or trying to teach, anyway) object-oriented programming for the last couple of weeks. I think I'm doing fairly well, but I've come to a spot that I'm completely stuck on, and I'm hoping someone can at least point me in the right direction!
    We've made a timer utility that allows input of several timers, each with a selector button, description and a time in the format mm:ss(horizontally displayed). We can Stop, Start, Pause, and Reset each timer (each separate timer is below the one before it). My most recent assignment was to add an ADD button, to add another timer to the bottom of the list. It's adding fine, but I can't figure out for the life of me how to make it display properly! If I resize the window manually, the added fields show up just fine. What I WANT is for the window to resize itself automatically to show the added timer. If I set the window so that it's not user-resizable, the added timer doesn't show up at all, which is no good either. That's probably terribly vague, but since I've only just started, the proper terms don't leap immediately to mind..lol
    (After this, my next assignment is to be able to remove a selected timer from the window, but I'm thinking the same technique would apply there as well.)
    Any ideas, thwaps upside the head, or "duh - just do this!" kind of advice available?

    public class EQTimer {
       private static final int DEFAULT_NUM_OF_TIMERS = 1;
       public static void main(String args[]) {
    //        UIManager.LookAndFeelInfo[] lafi = UIManager.getInstalledLookAndFeels();
    //        for (int i=0; i < lafi.length; i++) {
    //            System.out.println("----------");
    //            System.out.println(lafi.getClassName());
    try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    e.printStackTrace(); // pass System.out to printStackTrace() if running under tomcat
    JFrame mainWindow = new JFrame("EQ Timer Utility");
    mainWindow.getContentPane().setLayout(new BoxLayout(mainWindow.getContentPane(), BoxLayout.Y_AXIS));
    mainWindow.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    TimerPanel tp = null;
    CommandPanel cp = null;
    tp = new TimerPanel("TimerPanel", DEFAULT_NUM_OF_TIMERS);
    cp = new CommandPanel("CommandPanel", tp);
    tp.setCommandPanel(cp);
    mainWindow.getContentPane().add(tp);
    mainWindow.getContentPane().add(cp);
    mainWindow.setResizable(true);
    mainWindow.pack();
    mainWindow.show();
    public class TimerControl extends JPanel {
    private final int STATUS_IDLE = 0;
    private final int STATUS_STARTED = 1;
    private final int STATUS_PAUSED = 2;
    public final JRadioButton selectorButton = new JRadioButton();
    private final JTextField messageField = new JTextField("[ New Message ]");
    private final TimerField timeLeftField = new TimerField("");
    private int status;
    private String resetTimeLeftText;
    private Timer javaTimer;
    private CommandPanel commandPanel;
    private AudioClip alarmSound;
    public TimerControl(String name, ButtonGroup selectorGroup) {
    setName(name);
    status = STATUS_IDLE;
    javaTimer = new Timer(1000, new JavaTimerListener());
    messageField.setPreferredSize(new Dimension(200, 21));
    timeLeftField.setPreferredSize(new Dimension(50, 21));
    add(selectorButton);
    add(messageField);
    add(timeLeftField);
    selectorGroup.add(selectorButton);
    setupSelectorButtonListeners();
    setupMessageFieldListeners();
    setupTimeLeftFieldListeners();
    initAlarmSound();
    private void initAlarmSound() {
    URL clipURL = null;
    String urlString = "file:" + System.getProperty("user.dir") + "\\sounds\\endquest.wav";
    System.out.println(urlString);
    try {
    clipURL = new URL(urlString);
    } catch (MalformedURLException e) {
    e.printStackTrace(); //To change body of catch statement use Options | File Templates.
    alarmSound = Applet.newAudioClip(clipURL);
    public void setCommandPanel(CommandPanel cp) {
    commandPanel = cp;
    private void setupSelectorButtonListeners() {
    selectorButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    select();
    private void setupMessageFieldListeners() {
    messageField.addFocusListener(new FocusListener() {
    public void focusLost(FocusEvent fe) {}
    public void focusGained(FocusEvent fe) {
    select();
    private void setupTimeLeftFieldListeners() {
    timeLeftField.addFocusListener(new FocusListener() {
    public void focusLost(FocusEvent fe) { }
    public void focusGained(FocusEvent fe) {
    select();
    public void select() {
    selectorButton.setSelected(true);
    formatCommandPanel();
    public void formatCommandPanel() {
    if (commandPanel != null) {
    switch (status) {
    case STATUS_IDLE:
    commandPanel.enableButton(commandPanel.NAME_START);
    commandPanel.disableButton(commandPanel.NAME_PAUSE);
    commandPanel.disableButton(commandPanel.NAME_STOP);
    commandPanel.enableButton(commandPanel.NAME_RESET);
    break;
    case STATUS_STARTED:
    commandPanel.disableButton(commandPanel.NAME_START);
    commandPanel.enableButton(commandPanel.NAME_PAUSE);
    commandPanel.enableButton(commandPanel.NAME_STOP);
    commandPanel.enableButton(commandPanel.NAME_RESET);
    break;
    case STATUS_PAUSED:
    commandPanel.enableButton(commandPanel.NAME_START);
    commandPanel.enableButton(commandPanel.NAME_PAUSE);
    commandPanel.enableButton(commandPanel.NAME_STOP);
    commandPanel.enableButton(commandPanel.NAME_RESET);
    break;
    commandPanel.validate();
    private void decrementTimeLeftField() {
    long secsLeft = timeLeftField.getSecondsLeft();
    timeLeftField.setSecondsLeft(--secsLeft);
    private void checkForZero() {
    long secsLeft = timeLeftField.getSecondsLeft();
    if (secsLeft <= 0) {
    stop();
    reset();
    alarm();
    private void alarm() {
    alarmSound.play();
    showAlarmDialog();
    private void showAlarmDialog() {
    DialogListener dialogListener = new DialogListener();
    String buttonLabels[] = new String[2];
    buttonLabels[0] = "OK";
    buttonLabels[1] = "Restart";
    int results = JOptionPane.showOptionDialog(null, messageField.getText(), "Time's Up!", 0, JOptionPane.WARNING_MESSAGE, null, buttonLabels, buttonLabels[0]);
    System.out.println(results);
    if (results == 1) {
    start();
    //JOptionPane.showMessageDialog(new JFrame(), messageField.getText(), "Alarm", JOptionPane.WARNING_MESSAGE);
    public void start() {
    switch (status) {
    case STATUS_IDLE:
    if (timeLeftField.getSecondsLeft() > 0) {
    status = STATUS_STARTED;
    formatCommandPanel();
    resetTimeLeftText = timeLeftField.getText();
    timeLeftField.setEnabled(false);
    setColorScheme(status);
    javaTimer.start();
    break;
    case STATUS_PAUSED:
    unpause();
    break;
    public void stop() {
    status = STATUS_IDLE;
    formatCommandPanel();
    timeLeftField.setEnabled(true);
    setColorScheme(status);
    javaTimer.stop();
    reset();
    public void pause() {
    switch (status) {
    case STATUS_STARTED:
    status = STATUS_PAUSED;
    formatCommandPanel();
    setColorScheme(status);
    javaTimer.stop();
    break;
    case STATUS_PAUSED:
    unpause();
    break;
    private void unpause() {
    if (status == STATUS_PAUSED) {
    status = STATUS_STARTED;
    formatCommandPanel();
    setColorScheme(status);
    javaTimer.start();
    public void reset() {
    timeLeftField.setText(resetTimeLeftText);
    private void setColorScheme(int status) {
    switch (status) {
    case STATUS_IDLE:
    timeLeftField.setBackground(Color.white);
    timeLeftField.setForeground(Color.black);
    break;
    case STATUS_STARTED:
    timeLeftField.setBackground(Color.lightGray);
    timeLeftField.setForeground(Color.white);
    break;
    case STATUS_PAUSED:
    timeLeftField.setBackground(Color.pink);
    timeLeftField.setForeground(Color.white);
    break;
    class JavaTimerListener implements ActionListener {
    public synchronized void actionPerformed(ActionEvent ae) {
    decrementTimeLeftField();
    checkForZero();
    class DialogListener implements ActionListener {
    public void actionPerformed(ActionEvent ae) {
    // parentFrame.setVisible(false);
    System.out.println("Click!");
    class CommandPanel extends JPanel {
    public final String NAME_START = "Start";
    public final String NAME_PAUSE = "Pause";
    public final String NAME_STOP = "Stop";
    public final String NAME_RESET = "Reset";
    public final String NAME_ADD = "Add";
    private final JButton btnStart = new JButton("Start");
    private final JButton btnPause = new JButton("Pause");
    private final JButton btnStop = new JButton("Stop");
    private final JButton btnReset = new JButton("Reset");
    private final JButton btnAdd = new JButton("Add");
    private TimerPanel timerPanel;
    public CommandPanel(String panelName, TimerPanel timerPanelToControl) {
    setName(panelName);
    this.timerPanel = timerPanelToControl;
    add(btnStart);
    add(btnPause);
    add(btnStop);
    add(btnReset);
    add(btnAdd);
    setupListeners();
    private void setupListeners() {
    ClickListener cl = new ClickListener();
    btnStart.addActionListener(cl);
    btnPause.addActionListener(cl);
    btnStop.addActionListener(cl);
    btnReset.addActionListener(cl);
    btnAdd.addActionListener(cl);
    public void enableButton(String buttonText) {
    enableDisableJButton(buttonText, true);
    public void disableButton(String buttonText) {
    enableDisableJButton(buttonText, false);
    private JButton findJButton(String textToFind) {
    Component components[] = getComponents();
    for (int i=0; i < components.length; i++) {
    if (components[i] instanceof JButton) {
    JButton button = (JButton) components[i];
    if (button.getText().equals(textToFind)) {
    return button;
    return null;
    private void enableDisableJButton(String text, boolean enableFlag) {
    JButton button = findJButton(text);
    if (button != null) button.setEnabled(enableFlag);
    class ClickListener implements ActionListener {
    public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand() == btnStart.getText()) handleStartClick();
    if (ae.getActionCommand() == btnPause.getText()) handlePauseClick();
    if (ae.getActionCommand() == btnStop.getText()) handleStopClick();
    if (ae.getActionCommand() == btnReset.getText()) handleResetClick();
    if (ae.getActionCommand() == btnAdd.getText()) handleAddClick();
    private void handleStartClick() {
    TimerControl tc = timerPanel.getSelectedTimer();
    tc.start();
    private void handlePauseClick() {
    timerPanel.getSelectedTimer().pause();
    private void handleStopClick() {
    timerPanel.getSelectedTimer().stop();
    private void handleResetClick() {
    timerPanel.getSelectedTimer().reset();
    private void handleAddClick(){
    System.out.println("Trying to add a timer");
    timerPanel.addTimer();
    timerPanel.validate();
    class TimerPanel extends JPanel {
    private ButtonGroup selectorGroup = new ButtonGroup();
    private TimerControl[] timerControls;
    public TimerPanel(String panelName, int numberOfTimers) {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setName(panelName);
    initTimerPanelGui(numberOfTimers);
    selectTimer(0);
    public void setCommandPanel(CommandPanel cp) {
    for (int i=0; i < timerControls.length; i++) {
    timerControls[i].setCommandPanel(cp);
    getSelectedTimer().formatCommandPanel();
    private void initTimerPanelGui(int numberOfTimers) {
    timerControls = new TimerControl[numberOfTimers];
    for (int i=0; i < timerControls.length; i++) {
    timerControls[i] = new TimerControl("Timer_" + i, selectorGroup);
    add(timerControls[i]);
    private void selectTimer(int timerIndex) {
    if (timerIndex < 0) timerIndex = 0;
    if (timerIndex >= timerControls.length) timerIndex = timerControls.length - 1;
    timerControls[timerIndex].select();
    private int getIndexOfSelectedTimer() {
    int index = -1;
    for (int i=0; i < timerControls.length; i++) {
    if (timerControls[i].selectorButton.isSelected()) {
    index = i;
    break;
    return index;
    public TimerControl getSelectedTimer() {
    int index = getIndexOfSelectedTimer();
    return timerControls[index];
    public void addTimer() {
    addTimerToArray();
    add(timerControls[timerControls.length - 1]);
    int panelHeight = timerControls[0].getHeight() * timerControls.length;
    this.setSize(timerControls[0].getWidth(), panelHeight);
    timerControls[timerControls.length - 1].validate();
    private void addTimerToArray() {
    TimerControl tempTimers[] = new TimerControl[timerControls.length + 1];
    for(int i = 0; i < timerControls.length; i++){
    tempTimers[i] = timerControls[i];
    tempTimers[tempTimers.length -1] = new TimerControl("Timer_" + (tempTimers.length - 1), selectorGroup);
    timerControls = tempTimers;
    public class TimerField extends JTextField {
    public final String TIME_FORMAT = "mm:ss";
    public TimerField(String text) {
    super(text);
    setupListeners();
    private void setupListeners() {
    addFocusListener(new FocusListener() {
    public void focusLost(FocusEvent fe) {
    String text = getText();
    setText(text);
    public void focusGained(FocusEvent fe) {
    public void setText(String newText) {
    String formattedText = formatText(newText);
    super.setText(formattedText);
    private String formatText(String textIn) {
    // TIME_FORMAT is what we're shooting for.
    if (textIn == null) return "00:00";
    String minString, secString;
    int colonByte = textIn.indexOf(":");
    if (colonByte == -1) return TIME_FORMAT;
    if (colonByte == 0) minString = "";
    else minString = textIn.substring(0, colonByte);
    if (colonByte == textIn.length() - 1) secString = "";
    else secString = textIn.substring(colonByte + 1);
    long mins, secs;
    try {
    mins = new Long(minString).longValue();
    } catch (Exception e) {
    mins = 0;
    try {
    secs = new Long(secString).longValue();
    } catch (Exception e) {
    secs = 0;
    if (secs > 59) {
    mins += secs / 60;
    secs = secs % 60;
    if (mins > 99) mins = 99;
    minString = new Long(mins).toString();
    secString = new Long(secs).toString();
    if (minString.length() == 1) minString = "0" + minString;
    if (secString.length() == 1) secString = "0" + secString;
    String textOut = minString + ":" + secString;
    return textOut;
    public long getSecondsLeft() {
    String displayText = super.getText();
    int colonByte = displayText.indexOf(":");
    long totalSeconds = 0;
    if (colonByte > 0) {
    String minString = displayText.substring(0, colonByte);
    String secString = displayText.substring(colonByte + 1);
    long mins = new Long(minString).longValue();
    long secs = new Long(secString).longValue();
    totalSeconds = mins * 60 + secs;
    return totalSeconds;
    public void setSecondsLeft(long seconds) {
    long mins = seconds / 60;
    long secs = seconds % 60;
    String minString = new Long(mins).toString();
    String secString = new Long(secs).toString();
    if (minString.length() == 1) minString = "0" + minString;
    if (secString.length() == 1) secString = "0" + secString;
    String results = minString + ":" + secString;
    super.setText(results);
    I think that's everything...

  • SAP GUI with SNC logon and Hummingbird Exceed - SAP GUI window size issue

    We have discovered an issue when SAP GUI 7.10 is used to logon via SNC and Hummingbird Exceed is used on the same workstation to logon to a UNIX system either via x-windows or telnet.
    When the user logs onto a UNIX system using Hummingbird Exceed, then uses SAP GUI to logon to a SAP system with SNC authentication, the SAP GUI authentication works, but the favourites list is not fully displayed and has to be resized before any of the entries are available.
    Has anybody else seen this issue, and do they know if there is a fix available ? We wondered if there might be an issue with fonts or some other sort of conflict between Exceed and SAP GUI, but it is strange that the problem only occurs if SNC authentication is being used, and when userid+password is used to logon to SAP the problem does not occur.
    Cheers,
    Tim

    Hello Tim and Wolfgang,
    I was curious too as I found it interesting... so I tested a few combinations, but could not reproduce what Tim has described, at least not before my CPU reached 100% and the applications stopped responding (~2GHz processor, 1GB RAM, 48 kbps connection, latency ~ 2 x width of the Pacific Ocean, but Backend 7.00!).
    However I did notice some indications which might be a help (based on 7.00!):
    Back in 4.?? there was a problem in that large menus could not be searched(!). Sorry, I don't have access to SAP now, but from memory the note # was 444043 (or very similar) and introduced a form routine for large menus - from a printscreen I still have the message number which led me to the note - 'I476(S#)'.
    The system certainly distinguishes between MENU_TYPEs and the above note corrections could be found in several locations relating to the SAP menu 'S', the role menu 'A' etc, but I could only see that for favourites 'F' this is implemented for the menu search (when searching, not when loading).
    @ Tim: Ask you customer to create a favourites menu which only has 1 node or max 2 (certainly not more than 4!) and ~ 20 executable objects in it (not more than 30!)? Can they under any conditions achieve the described problem with such a menu?
    If not possible to reproduce, then the closest I could guess is a maximum limit of 4 nodes and max 30 objects for a 'F'avourite menu, before it is a minimum candidate for "performance problems" and consideration to be converted to a role ('A'ctivity group) menu instead.
    Sorry that I can only help by speculating, because I could not reproduce what you have described.
    Hopefully this problem will not happen to me in the New Year, and hope you will solve it for the rest of the year
    Cheers,
    Julius
    Updated memory (not RAM) by: Julius Bussche on Jan 3, 2008 9:07 AM

  • Which approach to use for resizing image

    There are two ways of resizing images as I know:
    1. image.getScaledInstance(width,height,hint);
    Using hint like Image.SCALE_AREA_AVERAGING gives somehwat satisfactory resizing.
    2. static BufferedImage resize(GraphicsConfiguration gc, BufferedImage source, int w, int h, Object hintValue) {
    BufferedImage result = gc.createCompatibleImage(w, h, source.getTransparency());
    Graphics2D g2 = result.createGraphics();
    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hintValue);
    double sx = (double) w / source.getWidth(), sy = (double) h / source.getHeight();
    g2.drawRenderedImage(source, AffineTransform.getScaleInstance(sx, sy));
    g2.dispose();
    return result;
    where the hint passed is RenderingHints.VALUE_INTERPOLATION_BILINEAR ;
    Now which of the two method method should I use-using image.getScaledInstance() or using AffineTranform ? opr is there any other way which is faster but provides good result?
    i am creating an image editor, so the GUI dialog will have oprtion to choose the algorithm. I want the method which provides better result yet faster.
    Tanveer

    http://forum.java.sun.com/thread.jsp?forum=20&thread=522483

  • Problem with GUI in applet

    Hai to all,
    I am having a problem with GUI in applets
    My first class extends a JPanel named A_a
    import javax.swing .*;
    import java.awt.*;
    import java.awt.event.*;
    public class A_a extends JPanel
    JButton jb;
    JTextArea text;
    public A_a()
    setLayout(new FlowLayout());
    jb=new JButton("Click me");
    //add(jb);
    text=new JTextArea(5,20);
    add(text);
    public void text_appendText(String aa)
    System.out.println("I AM IN A_a");
    text.append(aa);
    text.revalidate();
    revalidate();
    /*public static void main(String ags[])
    A_a a = new A_a();
    JFrame frame=new JFrame();
    frame.getContentPane().add(a);
    frame.pack();
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) { System.exit(0); }
    frame.setSize(200,200);
    frame.show();
    and then I am using other class B_b which is an applet carries a exitsing panel (A_a) inside it .
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class B_b extends JApplet
    public A_a a;
    public void init()
    a=new A_a();
    getContentPane().add(a);
    public void text_appendText(String aa)
    final String aaa =aa;
    new Thread(new Runnable()
    public void run()
    a=new A_a();
    a.setBackground(new java.awt.Color(255,200,200));
    System.out.println("I AM IN B_b");
    a.text.append(aaa);
    a.text.revalidate();
    getContentPane().remove(a);
    resize(500,500);
    }).start();
    and the I am using the second applet C_c in which by performing a button action the old panel A_a should get removed and replace the new panel D_a (which is not here )in the applet B_b with all other components(namely button , text fields etc)
    import javax.swing .*;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.util.*;
    public class C_c extends JApplet implements ActionListener
    JButton jbt;
    JTextArea jta;
    public void init()
    getContentPane().setLayout(new FlowLayout());
    jbt=new JButton("Click me");
    jbt.addActionListener(this);
    getContentPane().add(jbt);
    jta=new JTextArea(5,20);
    getContentPane().add(jta);
    public void actionPerformed(ActionEvent ae)
    Enumeration e = getAppletContext().getApplets();
    Applet applets = null;
    while(e.hasMoreElements())
    applets=(Applet)e.nextElement();
    if ( applets instanceof B_b)
    System.out.println("I AM CLASS C_c");
    ((B_b)applets).text_appendText(jta.getText());
    ((B_b)applets).remove());
    ((B_b)applets).getContentPane().add(D_d);
    both the applets C_c and B_b are in same browser page
    How can i achive that pls help .

    Just to make the code readable...
    import javax.swing .*;
    import java.awt.*;
    import java.awt.event.*;
    public class A_a extends JPanel
    JButton jb;
    JTextArea text;
    public A_a()
    setLayout(new FlowLayout());
    jb=new JButton("Click me");
    //add(jb);
    text=new JTextArea(5,20);
    add(text);
    public void text_appendText(String aa)
    System.out.println("I AM IN A_a");
    text.append(aa);
    text.revalidate();
    revalidate();
    /*public static void main(String ags[])
    A_a a = new A_a();
    JFrame frame=new JFrame();
    frame.getContentPane().add(a);
    frame.pack();
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) { System.exit(0); }
    frame.setSize(200,200);
    frame.show();
    }and then I am using other class B_b which is an applet carries a exitsing panel (A_a) inside it .
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class B_b extends JApplet
    public A_a a;
    public void init()
    a=new A_a();
    getContentPane().add(a);
    public void text_appendText(String aa)
    final String aaa =aa;
    new Thread(new Runnable()
    public void run()
    a=new A_a();
    a.setBackground(new java.awt.Color(255,200,200));
    System.out.println("I AM IN B_b");
    a.text.append(aaa);
    a.text.revalidate();
    getContentPane().remove(a);
    resize(500,500);
    }).start();
    }and the I am using the second applet C_c in which by performing a button action the old panel A_a should get removed and replace the new panel D_a (which is not here )in the applet B_b with all other components(namely button , text fields etc)
    import javax.swing .*;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.util.*;
    public class C_c extends JApplet implements ActionListener
    JButton jbt;
    JTextArea jta;
    public void init()
    getContentPane().setLayout(new FlowLayout());
    jbt=new JButton("Click me");
    jbt.addActionListener(this);
    getContentPane().add(jbt);
    jta=new JTextArea(5,20);
    getContentPane().add(jta);
    public void actionPerformed(ActionEvent ae)
    Enumeration e = getAppletContext().getApplets();
    Applet applets = null;
    while(e.hasMoreElements())
    applets=(Applet)e.nextElement();
    if ( applets instanceof B_b)
    System.out.println("I AM CLASS C_c");
    ((B_b)applets).text_appendText(jta.getText());
    ((B_b)applets).remove());
    ((B_b)applets).getContentPane().add(D_d);
    }

  • [SOLVED] Terminal emulator that allows free resizing?

    EDIT: Answered my own question; terminator allows per-pixel resizing if you disable window hinting in the preferences.
    I have an annoyance with resizing terminal emulators. I use stacking WMs (xfwm4 on one setup, compiz standalone on another) but I usually like to tile my windows manually. I've enabled edge snapping in both of these WMs. However, whenever I'm resizing a terminal window, the snapping doesn't work because the terminal window can't be freely resized - I can only change the size of the window by one character's height/width. For example, if a terminal is open at 80x36, and I want to make it just a little bit wider to snap against the edge of another window, I can't because it won't let me resize the window between 80 and 81 characters.
    I've tried xfce's terminal, gnome-terminal, lxterminal, xterm, urxvt, and st. Can someone direct me to a terminal emulator that will let me resize windows to whatever size I want, regardless of whether it is a discrete character size, or am I out of luck?
    P.S. I've noticed that if I resize a window with wmctrl and issue the resize command twice, then xfce's terminal behaves the way it should. Can I replicate this behavior for resizing with the mouse?
    Last edited by thorion (2012-10-19 05:14:41)

    A terminal emulator and X Window GUI are different things. You can have a terminal emulator in a graphical desktop environment, but you cannot display GUI in a terminal.
    Putty is just a SSH client and terminal emulator (VT) and can be used with X-forwarding to display remote GUI applications (Linux), provided you are have a X Window server installed and running on your local computer, e.g. Xming Server for Windows.
    Perhaps you will find the free version of http://mobaxterm.mobatek.net/ useful. It is a single application based on Cygwin that allows you run GUI applications from your remote Linux system.
    By far the best terminal emulator in terms of user interface and configuration options that I’m aware of is the Terminal App of MacOSX, which also automatically opens Xorg if you open a GUI application. And it provides the full set of terminal escape sequences. But if you are on Windows….
    Alternatively, use VNC. You can run VNC in several modes, either to open an existing remote desktop connection, start a new desktop connection, or run a minimal X windows server, such as TWM that does not require you to install or run a graphical user desktop on your remote Linux server. If you are interested in VNC, perhaps check the following: https://community.oracle.com/thread/2456580. You can also tunnel VNC through SSH if your network firewall prevents communication.

Maybe you are looking for

  • Data loading after field enhancement.

    Dear all, We are using BI7.00 and in one of our data source, a new field has to be enabled. Our people are under the impression that without downtime, the previous data which is available in the Target and the PSA can have values for the new field al

  • While Activating  Message mapping, error.

    Hi While activating my message mapping  i am getting this error "JMS server failed" How to resolve this and whats the cause of it? Please do not post links. Thanks in advance Saiyog Points will be awarded Edited by: Saiyog Gonsalves on Jun 13, 2008 6

  • Why can't I get the "save as" option when I download a file, it automatically saves EVERYTHING to download folder.

    When I download a file, I used to get an option to "save as", instead of just save. If I download a file I like to immediately download it into the appropriate folder on my desktop (not just one folder.) Instead I have to download it, go into the dow

  • Daily Report Layout Customization

    Is it possible to customize the layout in the Daily Report - LABOR tab? I wish to rearrange the column order and the widths. It is possible at the Daily Report level but I don't see how it is possible at the Tab level...

  • Having problem connecting to the livecache server from APO instance

    Could not able to connect to the live cache server from the APO server after installing both the instances separately on two different systems, while using the T-code LC10 to make a connection from APO DDIC login its displaying the following message