小编Jav*_*Man的帖子

JavaFX TableColumn调整大小以适合单元格内容

我正在寻找一种方法来在TableView中调整TableColumn的大小,以便所有内容在每个单元格中都可见(即没有截断).

我注意到双击列分隔符会自动使列适合其单元格的内容.有没有办法以编程方式触发此操作?

javafx tableview

10
推荐指数
3
解决办法
2万
查看次数

致力于在JavaFX中创建图库.无法正常显示图像

我正在使用javafx创建图库.我在互联网上发现了许多有关此问题的内容,但无法为此问题获得任何合适的帮助.我必须像picasa查看器一样创建一个图库.所有图像都在我的图像视图中的缩略图视图中,然后选择弹出查看器中的图像.我做了一些代码,但我得不到合适的输出.文件夹中的所有图像都从相同的坐标重绘.下面是我的代码和输出.

@Override
public void initialize(URL url, ResourceBundle rb) {

    String path = "/home/ubuntu/eclipse with liferay/Desktop/imagetest/";

    File folder = new File(path);
    File[] listOfFiles = folder.listFiles();

    for (final File file : listOfFiles) {

            ImageView imageView;
            imageView = createImageView(file);
            imagecontainer.getChildren().addAll(imageView);

    }

}
 private ImageView createImageView(final File imageFile) throws FileNotFoundException, FileNotFoundException, FileNotFoundException, FileNotFoundException {
    // DEFAULT_THUMBNAIL_WIDTH is a constant you need to define  
    // The last two arguments are: preserveRatio, and use smooth (slower) resizing  

    ImageView imageView = null;
    try {

        final Image image; …
Run Code Online (Sandbox Code Playgroud)

java javafx gallery imageview

9
推荐指数
1
解决办法
1万
查看次数

hibernate会话的get()和load()方法在获取方面有什么区别?

get()和load()方法有什么区别?关于数据获取方法

 public static void main(String[] args) {
    SessionFactory factory= new Configuration().configure().buildSessionFactory();
     Session session = factory.openSession();
     Transaction tx = null;
      tx = session.beginTransaction();
       System.out.println("1 st time calling load method");
        Account acc = 
               (Account)session.load(Account.class, 180); 
             System.out.println("bal"+acc.getBalance());

          System.out.println("2nd   time calling load method");
          Account  acc1=(Account)session.load(Account.class, 180); 
           System.out.println("bal"+acc1.getBalance());


        System.out.println("1 st time calling get method");
     Account acc2= (Account) session.get(Account.class, accId);

      System.out.println("bal"+acc2.getBalance());    

      System.out.println("2 st time calling get method");

     Account  acc2= (Account) session.get(Account.class, accId);

    System.out.println("bal"+acc2.getBalance());


     tx.commit();

   session.close(); 
Run Code Online (Sandbox Code Playgroud)

}

我得到了以下输出

1 st time calling load method
Hibernate: 
/* load …
Run Code Online (Sandbox Code Playgroud)

java hibernate

7
推荐指数
1
解决办法
2万
查看次数

使用子查询进行Sqlite Update查询

我必须使用表"testconsent_id"的id值更新表test_test列,test_groupedconsent,其中patient_idin test_testpatient_idin test_groupedconsent表匹配,并且两个表中的creation_date匹配.我正在使用以下查询但收到错误 - "near "as": syntax error".

查询有什么问题?

Update test_test as Tinner join (select id,patient_id,creation_date from test_groupedconsent) as Aon A.patient_id = T.patient_id and A.creation_date = T.creation_dateset T.testconsent_id = A.id;
Run Code Online (Sandbox Code Playgroud)

sql sqlite

6
推荐指数
2
解决办法
5858
查看次数

当我们在不同的命令提示中发出java命令时,将创建多少个JVM实例?

任何人都可以告诉我,当我们在不同的命令中发出以下命令时,将创建多少个jvm实例.

- command 1: c:\java -Xms32m -Xmx512m -Xss254k AccountSalary
- command 2: d:\java -Xms32m -Xmx512m -Xss254k AccountSalary
- command 3: c:\java -Xms32m -Xmx512m -Xss254k AccountSalary
Run Code Online (Sandbox Code Playgroud)

他们是否会使用save jvm heap size或者每个java进程使用不同的堆大小?

java jvm cmd

6
推荐指数
1
解决办法
3401
查看次数

PHP:如何一一获取字符串的字符

$str = "8560841836";
$mystr = array($str);
$string = strlen($str);
for($i=0; $i<=$string; $i++){   echo $string[$i]."\n";  }
Run Code Online (Sandbox Code Playgroud)

这段代码在一行中打印这个字符串,但我希望它在一行中的一个字符中打印,等等......

php string

6
推荐指数
3
解决办法
2万
查看次数

JTable 选择侦听器

我有一个代码,它在小程序中显示表格 & 由两列组成:-

  1. 图像图标
  2. 描述

这是我的代码:

    import javax.swing.table.*;

    public class TableIcon extends JFrame
     {
    public TableIcon()
    {
    ImageIcon aboutIcon = new ImageIcon("about16.gif");
    ImageIcon addIcon = new ImageIcon("add16.gif");
    ImageIcon copyIcon = new ImageIcon("copy16.gif");

    String[] columnNames = {"Picture", "Description"};
    Object[][] data =
    {
        {aboutIcon, "About"},
        {addIcon, "Add"},
        {copyIcon, "Copy"},
    };

    DefaultTableModel model = new DefaultTableModel(data, columnNames);
    JTable table = new JTable( model )
    {
        //  Returning the Class of each column will allow different
        //  renderers to be used based on Class …
Run Code Online (Sandbox Code Playgroud)

java swing jtable jtextarea

5
推荐指数
3
解决办法
4万
查看次数

Cafe Wall Illusion

这是我的代码的预期输出:

预期的结果

这是我的代码:

import java.awt.*;

public class CafeWall
{
    final static int MORTAR = 2;
    final static int WIDTH  = 650;
    final static int HEIGHT = 400;

    public static void main( String[] args )
    {
        StdDraw.setCanvasSize(WIDTH, HEIGHT);
        StdDraw.setXscale(0, WIDTH);
        StdDraw.setYscale(0, HEIGHT);

 // Change from Color.GRAY to change background color.
        StdDraw.setPenColor( Color.GRAY );
        StdDraw.filledRectangle(WIDTH/2, HEIGHT/2, WIDTH/2, HEIGHT/2);

 drawRow(    0, 378, 4, 20 );
 drawRow(   50, 300, 5, 30 );

 drawGrid(  10, 36, 4, 25, 0 );

 drawGrid( 250, 40,  3, 25, 10 …
Run Code Online (Sandbox Code Playgroud)

java swing awt

5
推荐指数
1
解决办法
7472
查看次数

如何在javafx中使子自动调整大小(子是Pane,父是VBox)

我有2个问题

1.在javafx应用程序中,我想将child(crosshairArea)放在其父级的左上角,宽度和高度也为1/2。认为我可以通过覆盖父函数“layoutChildren”(VBox)来做到这一点,还有其他方法可以做到吗?例如属性绑定?

2.最初VBox会占据整个场景区域,如何使它(重定位)到场景的半底部?

public class Crossh extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) {        
        VBox root = new VBox(5);
        // root.setPadding(new Insets(20,20,20,20));
        root.setStyle("-fx-border-color:red");

        Pane crosshairArea = new Pane();
        crosshairArea.maxWidthProperty().bind(root.widthProperty());
        crosshairArea.setStyle("-fx-border-color:black");       

        root.getChildren().add(crosshairArea);
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.setTitle("Location Crosshair");
        stage.setWidth(900);
        stage.setHeight(700);        
        stage.show();
    }
}
Run Code Online (Sandbox Code Playgroud)

javafx pane vbox

4
推荐指数
1
解决办法
2万
查看次数

java用JPanel制作屏幕截图预览

我正在java中制作一个有趣的小测试屏幕录制程序,我希望它在你开始录制之前预览你的屏幕..但它是一个非常缓慢而且很差的方法,我正在使用它,包括捕获图像,保存它,然后通过bufferedimage读取它并使用Graphics绘制该图像.它非常慢并且作为"预览"没有用,有一种方法可以加速并拥有更高效的"预览系统".这是我到目前为止:

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class MainFrame implements ActionListener, Runnable {
    //add frame components
    public static JFrame frame = new JFrame("Screen Caper - v1.0.1");
    JButton start = new JButton("record");
    JButton close = new JButton("Exit");
    JPanel preview = new JPanel();
    public static boolean running = false; …
Run Code Online (Sandbox Code Playgroud)

java performance swing bufferedimage screen-recording

3
推荐指数
1
解决办法
686
查看次数