Swing/AWT/SWT :: JXTable Width To Adjust According To Content

Jul 9, 2014

I have a JXTable that is created like this:

JScrollPane scrollPane = new JScrollPane();
contentPanel.add(scrollPane, BorderLayout.CENTER);
tbl = new JXTable();
tbl.setColumnSelectionAllowed(true);
tbl.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
tbl.setEditable(false);
scrollPane.setViewportView(tbl);

The problem is that when it gets filled, all the columns are squashed together to fit into the jxtable. I expected the columns to be adjusted according to the width of the column header or column value (which ever is wider) and then for a horizontal scroll bar to be displayed that will enable me to scroll left or right.

View Replies


ADVERTISEMENT

JavaFX 2.0 :: Tableview - Width Of Columns Computed For Content Of Cells And Ignoring Header

Nov 20, 2014

I'm using the tableview-component. The size of font of header is greater then that of cells. The problem is: the width of the column bases on the cell with the longest string and if the header-string is longer then the header gets truncated (it shows ellipsis) and I have to change the width of column manually. How could I solve this problem? The easiest way would be to compute the column-width on myself. I can't find any method in javafx, that would allow to compute the width of string in pixels. In Swing there is the FontMetrics class and Graphics class, so it is easy to get the width in pixels. Are there any pendants to this classes in JavaFX?

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 :: Sizing JScrollPane Width To Its Contained JTable

Feb 21, 2015

Returning true from getScrollableTracksViewportWidth() makes the table (or other Scrollable) size its width to match the viewport. I need the opposite: for the viewport to expand its width to accommodate the table (of course, limited by the constraints imposed by the scroll pane's container's layout manager) without reducing column widths i.e. setAutoResizeMode(AUTO_RESIZE_OFF).

I have achieved this by overriding

getPreferredScrollableViewportSize(): JTable table = new JTable() {
@Override
public Dimension getPreferredScrollableViewportSize() {
return new Dimension(super.getPreferredSize().width,
super.getPreferredScrollableViewportSize().height);
}
};

Now when the scroll pane is added at BorderLayout.CENTER and the frame is pack()ed, all columns of the table are displayed, without need for a horizontal scrollbar.

View Replies View Related

Swing/AWT/SWT :: Change Content Pane Color Of JFilechooser

Mar 25, 2015

I'm dealing with, change the content pane color of jFilechooser. Color has been changed but the problem is when I open the subdirectory leads errors; Note : It also trigger error when I set default directory; like chooser.setCurrentDirectory(file);

The following error is the result:

Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at javax.swing.plaf.metal.MetalFileChooserUI$IndentIcon.getIconWidth(MetalFileChooserUI.java:912)
at javax.swing.SwingUtilities.layoutCompoundLabelImpl(SwingUtilities.java:961)
at javax.swing.SwingUtilities.layoutCompoundLabel(SwingUtilities.java:888)
at javax.swing.plaf.basic.BasicLabelUI.layoutCL(BasicLabelUI.java:94)
at javax.swing.plaf.basic.BasicLabelUI.getPreferredSize(BasicLabelUI.java:239)

[Code]...

Following is the code base

import javax.swing.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.*;
import javax.swing.event.*;
import javax.swing.plaf.*;
import javax.swing.plaf.basic.*;

[Code]...

View Replies View Related

Swing/AWT/SWT :: How To Print JFrame Content Using NetBeans Java

Sep 10, 2014

I am developing a program in netbeans forms. I've got to a point where I will click a jButton to print the content of either JFrame or JPanel. I am using Netbeans forms to develop the project....

View Replies View Related

Swing/AWT/SWT :: Reading From HTMLEditorKit Doesn't Display Text While In Text / HTML Content Type?

Apr 24, 2015

I'm working on a simple text editor, and I'm currently saving the contents of my JTextPane in a file using an HTMLEditorKit (text is a JTextPane):

private void save() throws IOException {
int returnVal = fc.showSaveDialog(window);
if (returnVal == JFileChooser.APPROVE_OPTION) {
StyledDocument doc = (StyledDocument)text.getDocument();
HTMLEditorKit kit = new HTMLEditorKit();
BufferedOutputStream out;

[Code] ....

The problem I'm having is that after opening a file that I saved, it does not display (if I disable text/html, it displays the entire html code, but when I re-enable it, nothing displays at all.) Am I loading it wrong, or am I setting the JTextPane's text incorrectly? Or is it, perhaps, another error that I didn't catch?

View Replies View Related

How To Control Width Of Stroke

Nov 18, 2014

how am i supposed to make line1B with "1f" and line2B with width of "10f"?

PHP Code:

import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;

[code]....

View Replies View Related

Int Declarations - Assigning Length And Width

Mar 19, 2015

What is happening in below mentioned java code. Why in method insert, int l, int w is declaring & it is assigning to length & width.

class Rectangle{
int length;
int width;
void insert(int l,int w){
length=l;
width=w;

[Code] ....

View Replies View Related

How To Get Specified Width Of Integer Printed Output

Jul 21, 2014

If I code:

int num0=0,num1=1,num999=999;
System.out print(num0+","+num1);
System.out println(","+num999);

I believe I'll get: 0,1,999 but I want 0000,0001,0999 i.e. a width of 4 for small integers.

View Replies View Related

JavaFX 2.0 :: Why Bind Of Width Of TableColumn Is Not Working

Oct 1, 2014

I would like to bind the width of the second column of my TableView with the width of my TableView.
My custom TableView class :

public class CustomTableView<T> extends  
TableView<ObservableList<Pair<String, Object>>> implements Cloneable {  
private static Logger logger = Logger.getLogger(CustomTableView.class);  
private double prefWidth; // optionnel   private double minWidth; // optionnel  
private double maxWidth; // optionnel   private double height; // optionnel  
private List<InfoColumnBean> cols; // optionnel 

[Code]....

View Replies View Related

How To Set Column Width In Csv File Using Java Code

May 25, 2013

how to set the columnwidth in csv file using javacode.

I used FileWriter class to upload data into the csv file but csv file is taking default width while showing content. Is there a way to set the fixed column width or set width dinamically based on value?

View Replies View Related

Calculating Area Of A Rectangle (height Multiply By Width)

Mar 19, 2014

I was suppose to create a simple Java program for calculating the area of a rectangle (height * width). Then check the user’s input, and make sure that they enter in a positive integer, and letting them try again if they enter in a negative number. (I'm not sure how to get them to try again.

I am suppose to use an "if" statements and indeterminate loops to achieve the solution. The program will have the following requirements:

1. Ask the user to enter in both a height and width (as an integer)
2. If the user enters in a negative number, display an error
3. If the user enters in a negative number, give them another chance to enter in the correct value
4. Calculate the area and display to the screen once two positive integers have been entered.

import java.util.Scanner;
public class RectangleAreaCalc
{
public static void main(String[] args)
{
int length;
int width;
int area;
 
[Code] ....

View Replies View Related

Java Window Settings - Open With Certain Width And Height

May 19, 2014

Any way to get my Java window to open with a certain width and height. I've been googling and haven't found to much valuable information. Here is what I have so far.

import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class JavaWindow{
//Bring up the frame.
private JFrame f = new JFrame("JavaWindow");

[Code] ....

When you compile that it runs a small window. I would like that window to be bigger when the file opens.

View Replies View Related

ActionListener And GetActionCommand - Volume For Length / Width And Height?

May 17, 2013

I do not understand the getActionCommand and ActionListener concepts. This code does not resolve the volume for length, width, and height.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.awt.Container;
public class rectangularSolid extends JApplet implements ActionListener {

[Code] ....

View Replies View Related

JavaFX 2.0 :: Sizing Width Of ComboBox Based On Items

Apr 16, 2015

I have a ComboBox -- just a simple ComboBox with string items.
 
My string items aren't very long (5 letters max), but the ComboBox shows quite wide relative to my strings. So I would like to size my ComboBox to the size of my strings.
 
I messed around with setting the CellFactory of the ComboBox, and have the Cells produced by the CellFactory set the preferred width of the cells to some constant like 100. That worked in terms of changing the size of the ComboBox to the preferred width of 100.
 
But what I really want to do is to compute the preferred width from the string items. For that I need to be able to compute how wide a string item will be when rendered. And I guess that depends on the font size used by the ComboBox to render strings, which probably depends on the platform (OS X different to Windows?).

View Replies View Related

Java-8 :: Button Width Calculated Wrong Under Windows?

May 7, 2014

I am developing a JavaFX application under Java 8 on my Ubuntu 14.04 (32 bit) system. When I run it on the Ubuntu box, all is fine, but when I run it under Windows 7 Home Premium (64 bit) with the same Java8 release installed, all my buttons have their text ellipsised (sp?). Why the behavior is different? Or is this a bug in JavaFX? Here are the particulars:
 
fxml:
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?><?import java.util.*?><?import javafx.geometry.*?><?import javafx.scene.*?><?import javafx.scene.control.*?><?import javafx.scene.layout.*?><?import javafx.scene.text.*?>
<AnchorPane id="AnchorPane" prefHeight="91.0" prefWidth="-1.0" xmlns:fx="http://javafx.com/fxml"> 

[Code] ....

Java:
java version "1.8.0_05"Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) Server VM (build 25.5-b02, mixed mode)

View Replies View Related

Input Length And Width - Calculate And Print Perimeter And Area Of A Rectangle

Feb 16, 2015

Create a program to input the length and width of a rectangle and calculate and print the perimeter and area of the rectangle. To do this you will need to write a Rectangle class and a separate runner class. Your program should include instance variables, constructors, an area method, a perimeter method, a toString method, accessor and mutator methods, and user input. Your runner class should include 3 Rectangle objects. One default rectangle, one coded rectangle, and one user input rectangle. All methods should be tested in the runner class.

This is my code:

import java.util.Scanner;
 public class Rectangle {
double length;
double width;
public Rectangle() {

[Code] ...

What have I done??? I have created this program using the few different resources with which I am supplied, but I don't understand the resources.

View Replies View Related

User Enter A Number For Width And Length - Calculate Area And Perimeter

Apr 27, 2014

I am trying to make a program so that the user has to enter a number for the width and length and it will give the area and perimeter:

import java.util.* ;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class jframe extends JFrame {
private static final int WIDTH = 400;
private static final int HEIGHT = 300;

[Code] ....

It is giving me an error saying that the ExitButtonHandler and ebHandler do not have classes but I don't understand why.

View Replies View Related

Calculate Cost To Fill A Pool Based On Its Shape / Length / Width And Depth

Sep 17, 2014

This program is for a swimming pool filling service company. They charge 2 cents per gallon and $50 per hour to fill a pool. The truck can fill at a rate of 730 gallons per hour.

Create the Pool class that calculates the cost to fill a pool based on it's Shape, length, width and depth. (Input order is S L W D)

The pool class will need data fields for String shape, double length, double width, double depth, static double GallonsPerSqFoot = 7.4805, static double price per gallon = .02, static double FillingFeePerHour = 50.0, and static double FillingRate = 730gal/hr.

Create a No-Arg constructor and a constructor that accepts the non-static values, and has the methods: getShape, getLength, getWidth, getDepth, getGallons, getHours, getFillingFeePerHour, getHourlyCost and getTotalCost.

At the end of the class, create a main() method that asks for the input and returns the output based on the Pool class gets.. methods.

The shape options are oblong or rectangle. (A round pool would be oblong with the same width and height, a square pool would have the same width and height)

Formulas:
Rectangle cubic ft = length * width * depth.
Oblong cubic ft= ((Math.PI * Math.pow(width/2,2)* depth) +((length-width) * width * depth))
Gallons = cubic ft * 7.4805.
hours = total gallons/730.
Total cost = (total Gallons * .02)+(hours * $50)

Example Output
An oblong pool 18.00 feet long by 12.00 feet wide and 5.00 feet deep will use 6923.10 gallons of water and take 9.48 hours to fill. The total cost will be 612.65.

Here is my code:

import java.util.Scanner;
import java.util.*;
public class Pool
{
private String poolshape1 = "oblong";
private String poolshape1 = "rectangle";
private double length;
private double width;
private double depth;
private static double GallonsPerSqFoot = 7.4805;

[Code] .....

View Replies View Related

Page Is Not Displaying The Content?

Sep 14, 2014

One of my official site is not disaplying the content in machine#1 IE10 browser.And the same site is showing data in another machine#2. I compared the both machines JRE and JDK settings but no difference found.

how to link the JRE to browser.

View Replies View Related

JSF :: CommandLink - Cannot Change Content

Mar 4, 2015

I'm a first timer at jsf, and right now I'm learning how to use ajax in jsf. i got a problem when i click a command link i want to change in a content, but when i run my web and i click the command link it didn't do anything. This is the source :

<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"

[Code] ....

In this code when i click the Home button it suppose to change the ouput text to a string that store in my bean. This is my bean:

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package UI;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

[Code] .....

At first the output text value is the same as the string i store in the bean. but when i click the commandlink, it didn't do anything, is there something wrong with my code?

View Replies View Related

Reading Content From FTP File?

Jan 27, 2013

I am trying to read a content of file downloaded from ftp and return it as a String. This is what I use:

Java Code:

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.net.ftp.FTPClient;
public class Test {
public static void main(String [] args) throws IOException{
FTPClient ftp = new FTPClient();

[code]....

The code does not work, although all the links are correct.

View Replies View Related

How To Read Content From A Website To App

Nov 27, 2014

I am working on a little project to create an App that can read contents from a website and return it back to my app. What protocol to use for that. Just the reading/retrieving content from a website.

View Replies View Related

Cannot Read Zip Files Content

Dec 30, 2014

I am fallowing programming tutorials on youtube.And this code is for reading zip files content.I did the same things like in the video.But Code dosent work

try {
ZipInputStream zis=
new ZipInputStream(new FileInputStream("C:UsersxxxDesktop ry.rar"));
ZipEntry zip;
while((zip=zis.getNextEntry())!=null){
jTextArea1.append(zip.getName());
zis.closeEntry();
}
zis.close();
} catch (FileNotFoundException ex) {
Logger.getLogger(Zip.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(Zip.class.getName()).log(Level.SEVERE, null, ex);
}

View Replies View Related

Lined Out Content In Eclipse

Aug 26, 2014

I am new to Java and Eclipse. What does lined-out lines mean?

View Replies View Related







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