Swing/AWT/SWT :: JTextArea Position And Size

Nov 6, 2014

I need to make a simple applet, but I'm stuck with something. This is how my applet should look:

And this is how that part looks in my applet:

What I've done until now is create one JPanel which includes two other JPanels.. The first one contains only the JTextArea you can see, and the other one includes the other elements.

I just need to make the JTextArea taller, like in the example, so everything comes into place...

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: Revalidate Is Resetting JTextArea Position On JPanel

Nov 3, 2014

So, I have a program that allows me to dynamically add JTextAreas and then drag them around the screen. The problem is, when I add a new JTextArea, I call revlidate() to update the panel. This causes all of the JTextAreas to reset their positions. How can I prevent this from happening? It is happening on this code:

public void addBox() {
drag = new DragListener();
JTextArea textArea2 = new JTextArea("Some text
Some other text");
textArea2.setLineWrap(true);
textArea2.setWrapStyleWord(true);

[Code] .....

View Replies View Related

Swing/AWT/SWT :: JTable Instead Of JTextArea

May 3, 2015

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

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

[code]....

View Replies View Related

Swing/AWT/SWT :: How To Implement JTextArea In Netbeans

Apr 20, 2014

I have dragged and dropped a jTextArea from netbeans palette onto my form. But when I right clicked for Event > action > actionPerformed for implementation, I realized such was not there, unlike the jTextField component. For example, I have tried this but it didn't work:

//{
Import java.swing.*;
JTextArea txa = new JTextArea();
txa.getText(jTextArea1);
txa.setText(jTextArea1);
txa.setTextWrap(true);
//}

View Replies View Related

Swing/AWT/SWT :: Using SetBounds Or SetLocation On JTextArea Not Working

Oct 31, 2014

I am adding a JTextArea to my JPanel with this code:

commentTextArea.setLineWrap(true);
commentTextArea.setWrapStyleWord(true);
commentTextArea.setVisible(true);
this.add(commentTextArea);
commentTextArea.setBounds(0, 0, 100, 100);
//commentTextArea.setLocation(0, 0);

Whenever I use setLocation(0,0), the JTextArea never moves. It is always in the top middle of the screen, not at (0,0). The same goes for setBounds(0,0,100,100) BUT the height and width are set this way, just not the location. Why is this?

Full Code

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.JFrame;
import javax.swing.JMenuBar;

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Display Console Result In JTextarea

Mar 29, 2014

I have a problem with my code,in fact I can't output the stream from console to my jTextarea,this is my code:

public class AudioFrame extends javax.swing.JFrame {
static double[] audioFile;
static String audioToDecode;
static String audioKey;
static String outputName;
static String outAudio;
static String name;
static int command;
static String textToEncode;

[Code]...

View Replies View Related

Swing/AWT/SWT :: Save Text From JTextArea - String Formatting

Dec 30, 2014

I am currently working on a project that can save text from a JTextArea and also open that same saved text. The problem I am having is that when I open the saved text file it is no longer formatted.

How the file looks before saving/closing:

public class HelloWorld{
System.out.println("Hello World!");
}

How the file looks after being saved/closed then opened:

public class HelloWorld{ System.out.println("Hello World!");}

When I save the file I'm actually saving the entire thing to a single string. When I do this the String eliminates all tabbed spacing and pushes all characters to one single line.

The only ideas I had for fixing this were to either somehow use Format in the String class or record every time user tabs and add to the String.

View Replies View Related

Swing/AWT/SWT :: Give JTextArea Focus - Using It On A Panel And With JToolBar

Apr 21, 2014

I have a program with a main panel JPanel that implements KeyListener. I added a JTextArea to which I added as the KeyListener: this, meaning the main panel. I made the JTextArea fill the entire main panel because I want to catch a key press anywhere in the main panel.I catch the key presses and the program does what I want it to.

I added a JToolBar to the program; it is working just fine.Now that I have two components on the main panel - toolbar and panel with textarea -, the textarea must have the focus before it will send the KeyEvent and call keyPressed(). I don't want to expect the user to click on the main window to get the program to start or after each time they use the toolbar.

I have tried calling both requestFocus() and requestFocusInWindow() on the textarea; neither call worked. I put the toolbar at PAGE_END instead of PAGE_START; this worked to allow the program to start but I don't want to have the toolbar at the bottom and once I clicked on a toolbar button, the textarea lost the focus.

I need to be able to give the textarea the focus when the program starts and after the user uses a toolbar button. (I suspect that if I solve the problem when the program starts, I can use the same method after handling a button press.)

View Replies View Related

Swing/AWT/SWT :: 2D Spaceship Game - Image Rotation And Position

Aug 29, 2014

I'm attempting to create a 2D spaceship game from scratch. My problem is that I feel like the way Im rotating images is awkward and just wrong. I believe what I'm doing in the following code is loading an image into a JPanel and rotating the image and moving the JPanel.

The code is unrefined and only partial, but it show how I am manipulating images.

import java.util.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.geom.AffineTransform;
import javax.swing.*;
import java.lang.Math.*;
import java.io.*;
import javax.imageio.*;

[Code] .....

What seems so awkward is that I have to create a new JPanel for every image, I would think there is a better way but I don't know. I have tried to get one image on top of an other with the JPanels to no avail. That said I haven't put much time into trying to get that to work. I want to know if I should continue my attempt with JPanels or to pursue a different method.

View Replies View Related

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

Jan 9, 2014

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

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

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

View Replies View Related

Swing/AWT/SWT :: Test Orders Not Showing Up In JTextArea Instead Printing To Console

Jan 8, 2015

I have small problem in GUI. I have a text area which has to display my test orders now what is happening instead of the text showing up in the JtextArea its still printing to the console so this order code (yes i did not use proper code standers) runs though my order class fine but its not loading the text in the JtextArea

Order code

public static String testCase1(){
orders ords = new orders();
System.out.println("Test Case 1: " + "
" + ords.getOrderDetails());
return " ";

My jbutton code :

txtContent.setText(new orderTester().testCase1());
txtContent.setText(new orderTester().testCase2());
txtContent.setText(new orderTester().testCase3());

I have 10 test case to load in the jTextArea

View Replies View Related

Swing/AWT/SWT :: Java Stop JScrollPane Auto Scrolling Back To The Top When JTextArea Updated

Feb 7, 2014

I have a swing application that gets football scores from a website using Jsoup.

When the "Get Scores" button is pressed, the scores are printed to a JTextArea with a JScrollPane.

I have also used a SwingWorker to update the scores every couple of seconds.

My problem is that every time the JTextArea updates, the JScrollPane scrolls back to the top of the text area. I wan the scroll bar to stay where the user left it.

Here is my code (The update is currently set to update every 1 second so you can see what the scroll bar is like).

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
public class frame extends JFrame {

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Setting Size Of JFrame

May 26, 2014

I am rather new to Swing, and I am building a game right now in which I need to display a pop-up window as a reminder for what commands exist within the game. I created a class extending JFrame for this and added all the information I need. However, for some reason, no matter how many different ways I try to set the size of this window (setSize(w, h), pack(), using a different layout, adding the compnents to a JPanel first and setting the preffered size of that, then adding the JPanel to the JFrame), it doesn't work. Instead of a window of my requested size, I get a tiny, maybe 100 x 100 pixel window that needs to be resized in order for its contents to be visible.

import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

[code]....

View Replies View Related

Swing/AWT/SWT :: Adjusting Size Of Box With Mouse

Oct 16, 2014

I'm running the code below which compiles ok using latest version of Java and on Sublime. The problem when it complies the output screen is blank and I can only see the text by adjusting the size of the box with my mouse - and then it colours in black. Code and screenshot below. Is there something wrong with the paint/graf part of the code?

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BackArray extends JFrame {
int store[] = {2,6,4,8,34,67,19,99,10,12,89,68,45,37};
int xcoord = 100;
boolean firsttime=true;

[code]....

View Replies View Related

Swing/AWT/SWT :: Change Size Of Entire GUI?

Feb 4, 2015

I built a GUI and after testing it on various platforms I think I would like to make it bigger by a factor of 2.2 or so.

Is there an easy way to just enter the factor 2.2 and have the GUI change by that factor?

I have over 50 components in the GUI. Ideally each one would just enlarge by the factor including the fonts.

This was my first (and only so far) java program. I didn't know anything about layout managers. I used netbeans and it generated all the code.

View Replies View Related

Swing/AWT/SWT :: Screen Resolution / Size

Sep 29, 2014

I have created a java gui on Windows 7 with Eclipse EE, using a screen resolution of 1366 x 768. I used groups with specified boundaries. For example:

final Group g5_script_data = new Group(shell, SWT.BORDER_SOLID);
g5_script_data.setText("Current DB");
g5_script_data.setBounds(0, 0, 680, 380);
g5_script_data.setBackground(green);

The groups cover the whole screen.

However my colleague with a smaller resolution looses the far right of the screen.

As this is a proto-type and I'm new to Java I don't want to rework everything or convert it to say a grid layout until the proto-type is accepted and I can start from scratch with a real detailed design. It already has 6500 lines of source.

Just wondered what is my quickest/easiest way to get my app to display on a slightly smaller resolution. For sure it will not be anything silly. Something like 1280 x 768 to 1366 x 768 would do.

View Replies View Related

Swing/AWT/SWT :: How To Change JFrame Size

Jan 14, 2015

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

[Code].....

View Replies View Related

Swing/AWT/SWT :: Want To Maximize JFrame Size

Apr 13, 2014

I have a simple application where I display a JFrame. I want to maximize the JFrame size, so I have the code this.setExtendedState(MAXIMIZED_BOTH); in the constructor. How do I find the dimensions of this JFrame in its extended state though? I tried this.getSize().Height , this getSize().getHeight() and this.getHeight()? None of them work because they just return a value of 0. And what is the difference in all these statements in terms of what they do?

View Replies View Related

Swing/AWT/SWT :: Move Focus From Specific Jcombobox To Specific Jtextarea?

Nov 5, 2014

How do I move focus from a jcombobox to a specific component say a jtextarea.

My attempt below seems to be moving to a random component not the desired jtextarea.

takenByCombo.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_TAB ) {
e.consume();
dayJTArea.requestFocus(); // focust not moving dayJTArea
}
}
});

I applied the above logic to move focus from a specific jtextarea to another jtextarea as seen below and it works as desired.

dayJTArea.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_TAB ) {
e.consume();
monthJTArea.requestFocus();
}
}
});

View Replies View Related

How To Change Fonts And Font Size In Swing

Feb 10, 2014

So, I have a game. I would like to make a game where you press "start" and THEN it starts. Also, I want to have collision with triangles, not just squares. The way I handle collision right now is with if statements, if the object is within the other, game over.How would I do collision with triangles? Lastly, how do I set a high score? how to change fonts and font size in swing?

View Replies View Related

Swing/AWT/SWT :: Getting Icons To Change Size With Window Resize

Jan 19, 2014

I'm using a jpanel with an 8 by 8 grid layout of jlabels to which I'm adding images to represent a chess board. At first, I was using the ImageIcon class to initialize my icons, but as soon as I added these icons to the labels, the labels no longer changed size with the window (which I want to happen). URL...

So I copied in the class, and initialized a different set of icons using the stretch icon class (specifically, the method that allows you to initialize a stretch icon from a filename), however, when I use these stretch icons, the result is the same. Is something wrong with the class, or with my implimentation of it, and how would I fix this?

View Replies View Related

Swing/AWT/SWT :: JTextField Size Changes With JLabel Text Length

Nov 11, 2014

I want to create 3 JTextFields in a row with all being of equal size.But my first Text field gets so wide than the other two.After adding each component at a time and seeing what causes the problem I realized that if I type a long text for the JLabel that's when this problem occurs.If I reduce the length of the text in the JLabel JTextFields get into the sizes I want. Here's my code

import java.awt.*;
import java.awt.event.*;
import java.lang.Math;
public class Calculator1 extends JFrame {
JTextField value1=new JTextField("0");
JTextField value2=new JTextField("0");

[Code] ....

How can I stop the JTextFields changing size when I change the JLabel label1's text length...

View Replies View Related

Swing/AWT/SWT :: Getting Icons To Change Size With Window Resize?

Jan 16, 2014

I'm using a jpanel with an 8 by 8 grid layout of jlabels to which I'm adding images to represent a chess board. At first, I was using the ImageIcon class to initialize my icons, but as soon as I added these icons to the labels, the labels no longer changed size with the window (which I want to happen). Someone suggested to me to use this custom stretch icon class, found here:

[URL] ....

So I copied in the class, and initialized a different set of icons using the stretch icon class (specifically, the method that allows you to initialize a stretch icon from a filename), however, when I use these stretch icons, the result is the same. Is something wrong with the class, or with my implementation of it, and how would I fix this?

View Replies View Related

Swing/AWT/SWT :: Jscrollpane Not Shown Until Adjust Window Size With Mouse?

Nov 16, 2014

So for a test i have a small array set as a jlist which is the contents of my jscrollpane, and it appears as if nothing is there until i adjust the window size by dragging it out or in... whats going on?

Here is the full code

import java.awt.BorderLayout;
import java.awt.ComponentOrientation;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;

[Code] ...

View Replies View Related

Swing/AWT/SWT :: Mini Paint Program - Changing Size Of Shapes

Jun 4, 2014

I am currently writing a small drawing program and I am having trouble with changing the size of the shapes. To do this, I have to access the arraylist shapes, check whether pressedX/pressedY is on any of the shapes in the arraylist using the findShape() method and then when released, uses moveBy() in the Rectangle/Oval/Line class and moveShape() in the miniDraw class to move the shape and draw it in the newreleasedX/releasedY position.

So far I think I have pin pointed the problem to being the method in all the shapes classes, that checks whether the pressedX/pressedY which is the on() method, and the findShape() method in the miniDraw class.

This is the minidraw class

import ecs100.*;
import java.awt.Color;
import java.io.*;
import java.util.*;
import javax.swing.JColorChooser;

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Automatic Adjustment To Suit Size Of Operators Monitor

Feb 12, 2014

I'm building an application in Netbeans and so far I'm making good progress with it. I have created an animated splash screen in myspacegen.com and then downloaded it as a GUI file. I've then imported it into my application in Netbeans but I was restricted in myspacegens.com to the size of the image I could create. I want to know if it is possible to add code to the splash screen project within Netbeans so that it automatically adjusts to fill the screen. I have used the java commands get width and get height elsewhere in my application so that the window I create in a project automatically adjusts to fill the operator's screen but that has a 'window' to adjust and I do not want my splash screen to have a visible window.

View Replies View Related







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