我如何拍摄String[],并制作副本String[],但没有第一个字符串?示例:如果我有这个......
String[] colors = {"Red", "Orange", "Yellow"};
Run Code Online (Sandbox Code Playgroud)
我如何制作一个新的字符串,就像字符串集合颜色,但没有红色?
当我运行我的代码,我希望看到一个JPanel在我JFrame,但没有显示出来.我在框架中有一个按钮,它出现了.但是JPanel没有出现,我甚至用红色着色.这是我的代码JPanel:
import java.awt.*;
import javax.swing.JPanel;
public class graphic extends JPanel {
private static final long serialVersionUID = -3458717449092499931L;
public Game game;
public graphic(Game game){
this.game = game;
this.setPreferredSize(new Dimension(400,400));
this.setBackground(Color.RED);
}
public void paintComponent(Graphics g){
for (Line l:game.mirrors){
g.setColor(Color.BLACK);
g.drawLine(l.start.x, l.start.y, l.end.x, l.end.y);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的JFrame代码:
import java.awt.Container;
import java.awt.event.*;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.*;
public class Viewer implements ActionListener {
public JFrame frame;
public JButton drawShoot;
public boolean draw; …Run Code Online (Sandbox Code Playgroud) 所以,我有这个项目,你可以在其中绘制图像.我希望人们能够使用它,但是当我使用时起初它太慢了repaint()所以我使用了这个repaint(Rectangle r)工具.它更好,但仍然不是我想要的速度.这是代码:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class DrawingPad extends JPanel implements MouseListener,MouseMotionListener,ListSelectionListener{
public Color[][] picture = new Color[601][601];
public Color selected;
public String action;
public Maker m;
private static final long serialVersionUID = 1L;
public DrawingPad(Maker m){
this.m = m;
this.setPreferredSize(new Dimension(600,600));
this.setVisible(true);
for (int x = 1;x<=600;x++){
for (int y = 1; y<=600;y++){
picture[x][y]=Color.WHITE;
}
}
}
public void addColor(int x, int y){
try{
picture[x][y]=selected;
repaint(new Rectangle(x,y,x,y));
}catch (Exception e){ …Run Code Online (Sandbox Code Playgroud) 我想知道我是否可以添加像数字一样的布尔值.我正在制作使用网格的东西,我想让它找到周围的方块并返回一个数字.编辑:这就是我对布尔数的看法.
int count = 0;
for (int x = -1; x<=1;x++){
for (int y = -1; y <=1;y++){
if (grid[xPos+x][yPos+y]){
count++;
}
}
}
Run Code Online (Sandbox Code Playgroud) 我尝试为我的skype-bot制作一个简单的项目,它看起来像这样:
import com.skype.Skype;
import com.skype.SkypeException;
public class SkypeDemo {
public static void main(String[] args) throws SkypeException {
System.out.println(Skype.getVersion());
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我开始它时,我得到这个错误:
Exception in thread "main" com.skype.SkypeException: Loading libskype.jnilib failed.
at com.skype.Utils.convertToSkypeException(Unknown Source)
at com.skype.Utils.getProperty(Unknown Source)
at com.skype.Skype.getVersion(Unknown Source)
at SkypeDemo.main(SkypeDemo.java:6)
Caused by: com.skype.connector.LoadLibraryException: Loading libskype.jnilib failed.
at com.skype.connector.ConnectorUtils.loadLibrary(Unknown Source)
at com.skype.connector.osx.SkypeFramework.init(Unknown Source)
at com.skype.connector.osx.OSXConnector.initializeImpl(Unknown Source)
at com.skype.connector.Connector.initialize(Unknown Source)
at com.skype.connector.Connector.connect(Unknown Source)
at com.skype.connector.Connector.assureAttached(Unknown Source)
at com.skype.connector.Connector.execute(Unknown Source)
at com.skype.connector.Connector.execute(Unknown Source)
at com.skype.connector.Connector.execute(Unknown Source)
at com.skype.connector.Connector.execute(Unknown Source)
... 3 more
Run Code Online (Sandbox Code Playgroud)
那么我该如何解决这个错误呢?请记住,我在构建路径中有两个Skype …
帮我!每当我尝试启动下面的代码时,它只显示底部的按钮和其他地方的密码字段.我希望能够看到一切,但我不能
public void setup(){
frame = new JFrame("Votinator 3000");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
voteconfirm = new JLabel("");
textarea = new JTextField(1);
submit = new JButton("Submit Vote!");
chooser = new JList(items);
password = new JPasswordField(1);
password.setVisible(true);
choices = new JComboBox();
choices.addItem("Choose");
choices.addItem("Submit Own");
type = new JPanel();
type.add(textarea);
choices.setEditable(false);
choices.setSelectedIndex(0);
frame.setBounds(300, 300, 400, 400);
frame.getContentPane().add(type);
frame.getContentPane().add(choices);
frame.getContentPane().add(voteconfirm);
frame.getContentPane().add(chooser);
frame.getContentPane().add(textarea);
frame.getContentPane().add(password,BorderLayout.CENTER);
frame.getContentPane().add(submit,BorderLayout.SOUTH);
frame.setVisible(true);
}
Run Code Online (Sandbox Code Playgroud) 我有一个名为image [] []的数组,我想创建一个BufferedImage,所以我可以让播放器将它存储在一个文件中.